use of org.openforis.idm.model.expression.internal.CustomFunctions in project collect by openforis.
the class ExpressionFactory method registerFunctions.
private void registerFunctions(CustomFunctions... functionsLibrary) {
jxPathContext = (ModelJXPathContext) JXPathContext.newContext(null);
FunctionLibrary library = new FunctionLibrary();
for (CustomFunctions functions : functionsLibrary) {
library.addFunctions(functions);
String namespace = functions.getNamespace();
if (customFunctionsByNamespace.containsKey(namespace)) {
throw new IllegalStateException(String.format("Functions for namespace %s already registered", namespace));
}
customFunctionsByNamespace.put(namespace, functions);
}
jxPathContext.setFunctions(library);
}
use of org.openforis.idm.model.expression.internal.CustomFunctions in project collect by openforis.
the class ExpressionFactory method isValidFunction.
public boolean isValidFunction(String namespace, String functionName) {
boolean inDefaultNamespace = StringUtils.isBlank(namespace);
if (inDefaultNamespace) {
return CORE_FUNCTION_NAMES.contains(functionName);
}
CustomFunctions functions = customFunctionsByNamespace.get(namespace);
return functions != null && functions.containsFunction(functionName);
}
use of org.openforis.idm.model.expression.internal.CustomFunctions in project collect by openforis.
the class ExpressionFactory method lookupFunction.
public CustomFunction lookupFunction(ModelExtensionFunction modelExtensionFunction) {
String namespace = modelExtensionFunction.getPrefix();
CustomFunctions customFunctions = customFunctionsByNamespace.get(namespace);
return (CustomFunction) customFunctions.getFunction(namespace, modelExtensionFunction.getName(), modelExtensionFunction.getArguments());
}
Aggregations