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


Java ColumnType.INTEGER属性代码示例

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


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

示例1: getColumnType

private ColumnType getColumnType(ValueMetaInterface valueMeta) {
    switch (valueMeta.getType()) {
    case ValueMetaInterface.TYPE_STRING:
        return ColumnType.VARCHAR;
    case ValueMetaInterface.TYPE_INTEGER:
        return ColumnType.INTEGER;
    case ValueMetaInterface.TYPE_DATE:
        return ColumnType.DATE;
    case ValueMetaInterface.TYPE_BOOLEAN:
        return ColumnType.BOOLEAN;
    case ValueMetaInterface.TYPE_NUMBER:
        return ColumnType.DOUBLE;
    case ValueMetaInterface.TYPE_BINARY:
        return ColumnType.BINARY;
    case ValueMetaInterface.TYPE_BIGNUMBER:
        return ColumnType.DECIMAL;
    }
    throw new RuntimeException("It is currently not possible to profile values of type: " + valueMeta.getTypeDesc());
}
 
开发者ID:datacleaner,项目名称:pdi-datacleaner,代码行数:19,代码来源:KettleDataContext.java

示例2: before

@Before
public void before() throws Exception {
    loadConfiguration();

    if (isConfigured()) {
        final int timeout = 8 * 1000; // 8 seconds should be more than
                                      // enough
        httpClient = new StdHttpClient.Builder().socketTimeout(timeout).host(getHostname()).build();

        // set up a simple database
        couchDbInstance = new StdCouchDbInstance(httpClient);

        final String databaseName = getDatabaseName();
        if (couchDbInstance.getAllDatabases().contains(databaseName)) {
            throw new IllegalStateException("Couch DB instance already has a database called " + databaseName);
        }
        connector = couchDbInstance.createConnector(databaseName, true);

        final String[] columnNames = new String[] { "name", "gender", "age" };
        final ColumnType[] columnTypes = new ColumnType[] { ColumnType.STRING, ColumnType.CHAR,
                ColumnType.INTEGER };
        predefinedTableDef = new SimpleTableDef(databaseName, columnNames, columnTypes);
    }

}
 
开发者ID:apache,项目名称:metamodel,代码行数:25,代码来源:CouchDbDataContextTest.java

示例3: rewriteColumnType

@Override
public String rewriteColumnType(ColumnType columnType, Integer columnSize) {
    if (columnType == ColumnType.INTEGER) {
        return "INT";
    }

    if(columnType == ColumnType.STRING) {
        return "STRING";
    }

    // Hive does not support VARCHAR without a width, nor VARCHAR(MAX).
    // Returning max allowable column size instead.
    if (columnType == ColumnType.VARCHAR && columnSize == null) {
        return super.rewriteColumnType(columnType, 65535);
    }
    return super.rewriteColumnType(columnType, columnSize);
}
 
开发者ID:apache,项目名称:metamodel,代码行数:17,代码来源:HiveQueryRewriter.java

示例4: testScenarioWithMap

public void testScenarioWithMap() throws Exception {
    final SimpleTableDef tableDef = new SimpleTableDef("bar", new String[] { "col1", "col2", "col3" },
            new ColumnType[] { ColumnType.VARCHAR, ColumnType.INTEGER, ColumnType.BOOLEAN });
    final List<Map<String, ?>> maps = new ArrayList<Map<String, ?>>();
    maps.add(createMap("2", 1000, true));
    maps.add(createMap("1", 1001, false));
    maps.add(createMap("1", 1002, true));
    maps.add(createMap("2", 1003, false));
    maps.add(createMap("2", 1004, false));
    final TableDataProvider<?> tableDataProvider = new MapTableDataProvider(tableDef, maps);
    runScenario(tableDataProvider);
}
 
开发者ID:apache,项目名称:metamodel,代码行数:12,代码来源:PojoDataContextTest.java

示例5: testScenarioWithArrays

