Search in sources :

Example 1 with Resource

use of org.teiid.query.metadata.VDBResources.Resource in project teiid by teiid.

the class VDBMetadataFactory method getVDBMetadata.

public static TransformationMetadata getVDBMetadata(String vdbName, URL vdbURL, URL udfFile) throws IOException {
    TransformationMetadata vdbmetadata = VDB_CACHE.get(vdbURL);
    if (vdbmetadata != null) {
        return vdbmetadata;
    }
    try {
        IndexVDB imf = loadMetadata(vdbName, vdbURL);
        Resource r = imf.resources.getEntriesPlusVisibilities().get("/META-INF/vdb.xml");
        VDBMetaData vdb = null;
        if (r != null) {
            vdb = VDBMetadataParser.unmarshell(r.openStream());
        }
        Collection<FunctionMethod> methods = null;
        Collection<FunctionTree> trees = null;
        if (udfFile != null) {
            String schema = FileUtils.getFilenameWithoutExtension(udfFile.getPath());
            methods = FunctionMetadataReader.loadFunctionMethods(udfFile.openStream());
            trees = Arrays.asList(new FunctionTree(schema, new UDFSource(methods), true));
        }
        SystemFunctionManager sfm = SystemMetadata.getInstance().getSystemFunctionManager();
        vdbmetadata = new TransformationMetadata(vdb, new CompositeMetadataStore(Arrays.asList(SystemMetadata.getInstance().getSystemStore(), imf.store)), imf.resources.getEntriesPlusVisibilities(), sfm.getSystemFunctions(), trees);
        VDB_CACHE.put(vdbURL, vdbmetadata);
        return vdbmetadata;
    } catch (XMLStreamException e) {
        throw new IOException(e);
    }
}
Also used : UDFSource(org.teiid.query.function.UDFSource) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) FunctionTree(org.teiid.query.function.FunctionTree) SystemFunctionManager(org.teiid.query.function.SystemFunctionManager) Resource(org.teiid.query.metadata.VDBResources.Resource) IOException(java.io.IOException) CompositeMetadataStore(org.teiid.query.metadata.CompositeMetadataStore) XMLStreamException(javax.xml.stream.XMLStreamException) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) FunctionMethod(org.teiid.metadata.FunctionMethod)

Aggregations

IOException (java.io.IOException)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)1 FunctionMethod (org.teiid.metadata.FunctionMethod)1 FunctionTree (org.teiid.query.function.FunctionTree)1 SystemFunctionManager (org.teiid.query.function.SystemFunctionManager)1 UDFSource (org.teiid.query.function.UDFSource)1 CompositeMetadataStore (org.teiid.query.metadata.CompositeMetadataStore)1 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)1 Resource (org.teiid.query.metadata.VDBResources.Resource)1