Skip to content

Commit

Permalink
fix using of path evaluator for basic type of variable
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed May 27, 2021
1 parent 8f15476 commit f3bb1ef
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 184 deletions.
Expand Up @@ -26,114 +26,49 @@
<q:path>targetRef</q:path>
<expression>
<queryInterpretationOfNoValue>filterAll</queryInterpretationOfNoValue>
<script>
<objectVariableMode>prismReference</objectVariableMode>
<code>
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;

if (!target) {
return null;
}

ObjectReferenceType ort = new ObjectReferenceType();
ort.setOid(target.getOid());
ort.setRelation(target.getRelation());
ort.setType(target.getTargetType());
return ort;
</code>
</script>
<path>$target</path>
</expression>
</q:ref>
<q:ref>
<q:path>initiatorRef</q:path>
<expression>
<queryInterpretationOfNoValue>filterAll</queryInterpretationOfNoValue>
<script>
<objectVariableMode>prismReference</objectVariableMode>
<code>
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;

if (!initiator) {
return null;
}

ObjectReferenceType ort = new ObjectReferenceType();
ort.setOid(initiator.getOid());
ort.setRelation(initiator.getRelation());
ort.setType(initiator.getTargetType());
return ort;
</code>
</script>
<path>$initiator</path>
</expression>
</q:ref>
<q:equal>
<q:path>outcome</q:path>
<expression>
<queryInterpretationOfNoValue>filterAll</queryInterpretationOfNoValue>
<script>
<code>
if (!outcome) {
return null;
}
return outcome;
</code>
</script>
<path>$outcome</path>
</expression>
</q:equal>
<q:equal>
<q:path>eventType</q:path>
<expression>
<queryInterpretationOfNoValue>filterAll</queryInterpretationOfNoValue>
<script>
<code>
if (!eventType) {
return null;
}
return eventType;
</code>
</script>
<path>$eventType</path>
</expression>
</q:equal>
<q:equal>
<q:path>eventStage</q:path>
<expression>
<queryInterpretationOfNoValue>filterAll</queryInterpretationOfNoValue>
<script>
<code>
if (!eventStage) {
return null;
}
return eventStage;
</code>
</script>
<path>$eventStage</path>
</expression>
</q:equal>
<q:greater>
<q:path>timestamp</q:path>
<expression>
<queryInterpretationOfNoValue>filterAll</queryInterpretationOfNoValue>
<script>
<code>
if (!from) {
return null;
}
return from;
</code>
</script>
<path>$from</path>
</expression>
</q:greater>
<q:less>
<q:path>timestamp</q:path>
<expression>
<queryInterpretationOfNoValue>filterAll</queryInterpretationOfNoValue>
<script>
<code>
if (!to) {
return null;
}
return to;
</code>
</script>
<path>$to</path>
</expression>
</q:less>
</q:and>
Expand Down
Expand Up @@ -26,36 +26,14 @@
<q:path>resourceRef</q:path>
<expression>
<queryInterpretationOfNoValue>filterAll</queryInterpretationOfNoValue>
<script>
<objectVariableMode>prismReference</objectVariableMode>
<code>
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;

if (!resource) {
return null;
}

ObjectReferenceType ort = new ObjectReferenceType();
ort.setOid(resource.getOid());
ort.setRelation(resource.getRelation());
ort.setType(resource.getTargetType());
return ort;
</code>
</script>
<path>$resource</path>
</expression>
</q:ref>
<q:equal>
<q:path>synchronizationSituation</q:path>
<expression>
<queryInterpretationOfNoValue>filterAll</queryInterpretationOfNoValue>
<script>
<code>
if (!situation) {
return null;
}
return situation;
</code>
</script>
<path>$situation</path>
</expression>
</q:equal>
<q:equal>
Expand All @@ -75,28 +53,14 @@
<q:path>kind</q:path>
<expression>
<queryInterpretationOfNoValue>filterAll</queryInterpretationOfNoValue>
<script>
<code>
if (!kind) {
return null;
}
return kind;
</code>
</script>
<path>$kind</path>
</expression>
</q:equal>
<q:equal>
<q:path>intent</q:path>
<expression>
<queryInterpretationOfNoValue>filterAll</queryInterpretationOfNoValue>
<script>
<code>
if (!intent) {
return null;
}
return intent;
</code>
</script>
<path>$intent</path>
</expression>
</q:equal>
</q:and>
Expand Down
Expand Up @@ -23,80 +23,28 @@
<q:path>activation/administrativeStatus</q:path>
<expression>
<queryInterpretationOfNoValue>filterAll</queryInterpretationOfNoValue>
<script>
<code>
if (!activation) {
return null;
}
return activation;
</code>
</script>
<path>$activation</path>
</expression>
</q:equal>
<q:ref>
<q:path>assignment/targetRef</q:path>
<expression>
<queryInterpretationOfNoValue>filterAll</queryInterpretationOfNoValue>
<script>
<objectVariableMode>prismReference</objectVariableMode>
<code>
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;

