本文整理汇总了Java中org.apache.metamodel.schema.Schema类的典型用法代码示例。如果您正苦于以下问题:Java Schema类的具体用法?Java Schema怎么用?Java Schema使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Schema类属于org.apache.metamodel.schema包,在下文中一共展示了Schema类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compare
import org.apache.metamodel.schema.Schema; //导入依赖的package包/类
@Override
public int compare(final Schema o1, final Schema o2) {
if (o1 == null) {
return -1;
}
if (o2 == null) {
return 1;
}
if (MetaModelHelper.isInformationSchema(o1)) {
return -1;
}
if (MetaModelHelper.isInformationSchema(o2)) {
return 1;
}
return o1.compareTo(o2);
}
示例2: getMainSchema
import org.apache.metamodel.schema.Schema; //导入依赖的package包/类
@Override
protected Schema getMainSchema() throws MetaModelException {
return new AbstractSchema() {
private static final long serialVersionUID = 1L;
@Override
public String getQuote() {
return null;
}
@Override
public List<Table> getTables() {
return Collections.singletonList(_outputDataStream.getTable());
}
@Override
public String getName() {
return null;
}
};
}
示例3: getTable
import org.apache.metamodel.schema.Schema; //导入依赖的package包/类
private static Table getTable(final UpdateableDataContext dataContext, final String sheetName,
final String[] columnNames) {
final Schema schema = dataContext.getDefaultSchema();
Table table = schema.getTableByName(sheetName);
if (table == null) {
final MutableRef<Table> tableRef = new MutableRef<>();
dataContext.executeUpdate(callback -> {
final TableCreationBuilder tableBuilder = callback.createTable(schema, sheetName);
for (final String columnName : columnNames) {
tableBuilder.withColumn(columnName);
}
tableRef.set(tableBuilder.execute());
});
table = tableRef.get();
}
return table;
}
示例4: resolveForeignColumn
import org.apache.metamodel.schema.Schema; //导入依赖的package包/类
public Column resolveForeignColumn(final DatastoreCatalog datastoreCatalog) {
final Datastore datastore = datastoreCatalog.getDatastore(getForeignDatastoreName());
if (datastore == null) {
return null;
}
try (DatastoreConnection connection = datastore.openConnection()) {
final DataContext dataContext = connection.getDataContext();
final Schema schema = dataContext.getSchemaByName(getForeignSchemaName());
if (schema == null) {
return null;
}
final Table table = schema.getTableByName(getForeignTableName());
if (table == null) {
return null;
}
return table.getColumnByName(getForeignColumnName());
}
}
示例5: toString
import org.apache.metamodel.schema.Schema; //导入依赖的package包/类
@Override
public String toString(final 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;
}
示例6: testConnectAndExplore
import org.apache.metamodel.schema.Schema; //导入依赖的package包/类
public void testConnectAndExplore() throws Exception {
final SasDatastore ds = new SasDatastore("my sas ds", new File("src/test/resources/sas"));
try (DatastoreConnection con = ds.openConnection()) {
final Schema schema = con.getSchemaNavigator().getDefaultSchema();
assertEquals("[dummy1, dummy2, pizza]", schema.getTableNames().toString());
final Table table = schema.getTableByName("pizza");
assertEquals("[id, mois, prot, fat, ash, sodium, carb, cal, brand]",
table.getColumnNames().toString());
final Column col = table.getColumnByName("brand");
final Query q = con.getDataContext().query().from(table).select(col).orderBy(col).toQuery();
q.getSelectClause().setDistinct(true);
final List<Object[]> objectArrays = con.getDataContext().executeQuery(q).toObjectArrays();
assertEquals(10, objectArrays.size());
assertEquals("a", objectArrays.get(0)[0]);
assertEquals("b", objectArrays.get(1)[0]);
}
}
示例7: executeBlockingly
import org.apache.metamodel.schema.Schema; //导入依赖的package包/类
public void executeBlockingly() {
if (!isNeeded()) {
return;
}
final Schema schema = (Schema) _schemaNode.getUserObject();
final List<Table> tables = schema.getTables();
for (final Table table : tables) {
final String name = table.getName();
logger.debug("Building table node: {}", name);
final DefaultMutableTreeNode tableNode = new DefaultMutableTreeNode(table);
final DefaultMutableTreeNode loadingColumnsNode = new DefaultMutableTreeNode(LOADING_COLUMNS_STRING);
tableNode.add(loadingColumnsNode);
_schemaNode.add(tableNode);
}
_schemaNode.remove(0);
}
示例8: mouseClicked
import org.apache.metamodel.schema.Schema; //导入依赖的package包/类
@Override
public void mouseClicked(final MouseEvent e) {
final TreePath path = _schemaTree.getPathForLocation(e.getX(), e.getY());
if (path == null) {
return;
}
final DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
final Object userObject = node.getUserObject();
if (userObject instanceof Schema) {
final Schema schema = (Schema) userObject;
final int button = e.getButton();
if (button == MouseEvent.BUTTON2 || button == MouseEvent.BUTTON3) {
final JPopupMenu popup = new JPopupMenu();
popup.setLabel(schema.getName());
addAddTablesToSourceMenuItem(schema, popup);
addCreateTableMenuItem(schema, popup);
popup.show((Component) e.getSource(), e.getX(), e.getY());
}
}
}
示例9: addCreateTableMenuItem
import org.apache.metamodel.schema.Schema; //导入依赖的package包/类
private void addCreateTableMenuItem(final Schema schema, final JPopupMenu popup) {
final Datastore datastore = _schemaTree.getDatastore();
if (CreateTableDialog.isCreateTableAppropriate(datastore, schema)) {
popup.addSeparator();
final UpdateableDatastore updateableDatastore = (UpdateableDatastore) datastore;
final JMenuItem createTableMenuItem =
WidgetFactory.createMenuItem("Create table", IconUtils.ACTION_CREATE_TABLE);
createTableMenuItem.addActionListener(e -> {
final CreateTableDialog dialog = new CreateTableDialog(_windowContext, updateableDatastore, schema);
dialog.addListener((datastore1, schema1, tableName) -> _schemaTree.refreshDatastore());
dialog.open();
});
popup.add(createTableMenuItem);
}
}
示例10: setDatastore
import org.apache.metamodel.schema.Schema; //导入依赖的package包/类
public void setDatastore(final Datastore datastore) {
final String previousValue = getValue();
_datastoreRef.set(datastore);
if (datastore == null) {
_comboBox.setModel(new DefaultComboBoxModel<>(new Schema[1]));
} else {
try (DatastoreConnection con = datastore.openConnection()) {
Schema[] schemas = con.getSchemaNavigator().getSchemas();
schemas = CollectionUtils.array(new Schema[1], schemas);
_comboBox.setModel(new DefaultComboBoxModel<>(schemas));
Schema newValue = null;
if (previousValue != null) {
newValue = con.getSchemaNavigator().getSchemaByName(previousValue);
}
if (newValue == null) {
newValue = con.getSchemaNavigator().getDefaultSchema();
}
_comboBox.setSelectedItem(newValue);
}
}
}
示例11: getMainSchema
import org.apache.metamodel.schema.Schema; //导入依赖的package包/类
@Override
protected Schema getMainSchema() throws MetaModelException {
MutableSchema schema = new MutableSchema(getMainSchemaName());
File[] tableFiles = _directory.listFiles(new SasFilenameFilter());
if (tableFiles.length == 0) {
logger.warn("Directory did not contain any SAS tables: {}",
_directory);
}
Arrays.sort(tableFiles);
for (File file : tableFiles) {
SasTable table = new SasTable(file, schema);
schema.addTable(table);
}
return schema;
}
示例12: resolveForeignColumn
import org.apache.metamodel.schema.Schema; //导入依赖的package包/类
public Column resolveForeignColumn(DatastoreCatalog datastoreCatalog) {
Datastore datastore = datastoreCatalog.getDatastore(getForeignDatastoreName());
if (datastore == null) {
return null;
}
try (DatastoreConnection connection = datastore.openConnection()) {
DataContext dataContext = connection.getDataContext();
Schema schema = dataContext.getSchemaByName(getForeignSchemaName());
if (schema == null) {
return null;
}
Table table = schema.getTableByName(getForeignTableName());
if (table == null) {
return null;
}
Column column = table.getColumnByName(getForeignColumnName());
return column;
}
}
示例13: toString
import org.apache.metamodel.schema.Schema; //导入依赖的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;
}
示例14: testConnectAndExplore
import org.apache.metamodel.schema.Schema; //导入依赖的package包/类
public void testConnectAndExplore() throws Exception {
final SasDatastore ds = new SasDatastore("my sas ds", new File("src/test/resources/sas"));
try (final DatastoreConnection con = ds.openConnection()) {
Schema schema = con.getSchemaNavigator().getDefaultSchema();
assertEquals("[dummy1, dummy2, pizza]", Arrays.toString(schema.getTableNames()));
Table table = schema.getTableByName("pizza");
assertEquals("[id, mois, prot, fat, ash, sodium, carb, cal, brand]",
Arrays.toString(table.getColumnNames()));
Column col = table.getColumnByName("brand");
Query q = con.getDataContext().query().from(table).select(col).orderBy(col).toQuery();
q.getSelectClause().setDistinct(true);
List<Object[]> objectArrays = con.getDataContext().executeQuery(q).toObjectArrays();
assertEquals(10, objectArrays.size());
assertEquals("a", objectArrays.get(0)[0]);
assertEquals("b", objectArrays.get(1)[0]);
}
}
示例15: getMainSchema
import org.apache.metamodel.schema.Schema; //导入依赖的package包/类
@Override
protected Schema getMainSchema() throws MetaModelException {
MutableSchema schema = new MutableSchema(getTransformationName());
MutableTable table = new MutableTable(getStepName(), TableType.TABLE);
table.setSchema(schema);
RowMetaInterface rowMeta = getRowMeta();
for (int i = 0; i < rowMeta.size(); i++) {
ValueMetaInterface valueMeta = rowMeta.getValueMeta(i);
MutableColumn column = new MutableColumn(valueMeta.getName(), getColumnType(valueMeta), table, i,
Integer.valueOf(valueMeta.getLength()), valueMeta.getTypeDesc(), true, valueMeta.getComments(),
false, "");
table.addColumn(column);
}
schema.addTable(table);
return schema;
}