• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ArrayTableDataProvider类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.metamodel.pojo.ArrayTableDataProvider的典型用法代码示例。如果您正苦于以下问题:Java ArrayTableDataProvider类的具体用法?Java ArrayTableDataProvider怎么用?Java ArrayTableDataProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ArrayTableDataProvider类属于org.apache.metamodel.pojo包,在下文中一共展示了ArrayTableDataProvider类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setUp

import org.apache.metamodel.pojo.ArrayTableDataProvider; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();

    final List<TableDataProvider<?>> tableDataProviders = new ArrayList<>();
    tableDataProviders
            .add(new ArrayTableDataProvider(new SimpleTableDef("table", new String[] { "name", "age", "country" }),
                    new ArrayList<>()));

    ajb = new AnalysisJobBuilder(_configuration);
    ajb.setDatastore(new PojoDatastore("ds", "sch", tableDataProviders));
    ajb.addSourceColumns("name", "age", "country");
    sourceColumns = ajb.getSourceColumns();

    nameColumn = sourceColumns.get(0);
    ageColumn = sourceColumns.get(1);
    countryColumn = sourceColumns.get(2);
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:19,代码来源:ConsumeRowHandlerTest.java


示例2: setUp

import org.apache.metamodel.pojo.ArrayTableDataProvider; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    final SimpleTableDef tableDef = new SimpleTableDef("table", new String[] { "col1" });
    final List<Object[]> rowData = new ArrayList<>();
    rowData.add(new Object[] { "foo" });
    rowData.add(new Object[] { "bar" });
    rowData.add(new Object[] { "baz" });
    rowData.add(new Object[] { "hello" });
    rowData.add(new Object[] { "world" });
    datastore = new PojoDatastore("ds", "sch", new ArrayTableDataProvider(tableDef, rowData));

    final DatastoreCatalog datastoreCatalog = new DatastoreCatalogImpl(datastore);
    configuration = new DataCleanerConfigurationImpl().withDatastoreCatalog(datastoreCatalog);

    jobBuilder = new AnalysisJobBuilder(configuration);
    jobBuilder.setDatastore(datastore);
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:19,代码来源:FilterRequirementMergingTest.java


示例3: setUp

import org.apache.metamodel.pojo.ArrayTableDataProvider; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();

    // define the datastore that the wrapped job will refer to
    final TableDataProvider<?> origTableDataProvider =
            new ArrayTableDataProvider(new SimpleTableDef("table", new String[] { "foo", "bar", "baz" }),
                    new ArrayList<>(0));
    final Datastore origInput = new PojoDatastore("orig_input", origTableDataProvider);

    // define the datastore that our actual job refers to
    final ArrayList<Object[]> rows = new ArrayList<>();
    final TableDataProvider<?> actualTableDataProvider =
            new ArrayTableDataProvider(new SimpleTableDef("table", new String[] { "name" }), rows);
    rows.add(new Object[] { "Tomasz" });
    rows.add(new Object[] { "Kasper" });
    rows.add(new Object[] { "Claudia" });
    rows.add(new Object[] { "Anders" });
    final Datastore actualInput = new PojoDatastore("actual_input", actualTableDataProvider);

    final DatastoreCatalog datastoreCatalog = new DatastoreCatalogImpl(origInput, actualInput);
    _configuration = new DataCleanerConfigurationImpl().withDatastoreCatalog(datastoreCatalog);
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:24,代码来源:AbstractWrappedAnalysisJobTransformerTest.java


示例4: setUp

import org.apache.metamodel.pojo.ArrayTableDataProvider; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();

    List<TableDataProvider<?>> tableDataProviders = new ArrayList<TableDataProvider<?>>();
    tableDataProviders.add(new ArrayTableDataProvider(new SimpleTableDef("table", new String[] { "name", "age",
            "country" }), new ArrayList<Object[]>()));

    ajb = new AnalysisJobBuilder(analyzerBeansConfiguration);
    ajb.setDatastore(new PojoDatastore("ds", "sch", tableDataProviders));
    ajb.addSourceColumns("name", "age", "country");
    sourceColumns = ajb.getSourceColumns();

    nameColumn = sourceColumns.get(0);
    ageColumn = sourceColumns.get(1);
    countryColumn = sourceColumns.get(2);
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:18,代码来源:ConsumeRowHandlerTest.java


示例5: setUp