if (!organization) {
return null;
}

ObjectReferenceType ort = new ObjectReferenceType();
ort.setOid(organization.getOid());
ort.setRelation(organization.getRelation());
ort.setType(organization.getTargetType());
return ort;
</code>
</script>
<path>$organization</path>
</expression>
</q:ref>
<q:ref>
<q:path>assignment/targetRef</q:path>
<expression>
<queryInterpretationOfNoValue>filterAll</queryInterpretationOfNoValue>
<script>
<objectVariableMode>prismReference</objectVariableMode>
<code>
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;

if (!role) {
return null;
}

ObjectReferenceType ort = new ObjectReferenceType();
ort.setOid(role.getOid());
ort.setRelation(role.getRelation());
ort.setType(role.getTargetType());
return ort;
</code>
</script>
<path>$role</path>
</expression>
</q:ref>
<q:ref>
<q:path>assignment/construction/resourceRef</q:path>
<expression>
<queryInterpretationOfNoValue>filterAll</queryInterpretationOfNoValue>
<script>
<objectVariableMode>prismReference</objectVariableMode>
<code>
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;

if (!resource) {
return null;
}

ObjectReferenceType ort = new ObjectReferenceType();
ort.setOid(resource.getOid());
ort.setRelation(resource.getRelation());
ort.setType(resource.getTargetType());
return ort;
</code>
</script>
<path>$resource</path>
</expression>
</q:ref>
</q:and>
Expand Down
Expand Up @@ -21,14 +21,7 @@
<q:path>../name</q:path>
<expression>
<queryInterpretationOfNoValue>filterAll</queryInterpretationOfNoValue>
<script>
<code>
if (!campaignName) {
return null;
}
return campaignName.getName();
</code>
</script>
<path>$campaignName</path>
</expression>
</q:equal>
</filter>
Expand Down
Expand Up @@ -21,14 +21,7 @@
<q:path>../name</q:path>
<expression>
<queryInterpretationOfNoValue>filterAll</queryInterpretationOfNoValue>
<script>
<code>
if (!campaignName) {
return null;
}
return campaignName.getName();
</code>
</script>
<path>$campaignName</path>
</expression>
</q:equal>
</filter>
Expand Down
Expand Up @@ -87,6 +87,15 @@ private ResolutionContext getInitialResolveContextFromVariable() throws Expressi
return IdiResolutionContext.fromAnyObject(variableValue);
} else if (variableValue instanceof PrismValue) {
return new ValueResolutionContext((PrismValue) variableValue, context.getContextDescription());
} else if (!(variableValue instanceof Containerable) && variableValueAndDefinition.getTypeClass().isAssignableFrom(variableValue.getClass())) {
V prismValue;
if (variableValue instanceof Referencable){
prismValue = (V) evaluator.getPrismContext().itemFactory().createReferenceValue(((Referencable) variableValue).getOid(), ((Referencable) variableValue).getType());
((PrismReferenceValue)prismValue).setRelation(((Referencable)variableValue).getRelation());
} else {
prismValue = (V) evaluator.getPrismContext().itemFactory().createPropertyValue(variableValue);
}
return new ValueResolutionContext(prismValue, context.getContextDescription());
} else {
throw new ExpressionEvaluationException("Unexpected variable value "+variableValue+" ("+variableValue.getClass()+")");
}
Expand Down

0 comments on commit f3bb1ef

Please sign in to comment.