public void testScenarioWithArrays() throws Exception {
    final SimpleTableDef tableDef = new SimpleTableDef("bar", new String[] { "col1", "col2", "col3" },
            new ColumnType[] { ColumnType.VARCHAR, ColumnType.INTEGER, ColumnType.BOOLEAN });
    final List<Object[]> arrays = new ArrayList<Object[]>();
    arrays.add(new Object[] { "2", 1000, true });
    arrays.add(new Object[] { "1", 1001, false });
    arrays.add(new Object[] { "1", 1002, true });
    arrays.add(new Object[] { "2", 1003, false });
    arrays.add(new Object[] { "2", 1004, false });
    final TableDataProvider<?> tableDataProvider = new ArrayTableDataProvider(tableDef, arrays);
    runScenario(tableDataProvider);
}
 
开发者ID:apache,项目名称:metamodel,代码行数:12,代码来源:PojoDataContextTest.java

示例6: getType

/**
 * Determines the best fitting type. For reference of ElasticSearch types,
 * see
 *
 * <pre>
 * http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html
 * </pre>
 *
 *
 * @param column
 * @return
 */
private static String getType(Column column) {
    String nativeType = column.getNativeType();
    if (!Strings.isNullOrEmpty(nativeType)) {
        return nativeType;
    }

    final ColumnType type = column.getType();
    if (type == null) {
        throw new IllegalStateException("No column type specified for '" + column.getName()
                + "' - cannot build ElasticSearch mapping without type.");
    }

    if (type.isLiteral()) {
        return "text";
    } else if (type == ColumnType.FLOAT) {
        return "float";
    } else if (type == ColumnType.DOUBLE || type == ColumnType.NUMERIC || type == ColumnType.NUMBER) {
        return "double";
    } else if (type == ColumnType.SMALLINT) {
        return "short";
    } else if (type == ColumnType.TINYINT) {
        return "byte";
    } else if (type == ColumnType.INTEGER) {
        return "integer";
    } else if (type == ColumnType.DATE || type == ColumnType.TIMESTAMP) {
        return "date";
    } else if (type == ColumnType.BINARY || type == ColumnType.VARBINARY) {
        return "binary";
    } else if (type == ColumnType.BOOLEAN || type == ColumnType.BIT) {
        return "boolean";
    } else if (type == ColumnType.MAP) {
        return "object";
    }

    throw new UnsupportedOperationException("Unsupported column type '" + type.getName() + "' of column '" + column
            .getName() + "' - cannot translate to an ElasticSearch type.");
}
 
开发者ID:apache,项目名称:metamodel,代码行数:49,代码来源:ElasticSearchUtils.java

示例7: toColumnType

protected static ColumnType toColumnType(FieldType type) {
    switch (type) {
    case _boolean:
        return ColumnType.BOOLEAN;
    case _int:
        return ColumnType.INTEGER;
    case _double:
    case currency:
        return ColumnType.DOUBLE;
    case date:
        return ColumnType.DATE;
    case datetime:
        return ColumnType.TIMESTAMP;
    case time:
        return ColumnType.TIME;
    case string:
    case email:
    case url:
    case phone:
    case reference:
    case textarea:
    case encryptedstring:
    case base64:
    case id:
    case picklist:
        return ColumnType.VARCHAR;
    default:
        return ColumnType.OTHER;
    }
}
 
开发者ID:apache,项目名称:metamodel,代码行数:30,代码来源:SalesforceTable.java

示例8: setup

