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());
}
}
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();
}
}
Aggregations