use of org.teiid.query.function.UDFSource in project teiid by teiid.
the class TranslationUtility method addUDF.
public void addUDF(String schema, Collection<FunctionMethod> methods) {
if (methods == null || methods.isEmpty()) {
return;
}
this.functions.add(new FunctionTree(schema, new UDFSource(methods)));
SystemFunctionManager sfm = SystemMetadata.getInstance().getSystemFunctionManager();
functionLibrary = new FunctionLibrary(sfm.getSystemFunctions(), this.functions.toArray(new FunctionTree[this.functions.size()]));
}
use of org.teiid.query.function.UDFSource in project teiid by teiid.
the class UDFMetaData method addFunctions.
public void addFunctions(String name, Collection<FunctionMethod> funcs) {
if (funcs.isEmpty()) {
return;
}
UDFSource udfSource = this.methods.get(name);
if (udfSource != null) {
// this is ambiguous about as to what classloader to use, but we assume the first is good and that the user will have set
// the Java method if that's not the case
ArrayList<FunctionMethod> allMethods = new ArrayList<FunctionMethod>(udfSource.getFunctionMethods());
allMethods.addAll(funcs);
ClassLoader cl = udfSource.getClassLoader();
udfSource = new UDFSource(allMethods);
udfSource.setClassLoader(cl);
} else {
udfSource = new UDFSource(funcs);
udfSource.setClassLoader(classLoader);
}
this.methods.put(name, udfSource);
}
use of org.teiid.query.function.UDFSource 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;
}
Aggregations