Search in sources :

Example 86 with Schema

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;
}
Also used : UDFSource(org.teiid.query.function.UDFSource) CompositeMetadataStore(org.teiid.query.metadata.CompositeMetadataStore) MetadataStore(org.teiid.metadata.MetadataStore) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) FunctionTree(org.teiid.query.function.FunctionTree) CompositeMetadataStore(org.teiid.query.metadata.CompositeMetadataStore) Schema(org.teiid.metadata.Schema) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 87 with Schema

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);
}
Also used : Schema(org.teiid.metadata.Schema) Procedure(org.teiid.metadata.Procedure)

Example 88 with Schema

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);
    }
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) Schema(org.teiid.metadata.Schema) Database(org.teiid.metadata.Database)

Example 89 with Schema

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);
    }
}
Also used : ProcedureParameter(org.teiid.metadata.ProcedureParameter) Table(org.teiid.metadata.Table) Column(org.teiid.metadata.Column) Schema(org.teiid.metadata.Schema) Procedure(org.teiid.metadata.Procedure)

Example 90 with Schema

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;
}
Also used : VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) Schema(org.teiid.metadata.Schema)

Aggregations

Schema (org.teiid.metadata.Schema)92 MetadataStore (org.teiid.metadata.MetadataStore)47 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)37 Table (org.teiid.metadata.Table)35 Test (org.junit.Test)34 QueryNode (org.teiid.query.mapping.relational.QueryNode)20 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)19 Column (org.teiid.metadata.Column)18 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)18 Procedure (org.teiid.metadata.Procedure)16 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)11 List (java.util.List)10 ArrayList (java.util.ArrayList)9 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)8 ProcedureParameter (org.teiid.metadata.ProcedureParameter)8 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)7 FunctionMethod (org.teiid.metadata.FunctionMethod)6 TempMetadataStore (org.teiid.query.metadata.TempMetadataStore)6 CompositeMetadataStore (org.teiid.query.metadata.CompositeMetadataStore)5 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)5