use of org.teiid.metadata.Schema in project teiid by teiid.
the class CompositeVDB method buildTransformationMetaData.
private static TransformationMetadata buildTransformationMetaData(VDBMetaData vdb, LinkedHashMap<String, VDBResources.Resource> visibilityMap, MetadataStore store, UDFMetaData udf, FunctionTree systemFunctions, MetadataStore[] additionalStores, boolean allowEnv) {
Collection<FunctionTree> udfs = new ArrayList<FunctionTree>();
if (udf != null) {
for (Map.Entry<String, UDFSource> entry : udf.getFunctions().entrySet()) {
udfs.add(new FunctionTree(entry.getKey(), entry.getValue(), true));
}
}
// add functions for procedures
for (Schema schema : store.getSchemas().values()) {
if (!schema.getProcedures().isEmpty()) {
FunctionTree ft = FunctionTree.getFunctionProcedures(schema);
if (ft != null) {
udfs.add(ft);
}
}
}
CompositeMetadataStore compositeStore = new CompositeMetadataStore(store);
for (MetadataStore s : additionalStores) {
compositeStore.merge(s);
for (Schema schema : s.getSchemas().values()) {
if (!schema.getFunctions().isEmpty()) {
UDFSource source = new UDFSource(schema.getFunctions().values());
if (udf != null) {
source.setClassLoader(udf.getClassLoader());
}
udfs.add(new FunctionTree(schema.getName(), source, true));
}
if (!schema.getProcedures().isEmpty()) {
FunctionTree ft = FunctionTree.getFunctionProcedures(schema);
if (ft != null) {
udfs.add(ft);
}
}
}
}
TransformationMetadata metadata = new TransformationMetadata(vdb, compositeStore, visibilityMap, systemFunctions, udfs);
metadata.setAllowENV(allowEnv);
metadata.setUseOutputNames(false);
metadata.setWidenComparisonToString(WIDEN_COMPARISON_TO_STRING);
return metadata;
}
use of org.teiid.metadata.Schema in project teiid by teiid.
the class EventDistributorImpl method setProcedureDefinition.
@Override
public void setProcedureDefinition(String vdbName, String vdbVersion, String schema, String procName, String definition) {
Schema s = getSchema(vdbName, vdbVersion, schema);
if (s == null) {
return;
}
Procedure p = s.getProcedures().get(procName);
if (p == null) {
return;
}
DdlPlan.alterProcedureDefinition(getVdbRepository().getLiveVDB(vdbName, vdbVersion), p, definition, true);
}
use of org.teiid.metadata.Schema in project teiid by teiid.
the class EmbeddedAdminImpl method getSchema.
@Override
public String getSchema(String vdbName, String vdbVersion, String modelName, EnumSet<SchemaObjectType> allowedTypes, String typeNamePattern) throws AdminException {
if (vdbVersion == null) {
vdbVersion = "1";
}
VDBMetaData vdb = checkVDB(vdbName, vdbVersion);
MetadataStore metadataStore = vdb.getAttachment(TransformationMetadata.class).getMetadataStore();
if (modelName != null) {
Schema schema = metadataStore.getSchema(modelName);
return DDLStringVisitor.getDDLString(schema, allowedTypes, typeNamePattern);
} else {
Database db = DatabaseUtil.convert(vdb, metadataStore);
return DDLStringVisitor.getDDLString(db);
}
}
use of org.teiid.metadata.Schema in project teiid by teiid.
the class MultiSourceMetadataRepository method loadMetadata.
@Override
public void loadMetadata(MetadataFactory factory, ExecutionFactory<Object, Object> executionFactory, Object connectionFactory) throws TranslatorException {
Schema s = factory.getSchema();
for (Table t : s.getTables().values()) {
if (!t.isPhysical()) {
continue;
}
Column c = t.getColumnByName(multiSourceColumnName);
if (c == null) {
c = factory.addColumn(multiSourceColumnName, DataTypeManager.DefaultDataTypes.STRING, t);
MultiSourceMetadataWrapper.setMultiSourceElementMetadata(c);
}
}
outer: for (Procedure p : s.getProcedures().values()) {
if (p.isVirtual()) {
continue;
}
for (ProcedureParameter pp : p.getParameters()) {
if (multiSourceColumnName.equalsIgnoreCase(pp.getName())) {
continue outer;
}
}
ProcedureParameter pp = factory.addProcedureParameter(multiSourceColumnName, DataTypeManager.DefaultDataTypes.STRING, Type.In, p);
pp.setNullType(NullType.Nullable);
}
}
use of org.teiid.metadata.Schema in project teiid by teiid.
the class TestCompositeVDB method createVDBMetadata.
static VDBMetaData createVDBMetadata(MetadataStore metadataStore, String vdbName) {
VDBMetaData vdbMetaData = new VDBMetaData();
// $NON-NLS-1$
vdbMetaData.setName(vdbName);
vdbMetaData.setVersion(1);
for (Schema schema : metadataStore.getSchemas().values()) {
vdbMetaData.addModel(RealMetadataFactory.createModel(schema.getName(), schema.isPhysical()));
}
return vdbMetaData;
}
Aggregations