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

Java Column类代码示例

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

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



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

示例1: addColumn

import org.apache.metamodel.schema.Column; //导入依赖的package包/类
private void addColumn(Column rawColumn, MTable mTable) {
    String columnName = rawColumn.getName();
    ColumnType columnType = rawColumn.getType();
    if (ColumnType.STRING.getName().equalsIgnoreCase(columnType.getName())) {
        columnType = ColumnTypeImpl.convertColumnType(Types.VARCHAR);
    }
    int jdbcType = columnType.getJdbcType();
    int typeInfo = -1;
    if (jdbcType == Types.VARCHAR) {
        Integer columnSize = rawColumn.getColumnSize();
        if (columnSize == null) {
            // FIXME: what is the proper length value?
            typeInfo = 128;
        } else {
            typeInfo = columnSize;
        }
    }

    LOG.debug("add column. columnName=" + columnName + ", jdbcType=" + jdbcType + ", typeInfo=" + typeInfo);
    MColumn mColumn = new MColumn(columnName, jdbcType, typeInfo, mTable);
    pm.makePersistent(mColumn);
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:23,代码来源:JDOMetaContext.java


示例2: updateColumnsOfTable

import org.apache.metamodel.schema.Column; //导入依赖的package包/类
private void updateColumnsOfTable(Table rawTable, MTable mTable) throws MetaException {
    Map<String, MColumn> oldColumns = new HashMap<>();

    for (MetaColumn col : mTable.getColumns())
        oldColumns.put(col.getName(), (MColumn) col);

    Set<String> oldColumnNames = new TreeSet<>(oldColumns.keySet());
    Set<String> newColumnNames = new TreeSet<>();

    for (Column rawColumn : getRawTableColumns(rawTable)) {
        String colName = rawColumn.getName();

        newColumnNames.add(colName);

        /* NOTE: column order could be wrong! */
        if (!oldColumns.containsKey(colName))
            addColumn(rawColumn, mTable);
    }

    // remove old columns
    oldColumnNames.removeAll(newColumnNames);
    for (String name : oldColumnNames)
        pm.deletePersistent(oldColumns.get(name));
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:25,代码来源:JDOMetaContext.java


示例3: readComplexData

import org.apache.metamodel.schema.Column; //导入依赖的package包/类
public void readComplexData() throws Exception {
		Column primaryColumn = dataContext.getTableByQualifiedLabel(joinTable).getColumnByName(secondFkey);
		System.out.println(dataContext.query().from(joinTable).select(primaryColumn).groupBy(primaryColumn).toQuery().toString());
		DataSet dataSet = dataContext.query().from(joinTable).select(primaryColumn).groupBy(primaryColumn).execute();
		while (dataSet.next()) {

			arrayData = new ArrayList<Row>();
			Object dataValue = dataSet.getRow().getValue(primaryColumn);
			DataSet dataSetArray = dataContext.query().from(joinTable).select(forgeinKey).where(primaryColumn)
					.eq(dataValue).execute();
			System.out.println( dataContext.query().from(joinTable).select(forgeinKey).where(primaryColumn)
					.eq(dataValue).toQuery().toSql());
			readDataSet(dataSetArray);
			ComplexData complexDataObject = new ComplexData(dataSet.getRow(), arrayData);
			queueComplexData.put(complexDataObject);
			dataSetArray.close();
//			dataContext.executeUpdate();

		}
		insertPosion();
		dataSet.close();

	}
 
开发者ID:Iranox,项目名称:mapbench-datadistributor,代码行数:24,代码来源:ComplexDataReader.java


示例4: setColumns

import org.apache.metamodel.schema.Column; //导入依赖的package包/类
public void setColumns(final Collection<Column> columns) {
    final Iterator<Column> it = columns.iterator();
    final Component[] components = _sourceComboBoxPanel.getComponents();
    for (final Component component : components) {
        if (component instanceof SourceColumnComboBox) {
            if (!it.hasNext()) {
                return;
            }

            final Column column = it.next();
            final SourceColumnComboBox sourceColumnComboBox = (SourceColumnComboBox) component;
            sourceColumnComboBox.setSelectedItem(column);
        }
    }

    while (it.hasNext()) {
        createSourceColumnComboBox(it.next());
    }
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:20,代码来源:MultiSourceColumnComboBoxPanel.java


示例5: addSourceColumns

import org.apache.metamodel.schema.Column; //导入依赖的package包/类
public AnalysisJobBuilder addSourceColumns(String... columnNames) {
    if (_datastoreConnection == null) {
        throw new IllegalStateException(
                "Cannot add source columns by name when no Datastore or DatastoreConnection has been set");
    }
    SchemaNavigator schemaNavigator = _datastoreConnection.getSchemaNavigator();
    Column[] columns = new Column[columnNames.length];
    for (int i = 0; i < columns.length; i++) {
        String columnName = columnNames[i];
        Column column = schemaNavigator.convertToColumn(columnName);
        if (column == null) {
            throw new IllegalArgumentException("No such column: " + columnName);
        }
        columns[i] = column;
    }
    return addSourceColumns(columns);
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:18,代码来源:AnalysisJobBuilder.java


示例6: updateMappedColumns

import org.apache.metamodel.schema.Column; //导入依赖的package包/类
private void updateMappedColumns() {
    final Table table = _tableRef.get();
    final Set<Entry<InputColumn<?>, SourceColumnComboBox>> entrySet = _mappedColumnComboBoxes.entrySet();

    batchUpdateWidget(() -> {
        for (final Entry<InputColumn<?>, SourceColumnComboBox> entry : entrySet) {
            final InputColumn<?> inputColumn = entry.getKey();
            final SourceColumnComboBox comboBox = entry.getValue();

            if (table == null) {
                comboBox.setEmptyModel();
            } else {
                comboBox.setModel(table);
                if (comboBox.getSelectedItem() == null) {
                    final Column column = getDefaultMappedColumn(inputColumn, table);
                    if (column != null) {
                        comboBox.setEditable(true);
                        comboBox.setSelectedItem(column);
                        comboBox.setEditable(false);
                    }
                }
            }
        }
    });
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:26,代码来源:MultipleMappedColumnsPropertyWidget.java


示例7: testOptimizeQueryValuesArray

import org.apache.metamodel.schema.Column; //导入依赖的package包/类
public void testOptimizeQueryValuesArray() throws Exception {
    final DatastoreConnection con = datastore.openConnection();
    final Column column = con.getSchemaNavigator().convertToColumn("PUBLIC.EMPLOYEES.FIRSTNAME");
    final InputColumn<?> inputColumn = new MetaModelInputColumn(column);

    final EqualsFilter filter = new EqualsFilter(new String[] { "foobar" }, inputColumn);
    assertTrue(filter.isOptimizable(EqualsFilter.Category.EQUALS));
    assertTrue(filter.isOptimizable(EqualsFilter.Category.NOT_EQUALS));

    final Query query = con.getDataContext().query().from(column.getTable()).select(column).toQuery();
    final String originalSql = query.toSql();
    assertEquals("SELECT \"EMPLOYEES\".\"FIRSTNAME\" FROM PUBLIC.\"EMPLOYEES\"", originalSql);

    Query result;
    result = filter.optimizeQuery(query.clone(), EqualsFilter.Category.EQUALS);
    assertEquals(originalSql + " WHERE \"EMPLOYEES\".\"FIRSTNAME\" = 'foobar'", result.toSql());

    result = filter.optimizeQuery(query.clone(), EqualsFilter.Category.NOT_EQUALS);
    assertEquals(originalSql + " WHERE \"EMPLOYEES\".\"FIRSTNAME\" <> 'foobar'", result.toSql());

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


示例8: addPrimaryKeysIfSourced

import org.apache.metamodel.schema.Column; //导入依赖的package包/类
/**
 * Inspects the row processed tables primary keys. If all primary keys are
 * in the source columns of the AnalysisJob, they will be added to the
 * physically queried columns.
 *
 * Adding the primary keys to the query is a trade-off: It helps a lot in
 * making eg. annotated rows referenceable to the source table, but it may
 * also potentially make the job heavier to execute since a lot of (unique)
 * values will be retrieved.
 */
public void addPrimaryKeysIfSourced() {
    final List<Column> primaryKeyColumns = getTable().getPrimaryKeys();
    if (primaryKeyColumns == null || primaryKeyColumns.isEmpty()) {
        logger.info("No primary keys defined for table {}, not pre-selecting primary keys", getTable().getName());
        return;
    }

    final Collection<InputColumn<?>> sourceInputColumns = getAnalysisJob().getSourceColumns();
    final List<Column> sourceColumns = CollectionUtils.map(sourceInputColumns, InputColumn::getPhysicalColumn);

    for (final Column primaryKeyColumn : primaryKeyColumns) {
        if (!sourceColumns.contains(primaryKeyColumn)) {
            logger.info("Primary key column {} not added to source columns, not pre-selecting primary keys");
            return;
        }
    }

    addPhysicalColumns(primaryKeyColumns);
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:30,代码来源:SourceTableRowProcessingPublisher.java


示例9: isQueryOutputColumnsUpdated

import org.apache.metamodel.schema.Column; //导入依赖的package包/类
/**
 * Checks the validity of the current (cached) output columns array.
 * 
 * @return true if the current columns are valid
 */
private boolean isQueryOutputColumnsUpdated() {
    if (queryOutputColumns.length != outputColumns.length) {
        return false;
    }
    for (int i = 0; i < queryOutputColumns.length; i++) {
        Column outputColumn = queryOutputColumns[i];
        String expectedName = outputColumns[i];
        if (!expectedName.equals(outputColumn.getName())) {
            return false;
        }
        if (tableName != null && !tableName.equals(outputColumn.getTable().getName())) {
            return false;
        }
    }

    return true;
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:23,代码来源:TableLookupTransformer.java


示例10: addPrimaryKeysIfSourced

import org.apache.metamodel.schema.Column; //导入依赖的package包/类
/**
 * Inspects the row processed tables primary keys. If all primary keys are
 * in the source columns of the AnalysisJob, they will be added to the
 * physically queried columns.
 * 
 * Adding the primary keys to the query is a trade-off: It helps a lot in
 * making eg. annotated rows referenceable to the source table, but it may
 * also potentially make the job heavier to execute since a lot of (unique)
 * values will be retrieved.
 */
public void addPrimaryKeysIfSourced() {
    Column[] primaryKeyColumns = _table.getPrimaryKeys();
    if (primaryKeyColumns == null || primaryKeyColumns.length == 0) {
        logger.info("No primary keys defined for table {}, not pre-selecting primary keys", _table.getName());
        return;
    }

    final AnalysisJob analysisJob = _publishers.getAnalysisJob();
    final Collection<InputColumn<?>> sourceInputColumns = analysisJob.getSourceColumns();
    final List<Column> sourceColumns = CollectionUtils.map(sourceInputColumns, new Func<InputColumn<?>, Column>() {
        @Override
        public Column eval(InputColumn<?> inputColumn) {
            return inputColumn.getPhysicalColumn();
        }
    });

    for (Column primaryKeyColumn : primaryKeyColumns) {
        if (!sourceColumns.contains(primaryKeyColumn)) {
            logger.info("Primary key column {} not added to source columns, not pre-selecting primary keys");
            return;
        }
    }

    addPhysicalColumns(primaryKeyColumns);
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:36,代码来源:RowProcessingPublisher.java


示例11: getValues

import org.apache.metamodel.schema.Column; //导入依赖的package包/类
public ReferenceValues<String> getValues() {
	if (_cachedRefValues == null) {
		synchronized (this) {
			if (_cachedRefValues == null) {
				Datastore datastore = getDatastore();

				DatastoreConnection datastoreConnection = datastore.openConnection();
				SchemaNavigator schemaNavigator = datastoreConnection.getSchemaNavigator();
				Column column = schemaNavigator.convertToColumns(new String[] { _qualifiedColumnName })[0];
				if (column == null) {
					throw new IllegalStateException("Could not resolve column " + _qualifiedColumnName);
				}
				_cachedRefValues = new DatastoreReferenceValues(datastore, column);
				datastoreConnection.close();
			}
		}
	}
	return _cachedRefValues;
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:20,代码来源:DatastoreDictionary.java


示例12: loadIntoMemory

import org.apache.metamodel.schema.Column; //导入依赖的package包/类
public SimpleDictionary loadIntoMemory(final DatastoreConnection datastoreConnection) {
    final DataContext dataContext = datastoreConnection.getDataContext();
    final Column column = getColumn(datastoreConnection);

    final Query query = dataContext.query().from(column.getTable()).select(column).toQuery();
    if (datastoreConnection.getDatastore().getPerformanceCharacteristics().isQueryOptimizationPreferred()) {
        query.getSelectClause().setDistinct(true);
    }

    final Set<String> values = new HashSet<>();

    try (DataSet dataSet = dataContext.executeQuery(query)) {
        while (dataSet.next()) {
            final Object value = dataSet.getRow().getValue(0);
            if (value != null) {
                values.add(value.toString());
            }
        }
    }

    return new SimpleDictionary(getName(), values);
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:23,代码来源:DatastoreDictionary.java


示例13: isQueryOutputColumnsUpdated

import org.apache.metamodel.schema.Column; //导入依赖的package包/类
/**
 * Checks the validity of the current (cached) output columns array.
 *
 * @return true if the current columns are valid
 */
private boolean isQueryOutputColumnsUpdated() {
    if (queryOutputColumns.length != outputColumns.length) {
        return false;
    }
    for (int i = 0; i < queryOutputColumns.length; i++) {
        final Column outputColumn = queryOutputColumns[i];
        final String expectedName = outputColumns[i];
        if (!expectedName.equals(outputColumn.getName())) {
            return false;
        }
        if (tableName != null && !tableName.equals(outputColumn.getTable().getName())) {
            return false;
        }
    }

    return true;
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:23,代码来源:TableLookupTransformer.java


示例14: performQuery

import org.apache.metamodel.schema.Column; //导入依赖的package包/类
private Object[] performQuery(final InputRow row, final List<Object> queryInput) {
    try {
        final Column[] queryConditionColumns = getQueryConditionColumns();

        final Object[] parameterValues = new Object[queryConditionColumns.length];
        for (int i = 0; i < queryConditionColumns.length; i++) {
            parameterValues[i] = queryInput.get(i);
        }

        try (DataSet dataSet = datastoreConnection.getDataContext().executeQuery(lookupQuery, parameterValues)) {
            return handleDataSet(row, dataSet);
        }
    } catch (final RuntimeException e) {
        logger.error("Error occurred while looking up based on conditions: " + queryInput, e);
        throw e;
    }
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:18,代码来源:TableLookupTransformer.java


示例15: testDelegateOnPhysicalColumn

import org.apache.metamodel.schema.Column; //导入依赖的package包/类
public void testDelegateOnPhysicalColumn() throws Exception {
    final Column col1 = new MutableColumn("foo");
    final InputColumn<?> inputColumn1 = new MetaModelInputColumn(col1);

    final Column col2 = new MutableColumn("bar");
    final InputColumn<?> inputColumn2 = new MetaModelInputColumn(col2);

    final SelectItem[] selectItems = new SelectItem[] { new SelectItem(col1), new SelectItem(col2) };
    final Object[] values = new Object[] { 1234, 4567 };
    final DataSetHeader header = new SimpleDataSetHeader(selectItems);
    final TransformedInputRow row =
            new TransformedInputRow(new MetaModelInputRow(0, new DefaultRow(header, values)), 1);

    assertEquals(1234, row.getValue(inputColumn1));
    assertEquals(4567, row.getValue(inputColumn2));
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:17,代码来源:TransformedInputRowTest.java


示例16: testSimpleInteractions

import org.apache.metamodel.schema.Column; //导入依赖的package包/类
public void testSimpleInteractions() throws Exception {
    final SimpleTableDef tableDef = new SimpleTableDef("foo", new String[] { "col1", "col2" });
    final Collection<Map<String, ?>> maps = new ArrayList<Map<String, ?>>();

    final TableDataProvider<?> tableDataProvider = new MapTableDataProvider(tableDef, maps);
    maps.add(new HashMap<String, Object>());

    final List<TableDataProvider<?>> tableDataProviders = new ArrayList<TableDataProvider<?>>();
    tableDataProviders.add(tableDataProvider);

    final PojoDatastore ds = new PojoDatastore("foobar", tableDataProviders);

    assertEquals("foobar", ds.getName());

    assertFalse(ds.getPerformanceCharacteristics().isQueryOptimizationPreferred());

    ds.setDescription("foo");
    assertEquals("foo", ds.getDescription());

    final UpdateableDatastoreConnection con = ds.openConnection();
    assertNotNull(con);

    final Column col = con.getSchemaNavigator().convertToColumn("foo.col1");
    assertEquals("Column[name=col1,columnNumber=0,type=VARCHAR,nullable=true,"
            + "nativeType=null,columnSize=null]", col.toString());
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:27,代码来源:PojoDatastoreTest.java


示例17: testOpenSpreadsheetXls

import org.apache.metamodel.schema.Column; //导入依赖的package包/类
public void testOpenSpreadsheetXls() throws Exception {
	Datastore datastore = new ExcelDatastore("foobar", null, "src/test/resources/Spreadsheet2003.xls");
	assertEquals("foobar", datastore.getName());
	DatastoreConnection con = datastore.openConnection();
	assertNotNull(con);

	Column col1 = con.getSchemaNavigator().convertToColumn("string");
	assertNotNull(col1);

	Column col2 = con.getSchemaNavigator().convertToColumn("number");
	assertNotNull(col2);

	Column col3 = con.getSchemaNavigator().convertToColumn("date");
	assertNotNull(col3);
	assertEquals(
			"Column[name=date,columnNumber=2,type=VARCHAR,nullable=true,nativeType=null,columnSize=null]",
			col3.toString());
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:19,代码来源:ExcelDatastoreTest.java


示例18: testCustomColumnNaming

import org.apache.metamodel.schema.Column; //导入依赖的package包/类
public void testCustomColumnNaming() throws Exception {
    final DatastoreConnection con = new ExcelDatastore("foobar", null, "src/test/resources/Spreadsheet2007.xlsx",
            Arrays.asList("first", "second", "third")).openConnection();

    assertNotNull(con.getSchemaNavigator().convertToColumn("first"));
    assertNotNull(con.getSchemaNavigator().convertToColumn("second"));

    final Column col3 = con.getSchemaNavigator().convertToColumn("third");
    assertNotNull(col3);
    assertEquals("Column[name=third,columnNumber=2,type=STRING,nullable=true,nativeType=null,columnSize=null]",
            col3.toString());

    assertEquals(NR_ENTRIES_IN_SPREADSHEET2007,
            con.getDataContext().executeQuery("select count(third) from Sheet1").toRows().get(0).getValue(0)
                    .toString());
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:17,代码来源:ExcelDatastoreTest.java


示例19: toString

import org.apache.metamodel.schema.Column; //导入依赖的package包/类
@Override
public String toString(Object o) {
    final String result;
    if (o instanceof Schema) {
        result = ((Schema) o).getName();
    } else if (o instanceof Table) {
        result = ((Table) o).getQualifiedLabel();
    } else if (o instanceof Column) {
        result = ((Column) o).getQualifiedLabel();
    } else if (o instanceof Dictionary) {
        result = ((Dictionary) o).getName();
    } else if (o instanceof SynonymCatalog) {
        result = ((SynonymCatalog) o).getName();
    } else if (o instanceof StringPattern) {
        result = ((StringPattern) o).getName();
    } else if (o instanceof Datastore) {
        result = ((Datastore) o).getName();
    } else {
        logger.warn("Could not convert type: {}", o.getClass().getName());
        result = o.toString();
    }
    return result;
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:24,代码来源:ConfigurationItemConverter.java


示例20: testOptimizeQueryValuesArray

import org.apache.metamodel.schema.Column; //导入依赖的package包/类
public void testOptimizeQueryValuesArray() throws Exception {
    DatastoreConnection con = datastore.openConnection();
    Column column = con.getSchemaNavigator().convertToColumn("PUBLIC.EMPLOYEES.FIRSTNAME");
    InputColumn<?> inputColumn = new MetaModelInputColumn(column);

    EqualsFilter filter = new EqualsFilter(new String[] { "foobar" }, inputColumn);
    assertTrue(filter.isOptimizable(ValidationCategory.VALID));
    assertTrue(filter.isOptimizable(ValidationCategory.INVALID));

    Query query = con.getDataContext().query().from(column.getTable()).select(column).toQuery();
    String originalSql = query.toSql();
    assertEquals("SELECT \"EMPLOYEES\".\"FIRSTNAME\" FROM PUBLIC.\"EMPLOYEES\"", originalSql);

    Query result;
    result = filter.optimizeQuery(query.clone(), ValidationCategory.VALID);
    assertEquals(originalSql + " WHERE (\"EMPLOYEES\".\"FIRSTNAME\" = 'foobar')", result.toSql());

    result = filter.optimizeQuery(query.clone(), ValidationCategory.INVALID);
    assertEquals(originalSql + " WHERE \"EMPLOYEES\".\"FIRSTNAME\" <> 'foobar'", result.toSql());

    con.close();
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:23,代码来源:EqualsFilterTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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