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

Java Schema类代码示例

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

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



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


示例16: testConvertTableDefs

import org.apache.metamodel.schema.Schema; //导入依赖的package包/类
public void testConvertTableDefs() throws Exception {
    final DataContextFactoryBean factoryBean = new DataContextFactoryBean();
    factoryBean.setType("POJO");
    factoryBean.setDatabaseName("my db");
    factoryBean.setTableDefinitions("hello world (greeting VARCHAR, who VARCHAR); foo (bar INTEGER, baz DATE);");

    final DataContext dataContext = factoryBean.getObject();
    assertTrue(dataContext instanceof PojoDataContext);

    Schema schema = dataContext.getDefaultSchema();
    assertEquals("my db", schema.getName());
    assertEquals("[foo, hello world]", Arrays.toString(schema.getTableNames().toArray()));

    assertEquals(
            "[Column[name=greeting,columnNumber=0,type=VARCHAR,nullable=true,nativeType=null,columnSize=null], "
                    + "Column[name=who,columnNumber=1,type=VARCHAR,nullable=true,nativeType=null,columnSize=null]]",
            Arrays.toString(schema.getTableByName("hello world").getColumns().toArray()));

    assertEquals("[Column[name=bar,columnNumber=0,type=INTEGER,nullable=true,nativeType=null,columnSize=null], "
            + "Column[name=baz,columnNumber=1,type=DATE,nullable=true,nativeType=null,columnSize=null]]",
            Arrays.toString(schema.getTableByName("foo").getColumns().toArray()));
}
 
开发者ID:apache,项目名称:metamodel,代码行数:23,代码来源:PojoDataContextFactoryBeanDelegateTest.java


示例17: getMainSchema

import org.apache.metamodel.schema.Schema; //导入依赖的package包/类
@Override
protected Schema getMainSchema() throws MetaModelException {

    final MutableSchema schema = new MutableSchema(_schemaName);
    final MutableTable primaryTable = new MutableTable(_tableName).setSchema(schema);
    primaryTable.addColumn(new MutableColumn("foo").setColumnNumber(0).setType(ColumnType.VARCHAR)
            .setTable(primaryTable));
    primaryTable.addColumn(new MutableColumn("bar").setColumnNumber(1).setType(ColumnType.VARCHAR)
            .setTable(primaryTable));
    primaryTable.addColumn(new MutableColumn("baz").setColumnNumber(2).setType(ColumnType.VARCHAR)
            .setTable(primaryTable));

    final MutableTable emptyTable = new MutableTable("an_empty_table").setSchema(schema);
    emptyTable.addColumn(new MutableColumn("foo").setColumnNumber(0).setType(ColumnType.VARCHAR)
            .setTable(emptyTable));
    emptyTable.addColumn(new MutableColumn("bar").setColumnNumber(1).setType(ColumnType.VARCHAR)
            .setTable(emptyTable));

    schema.addTable(primaryTable);
    schema.addTable(emptyTable);

    return schema;
}
 
开发者ID:apache,项目名称:metamodel,代码行数:24,代码来源:MockDataContext.java


示例18: getMainSchema

import org.apache.metamodel.schema.Schema; //导入依赖的package包/类
@Override
protected Schema getMainSchema() throws MetaModelException {
    final MutableSchema schema = new MutableSchema(_configuration.getSchemaName());

    try {
        SimpleTableDef[] tableDefinitions = _configuration.getTableDefinitions();
        if (tableDefinitions == null) {
            final HTableDescriptor[] tables = getAdmin().listTables();
            tableDefinitions = new SimpleTableDef[tables.length];
            for (int i = 0; i < tables.length; i++) {
                SimpleTableDef emptyTableDef = new SimpleTableDef(tables[i].getNameAsString(), new String[0]);
                tableDefinitions[i] = emptyTableDef;
            }
        }

        for (SimpleTableDef tableDef : tableDefinitions) {
            schema.addTable(new HBaseTable(this, tableDef, schema, _configuration.getDefaultRowKeyType()));
        }

        return schema;
    } catch (Exception e) {
        throw new MetaModelException(e);
    }
}
 
开发者ID:apache,项目名称:metamodel,代码行数:25,代码来源:HBaseDataContext.java


示例19: testMissingValues

import org.apache.metamodel.schema.Schema; //导入依赖的package包/类
public void testMissingValues() throws Exception {
    File file = copyOf("src/test/resources/xls_missing_values.xls");
    DataContext dc = new ExcelDataContext(file);
    Schema schema = dc.getDefaultSchema();
    assertEquals(2, schema.getTableCount());

    Table table = schema.getTables().get(0);
    assertEquals("[Column[name=a,columnNumber=0,type=VARCHAR,nullable=true,nativeType=null,columnSize=null], "
            + "Column[name=b,columnNumber=1,type=VARCHAR,nullable=true,nativeType=null,columnSize=null], "
            + "Column[name=c,columnNumber=2,type=VARCHAR,nullable=true,nativeType=null,columnSize=null], "
            + "Column[name=d,columnNumber=3,type=VARCHAR,nullable=true,nativeType=null,columnSize=null]]",
            Arrays.toString(table.getColumns().toArray()));

    Query q = new Query().select(table.getColumns()).from(table);
    DataSet ds = dc.executeQuery(q);
    assertTrue(ds.next());
    assertEquals("[1, 2, 3, null]", Arrays.toString(ds.getRow().getValues()));
    assertTrue(ds.next());
    assertEquals("[5, null, 7, 8]", Arrays.toString(ds.getRow().getValues()));
    assertTrue(ds.next());
    assertEquals("[9, 10, 11, 12]", Arrays.toString(ds.getRow().getValues()));
    assertFalse(ds.next());
}
 
开发者ID:apache,项目名称:metamodel,代码行数:24,代码来源:ExcelDataContextTest.java


示例20: testMissingColumnHeader

import org.apache.metamodel.schema.Schema; //导入依赖的package包/类
public void testMissingColumnHeader() throws Exception {
    File file = copyOf("src/test/resources/xls_missing_column_header.xls");
    DataContext dc = new ExcelDataContext(file);
    Schema schema = dc.getDefaultSchema();
    assertEquals(2, schema.getTableCount());

    Table table = schema.getTables().get(0);
    assertEquals("[Column[name=a,columnNumber=0,type=VARCHAR,nullable=true,nativeType=null,columnSize=null], "
            + "Column[name=b,columnNumber=1,type=VARCHAR,nullable=true,nativeType=null,columnSize=null], "
            + "Column[name=A,columnNumber=2,type=VARCHAR,nullable=true,nativeType=null,columnSize=null], "
            + "Column[name=d,columnNumber=3,type=VARCHAR,nullable=true,nativeType=null,columnSize=null]]",
            Arrays.toString(table.getColumns().toArray()));

    Query q = new Query().select(table.getColumns()).from(table);
    DataSet ds = dc.executeQuery(q);
    assertTrue(ds.next());
    assertEquals("[1, 2, 3, 4]", Arrays.toString(ds.getRow().getValues()));
    assertTrue(ds.next());
    assertEquals("[5, 6, 7, 8]", Arrays.toString(ds.getRow().getValues()));
    assertTrue(ds.next());
    assertEquals("[9, 10, 11, 12]", Arrays.toString(ds.getRow().getValues()));
    assertFalse(ds.next());
}
 
开发者ID:apache,项目名称:metamodel,代码行数:24,代码来源:ExcelDataContextTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java GroupConstants类代码示例发布时间:2022-05-22
下一篇:
Java OnStateChange类代码示例发布时间: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