@Before
public void setup() {
    query = new Query();

    MutableTable datastoreTable = new MutableTable("datastore", TableType.TABLE);

    MutableColumn dataSourceIdColumn = new MutableColumn("dataSourceIdColumn", ColumnType.VARCHAR);
    MutableColumn dataSourceNameColumn = new MutableColumn("dataSourceNameColumn", ColumnType.VARCHAR);
    MutableColumn versionColumn = new MutableColumn("versionColumn", ColumnType.INTEGER);
    MutableColumn changeSetColumn = new MutableColumn("changeSetColumn", ColumnType.INTEGER);

    SelectItem countSelectItem = new SelectItem(FunctionType.COUNT, dataSourceIdColumn);
    SelectItem dsIdSelectItem = new SelectItem(dataSourceIdColumn).setAlias("innerDataSourceRecordId");
    Query leftQuery = new Query();
    leftQuery.select(dsIdSelectItem);
    leftQuery.groupBy(dataSourceIdColumn);
    leftQuery.having(new FilterItem(countSelectItem.toSql() + " " + OperatorType.EQUALS_TO.toSql() + " 2"));
    leftQuery.where(dataSourceNameColumn, OperatorType.EQUALS_TO, new QueryParameter());
    leftQuery.from(datastoreTable);
    FromItem leftFrom = new FromItem(leftQuery);
    leftFrom.setAlias("innerDS");

    query.select(changeSetColumn);
    query.from(leftFrom, new FromItem(datastoreTable));
    query.where(versionColumn, OperatorType.EQUALS_TO, 2);
    query.where(changeSetColumn, OperatorType.EQUALS_TO, new QueryParameter());
    // Checks if max count is 2 in order to assert that this record has not
    // been a part of any changeSets previously and not processed by GR
    // creation in the current run.
    query.where(new SelectItem(dsIdSelectItem, leftFrom), OperatorType.EQUALS_TO, dsIdSelectItem);
    query.where(dataSourceNameColumn, OperatorType.EQUALS_TO, new QueryParameter());
}
 
开发者ID:apache,项目名称:metamodel,代码行数:32,代码来源:DefaultCompiledQueryTest.java

示例9: testLeftJoin

@Test
public void testLeftJoin() throws Exception {
    SelectItem si1 = new SelectItem(new MutableColumn("person_id", ColumnType.INTEGER));
    SelectItem si2 = new SelectItem(new MutableColumn("person_name", ColumnType.VARCHAR));
    SelectItem si3 = new SelectItem(new MutableColumn("person_age", ColumnType.INTEGER));
    SelectItem si4 = new SelectItem(new MutableColumn("person_role_id", ColumnType.INTEGER));
    SelectItem si5 = new SelectItem(new MutableColumn("role_id", ColumnType.INTEGER));
    SelectItem si6 = new SelectItem(new MutableColumn("role_name", ColumnType.VARCHAR));
    SelectItem si7 = new SelectItem(new MutableColumn("role_code", ColumnType.VARCHAR));
    List<Object[]> data1 = new ArrayList<Object[]>();
    data1.add(new Object[] { 1, "peter", 18, 1 });
    data1.add(new Object[] { 2, "tom", 19, 2 });
    data1.add(new Object[] { 3, "betty", 19, null });
    data1.add(new Object[] { 4, "barbara", 17, 3 });
    data1.add(new Object[] { 5, "susie", 18, 4 });

    List<Object[]> data2 = new ArrayList<Object[]>();
    data2.add(new Object[] { 1, "class president", "clpr" });
    data2.add(new Object[] { 2, "bad boy", "bb" });
    data2.add(new Object[] { 4, "trying harder", "try" });

    DataSet ds1 = createDataSet(Lists.newArrayList(si1, si2, si3, si4), data1);
    DataSet ds2 = createDataSet(Lists.newArrayList(si5, si6, si7), data2);
    FilterItem[] onConditions = new FilterItem[1];
    onConditions[0] = new FilterItem(si4, OperatorType.EQUALS_TO, si5);

    DataSet result = MetaModelHelper.getLeftJoin(ds1, ds2, onConditions);
    List<Object[]> objectArrays = result.toObjectArrays();
    assertEquals("[1, peter, 18, 1, 1, class president, clpr]", Arrays.toString(objectArrays.get(0)));
    assertEquals("[2, tom, 19, 2, 2, bad boy, bb]", Arrays.toString(objectArrays.get(1)));
    assertEquals("[3, betty, 19, null, null, null, null]", Arrays.toString(objectArrays.get(2)));
    assertEquals("[4, barbara, 17, 3, null, null, null]", Arrays.toString(objectArrays.get(3)));
    assertEquals("[5, susie, 18, 4, 4, trying harder, try]", Arrays.toString(objectArrays.get(4)));
    assertEquals(5, objectArrays.size());
}
 
开发者ID:apache,项目名称:metamodel,代码行数:35,代码来源:MetaModelHelperTest.java

示例10: testRightJoin