import org.apache.metamodel.pojo.ArrayTableDataProvider; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();

    // define the datastore that the wrapped job will refer to
    TableDataProvider<?> origTableDataProvider = new ArrayTableDataProvider(new SimpleTableDef("table",
            new String[] { "foo", "bar", "baz" }), new ArrayList<Object[]>(0));
    Datastore origInput = new PojoDatastore("orig_input", origTableDataProvider);

    // define the datastore that our actual job refers to
    ArrayList<Object[]> rows = new ArrayList<Object[]>();
    TableDataProvider<?> actualTableDataProvider = new ArrayTableDataProvider(new SimpleTableDef("table",
            new String[] { "name" }), rows);
    rows.add(new Object[] { "Tomasz" });
    rows.add(new Object[] { "Kasper" });
    rows.add(new Object[] { "Claudia" });
    rows.add(new Object[] { "Anders" });
    Datastore actualInput = new PojoDatastore("actual_input", actualTableDataProvider);

    DatastoreCatalog datastoreCatalog = new DatastoreCatalogImpl(origInput, actualInput);
    analyzerBeansConfiguration = new AnalyzerBeansConfigurationImpl().replace(datastoreCatalog);
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:23,代码来源:AbstractWrappedAnalysisJobTransformerTest.java


示例6: setUp

import org.apache.metamodel.pojo.ArrayTableDataProvider; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    SimpleTableDef tableDef = new SimpleTableDef("table", new String[] { "col1" });
    List<Object[]> rowData = new ArrayList<Object[]>();
    rowData.add(new Object[] { "foo" });
    rowData.add(new Object[] { "bar" });
    rowData.add(new Object[] { "baz" });
    rowData.add(new Object[] { "hello" });
    rowData.add(new Object[] { "world" });
    datastore = new PojoDatastore("ds", "sch", new ArrayTableDataProvider(tableDef, rowData));

    DatastoreCatalog datastoreCatalog = new DatastoreCatalogImpl(datastore);
    configuration = new AnalyzerBeansConfigurationImpl().replace(datastoreCatalog).replace(
            new SingleThreadedTaskRunner());

    jobBuilder = new AnalysisJobBuilder(configuration);
    jobBuilder.setDatastore(datastore);
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:20,代码来源:FilterRequirementMergingTest.java


示例7: buildAnalyzerBeansConfiguration

import org.apache.metamodel.pojo.ArrayTableDataProvider; //导入依赖的package包/类
public static AnalyzerBeansConfiguration buildAnalyzerBeansConfiguration() {
    List<TableDataProvider<?>> tableDataProviders = new ArrayList<TableDataProvider<?>>();
    SimpleTableDef tableDef1 = new SimpleTableDef("countrycodes", new String[] { "mainFamily:country_name",
            "mainFamily:iso2", "mainFamily:iso3" });
    SimpleTableDef tableDef2 = new SimpleTableDef("countrycodes_output", new String[] { "mainFamily:country_name",
            "mainFamily:iso2", "mainFamily:iso3" });
    tableDataProviders.add(new ArrayTableDataProvider(tableDef1, new ArrayList<Object[]>()));
    tableDataProviders.add(new ArrayTableDataProvider(tableDef2, new ArrayList<Object[]>()));
    Datastore datastore = new PojoDatastore("countrycodes_hbase", "countrycodes_schema", tableDataProviders);

    DatastoreCatalog datastoreCatalog = new DatastoreCatalogImpl(datastore);

    SimpleDescriptorProvider descriptorProvider = new SimpleDescriptorProvider(true);
    descriptorProvider.addTransformerBeanDescriptor(Descriptors.ofTransformer(ConcatenatorTransformer.class));
    descriptorProvider.addTransformerBeanDescriptor(Descriptors.ofTransformer(TokenizerTransformer.class));
    descriptorProvider.addAnalyzerBeanDescriptor(Descriptors.ofAnalyzer(InsertIntoTableAnalyzer.class));
    descriptorProvider.addAnalyzerBeanDescriptor(Descriptors.ofAnalyzer(StringAnalyzer.class));

    return new AnalyzerBeansConfigurationImpl().replace(datastoreCatalog).replace(descriptorProvider);
}
 
开发者ID:tomaszguzialek,项目名称:hadoop-datacleaner,代码行数:21,代码来源:ConfigurationSerializerTest.java


示例8: buildAnalyzerBeansConfiguration

