本文整理汇总了Java中org.apache.metamodel.pojo.PojoDataContext类的典型用法代码示例。如果您正苦于以下问题:Java PojoDataContext类的具体用法?Java PojoDataContext怎么用?Java PojoDataContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PojoDataContext类属于org.apache.metamodel.pojo包,在下文中一共展示了PojoDataContext类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDataContext
import org.apache.metamodel.pojo.PojoDataContext; //导入依赖的package包/类
@Override
public DataContext createDataContext(DataContextFactoryParameters params) {
SimpleTableDef[] tableDefs = params.getTableDefs();
if (tableDefs == null || tableDefs.length == 0) {
throw new IllegalArgumentException("Cannot create PojoDataContext with no tableDefs specified");
}
TableDataProvider<?>[] tableDataProviders = new ArrayTableDataProvider[tableDefs.length];
for (int i = 0; i < tableDataProviders.length; i++) {
ArrayTableDataProvider tableDataProvider = new ArrayTableDataProvider(tableDefs[i], new ArrayList<Object[]>());
tableDataProviders[i] = tableDataProvider;
}
String databaseName = params.getDatabaseName();
if (databaseName != null && !databaseName.isEmpty()) {
return new PojoDataContext(databaseName, tableDataProviders);
}
return new PojoDataContext(Arrays.asList(tableDataProviders));
}
示例2: testConvertTableDefs
import org.apache.metamodel.pojo.PojoDataContext; //导入依赖的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()));
}
示例3: PojoDatastore
import org.apache.metamodel.pojo.PojoDataContext; //导入依赖的package包/类
public PojoDatastore(final String datastoreName, final String schemaName,
final List<TableDataProvider<?>> tableDataProviders) {
_datastoreName = datastoreName;
_dataContext = new PojoDataContext(schemaName, tableDataProviders);
}
示例4: PojoDatastore
import org.apache.metamodel.pojo.PojoDataContext; //导入依赖的package包/类
public PojoDatastore(String datastoreName, String schemaName, List<TableDataProvider<?>> tableDataProviders) {
_datastoreName = datastoreName;
_dataContext = new PojoDataContext(schemaName, tableDataProviders);
}
示例5: testReadDataContext
import org.apache.metamodel.pojo.PojoDataContext; //导入依赖的package包/类
@Test
public void testReadDataContext() {
assertEquals(PojoDataContext.class, dataContext.getClass());
assertEquals("here's a value from springs XML file", dataContext.getDefaultSchema().getName());
}
示例6: createDataContext
import org.apache.metamodel.pojo.PojoDataContext; //导入依赖的package包/类
@Override
public DataContext createDataContext(DataContextFactoryParameters bean) {
String username = bean.getUsername();
return new PojoDataContext(username, new ArrayList<TableDataProvider<?>>());
}
示例7: createPojoDataContext
import org.apache.metamodel.pojo.PojoDataContext; //导入依赖的package包/类
/**
* Creates a new POJO data context that is empty but can be populated at
* will.
*
* @return a DataContext object that matches the request
*
*/
public static DataContext createPojoDataContext() {
return new PojoDataContext();
}