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


Java Schema类代码示例

本文整理汇总了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);
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:17,代码来源:SchemaComparator.java

示例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;
        }
    };
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:22,代码来源:OutputDataStreamDataContext.java

示例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;
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:18,代码来源:ExcelOutputWriterFactory.java

示例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());
    }
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:19,代码来源:ForeignKey.java

示例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;
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:24,代码来源:ConfigurationItemConverter.java

示例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]);
    }
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:22,代码来源:SasDatastoreTest.java

示例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);
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:17,代码来源:SchemaTree.java

示例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());
        }
    }
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:25,代码来源:SchemaMouseListener.java

示例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);
    }
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:17,代码来源:SchemaMouseListener.java

示例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);
        }
    }
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:22,代码来源:SchemaNamePropertyWidget.java

示例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;
}
 
开发者ID:datacleaner,项目名称:metamodel_extras,代码行数:20,代码来源:SasDataContext.java

示例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;
    }
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:20,代码来源:ForeignKey.java

示例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;
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:24,代码来源:ConfigurationItemConverter.java

示例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]);
    }
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:22,代码来源:SasDatastoreTest.java

示例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;
}
 
开发者ID:datacleaner,项目名称:pdi-datacleaner,代码行数:17,代码来源:KettleDataContext.java


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