@Test
public void testRightJoin() throws Exception {
    SelectItem si1 = new SelectItem(new MutableColumn("person_id", ColumnType.INTEGER));
    SelectItem si2 = new SelectItem(new MutableColumn("person_name", ColumnType.VARCHAR));
    SelectItem si3 = new SelectItem(new MutableColumn("person_age", ColumnType.INTEGER));
    SelectItem si4 = new SelectItem(new MutableColumn("person_role_id", ColumnType.INTEGER));
    SelectItem si5 = new SelectItem(new MutableColumn("role_id", ColumnType.INTEGER));
    SelectItem si6 = new SelectItem(new MutableColumn("role_name", ColumnType.VARCHAR));
    SelectItem si7 = new SelectItem(new MutableColumn("role_code", ColumnType.VARCHAR));
    List<Object[]> data1 = new ArrayList<Object[]>();
    data1.add(new Object[] { 1, "peter", 18, 1 });
    data1.add(new Object[] { 2, "tom", 19, 2 });
    data1.add(new Object[] { 3, "betty", 19, null });
    data1.add(new Object[] { 4, "barbara", 17, 3 });

    List<Object[]> data2 = new ArrayList<Object[]>();
    data2.add(new Object[] { 1, "class president", "clpr" });
    data2.add(new Object[] { 2, "bad boy", "bb" });
    data2.add(new Object[] { 4, "trying harder", "try" });

    DataSet ds1 = createDataSet(Lists.newArrayList(si1, si2, si3, si4), data1);
    DataSet ds2 = createDataSet(Lists.newArrayList(si5, si6, si7), data2);
    FilterItem[] onConditions = new FilterItem[1];
    onConditions[0] = new FilterItem(si4, OperatorType.EQUALS_TO, si5);

    DataSet result = MetaModelHelper.getRightJoin(ds1, ds2, onConditions);
    List<Object[]> objectArrays = result.toObjectArrays();
    assertEquals("[1, peter, 18, 1, 1, class president, clpr]", Arrays.toString(objectArrays.get(0)));
    assertEquals("[2, tom, 19, 2, 2, bad boy, bb]", Arrays.toString(objectArrays.get(1)));
    assertEquals("[null, null, null, null, 4, trying harder, try]", Arrays.toString(objectArrays.get(2)));
    assertEquals(3, objectArrays.size());
}
 
开发者ID:apache,项目名称:metamodel,代码行数:32,代码来源:MetaModelHelperTest.java

示例11: testSerializeAndDeserialize

