Search in sources :

Example 1 with TransitionPolicyConstraintType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.TransitionPolicyConstraintType in project midpoint by Evolveum.

the class PolicyRuleTypeUtil method toShortString.

private static void toShortString(StringBuilder sb, JAXBElement<? extends AbstractPolicyConstraintType> constraint, char join) {
    QName name = constraint.getName();
    String abbreviation = CONSTRAINT_NAMES.get(name.getLocalPart());
    if (sb.length() > 0) {
        sb.append(join);
    }
    if (QNameUtil.match(name, PolicyConstraintsType.F_AND)) {
        sb.append('(');
        sb.append(toShortString((PolicyConstraintsType) constraint.getValue(), JOIN_AND));
        sb.append(')');
    } else if (QNameUtil.match(name, PolicyConstraintsType.F_OR)) {
        sb.append('(');
        sb.append(toShortString((PolicyConstraintsType) constraint.getValue(), JOIN_OR));
        sb.append(')');
    } else if (QNameUtil.match(name, PolicyConstraintsType.F_NOT)) {
        sb.append('(');
        sb.append(toShortString((PolicyConstraintsType) constraint.getValue(), JOIN_AND));
        sb.append(')');
    } else if (QNameUtil.match(name, PolicyConstraintsType.F_TRANSITION)) {
        TransitionPolicyConstraintType trans = (TransitionPolicyConstraintType) constraint.getValue();
        sb.append(SYMBOL_TRANSITION);
        sb.append(toTransSymbol(trans.isStateBefore()));
        sb.append(toTransSymbol(trans.isStateAfter()));
        sb.append('(');
        sb.append(toShortString(trans.getConstraints(), JOIN_AND));
        sb.append(')');
    } else {
        sb.append(abbreviation != null ? abbreviation : name.getLocalPart());
    }
}
Also used : PolicyConstraintsType(com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType) QName(javax.xml.namespace.QName)

Example 2 with TransitionPolicyConstraintType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.TransitionPolicyConstraintType in project midpoint by Evolveum.

the class TransitionConstraintEvaluator method evaluate.

@Override
public <AH extends AssignmentHolderType> EvaluatedPolicyRuleTrigger evaluate(@NotNull JAXBElement<TransitionPolicyConstraintType> constraintElement, @NotNull PolicyRuleEvaluationContext<AH> rctx, OperationResult parentResult) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException {
    OperationResult result = parentResult.subresult(OP_EVALUATE).setMinor().build();
    try {
        TransitionPolicyConstraintType trans = constraintElement.getValue();
        List<EvaluatedPolicyRuleTrigger<?>> triggers = new ArrayList<>();
        boolean match = evaluateState(trans, rctx, ObjectState.BEFORE, trans.isStateBefore(), triggers, result) && evaluateState(trans, rctx, ObjectState.AFTER, trans.isStateAfter(), triggers, result);
        if (match) {
            return new EvaluatedTransitionTrigger(PolicyConstraintKindType.TRANSITION, trans, createMessage(constraintElement, rctx, result), createShortMessage(constraintElement, rctx, result), triggers);
        } else {
            return null;
        }
    } catch (Throwable t) {
        result.recordFatalError(t.getMessage(), t);
        throw t;
    } finally {
        result.computeStatusIfUnknown();
    }
}
Also used : TransitionPolicyConstraintType(com.evolveum.midpoint.xml.ns._public.common.common_3.TransitionPolicyConstraintType) EvaluatedPolicyRuleTrigger(com.evolveum.midpoint.model.api.context.EvaluatedPolicyRuleTrigger) EvaluatedTransitionTrigger(com.evolveum.midpoint.model.api.context.EvaluatedTransitionTrigger) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Aggregations

EvaluatedPolicyRuleTrigger (com.evolveum.midpoint.model.api.context.EvaluatedPolicyRuleTrigger)1 EvaluatedTransitionTrigger (com.evolveum.midpoint.model.api.context.EvaluatedTransitionTrigger)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 PolicyConstraintsType (com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType)1 TransitionPolicyConstraintType (com.evolveum.midpoint.xml.ns._public.common.common_3.TransitionPolicyConstraintType)1 ArrayList (java.util.ArrayList)1 QName (javax.xml.namespace.QName)1