Search in sources :

Example 1 with EvaluatedCompositeTrigger

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

the class CompositeConstraintEvaluator method evaluate.

@Override
public <AH extends AssignmentHolderType> EvaluatedCompositeTrigger evaluate(@NotNull JAXBElement<PolicyConstraintsType> constraint, @NotNull PolicyRuleEvaluationContext<AH> rctx, OperationResult parentResult) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException {
    OperationResult result = parentResult.subresult(OP_EVALUATE).setMinor().build();
    try {
        boolean isAnd = QNameUtil.match(PolicyConstraintsType.F_AND, constraint.getName());
        boolean isOr = QNameUtil.match(PolicyConstraintsType.F_OR, constraint.getName());
        boolean isNot = QNameUtil.match(PolicyConstraintsType.F_NOT, constraint.getName());
        assert isAnd || isOr || isNot;
        List<EvaluatedPolicyRuleTrigger<?>> triggers = policyRuleProcessor.evaluateConstraints(constraint.getValue(), !isOr, rctx, result);
        EvaluatedCompositeTrigger rv;
        if (isNot) {
            if (triggers.isEmpty()) {
                rv = createTrigger(NOT, constraint, triggers, rctx, result);
            } else {
                rv = null;
            }
        } else {
            if (!triggers.isEmpty()) {
                rv = createTrigger(isAnd ? AND : OR, constraint, triggers, rctx, result);
            } else {
                rv = null;
            }
        }
        if (rv != null) {
            result.addReturn("trigger", rv.toDiagShortcut());
        }
        return rv;
    } catch (Throwable t) {
        result.recordFatalError(t.getMessage(), t);
        throw t;
    } finally {
        result.computeStatusIfUnknown();
    }
}
Also used : EvaluatedPolicyRuleTrigger(com.evolveum.midpoint.model.api.context.EvaluatedPolicyRuleTrigger) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) EvaluatedCompositeTrigger(com.evolveum.midpoint.model.api.context.EvaluatedCompositeTrigger)

Aggregations

EvaluatedCompositeTrigger (com.evolveum.midpoint.model.api.context.EvaluatedCompositeTrigger)1 EvaluatedPolicyRuleTrigger (com.evolveum.midpoint.model.api.context.EvaluatedPolicyRuleTrigger)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1