Skip to content

Commit

Permalink
Add collectAssignedFocusMappingsResults() method
Browse files Browse the repository at this point in the history
This is to be used to implement non-tolerant focus mappings
induced by assignments (as opposed to those present in object
template).
  • Loading branch information
mederly committed Feb 14, 2018
1 parent c199011 commit 732a8c6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
Expand Up @@ -23,6 +23,8 @@
import javax.xml.namespace.QName;

import com.evolveum.midpoint.prism.Item;
import com.evolveum.midpoint.prism.PrismValue;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.util.LocalizableMessage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -1129,4 +1131,12 @@ Object executeAdHocProvisioningScript(String resourceOid, String language, Strin
*/
Boolean isEvaluateNew();

/**
* Returns all non-negative values from all focus mappings (targeted to given path)
* from all non-negative evaluated assignments.
*
* Highly experimental. Use at your own risk.
*/
@NotNull
Collection<PrismValue> collectAssignedFocusMappingsResults(@NotNull ItemPath path) throws SchemaException;
}
Expand Up @@ -32,6 +32,7 @@
import com.evolveum.midpoint.model.api.expr.MidpointFunctions;
import com.evolveum.midpoint.model.common.ConstantsManager;
import com.evolveum.midpoint.model.common.expression.script.ScriptExpressionEvaluationContext;
import com.evolveum.midpoint.model.common.mapping.Mapping;
import com.evolveum.midpoint.model.impl.ModelObjectResolver;
import com.evolveum.midpoint.model.impl.lens.EvaluatedAssignmentImpl;
import com.evolveum.midpoint.model.impl.lens.LensContext;
Expand All @@ -41,10 +42,7 @@
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.crypto.EncryptionException;
import com.evolveum.midpoint.prism.crypto.Protector;
import com.evolveum.midpoint.prism.delta.ChangeType;
import com.evolveum.midpoint.prism.delta.DeltaSetTriple;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.delta.*;
import com.evolveum.midpoint.prism.marshaller.ItemPathHolder;
import com.evolveum.midpoint.prism.match.DefaultMatchingRule;
import com.evolveum.midpoint.prism.match.PolyStringOrigMatchingRule;
Expand Down Expand Up @@ -100,6 +98,7 @@
import static com.evolveum.midpoint.schema.util.LocalizationUtil.toLocalizableMessage;
import static com.evolveum.midpoint.schema.util.ObjectTypeUtil.createObjectRef;
import static com.evolveum.midpoint.xml.ns._public.common.common_3.TaskExecutionStatusType.RUNNABLE;
import static java.util.Collections.emptySet;
import static java.util.Collections.singleton;

/**
Expand Down Expand Up @@ -1647,4 +1646,29 @@ public Boolean isEvaluateNew() {
}
return scriptContext.isEvaluateNew();
}

@Override
@NotNull
public Collection<PrismValue> collectAssignedFocusMappingsResults(@NotNull ItemPath path) throws SchemaException {
LensContext<ObjectType> lensContext = ModelExpressionThreadLocalHolder.getLensContext();
if (lensContext == null) {
throw new IllegalStateException("No lensContext");
}
DeltaSetTriple<EvaluatedAssignmentImpl<?>> evaluatedAssignmentTriple = lensContext.getEvaluatedAssignmentTriple();
if (evaluatedAssignmentTriple == null) {
return emptySet();
}
Collection<PrismValue> rv = new HashSet<>();
for (EvaluatedAssignmentImpl<?> evaluatedAssignment : evaluatedAssignmentTriple.getNonNegativeValues()) {
for (Mapping<?, ?> mapping : evaluatedAssignment.getFocusMappings()) {
if (path.equivalent(mapping.getOutputPath())) {
PrismValueDeltaSetTriple<?> outputTriple = mapping.getOutputTriple();
if (outputTriple != null) {
rv.addAll(outputTriple.getNonNegativeValues());
}
}
}
}
return rv;
}
}

0 comments on commit 732a8c6

Please sign in to comment.