import org.apache.metamodel.pojo.ArrayTableDataProvider; //导入依赖的package包/类
public static AnalyzerBeansConfiguration buildAnalyzerBeansConfiguration() {
    List<TableDataProvider<?>> tableDataProviders = new ArrayList<TableDataProvider<?>>();
    SimpleTableDef tableDef1 = new SimpleTableDef("countrycodes", new String[] { "mainFamily:country_name",
            "mainFamily:iso2", "mainFamily:iso3" });
    SimpleTableDef tableDef2 = new SimpleTableDef("countrycodes_output", new String[] { "mainFamily:country_name",
            "mainFamily:iso2", "mainFamily:iso3" });
    tableDataProviders.add(new ArrayTableDataProvider(tableDef1, new ArrayList<Object[]>()));
    tableDataProviders.add(new ArrayTableDataProvider(tableDef2, new ArrayList<Object[]>()));
    Datastore datastore = new PojoDatastore("countrycodes_hbase", "countrycodes_schema", tableDataProviders);

    DatastoreCatalog datastoreCatalog = new DatastoreCatalogImpl(datastore);

    ClasspathScanDescriptorProvider descriptorProvider = new ClasspathScanDescriptorProvider();
    descriptorProvider.scanPackage("org.eobjects", true);

    return new AnalyzerBeansConfigurationImpl().replace(datastoreCatalog).replace(descriptorProvider);
}
 
开发者ID:tomaszguzialek,项目名称:hadoop-datacleaner,代码行数:18,代码来源:SampleHBaseConfiguration.java


示例9: createDataContext

import org.apache.metamodel.pojo.ArrayTableDataProvider; //导入依赖的package包/类
@Override
public DataContext createDataContext(DataContextFactoryParameters params) {
    SimpleTableDef[] tableDefs = params.getTableDefs();
    if (tableDefs == null || tableDefs.length == 0) {
        throw new IllegalArgumentException("Cannot create PojoDataContext with no tableDefs specified");
    }
    
    TableDataProvider<?>[] tableDataProviders = new ArrayTableDataProvider[tableDefs.length];
    for (int i = 0; i < tableDataProviders.length; i++) {
        ArrayTableDataProvider tableDataProvider = new ArrayTableDataProvider(tableDefs[i], new ArrayList<Object[]>());
        tableDataProviders[i] = tableDataProvider;
    }
    
    String databaseName = params.getDatabaseName();
    if (databaseName != null && !databaseName.isEmpty()) {
        return new PojoDataContext(databaseName, tableDataProviders);
    }
    return new PojoDataContext(Arrays.asList(tableDataProviders));
}
 
开发者ID:apache,项目名称:metamodel,代码行数:20,代码来源:PojoDataContextFactoryBeanDelegate.java


示例10: setUp

import org.apache.metamodel.pojo.ArrayTableDataProvider; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    final List<TableDataProvider<?>> tableDataProviders = Collections.singletonList(
            new ArrayTableDataProvider(new SimpleTableDef("my table", new String[] { "col1", "col2" }),
                    Collections.emptyList()));
    dummyDatastore = new PojoDatastore("my ds", tableDataProviders);
    configuration = new DataCleanerConfigurationImpl().withDatastores(dummyDatastore);
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:10,代码来源:AbstractComponentBuilderTest.java


示例11: buildAnalyzerBeansConfiguration

import org.apache.metamodel.pojo.ArrayTableDataProvider; //导入依赖的package包/类
public static AnalyzerBeansConfiguration buildAnalyzerBeansConfiguration() {
	List<TableDataProvider<?>> tableDataProviders = new ArrayList<TableDataProvider<?>>();
	SimpleTableDef tableDef1 = new SimpleTableDef("countrycodes",
			new String[] { "mainFamily:country_name", "mainFamily:iso2",
					"mainFamily:iso3" });
	SimpleTableDef tableDef2 = new SimpleTableDef("countrycodes_output",
			new String[] { "mainFamily:country_name", "mainFamily:iso2",
					"mainFamily:iso3" });
	tableDataProviders.add(new ArrayTableDataProvider(tableDef1,
			new ArrayList<Object[]>()));
	tableDataProviders.add(new ArrayTableDataProvider(tableDef2,
			new ArrayList<Object[]>()));
	Datastore datastore = new PojoDatastore("countrycodes_hbase",
			"countrycodes_schema", tableDataProviders);

	DatastoreCatalog datastoreCatalog = new DatastoreCatalogImpl(datastore);

	SimpleDescriptorProvider descriptorProvider = new SimpleDescriptorProvider(
			true);
	descriptorProvider.addTransformerBeanDescriptor(Descriptors
			.ofTransformer(ConcatenatorTransformer.class));
	descriptorProvider.addTransformerBeanDescriptor(Descriptors
			.ofTransformer(TokenizerTransformer.class));
	descriptorProvider.addAnalyzerBeanDescriptor(Descriptors
			.ofAnalyzer(InsertIntoTableAnalyzer.class));
	descriptorProvider.addAnalyzerBeanDescriptor(Descriptors
			.ofAnalyzer(StringAnalyzer.class));

	return new AnalyzerBeansConfigurationImpl().replace(datastoreCatalog)
			.replace(descriptorProvider);
}
 
