当前位置: 首页>>代码示例>>Java>>正文


Java Table.getColumns方法代码示例

本文整理汇总了Java中org.apache.metamodel.schema.Table.getColumns方法的典型用法代码示例。如果您正苦于以下问题:Java Table.getColumns方法的具体用法?Java Table.getColumns怎么用?Java Table.getColumns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.metamodel.schema.Table的用法示例。


在下文中一共展示了Table.getColumns方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPreviewData

import org.apache.metamodel.schema.Table; //导入方法依赖的package包/类
private DataSet getPreviewData(final String filename) {
    if (!isPreviewDataAvailable()) {
        logger.info("Not displaying preview table because isPreviewDataAvailable() returned false");
        return null;
    }

    final D datastore = getPreviewDatastore(filename);
    try (DatastoreConnection con = datastore.openConnection()) {
        final DataContext dc = con.getDataContext();
        final Table table = getPreviewTable(dc);

        List<Column> columns = table.getColumns();
        if (columns.size() > getPreviewColumns()) {
            // include max 10 columns
            columns = columns.stream().limit(getPreviewColumns()).collect(Collectors.toList());
        }
        final Query q = dc.query().from(table).select(columns).toQuery();
        q.setMaxRows(7);

        return dc.executeQuery(q);
    }
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:23,代码来源:AbstractFileBasedDatastoreDialog.java

示例2: getRawTableColumns

import org.apache.metamodel.schema.Table; //导入方法依赖的package包/类
private Column[] getRawTableColumns(Table rawTable) throws MetaException {
    Column[] rawColumns = rawTable.getColumns();
    if (rawColumns == null || rawColumns.length < 1)
        throw new MetaException("table '" + rawTable.getName() + "' has no column");

    return rawColumns;
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:8,代码来源:JDOMetaContext.java

示例3: updateScriptWithIQueryRewriter

import org.apache.metamodel.schema.Table; //导入方法依赖的package包/类
private static UpdateScript updateScriptWithIQueryRewriter(final DataContext dataContext, final Table table,
		final IQueryRewriter typ) {

	UpdateScript updateScript = new UpdateScript() {

		public void run(UpdateCallback callback) {
			

			TableCreationBuilder tableCreation = callback.createTable(dataContext.getDefaultSchema(),
					table.getName());
			for (Column column : table.getColumns()) {
				if (column.getType().isLiteral()) {
					if (column.getColumnSize() < NUMBER) {
						tableCreation.withColumn(column.getName())
								.ofNativeType(typ.rewriteColumnType(column.getType(), column.getColumnSize()));
					} else {
						tableCreation.withColumn(column.getName())
								.ofNativeType(typ.rewriteColumnType(ColumnType.STRING, null)).nullable(true);
					}

				} else {
					tableCreation.withColumn(column.getName()).nullable(true)
							.ofNativeType(typ.rewriteColumnType(column.getType(), null));

				}

			}
			tableCreation.execute();

		}

	};

	return updateScript;
}
 
开发者ID:Iranox,项目名称:mapbench-datadistributor,代码行数:36,代码来源:UpdateScriptWriterHelp.java

示例4: removeSourceTable

import org.apache.metamodel.schema.Table; //导入方法依赖的package包/类
/**
 * Removes the specified table (or rather - all columns of that table) from
 * this job's source.
 *
 * @param table
 */
public AnalysisJobBuilder removeSourceTable(final Table table) {
    final List<Column> cols = table.getColumns();
    for (final Column col : cols) {
        removeSourceColumn(col);
    }
    return this;
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:14,代码来源:AnalysisJobBuilder.java

示例5: getPreviewData

import org.apache.metamodel.schema.Table; //导入方法依赖的package包/类
private DataSet getPreviewData(final Resource resource) {
    if (!isPreviewDataAvailable()) {
        logger.info("Not displaying preview table because isPreviewDataAvailable() returned false");
        return null;
    }

    logger.info("Attempting to fetch preview data from resource: {}", resource);

    final D datastore = getPreviewDatastore(resource);
    try (DatastoreConnection con = datastore.openConnection()) {
        final DataContext dc = con.getDataContext();
        final Table table = getPreviewTable(dc);
        if (table == null) {
            logger.info("Not displaying preview because getPreviewTable(..) returned null");
            return null;
        }

        List<Column> columns = table.getColumns();
        if (columns.size() > getPreviewColumns()) {
            // include max 10 columns
            columns = columns.stream().limit(getPreviewColumns()).collect(Collectors.toList());
        }
        final Query q = dc.query().from(table).select(columns).toQuery();
        q.setMaxRows(PREVIEW_ROWS);

        return dc.executeQuery(q);
    }
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:29,代码来源:AbstractResourceBasedDatastoreDialog.java

示例6: addTable

import org.apache.metamodel.schema.Table; //导入方法依赖的package包/类
/**
 * toggles whether or not the column is in the source selection
 */
public void addTable(final Table table) {
    final List<Column> columns = table.getColumns();
    for (final Column column : columns) {
        if (!_analysisJobBuilder.containsSourceColumn(column)) {
            _analysisJobBuilder.addSourceColumn(column);
        }
    }
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:12,代码来源:TableMouseListener.java

示例7: removeTable

import org.apache.metamodel.schema.Table; //导入方法依赖的package包/类
/**
 * toggles whether or not the column is in the source selection
 */
public void removeTable(final Table table) {
    final List<Column> columns = table.getColumns();
    for (final Column column : columns) {
        _analysisJobBuilder.removeSourceColumn(column);
    }
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:10,代码来源:TableMouseListener.java

示例8: doInBackground

import org.apache.metamodel.schema.Table; //导入方法依赖的package包/类
@Override
protected Void doInBackground() throws Exception {
    final Table table = (Table) _tableNode.getUserObject();
    final List<Column> columns = table.getColumns();
    for (final Column column : columns) {
        final String name = column.getName();
        logger.debug("Publishing column name: {}", name);
        publish(column);
    }
    return null;
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:12,代码来源:SchemaTree.java

示例9: setModel

import org.apache.metamodel.schema.Table; //导入方法依赖的package包/类
public void setModel(final Datastore datastore, final Table table) {
    final String previousColumnName;
    final Column previousItem = getSelectedItem();
    if (previousItem == null) {
        previousColumnName = null;
    } else {
        previousColumnName = previousItem.getName();
    }

    if (getTable() == table) {
        return;
    }
    setTable(table);

    if (datastore == null) {
        setDatastoreConnection(null);
    } else {
        setDatastoreConnection(datastore.openConnection());
    }
    if (table == null) {
        setModel(new DefaultComboBoxModel<>(new String[1]));
    } else {
        int selectedIndex = 0;

        final List<Column> comboBoxList = new ArrayList<>();
        comboBoxList.add(null);

        final List<Column> columns = table.getColumns();
        for (final Column column : columns) {
            comboBoxList.add(column);
            if (column.getName().equals(previousColumnName)) {
                selectedIndex = comboBoxList.size() - 1;
            }
        }
        final ComboBoxModel<Object> model = new DefaultComboBoxModel<>(comboBoxList.toArray());
        setModel(model);
        setSelectedIndex(selectedIndex);
    }
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:40,代码来源:SourceColumnComboBox.java

示例10: testQuery

import org.apache.metamodel.schema.Table; //导入方法依赖的package包/类
public void testQuery() throws Exception {
	Schema schema = dc.getSchemaByName("report.dbf");
	Table table = schema.getTableByName("report");

	List<Column> columns = table.getColumns();
	Query q = new Query().select(columns).from(table);
	DataSet ds = dc.executeQuery(q);

	while (ds.next()) {
		Row row = ds.getRow();
		List<SelectItem> selectItems = row.getSelectItems();
		for (int i = 0; i < selectItems.size(); i++) {
			SelectItem selectItem = selectItems.get(i);
			Column column = columns.get(i);
			assertSame(selectItem.getColumn(), column);

			Object selectItemValue = row.getValue(selectItem);
			Object columnValue = row.getValue(column);
			assertEquals(selectItemValue, columnValue);

			assertNotNull(columnValue);

			assertTrue(columnValue instanceof Character
					|| columnValue instanceof String);
		}
	}
	ds.close();
}
 
开发者ID:datacleaner,项目名称:metamodel_extras,代码行数:29,代码来源:DbaseDataContextReportTest.java

示例11: removeSourceTable

import org.apache.metamodel.schema.Table; //导入方法依赖的package包/类
/**
 * Removes the specified table (or rather - all columns of that table) from
 * this job's source.
 * 
 * @param table
 */
public AnalysisJobBuilder removeSourceTable(Table table) {
    final Column[] cols = table.getColumns();
    for (Column col : cols) {
        removeSourceColumn(col);
    }
    return this;
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:14,代码来源:AnalysisJobBuilder.java

示例12: testSerializeDeserializeDatastores

import org.apache.metamodel.schema.Table; //导入方法依赖的package包/类
@Test
public void testSerializeDeserializeDatastores() {
    String csv = ConfigurationSerializer.serializeAnalyzerBeansConfigurationDataStores(analyzerBeansConfiguration);
    logger.info("Csv: " + csv);
    AnalyzerBeansConfiguration deserialized = ConfigurationSerializer.deserializeAnalyzerBeansDatastores(csv);
    for (String datastoreName : analyzerBeansConfiguration.getDatastoreCatalog().getDatastoreNames()) {
        logger.info("Datastore: " + datastoreName);
        Datastore datastore = analyzerBeansConfiguration.getDatastoreCatalog().getDatastore(datastoreName);
        Datastore deserializedDatastore = deserialized.getDatastoreCatalog().getDatastore(datastoreName);
        Assert.assertNotNull(deserializedDatastore);

        SchemaNavigator schemaNavigator = datastore.openConnection().getSchemaNavigator();
        SchemaNavigator deserializedSchemaNavigator = deserializedDatastore.openConnection().getSchemaNavigator();
        for (Schema schema : schemaNavigator.getSchemas()) {
            String schemaName = schema.getName();
            logger.info("\tSchema: " + schemaName);
            Schema deserializedSchema = deserializedSchemaNavigator.getSchemaByName(schemaName);
            Assert.assertNotNull(deserializedSchema);

            for (Table table : schema.getTables()) {
                String tableName = table.getName();
                logger.info("\t\tTable: " + tableName);
                Table deserializedTable = deserializedSchema.getTableByName(tableName);
                Assert.assertNotNull(deserializedTable);

                for (Column column : table.getColumns()) {
                    String columnName = column.getName();
                    logger.info("\t\t\tColumn: " + columnName);
                    Column deserializedColumn = deserializedTable.getColumnByName(columnName);
                    Assert.assertNotNull(deserializedColumn);
                }
            }
        }
    }
}
 
开发者ID:tomaszguzialek,项目名称:hadoop-datacleaner,代码行数:36,代码来源:ConfigurationSerializerTest.java

示例13: generate

import org.apache.metamodel.schema.Table; //导入方法依赖的package包/类
@Override
public void generate() {
    try {
        //Get current execution path
        final String dir = System.getProperty("user.dir");
        System.out.println("Excuting in directory: " + dir);
        
        Database database = this.project.getDatabase();           
        String db = database.getSchema();            
        Connection conn = ConnectionFactory.create(database);
        DataContext dataContext = new JdbcDataContext(conn);
        
        List<Schema> schemaList = new ArrayList<>();
        List<Table> tableList = new ArrayList<>();
        List<Column> columnList = new ArrayList<>();
        
        //Traverse database
        Schema[] schemas = dataContext.getSchemas();
        schemaList = Arrays.asList(schemas);
        
        for (Schema schema : schemas) {
            System.out.println("Schema: " + schema.getName());
            
            if (schema.getName().equals(db)) {
                
                Table[] tables = schema.getTables();
                tableList = Arrays.asList(tables);
                
                for (Table table : tables) {
                    System.out.println("    Table: " + table.getName());
                    
                    Column[] columns = table.getColumns();
                    columnList = Arrays.asList(columns);
                    for (Column column : columns) {
                        System.out.println("        Column: " + column.getName() + "Type: " + column.getType());
                    }
                }
            }
        }
        
        System.out.println("table list: " + tableList.size());
        Writer writer = WriterFactory.createWriter(this.project, tableList);
        writer.write();
    } catch (IOException ex) {
        Logger.getLogger(DefaultGenerator.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:azzuwan,项目名称:Novogen,代码行数:48,代码来源:DefaultGenerator.java

示例14: createPojoDatastore

import org.apache.metamodel.schema.Table; //导入方法依赖的package包/类
/**
 * Creates a serialized POJO copy of a datastore.
 *
 * @param datastore
 *            the datastore to copy
 * @param columns
 *            the columns to include, or null if all tables/columns should
 *            be included.
 * @param maxRowsToQuery
 *            the maximum number of records to query and include in the
 *            datastore copy. Keep this number reasonably low, or else the
 *            copy might cause out-of-memory issues (Both while reading and
 *            writing).
 * @return
 */
public AbstractDatastoreType createPojoDatastore(final Datastore datastore, final Set<Column> columns,
        final int maxRowsToQuery) {
    final PojoDatastoreType datastoreType = new PojoDatastoreType();
    datastoreType.setName(datastore.getName());
    datastoreType.setDescription(datastore.getDescription());

    try (DatastoreConnection con = datastore.openConnection()) {
        final DataContext dataContext = con.getDataContext();

        final Schema schema;
        final List<Table> tables;
        if (columns == null || columns.isEmpty()) {
            schema = dataContext.getDefaultSchema();
            tables = schema.getTables();
        } else {
            tables = Arrays.asList(MetaModelHelper.getTables(columns));
            // TODO: There's a possibility that tables span multiple
            // schemas, but we cannot currently support that in a
            // PojoDatastore, so we just pick the first and cross our
            // fingers.
            schema = tables.get(0).getSchema();
        }

        datastoreType.setSchemaName(schema.getName());

        for (final Table table : tables) {
            final List<Column> usedColumns;
            if (columns == null || columns.isEmpty()) {
                usedColumns = table.getColumns();
            } else {
                usedColumns = Arrays.asList(MetaModelHelper.getTableColumns(table, columns));
            }

            final PojoTableType tableType = createPojoTable(dataContext, table, usedColumns, maxRowsToQuery);
            datastoreType.getTable().add(tableType);
        }
    }

    return datastoreType;
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:56,代码来源:JaxbPojoDatastoreAdaptor.java

示例15: testReadComplexDataInPojoDatastore

import org.apache.metamodel.schema.Table; //导入方法依赖的package包/类
public void testReadComplexDataInPojoDatastore() throws Exception {
    final DataCleanerConfiguration configuration = reader.create(
            new File("src/test/resources/example-configuration-pojo-datastore-with-complex-data.xml"));
    final Datastore datastore = configuration.getDatastoreCatalog().getDatastore("pojo");
    assertNotNull(datastore);

    final DatastoreConnection con = datastore.openConnection();
    final DataContext dc = con.getDataContext();
    final Table table = dc.getDefaultSchema().getTable(0);

    final List<Column> columns = table.getColumns();
    assertEquals("[Column[name=Foo,columnNumber=0,type=VARCHAR,nullable=true,nativeType=null,columnSize=null], "
                    + "Column[name=Bar,columnNumber=1,type=MAP,nullable=true,nativeType=null,columnSize=null], "
                    + "Column[name=Baz,columnNumber=2,type=LIST,nullable=true,nativeType=null,columnSize=null], "
                    + "Column[name=bytes,columnNumber=3,type=BINARY,nullable=true,nativeType=null,columnSize=null]]",
            columns.toString());

    final DataSet ds = dc.query().from(table).select(columns).execute();

    assertTrue(ds.next());
    assertEquals("Hello", ds.getRow().getValue(0).toString());
    assertEquals("{greeting=hello, person=world}", ds.getRow().getValue(1).toString());
    assertEquals("[hello, world]", ds.getRow().getValue(2).toString());
    assertEquals("{1,2,3,4,5}", ArrayUtils.toString(ds.getRow().getValue(3)));
    assertTrue(ds.getRow().getValue(1) instanceof Map);
    assertTrue(ds.getRow().getValue(2) instanceof List);
    assertTrue(ds.getRow().getValue(3) instanceof byte[]);

    assertTrue(ds.next());
    assertEquals("There", ds.getRow().getValue(0).toString());
    assertEquals("{greeting=hi, there you!, person={Firstname=Kasper, Lastname=Sørensen}}",
            ds.getRow().getValue(1).toString());
    assertEquals(null, ds.getRow().getValue(2));
    assertEquals(null, ds.getRow().getValue(3));
    assertTrue(ds.getRow().getValue(1) instanceof Map);

    assertTrue(ds.next());
    assertEquals("World", ds.getRow().getValue(0).toString());
    assertEquals(null, ds.getRow().getValue(1));
    assertEquals("[Sørensen, Kasper]", ds.getRow().getValue(2).toString());
    assertEquals("{-1,-2,-3,-4,-5}", ArrayUtils.toString(ds.getRow().getValue(3)));
    assertTrue(ds.getRow().getValue(2) instanceof List);
    assertTrue(ds.getRow().getValue(3) instanceof byte[]);
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:45,代码来源:JaxbConfigurationReaderTest.java


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