-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
infra/schema/src/main/java/com/evolveum/midpoint/schema/PrismQueryExpressionSupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.evolveum.midpoint.schema; | ||
|
||
import java.util.Map; | ||
|
||
import javax.xml.bind.JAXBElement; | ||
import javax.xml.namespace.QName; | ||
|
||
import com.evolveum.midpoint.prism.ExpressionWrapper; | ||
import com.evolveum.midpoint.prism.query.PrismQueryExpressionFactory; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ScriptExpressionEvaluatorType; | ||
import com.google.common.base.Strings; | ||
|
||
public class PrismQueryExpressionSupport implements PrismQueryExpressionFactory { | ||
|
||
private static final QName SCRIPT = new QName(ExpressionType.COMPLEX_TYPE.getNamespaceURI(), "script"); | ||
private static final QName EXPRESSION = new QName(ExpressionType.COMPLEX_TYPE.getNamespaceURI(), "expression"); | ||
@Override | ||
public ExpressionWrapper parseScript(Map<String, String> namespaceContext, String language, String script) { | ||
ExpressionType expressionT = new ExpressionType(); | ||
var scriptValue = new ScriptExpressionEvaluatorType(); | ||
if (!Strings.isNullOrEmpty(language)) { | ||
scriptValue.setLanguage(language); | ||
} | ||
scriptValue.setCode(script); | ||
expressionT.expressionEvaluator(new JAXBElement<>(SCRIPT, ScriptExpressionEvaluatorType.class, scriptValue)); | ||
return new ExpressionWrapper(EXPRESSION, expressionT); | ||
} | ||
} |