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);
}
}
Aggregations