public void testSerializeAndDeserialize() throws Exception {
    final Object map1 = buildMap(
            "{'some_number':1234, 'gender':'M','address':{'city':'Copenhagen','country':'DK','additional_info':null}}");
    final Object map2 =
            buildMap("{'some_number':5678,'gender':'M','address':{'city':'Amsterdam','countries':['NL','IN']}}");

    final SimpleTableDef tableDef = new SimpleTableDef("bar", new String[] { "id", "name", "details", "bytes" },
            new ColumnType[] { ColumnType.INTEGER, ColumnType.VARCHAR, ColumnType.MAP, ColumnType.BINARY });
    final Collection<Object[]> arrays = new ArrayList<>();
    arrays.add(new Object[] { 1, "Kasper Sørensen", map1, new byte[] { (byte) -40, (byte) -2 } });
    arrays.add(new Object[] { 2, "Ankit Kumar", map2, new byte[] { (byte) 1, (byte) 3, (byte) 3, (byte) 7 } });
    final TableDataProvider<?> tableProvider = new ArrayTableDataProvider(tableDef, arrays);
    final List<TableDataProvider<?>> tableProviders = new ArrayList<>();
    tableProviders.add(tableProvider);

    PojoDatastore datastore;
    datastore = new PojoDatastore("foo", tableProviders);

    final JaxbPojoDatastoreAdaptor adaptor = new JaxbPojoDatastoreAdaptor(new DataCleanerConfigurationImpl());
    AbstractDatastoreType serializedDatastore = adaptor.createPojoDatastore(datastore, null, 20);

    final DatastoreCatalogType serializedDatastoreCatalogType = new DatastoreCatalogType();
    serializedDatastoreCatalogType.getJdbcDatastoreOrAccessDatastoreOrCsvDatastore().add(serializedDatastore);
    Configuration serializedConfiguration = new Configuration();
    serializedConfiguration.setDatastoreCatalog(serializedDatastoreCatalogType);

    // serialize and deserialize
    final JAXBContext jaxbContext = JAXBContext
            .newInstance(ObjectFactory.class.getPackage().getName(), ObjectFactory.class.getClassLoader());
    final File file = new File("target/JaxbPojoDatastoreAdaptorTest_serialize_and_deserialize.xml");
    jaxbContext.createMarshaller().marshal(serializedConfiguration, file);
    serializedConfiguration = (Configuration) jaxbContext.createUnmarshaller().unmarshal(file);

    serializedDatastore =
            serializedConfiguration.getDatastoreCatalog().getJdbcDatastoreOrAccessDatastoreOrCsvDatastore().get(0);
    datastore = adaptor.read((PojoDatastoreType) serializedDatastore);

    final UpdateableDatastoreConnection con = datastore.openConnection();
    final DataSet ds = con.getDataContext().query().from("bar").select("id", "name", "details").execute();
    assertTrue(ds.next());
    assertTrue(ds.getRow().getValue(0) instanceof Integer);
    assertEquals(1, ds.getRow().getValue(0));
    assertTrue(ds.getRow().getValue(1) instanceof String);
    assertEquals("Kasper Sørensen", ds.getRow().getValue(1));
    assertTrue(ds.getRow().getValue(2) instanceof Map);

    @SuppressWarnings("unchecked") final Map<String, ?> map3 = (Map<String, ?>) ds.getRow().getValue(2);
    assertEquals("{some_number=1234, gender=M, address={city=Copenhagen, country=DK, additional_info=null}}",
            map3.toString());
    assertEquals(Integer.class, map3.get("some_number").getClass());

    assertTrue(ds.next());
    assertTrue(ds.getRow().getValue(0) instanceof Integer);
    assertEquals(2, ds.getRow().getValue(0));
    assertTrue(ds.getRow().getValue(1) instanceof String);
    assertEquals("Ankit Kumar", ds.getRow().getValue(1));
    assertTrue(ds.getRow().getValue(2) instanceof Map);

    @SuppressWarnings("unchecked") final Map<String, ?> map4 = (Map<String, ?>) ds.getRow().getValue(2);
    assertEquals("{some_number=5678, gender=M, address={city=Amsterdam, countries=[NL, IN]}}", map4.toString());
    assertEquals(Integer.class, map3.get("some_number").getClass());

    assertFalse(ds.next());

    assertEquals(map1, map3);
    assertEquals(map2, map4);
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:67,代码来源:JaxbPojoDatastoreAdaptorTest.java

示例12: getAvailableColumnTypes

private ColumnType[] getAvailableColumnTypes() {
    return new ColumnType[] { ColumnType.VARCHAR, ColumnType.DECIMAL, ColumnType.INTEGER, ColumnType.BOOLEAN,
            ColumnType.DATE, ColumnType.TIME, ColumnType.TIMESTAMP, ColumnType.MAP, ColumnType.LIST,
            ColumnType.BINARY };
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:5,代码来源:SimpleTableDefPanel.java

示例13: testSerializeAndDeserialize

public void testSerializeAndDeserialize() throws Exception {
    final Object map1 = buildMap("{'some_number':1234, 'gender':'M','address':{'city':'Copenhagen','country':'DK','additional_info':null}}");
    final Object map2 = buildMap("{'some_number':5678,'gender':'M','address':{'city':'Amsterdam','countries':['NL','IN']}}");

    SimpleTableDef tableDef = new SimpleTableDef("bar", new String[] { "id", "name", "details", "bytes" },
            new ColumnType[] { ColumnType.INTEGER, ColumnType.VARCHAR, ColumnType.MAP, ColumnType.BINARY });
    Collection<Object[]> arrays = new ArrayList<Object[]>();
    arrays.add(new Object[] { 1, "Kasper Sørensen", map1, new byte[] { (byte) -40, (byte) -2 } });
    arrays.add(new Object[] { 2, "Ankit Kumar", map2, new byte[] { (byte) 1, (byte) 3, (byte) 3, (byte) 7 } });
    TableDataProvider<?> tableProvider = new ArrayTableDataProvider(tableDef, arrays);
    List<TableDataProvider<?>> tableProviders = new ArrayList<TableDataProvider<?>>();
    tableProviders.add(tableProvider);

    PojoDatastore datastore;
    datastore = new PojoDatastore("foo", tableProviders);

    final JaxbPojoDatastoreAdaptor adaptor = new JaxbPojoDatastoreAdaptor();
    AbstractDatastoreType serializedDatastore = adaptor.createPojoDatastore(datastore, null, 20);

    DatastoreCatalogType serializedDatastoreCatalogType = new DatastoreCatalogType();
    serializedDatastoreCatalogType.getJdbcDatastoreOrAccessDatastoreOrCsvDatastore().add(serializedDatastore);
    Configuration serializedConfiguration = new Configuration();
    serializedConfiguration.setDatastoreCatalog(serializedDatastoreCatalogType);

    // serialize and deserialize
    JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class.getPackage().getName(),
            ObjectFactory.class.getClassLoader());
    File file = new File("target/JaxbPojoDatastoreAdaptorTest_serialize_and_deserialize.xml");
    jaxbContext.createMarshaller().marshal(serializedConfiguration, file);
    serializedConfiguration = (Configuration) jaxbContext.createUnmarshaller().unmarshal(file);

    serializedDatastore = serializedConfiguration.getDatastoreCatalog()
            .getJdbcDatastoreOrAccessDatastoreOrCsvDatastore().get(0);
    datastore = adaptor.read((PojoDatastoreType) serializedDatastore);

    UpdateableDatastoreConnection con = datastore.openConnection();
    DataSet ds = con.getDataContext().query().from("bar").select("id", "name", "details").execute();
    assertTrue(ds.next());
    assertTrue(ds.getRow().getValue(0) instanceof Integer);
    assertEquals(1, ds.getRow().getValue(0));
    assertTrue(ds.getRow().getValue(1) instanceof String);
    assertEquals("Kasper Sørensen", ds.getRow().getValue(1));
    assertTrue(ds.getRow().getValue(2) instanceof Map);

    @SuppressWarnings("unchecked")
    final Map<String, ?> map3 = (Map<String, ?>) ds.getRow().getValue(2);
    assertEquals("{some_number=1234, gender=M, address={city=Copenhagen, country=DK, additional_info=null}}",
            map3.toString());
    assertEquals(Integer.class, map3.get("some_number").getClass());

    assertTrue(ds.next());
    assertTrue(ds.getRow().getValue(0) instanceof Integer);
    assertEquals(2, ds.getRow().getValue(0));
    assertTrue(ds.getRow().getValue(1) instanceof String);
    assertEquals("Ankit Kumar", ds.getRow().getValue(1));
    assertTrue(ds.getRow().getValue(2) instanceof Map);

    @SuppressWarnings("unchecked")
    final Map<String, ?> map4 = (Map<String, ?>) ds.getRow().getValue(2);
    assertEquals("{some_number=5678, gender=M, address={city=Amsterdam, countries=[NL, IN]}}", map4.toString());
    assertEquals(Integer.class, map3.get("some_number").getClass());

    assertFalse(ds.next());

    assertEquals(map1, map3);
    assertEquals(map2, map4);
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:67,代码来源:JaxbPojoDatastoreAdaptorTest.java

示例14: testWorkingWithMapsAndLists

@Test
public void testWorkingWithMapsAndLists() throws Exception {
    if (!isConfigured()) {
        System.err.println(getInvalidConfigurationMessage());
        return;
    }

    connector = couchDbInstance.createConnector("test_table_map_and_list", true);

    final CouchDbDataContext dc = new CouchDbDataContext(couchDbInstance, new SimpleTableDef(
            "test_table_map_and_list", new String[] { "id", "foo", "bar" }, new ColumnType[] { ColumnType.INTEGER,
                    ColumnType.MAP, ColumnType.LIST }));
    Table table = null;
    try {
        table = dc.getTableByQualifiedLabel("test_table_map_and_list");
        Map<String, Object> exampleMap = new LinkedHashMap<String, Object>();
        exampleMap.put("hello", Arrays.asList("world", "welt", "verden"));
        exampleMap.put("foo", "bar");

        List<Map<String, Object>> exampleList = new ArrayList<Map<String, Object>>();
        exampleList.add(new LinkedHashMap<String, Object>());
        Map<String, Object> exampleMap2 = new LinkedHashMap<String, Object>();
        exampleMap2.put("meta", "model");
        exampleMap2.put("couch", "db");
        exampleList.add(exampleMap2);

        dc.executeUpdate(new InsertInto(table).value("id", 1).value("foo", exampleMap).value("bar", exampleList));

        DataSet ds = dc.query().from(table).select("id", "foo", "bar").execute();
        assertTrue(ds.next());
        Row row = ds.getRow();
        assertFalse(ds.next());
        ds.close();

        assertEquals("Row[values=[1, {hello=[world, welt, verden], foo=bar}, [{}, {meta=model, couch=db}]]]", row
                .toString());
        assertTrue(row.getValue(0) instanceof Integer);
        assertTrue(row.getValue(1) instanceof Map);
        assertTrue(row.getValue(2) instanceof List);

        CouchDbDataContext dc2 = new CouchDbDataContext(couchDbInstance, new SimpleTableDef(
                "test_table_map_and_list", new String[] { "foo.hello[0]", "bar[1].couch" }));
        ds = dc2.query().from("test_table_map_and_list").select("foo.hello[0]", "bar[1].couch").execute();
        assertTrue(ds.next());
        assertEquals("Row[values=[world, db]]", ds.getRow().toString());
        assertFalse(ds.next());
        ds.close();

    } finally {
        dc.executeUpdate(new DropTable(table));
    }

}
 
开发者ID:apache,项目名称:metamodel,代码行数:53,代码来源:CouchDbDataContextTest.java

示例15: rewriteColumnType

@Override
public String rewriteColumnType(ColumnType columnType, Integer columnSize) {
    if (columnType == ColumnType.NUMBER || columnType == ColumnType.NUMERIC || columnType == ColumnType.DECIMAL) {
        // as one of the only relational databases out there, Oracle has a
        // NUMBER type. For this reason NUMBER would be replaced by the
        // super-type's logic, but we handle it specifically here.
        super.rewriteColumnTypeInternal("NUMBER", columnSize);
    }
    if (columnType == ColumnType.BOOLEAN || columnType == ColumnType.BIT) {
        // Oracle has no boolean type, but recommends NUMBER(3) or CHAR(1).
        // For consistency with most other databases who have either a
        // boolean or a bit, we use the number variant because it's return
        // values (0 or 1) can be converted the most easily back to a
        // boolean.
        return "NUMBER(3)";
    }
    if (columnType == ColumnType.DOUBLE) {
        return "BINARY_DOUBLE";
    }
    if (columnType == ColumnType.FLOAT) {
        return "BINARY_FLOAT";
    }
    if (columnType == ColumnType.BINARY || columnType == ColumnType.VARBINARY) {
        return "RAW";
    }

    // following conversions based on
    // http://docs.oracle.com/cd/B19306_01/gateways.102/b14270/apa.htm
    if (columnType == ColumnType.TINYINT) {
        return "NUMBER(3)";
    }
    if (columnType == ColumnType.SMALLINT) {
        return "NUMBER(5)";
    }
    if (columnType == ColumnType.INTEGER) {
        return "NUMBER(10)";
    }
    if (columnType == ColumnType.BIGINT) {
        return "NUMBER(19)";
    }

    // Oracle has no "time only" data type but 'date' also includes time
    if (columnType == ColumnType.TIME) {
        super.rewriteColumnType(ColumnType.DATE, columnSize);
    }
    return super.rewriteColumnType(columnType, columnSize);
}
 
开发者ID:apache,项目名称:metamodel,代码行数:47,代码来源:OracleQueryRewriter.java


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