本文整理汇总了Java中org.teiid.adminapi.impl.VDBMetaData.addModel方法的典型用法代码示例。如果您正苦于以下问题:Java VDBMetaData.addModel方法的具体用法?Java VDBMetaData.addModel怎么用?Java VDBMetaData.addModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.teiid.adminapi.impl.VDBMetaData
的用法示例。
在下文中一共展示了VDBMetaData.addModel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testVDBConnectionProperty
import org.teiid.adminapi.impl.VDBMetaData; //导入方法依赖的package包/类
@Test public void testVDBConnectionProperty() throws Exception {
VDBMetaData vdb = new VDBMetaData();
vdb.setName("x");
vdb.addProperty("connection.foo", "bar");
ModelMetaData mmd = new ModelMetaData();
mmd.setName("x");
mmd.setSchemaSourceType("ddl");
mmd.setModelType(Type.VIRTUAL);
mmd.setSchemaText("create view v as select 1");
vdb.addModel(mmd);
odbcServer.server.deployVDB(vdb);
this.conn.close();
connect("x");
Statement s = conn.createStatement();
assertTrue(s.execute("show foo"));
ResultSet rs = s.getResultSet();
assertTrue(rs.next());
String value = rs.getString(1);
assertEquals("bar", value);
}
示例2: loadSchema
import org.teiid.adminapi.impl.VDBMetaData; //导入方法依赖的package包/类
private MetadataFactory loadSchema(VDBMetaData vdb, Properties p, String name, QueryParser parser) {
ModelMetaData mmd = new ModelMetaData();
mmd.setName(name);
vdb.addModel(mmd);
InputStream is = SystemMetadata.class.getClassLoader().getResourceAsStream("org/teiid/metadata/"+name+".sql"); //$NON-NLS-1$ //$NON-NLS-2$
try {
MetadataFactory factory = new MetadataFactory(vdb.getName(), vdb.getVersion(), name, typeMap, p, null);
parser.parseDDL(factory, new InputStreamReader(is, Charset.forName("UTF-8"))); //$NON-NLS-1$
for (Table t : factory.getSchema().getTables().values()) {
t.setSystem(true);
}
return factory;
} finally {
try {
is.close();
} catch (IOException e) {
throw new TeiidRuntimeException(e);
}
}
}
示例3: createTransformationMetadata
import org.teiid.adminapi.impl.VDBMetaData; //导入方法依赖的package包/类
public static TransformationMetadata createTransformationMetadata(CompositeMetadataStore store, String vdbName, Properties vdbProperties, FunctionTree... functionModels) {
VDBMetaData vdbMetaData = new VDBMetaData();
vdbMetaData.setName(vdbName); //$NON-NLS-1$
vdbMetaData.setVersion(1);
if (vdbProperties != null) {
vdbMetaData.setProperties(vdbProperties);
}
List<FunctionTree> udfs = new ArrayList<FunctionTree>();
udfs.addAll(Arrays.asList(functionModels));
for (Schema schema : store.getSchemas().values()) {
vdbMetaData.addModel(RealMetadataFactory.createModel(schema.getName(), schema.isPhysical()));
if (!schema.getFunctions().isEmpty()) {
udfs.add(new FunctionTree(schema.getName(), new UDFSource(schema.getFunctions().values()), true));
}
}
TransformationMetadata metadata = new TransformationMetadata(vdbMetaData, store, null, SFM.getSystemFunctions(), udfs);
vdbMetaData.addAttchment(TransformationMetadata.class, metadata);
vdbMetaData.addAttchment(QueryMetadataInterface.class, metadata);
return metadata;
}
示例4: example1VDB
import org.teiid.adminapi.impl.VDBMetaData; //导入方法依赖的package包/类
public static VDBMetaData example1VDB() {
VDBMetaData vdb = new VDBMetaData();
vdb.setName("example1");
vdb.setVersion(1);
vdb.addModel(RealMetadataFactory.createModel("pm1", true));
vdb.addModel(RealMetadataFactory.createModel("pm2", true));
vdb.addModel(RealMetadataFactory.createModel("pm3", true));
vdb.addModel(RealMetadataFactory.createModel("pm4", true));
vdb.addModel(RealMetadataFactory.createModel("pm5", true));
vdb.addModel(RealMetadataFactory.createModel("pm6", true));
vdb.addModel(RealMetadataFactory.createModel("vm1", false));
vdb.addModel(RealMetadataFactory.createModel("vm2", false));
vdb.addModel(RealMetadataFactory.createModel("tm1", false));
return vdb;
}
示例5: exampleBQTVDB
import org.teiid.adminapi.impl.VDBMetaData; //导入方法依赖的package包/类
public static VDBMetaData exampleBQTVDB() {
VDBMetaData vdb = new VDBMetaData();
vdb.setName("example1");
vdb.setVersion(1);
vdb.addModel(RealMetadataFactory.createModel("BQT1", true));
vdb.addModel(RealMetadataFactory.createModel("BQT2", true));
vdb.addModel(RealMetadataFactory.createModel("BQT3", true));
vdb.addModel(RealMetadataFactory.createModel("LOB", true));
vdb.addModel(RealMetadataFactory.createModel("VQT", false));
vdb.addModel(RealMetadataFactory.createModel("pm1", true));
vdb.addModel(RealMetadataFactory.createModel("pm2", true));
vdb.addModel(RealMetadataFactory.createModel("pm3", true));
vdb.addModel(RealMetadataFactory.createModel("pm4", true));
return vdb;
}
示例6: exampleMultiBindingVDB
import org.teiid.adminapi.impl.VDBMetaData; //导入方法依赖的package包/类
public static VDBMetaData exampleMultiBindingVDB() {
VDBMetaData vdb = new VDBMetaData();
vdb.setName("exampleMultiBinding");
vdb.setVersion(1);
ModelMetaData model = new ModelMetaData();
model.setName("MultiModel");
model.setModelType(Model.Type.PHYSICAL);
model.setVisible(true);
model.setSupportsMultiSourceBindings(true);
vdb.addModel(model);
vdb.addModel(RealMetadataFactory.createModel("Virt", false));
return vdb;
}
示例7: buildModel
import org.teiid.adminapi.impl.VDBMetaData; //导入方法依赖的package包/类
public static ModelMetaData buildModel(String modelName, boolean physical, VDBMetaData vdb, MetadataStore store, String ddl) throws Exception {
ModelMetaData model = new ModelMetaData();
model.setName(modelName);
model.setModelType(physical?Model.Type.PHYSICAL:Model.Type.VIRTUAL);
vdb.addModel(model);
DDLMetadataRepository repo = new DDLMetadataRepository();
MetadataFactory mf = new MetadataFactory("myVDB",1, modelName, TestDDLParser.getDataTypes(), new Properties(), ddl);
mf.setParser(QueryParser.getQueryParser());
mf.setBuiltinDataTypes(SystemMetadata.getInstance().getSystemStore().getDatatypes());
mf.getSchema().setPhysical(physical);
repo.loadMetadata(mf, null, null, ddl);
mf.mergeInto(store);
model.addAttchment(MetadataFactory.class, mf);
return model;
}
示例8: deploySourceVDB
import org.teiid.adminapi.impl.VDBMetaData; //导入方法依赖的package包/类
/**
* Deploys a SourceVDB for the specified dataSource, if it doesnt already exist
* @param sourceVDBName the name of the source VDB
* @param modelName the name of the model
* @param dataSourceName the name of the datasource
* @param jndiName the JNDI name of the datasource
* @param translator the name of the translator
* @param importProps the import properties
*/
private String deploySourceVDB(String sourceVDBName, String modelName, String dataSourceName, String jndiName, String translator, Properties importProps) throws DataVirtUiException {
try {
// Get VDB with the supplied name.
// -- If it already exists, return its status
VDBMetaData sourceVdb = clientAccessor.getClient().getVDB(sourceVDBName,1);
if(sourceVdb!=null) {
String sourceVdbStatus = getVDBStatusMessage(sourceVDBName);
if(!sourceVdbStatus.equals(Constants.SUCCESS)) {
return sourceVdbStatus;
}
return sourceVdbStatus;
}
// Create a new Source VDB to deploy
sourceVdb = vdbHelper.createVdb(sourceVDBName,1,new Properties());
// Create source model - same name as dataSource. Use model name for source mapping - will be unique
ModelMetaData model = vdbHelper.createSourceModel(modelName, modelName, jndiName, translator, importProps);
// Adding the SourceModel to the VDB
sourceVdb.addModel(model);
// Deploy VDB and wait for it to load
deployVdb(sourceVdb,sourceVDBName,Constants.VDB_LOADING_TIMEOUT_SECS);
// Get deployed VDB and return status
String vdbStatus = getVDBStatusMessage(sourceVDBName);
if(!vdbStatus.equals(Constants.SUCCESS)) {
return vdbStatus;
}
return Constants.SUCCESS;
} catch (Exception e) {
throw new DataVirtUiException(e.getMessage());
}
}
示例9: addModel
import org.teiid.adminapi.impl.VDBMetaData; //导入方法依赖的package包/类
private ModelMetaData addModel(VDBMetaData vdbMetaData, Schema schema) {
ModelMetaData model = new ModelMetaData();
model.setModelType(schema.isPhysical()?Type.PHYSICAL:Type.VIRTUAL);
model.setName(schema.getName());
vdbMetaData.addModel(model);
model.addSourceMapping("source", "translator", "jndi:source");
return model;
}
示例10: testOptionalFK
import org.teiid.adminapi.impl.VDBMetaData; //导入方法依赖的package包/类
@Test
public void testOptionalFK() throws Exception {
String ddl = "CREATE FOREIGN TABLE G1(g1e1 integer, g1e2 varchar, PRIMARY KEY(g1e1, g1e2));\n" +
"CREATE FOREIGN TABLE G2( g2e1 integer, g2e2 varchar, PRIMARY KEY(g2e1, g2e2)," +
"FOREIGN KEY (g2e1, g2e2) REFERENCES G1)";
MetadataFactory s = helpParse(ddl, "model");
Map<String, Table> tableMap = s.getSchema().getTables();
assertEquals(2, tableMap.size());
assertTrue("Table not found", tableMap.containsKey("G1"));
assertTrue("Table not found", tableMap.containsKey("G2"));
Table table = tableMap.get("G2");
ForeignKey fk = table.getForeignKeys().get(0);
assertEquals(fk.getColumns(), table.getColumns());
assertEquals("G1", fk.getReferenceTableName());
VDBMetaData vdb = new VDBMetaData();
vdb.setName("myVDB"); //$NON-NLS-1$
ModelMetaData modelOne = new ModelMetaData();
modelOne.setName("model"); //$NON-NLS-1$
vdb.addModel(modelOne);
ValidatorReport report = new MetadataValidator().validate(vdb, s.asMetadataStore());
assertFalse(report.hasItems());
assertEquals(fk.getPrimaryKey().getColumns(), tableMap.get("G1").getColumns());
}
示例11: testOptionalFKFail
import org.teiid.adminapi.impl.VDBMetaData; //导入方法依赖的package包/类
@Test
public void testOptionalFKFail() throws Exception {
String ddl = "CREATE FOREIGN TABLE G1(g1e1 integer, g1e2 varchar);\n" +
"CREATE FOREIGN TABLE G2( g2e1 integer, g2e2 varchar, PRIMARY KEY(g2e1, g2e2)," +
"FOREIGN KEY (g2e1, g2e2) REFERENCES G1)";
MetadataFactory s = helpParse(ddl, "model");
Map<String, Table> tableMap = s.getSchema().getTables();
assertEquals(2, tableMap.size());
assertTrue("Table not found", tableMap.containsKey("G1"));
assertTrue("Table not found", tableMap.containsKey("G2"));
Table table = tableMap.get("G2");
ForeignKey fk = table.getForeignKeys().get(0);
assertEquals(fk.getColumns(), table.getColumns());
assertEquals("G1", fk.getReferenceTableName());
VDBMetaData vdb = new VDBMetaData();
vdb.setName("myVDB"); //$NON-NLS-1$
ModelMetaData modelOne = new ModelMetaData();
modelOne.setName("model"); //$NON-NLS-1$
vdb.addModel(modelOne);
ValidatorReport report = new MetadataValidator().validate(vdb, s.asMetadataStore());
assertTrue(report.hasItems());
}
示例12: testFKAccrossSchemas
import org.teiid.adminapi.impl.VDBMetaData; //导入方法依赖的package包/类
@Test
public void testFKAccrossSchemas() throws Exception {
String ddl = "CREATE FOREIGN TABLE G1(g1e1 integer, g1e2 varchar, PRIMARY KEY(g1e1, g1e2));\n";
String ddl2 = "CREATE FOREIGN TABLE G2( g2e1 integer, g2e2 varchar, PRIMARY KEY(g2e1, g2e2)," +
"FOREIGN KEY (g2e1, g2e2) REFERENCES model.G1)";
MetadataFactory f1 = helpParse(ddl, "model");
MetadataFactory f2 = helpParse(ddl2, "model2");
VDBMetaData vdb = new VDBMetaData();
vdb.setName("myVDB"); //$NON-NLS-1$
ModelMetaData modelOne = new ModelMetaData();
modelOne.setName("model"); //$NON-NLS-1$
vdb.addModel(modelOne);
ModelMetaData modelTwo = new ModelMetaData();
modelTwo.setName("model2"); //$NON-NLS-1$
vdb.addModel(modelTwo);
MetadataStore s = f1.asMetadataStore();
f2.mergeInto(s);
ValidatorReport report = new MetadataValidator().validate(vdb, s);
assertFalse(report.hasItems());
Table table = s.getSchema("model2").getTable("G2");
ForeignKey fk = table.getForeignKeys().get(0);
assertEquals(fk.getColumns(), table.getColumns());
assertEquals("G1", fk.getReferenceTableName());
assertEquals(fk.getPrimaryKey().getColumns(), s.getSchema("model").getTable("G1").getColumns());
}
示例13: exampleTransformationMetadata
import org.teiid.adminapi.impl.VDBMetaData; //导入方法依赖的package包/类
private TransformationMetadata exampleTransformationMetadata()
throws TranslatorException {
Map<String, Datatype> datatypes = new HashMap<String, Datatype>();
Datatype dt = new Datatype();
dt.setName(DataTypeManager.DefaultDataTypes.STRING);
dt.setJavaClassName(String.class.getCanonicalName());
datatypes.put(DataTypeManager.DefaultDataTypes.STRING, dt);
MetadataFactory mf = new MetadataFactory(null, 1, "x", datatypes, new Properties(), null); //$NON-NLS-1$
mf.addProcedure("y"); //$NON-NLS-1$
Table t = mf.addTable("foo");
mf.addColumn("col", DataTypeManager.DefaultDataTypes.STRING, t);
MetadataFactory mf1 = new MetadataFactory(null, 1, "x1", datatypes, new Properties(), null); //$NON-NLS-1$
mf1.addProcedure("y"); //$NON-NLS-1$
Table table = mf1.addTable("doc");
table.setSchemaPaths(Arrays.asList("../../x.xsd"));
table.setResourcePath("/a/b/doc.xmi");
HashMap<String, VDBResources.Resource> resources = new HashMap<String, VDBResources.Resource>();
resources.put("/x.xsd", new VDBResources.Resource(VFS.getRootVirtualFile()));
CompositeMetadataStore cms = new CompositeMetadataStore(Arrays.asList(mf.asMetadataStore(), mf1.asMetadataStore()));
VDBMetaData vdb = new VDBMetaData();
vdb.setName("vdb");
vdb.setVersion(1);
vdb.addModel(buildModel("x"));
vdb.addModel(buildModel("x1"));
vdb.addModel(buildModel("y"));
return new TransformationMetadata(vdb, cms, resources, RealMetadataFactory.SFM.getSystemFunctions(), null);
}
示例14: testAmbiguousTableWithPrivateModel
import org.teiid.adminapi.impl.VDBMetaData; //导入方法依赖的package包/类
@Test public void testAmbiguousTableWithPrivateModel() throws Exception {
Map<String, Datatype> datatypes = new HashMap<String, Datatype>();
Datatype dt = new Datatype();
dt.setName(DataTypeManager.DefaultDataTypes.STRING);
dt.setJavaClassName(String.class.getCanonicalName());
datatypes.put(DataTypeManager.DefaultDataTypes.STRING, dt);
MetadataFactory mf = new MetadataFactory(null, 1, "x", datatypes, new Properties(), null); //$NON-NLS-1$
mf.addTable("y"); //$NON-NLS-1$
MetadataFactory mf1 = new MetadataFactory(null, 1, "x1", datatypes, new Properties(), null); //$NON-NLS-1$
mf1.addTable("y"); //$NON-NLS-1$
CompositeMetadataStore cms = new CompositeMetadataStore(Arrays.asList(mf.asMetadataStore(), mf1.asMetadataStore()));
VDBMetaData vdb = new VDBMetaData();
vdb.setName("foo");
vdb.setVersion(1);
ModelMetaData model = new ModelMetaData();
model.setName("x1");
vdb.addModel(model);
ModelMetaData model2 = new ModelMetaData();
model2.setName("x");
model2.setVisible(true);
vdb.addModel(model2);
TransformationMetadata tm = new TransformationMetadata(vdb, cms, null, RealMetadataFactory.SFM.getSystemFunctions(), null);
Collection result = tm.getGroupsForPartialName("y"); //$NON-NLS-1$
assertEquals(2, result.size());
RealMetadataFactory.buildWorkContext(tm, vdb);
model.setVisible(false);
tm = new TransformationMetadata(vdb, cms, null, RealMetadataFactory.SFM.getSystemFunctions(), null);
result = tm.getGroupsForPartialName("y"); //$NON-NLS-1$
assertEquals(1, result.size());
}
示例15: examplePrivatePhysicalModelVDB
import org.teiid.adminapi.impl.VDBMetaData; //导入方法依赖的package包/类
public static VDBMetaData examplePrivatePhysicalModelVDB() {
VDBMetaData vdb = new VDBMetaData();
vdb.setName("example1");
vdb.setVersion(1);
ModelMetaData m = RealMetadataFactory.createModel("pm1", true);
m.setVisible(false);
vdb.addModel(m);
vdb.addModel(RealMetadataFactory.createModel("vm1", false));
return vdb;
}