开发者ID:tomaszguzialek,项目名称:hadoop-datacleaner,代码行数:32,代码来源:HBaseTableReducerTest.java


示例12: read

import org.apache.metamodel.pojo.ArrayTableDataProvider; //导入依赖的package包/类
public PojoDatastore read(final PojoDatastoreType pojoDatastore) {
    final String name = pojoDatastore.getName();
    final String schemaName = (pojoDatastore.getSchemaName() == null ? name : pojoDatastore.getSchemaName());

    final List<TableDataProvider<?>> tableDataProviders = new ArrayList<>();
    final List<PojoTableType> tables = pojoDatastore.getTable();
    for (final PojoTableType table : tables) {
        final String tableName = table.getName();

        final List<Columns.Column> columns = table.getColumns().getColumn();
        final int columnCount = columns.size();
        final String[] columnNames = new String[columnCount];
        final ColumnType[] columnTypes = new ColumnType[columnCount];

        for (int i = 0; i < columnCount; i++) {
            final Columns.Column column = columns.get(i);
            columnNames[i] = column.getName();
            columnTypes[i] = ColumnTypeImpl.valueOf(column.getType());
        }

        final SimpleTableDef tableDef = new SimpleTableDef(tableName, columnNames, columnTypes);

        final Collection<Object[]> arrays = new ArrayList<>();
        final Rows rowsType = table.getRows();
        if (rowsType != null) {
            final List<Rows.Row> rows = rowsType.getRow();
            for (final Rows.Row row : rows) {
                final List<Object> values = row.getV();
                if (values.size() != columnCount) {
                    throw new IllegalStateException(
                            "Row value count is not equal to column count in datastore '" + name + "'. Expected "
                                    + columnCount + " values, found " + values.size() + " (table " + tableName
                                    + ", row no. " + arrays.size() + ")");
                }
                final Object[] array = new Object[columnCount];
                for (int i = 0; i < array.length; i++) {

                    final Class<?> expectedClass = columnTypes[i].getJavaEquivalentClass();

                    final Object rawValue = values.get(i);
                    final Object value = deserializeValue(rawValue, expectedClass);
                    array[i] = value;
                }
                arrays.add(array);
            }
        }

        final TableDataProvider<?> tableDataProvider = new ArrayTableDataProvider(tableDef, arrays);
        tableDataProviders.add(tableDataProvider);
    }

    return new PojoDatastore(name, schemaName, tableDataProviders);
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:54,代码来源:JaxbPojoDatastoreAdaptor.java


示例13: testSerializeAndDeserialize

import org.apache.metamodel.pojo.ArrayTableDataProvider; //导入依赖的package包/类
public void testSerializeAndDeserialize() throws Exception {
    final Object map1 = buildMap(
            "{'some_number':1234, 'gender':'M','address':{'city':'Copenhagen','country':'DK','additional_info':null}}");
    final Object map2 =
            buildMap("{'some_number':5678,'gender':'M','address':{'city':'Amsterdam','countries':['NL','IN']}}");

    final SimpleTableDef tableDef = new SimpleTableDef("bar", new String[] { "id", "name", "details", "bytes" },
            new ColumnType[] { ColumnType.INTEGER, ColumnType.VARCHAR, ColumnType.MAP, ColumnType.BINARY });
    final Collection<Object[]> arrays = new ArrayList<>();
    arrays.add(new Object[] { 1, "Kasper Sørensen", map1, new byte[] { (byte) -40, (byte) -2 } });
    arrays.add(new Object[] { 2, "Ankit Kumar", map2, new byte[] { (byte) 1, (byte) 3, (byte) 3, (byte) 7 } });
    final TableDataProvider<?> tableProvider = new ArrayTableDataProvider(tableDef, arrays);
    final List<TableDataProvider<?>> tableProviders = new ArrayList<>();
    tableProviders.add(tableProvider);

    PojoDatastore datastore;
    datastore = new PojoDatastore("foo", tableProviders);

    final JaxbPojoDatastoreAdaptor adaptor = new JaxbPojoDatastoreAdaptor(new DataCleanerConfigurationImpl());
    AbstractDatastoreType serializedDatastore = adaptor.createPojoDatastore(datastore, null, 20);

    final DatastoreCatalogType serializedDatastoreCatalogType = new DatastoreCatalogType();
    serializedDatastoreCatalogType.getJdbcDatastoreOrAccessDatastoreOrCsvDatastore().add(serializedDatastore);
    Configuration serializedConfiguration = new Configuration();
    serializedConfiguration.setDatastoreCatalog(serializedDatastoreCatalogType);

    // serialize and deserialize
    final JAXBContext jaxbContext = JAXBContext
            .newInstance(ObjectFactory.class.getPackage().getName(), ObjectFactory.class.getClassLoader());
    final File file = new File("target/JaxbPojoDatastoreAdaptorTest_serialize_and_deserialize.xml");
    jaxbContext.createMarshaller().marshal(serializedConfiguration, file);
    serializedConfiguration = (Configuration) jaxbContext.createUnmarshaller().unmarshal(file);

    serializedDatastore =
            serializedConfiguration.getDatastoreCatalog().getJdbcDatastoreOrAccessDatastoreOrCsvDatastore().get(0);
    datastore = adaptor.read((PojoDatastoreType) serializedDatastore);

    final UpdateableDatastoreConnection con = datastore.openConnection();
    final DataSet ds = con.getDataContext().query().from("bar").select("id", "name", "details").execute();
    assertTrue(ds.next());
    assertTrue(ds.getRow().getValue(0) instanceof Integer);
    assertEquals(1, ds.getRow().getValue(0));
    assertTrue(ds.getRow().getValue(1) instanceof String);
    assertEquals("Kasper Sørensen", ds.getRow().getValue(1));
    assertTrue(ds.getRow().getValue(2) instanceof Map);

    @SuppressWarnings("unchecked") final Map<String, ?> map3 = (Map<String, ?>) ds.getRow().getValue(2);
    assertEquals("{some_number=1234, gender=M, address={city=Copenhagen, country=DK, additional_info=null}}",
            map3.toString());
    assertEquals(Integer.class, map3.get("some_number").getClass());

    assertTrue(ds.next());
    assertTrue(ds.getRow().getValue(0) instanceof Integer);
    assertEquals(2, ds.getRow().getValue(0));
    assertTrue(ds.getRow().getValue(1) instanceof String);
    assertEquals("Ankit Kumar", ds.getRow().getValue(1));
    assertTrue(ds.getRow().getValue(2) instanceof Map);

    @SuppressWarnings("unchecked") final Map<String, ?> map4 = (Map<String, ?>) ds.getRow().getValue(2);
    assertEquals("{some_number=5678, gender=M, address={city=Amsterdam, countries=[NL, IN]}}", map4.toString());
    assertEquals(Integer.class, map3.get("some_number").getClass());

    assertFalse(ds.next());

    assertEquals(map1, map3);
    assertEquals(map2, map4);
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:68,代码来源:JaxbPojoDatastoreAdaptorTest.java


示例14: testFindOriginatingTableFromMaxRowsFilter

import org.apache.metamodel.pojo.ArrayTableDataProvider; //导入依赖的package包/类
public void testFindOriginatingTableFromMaxRowsFilter() throws Exception {
    final TableDataProvider<?> tableProvider1 =
            new ArrayTableDataProvider(new SimpleTableDef("table1", new String[] { "id", "foo" }),
                    new ArrayList<>());
    final TableDataProvider<?> tableProvider2 =
            new ArrayTableDataProvider(new SimpleTableDef("table2", new String[] { "id", "bar" }),
                    new ArrayList<>());

    final Datastore ds = new PojoDatastore("my datastore", tableProvider1, tableProvider2);
    final DataCleanerConfiguration configuration = new DataCleanerConfigurationImpl().withDatastores(ds);

    final AnalysisJob job;
    try (AnalysisJobBuilder jobBuilder = new AnalysisJobBuilder(configuration)) {
        // add source columns from two tables
        jobBuilder.setDatastore(ds);
        jobBuilder.addSourceColumns("table1.id", "table1.foo", "table2.id", "table2.bar");

        final FilterComponentBuilder<MaxRowsFilter, Category> filter = jobBuilder.addFilter(MaxRowsFilter.class);
        filter.addInputColumn(jobBuilder.getSourceColumnByName("foo"));

        final TransformerComponentBuilder<MockTransformer> transformer =
                jobBuilder.addTransformer(MockTransformer.class);
        transformer.addInputColumn(jobBuilder.getSourceColumnByName("foo"));
        transformer.setRequirement(filter, MaxRowsFilter.Category.VALID);

        // only wire columns from one of the tables (table1.foo)
        final AnalyzerComponentBuilder<MockAnalyzer> analyzer = jobBuilder.addAnalyzer(MockAnalyzer.class);
        analyzer.addInputColumn(transformer.getOutputColumns().get(0));

        job = jobBuilder.toAnalysisJob();
    }

    final TransformerJob transformerJob = job.getTransformerJobs().get(0);
    final InputColumn<?> transformedColumn = transformerJob.getOutput()[0];
    final FilterOutcome outcome =
            transformerJob.getComponentRequirement().getProcessingDependencies().iterator().next();

    final SourceColumnFinder sourceColumnFinder = new SourceColumnFinder();
    sourceColumnFinder.addSources(job);

    final Table transformerOriginTable = sourceColumnFinder.findOriginatingTable(transformedColumn);
    assertEquals("table1", transformerOriginTable.getName());

    assertNotNull(outcome);
    final Table filterOriginTable = sourceColumnFinder.findOriginatingTable(outcome);
    assertEquals("table1", filterOriginTable.getName());

    final Set<Column> transformerOriginColumns = sourceColumnFinder.findOriginatingColumns(transformedColumn);
    assertEquals(1, MetaModelHelper.getTables(transformerOriginColumns).length);
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:51,代码来源:SourceColumnFinderTest.java


示例15: testTwoWidgetsForSameProperty

import org.apache.metamodel.pojo.ArrayTableDataProvider; //导入依赖的package包/类
public void testTwoWidgetsForSameProperty() throws Exception {
    final TransformerDescriptor<TableLookupTransformer> descriptor =
            Descriptors.ofTransformer(TableLookupTransformer.class);

    final ConfiguredPropertyDescriptor datastoreProperty = descriptor.getConfiguredProperty("Datastore");
    final ConfiguredPropertyDescriptor tableProperty = descriptor.getConfiguredProperty("Table name");
    final ConfiguredPropertyDescriptor schemaProperty = descriptor.getConfiguredProperty("Schema name");

    final DataCleanerConfiguration configuration = new DataCleanerConfigurationImpl();
    final AnalysisJobBuilder analysisJobBuilder = new AnalysisJobBuilder(configuration);

    final TransformerComponentBuilder<TableLookupTransformer> tjb =
            analysisJobBuilder.addTransformer(TableLookupTransformer.class);

    final List<TableDataProvider<?>> tables = new ArrayList<>();
    tables.add(new ArrayTableDataProvider(new SimpleTableDef("foo", new String[] { "col1", "col2" }),
            new ArrayList<>()));
    tables.add(new ArrayTableDataProvider(new SimpleTableDef("bar", new String[] { "col3", "col4" }),
            new ArrayList<>()));

    final PojoDatastore ds = new PojoDatastore("myds", tables);

    final PropertyWidgetCollection collection1 = createPropertyWidgetCollection(tjb);
    final PropertyWidgetCollection collection2 = createPropertyWidgetCollection(tjb);

    final DatastoreCatalog datastoreCatalog = new DatastoreCatalogImpl(ds);
    final WindowContext windowContext = new SimpleWindowContext();

    final SingleDatastorePropertyWidget datastoreWidget1 =
            new SingleDatastorePropertyWidget(tjb, datastoreProperty, datastoreCatalog, new DCModuleImpl());
    final SchemaNamePropertyWidget schemaWidget1 = new SchemaNamePropertyWidget(tjb, schemaProperty);
    final SingleTableNamePropertyWidget tableWidget1 =
            new SingleTableNamePropertyWidget(tjb, tableProperty, windowContext);
    datastoreWidget1.connectToSchemaNamePropertyWidget(schemaWidget1);
    schemaWidget1.connectToTableNamePropertyWidget(tableWidget1);
    collection1.registerWidget(tableProperty, tableWidget1);

    final SingleDatastorePropertyWidget datastoreWidget2 =
            new SingleDatastorePropertyWidget(tjb, datastoreProperty, datastoreCatalog, new DCModuleImpl());
    final SchemaNamePropertyWidget schemaWidget2 = new SchemaNamePropertyWidget(tjb, schemaProperty);
    final SingleTableNamePropertyWidget tableWidget2 =
            new SingleTableNamePropertyWidget(tjb, tableProperty, windowContext);
    datastoreWidget2.connectToSchemaNamePropertyWidget(schemaWidget2);
    schemaWidget2.connectToTableNamePropertyWidget(tableWidget2);
    collection2.registerWidget(tableProperty, tableWidget2);

    datastoreWidget1.setValue(ds);
    datastoreWidget2.setValue(ds);

    assertEquals("myds", schemaWidget1.getSchema().getName());
    assertEquals("myds", schemaWidget2.getSchema().getName());

    assertEquals(null, tableWidget1.getTable());
    assertEquals(null, tableWidget2.getTable());

    assertEquals(3, tableWidget1.getComboBox().getItemCount());
    assertEquals(3, tableWidget2.getComboBox().getItemCount());

    assertEquals("Table[name=bar,type=TABLE,remarks=null]", tableWidget1.getComboBox().getItemAt(1).toString());
    assertEquals("Table[name=bar,type=TABLE,remarks=null]", tableWidget2.getComboBox().getItemAt(1).toString());

    tableWidget1.setValue("bar");

    assertEquals("bar", tableWidget1.getTable().getName());
    assertEquals("bar", tableWidget2.getTable().getName());

    analysisJobBuilder.close();
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:69,代码来源:TableNamePropertyWidgetTest.java


示例16: read

import org.apache.metamodel.pojo.ArrayTableDataProvider; //导入依赖的package包/类
public PojoDatastore read(PojoDatastoreType pojoDatastore) {
    final String name = pojoDatastore.getName();
    final String schemaName = (pojoDatastore.getSchemaName() == null ? name : pojoDatastore.getSchemaName());

    final List<TableDataProvider<?>> tableDataProviders = new ArrayList<TableDataProvider<?>>();
    final List<PojoTableType> tables = pojoDatastore.getTable();
    for (PojoTableType table : tables) {
        final String tableName = table.getName();

        final List<Columns.Column> columns = table.getColumns().getColumn();
        final int columnCount = columns.size();
        final String[] columnNames = new String[columnCount];
        final ColumnType[] columnTypes = new ColumnType[columnCount];

        for (int i = 0; i < columnCount; i++) {
            final Columns.Column column = columns.get(i);
            columnNames[i] = column.getName();
            columnTypes[i] = ColumnTypeImpl.valueOf(column.getType());
        }

        final SimpleTableDef tableDef = new SimpleTableDef(tableName, columnNames, columnTypes);

        final Collection<Object[]> arrays = new ArrayList<Object[]>();
        final Rows rowsType = table.getRows();
        if (rowsType != null) {
            final List<Rows.Row> rows = rowsType.getRow();
            for (Rows.Row row : rows) {
                final List<Object> values = row.getV();
                if (values.size() != columnCount) {
                    throw new IllegalStateException("Row value count is not equal to column count in datastore '"
                            + name + "'. Expected " + columnCount + " values, found " + values.size() + " (table "
                            + tableName + ", row no. " + arrays.size() + ")");
                }
                final Object[] array = new Object[columnCount];
                for (int i = 0; i < array.length; i++) {

                    final Class<?> expectedClass = columnTypes[i].getJavaEquivalentClass();

                    final Object rawValue = values.get(i);
                    final Object value = deserializeValue(rawValue, expectedClass);
                    array[i] = value;
                }
                arrays.add(array);
            }
        }

        final TableDataProvider<?> tableDataProvider = new ArrayTableDataProvider(tableDef, arrays);
        tableDataProviders.add(tableDataProvider);
    }

    final PojoDatastore ds = new PojoDatastore(name, schemaName, tableDataProviders);
    return ds;
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:54,代码来源:JaxbPojoDatastoreAdaptor.java


示例17: testSerializeAndDeserialize

import org.apache.metamodel.pojo.ArrayTableDataProvider; //导入依赖的package包/类
public void testSerializeAndDeserialize() throws Exception {
    final Object map1 = buildMap("{'some_number':1234, 'gender':'M','address':{'city':'Copenhagen','country':'DK','additional_info':null}}");
    final Object map2 = buildMap("{'some_number':5678,'gender':'M','address':{'city':'Amsterdam','countries':['NL','IN']}}");

    SimpleTableDef tableDef = new SimpleTableDef("bar", new String[] { "id", "name", "details", "bytes" },
            new ColumnType[] { ColumnType.INTEGER, ColumnType.VARCHAR, ColumnType.MAP, ColumnType.BINARY });
    Collection<Object[]> arrays = new ArrayList<Object[]>();
    arrays.add(new Object[] { 1, "Kasper Sørensen", map1, new byte[] { (byte) -40, (byte) -2 } });
    arrays.add(new Object[] { 2, "Ankit Kumar", map2, new byte[] { (byte) 1, (byte) 3, (byte) 3, (byte) 7 } });
    TableDataProvider<?> tableProvider = new ArrayTableDataProvider(tableDef, arrays);
    List<TableDataProvider<?>> tableProviders = new ArrayList<TableDataProvider<?>>();
    tableProviders.add(tableProvider);

    PojoDatastore datastore;
    datastore = new PojoDatastore("foo", tableProviders);

    final JaxbPojoDatastoreAdaptor adaptor = new JaxbPojoDatastoreAdaptor();
    AbstractDatastoreType serializedDatastore = adaptor.createPojoDatastore(datastore, null, 20);

    DatastoreCatalogType serializedDatastoreCatalogType = new DatastoreCatalogType();
    serializedDatastoreCatalogType.getJdbcDatastoreOrAccessDatastoreOrCsvDatastore().add(serializedDatastore);
    Configuration serializedConfiguration = new Configuration();
    serializedConfiguration.setDatastoreCatalog(serializedDatastoreCatalogType);

    // serialize and deserialize
    JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class.getPackage().getName(),
            ObjectFactory.class.getClassLoader());
    File file = new File("target/JaxbPojoDatastoreAdaptorTest_serialize_and_deserialize.xml");
    jaxbContext.createMarshaller().marshal(serializedConfiguration, file);
    serializedConfiguration = (Configuration) jaxbContext.createUnmarshaller().unmarshal(file);

    serializedDatastore = serializedConfiguration.getDatastoreCatalog()
            .getJdbcDatastoreOrAccessDatastoreOrCsvDatastore().get(0);
    datastore = adaptor.read((PojoDatastoreType) serializedDatastore);

    UpdateableDatastoreConnection con = datastore.openConnection();
    DataSet ds = con.getDataContext().query().from("bar").select("id", "name", "details").execute();
    assertTrue(ds.next());
    assertTrue(ds.getRow().getValue(0) instanceof Integer);
    assertEquals(1, ds.getRow().getValue(0));
    assertTrue(ds.getRow().getValue(1) instanceof String);
    assertEquals("Kasper Sørensen", ds.getRow().getValue(1));
    assertTrue(ds.getRow().getValue(2) instanceof Map);

    @SuppressWarnings("unchecked")
    final Map<String, ?> map3 = (Map<String, ?>) ds.getRow().getValue(2);
    assertEquals("{some_number=1234, gender=M, address={city=Copenhagen, country=DK, additional_info=null}}",
            map3.toString());
    assertEquals(Integer.class, map3.get("some_number").getClass());

    assertTrue(ds.next());
    assertTrue(ds.getRow().getValue(0) instanceof Integer);
    assertEquals(2, ds.getRow().getValue(0));
    assertTrue(ds.getRow().getValue(1) instanceof String);
    assertEquals("Ankit Kumar", ds.getRow().getValue(1));
    assertTrue(ds.getRow().getValue(2) instanceof Map);

    @SuppressWarnings("unchecked")
    final Map<String, ?> map4 = (Map<String, ?>) ds.getRow().getValue(2);
    assertEquals("{some_number=5678, gender=M, address={city=Amsterdam, countries=[NL, IN]}}", map4.toString());
    assertEquals(Integer.class, map3.get("some_number").getClass());

    assertFalse(ds.next());

    assertEquals(map1, map3);
    assertEquals(map2, map4);
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:68,代码来源:JaxbPojoDatastoreAdaptorTest.java



注:本文中的org.apache.metamodel.pojo.ArrayTableDataProvider类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GestureEndEvent类代码示例发布时间:2022-05-15
下一篇:
Java PlanValidationException类代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap