Search in sources :

Example 1 with EvaluatedAssignment

use of com.evolveum.midpoint.model.api.context.EvaluatedAssignment in project midpoint by Evolveum.

the class AssignmentCollector method evaluateAssignments.

private <AH extends AssignmentHolderType> Collection<EvaluatedAssignment<AH>> evaluateAssignments(AH focus, Collection<AssignmentType> assignments, AssignmentOrigin origin, AssignmentEvaluator<AH> assignmentEvaluator, Task task, OperationResult result) {
    List<EvaluatedAssignment<AH>> evaluatedAssignments = new ArrayList<>();
    RepositoryCache.enterLocalCaches(cacheConfigurationManager);
    try {
        PrismContainerDefinition<AssignmentType> standardAssignmentDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(AssignmentHolderType.class).findContainerDefinition(AssignmentHolderType.F_ASSIGNMENT);
        for (AssignmentType assignmentType : emptyIfNull(assignments)) {
            try {
                // noinspection unchecked
                PrismContainerDefinition<AssignmentType> definition = defaultIfNull(assignmentType.asPrismContainerValue().getDefinition(), standardAssignmentDefinition);
                ItemDeltaItem<PrismContainerValue<AssignmentType>, PrismContainerDefinition<AssignmentType>> assignmentIdi = new ItemDeltaItem<>(LensUtil.createAssignmentSingleValueContainer(assignmentType), definition);
                EvaluatedAssignment<AH> assignment = assignmentEvaluator.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, focus, focus.toString(), origin, task, result);
                evaluatedAssignments.add(assignment);
            } catch (SchemaException | ObjectNotFoundException | ExpressionEvaluationException | PolicyViolationException | SecurityViolationException | ConfigurationException | CommunicationException e) {
                LOGGER.error("Error while processing assignment of {}: {}; assignment: {}", focus, e.getMessage(), assignmentType, e);
            }
        }
    } finally {
        RepositoryCache.exitLocalCaches();
    }
    return evaluatedAssignments;
}
Also used : PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) ArrayList(java.util.ArrayList) EvaluatedAssignment(com.evolveum.midpoint.model.api.context.EvaluatedAssignment) ItemDeltaItem(com.evolveum.midpoint.prism.util.ItemDeltaItem) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) AssignmentHolderType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType)

Aggregations

EvaluatedAssignment (com.evolveum.midpoint.model.api.context.EvaluatedAssignment)1 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)1 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)1 ItemDeltaItem (com.evolveum.midpoint.prism.util.ItemDeltaItem)1 AssignmentHolderType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType)1 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)1 ArrayList (java.util.ArrayList)1