本文整理汇总了Java中org.apache.metamodel.schema.Column类的典型用法代码示例。如果您正苦于以下问题:Java Column类的具体用法?Java Column怎么用?Java Column使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Column类属于org.apache.metamodel.schema包,在下文中一共展示了Column类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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));
}
示例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();
}
示例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());
}
}
示例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);
}
示例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);
}
}
}
}
});
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}
示例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));
}