use of com.evolveum.midpoint.model.api.context.PolicyRuleExternalizationOptions in project midpoint by Evolveum.
the class PolicyStateRecorder method compute.
private ComputationResult compute(@NotNull List<EvaluatedPolicyRule> rulesToRecord, @NotNull List<String> existingPolicySituation, @NotNull List<EvaluatedPolicyRuleType> existingTriggeredPolicyRule) {
ComputationResult cr = new ComputationResult();
for (EvaluatedPolicyRule rule : rulesToRecord) {
cr.newPolicySituations.add(rule.getPolicySituation());
RecordPolicyActionType recordAction = rule.getEnabledAction(RecordPolicyActionType.class);
if (recordAction.getPolicyRules() != TriggeredPolicyRulesStorageStrategyType.NONE) {
PolicyRuleExternalizationOptions externalizationOptions = new PolicyRuleExternalizationOptions(recordAction.getPolicyRules(), false, true);
rule.addToEvaluatedPolicyRuleBeans(cr.newTriggeredRules, externalizationOptions, null, prismContext);
}
}
cr.oldPolicySituations.addAll(existingPolicySituation);
cr.oldTriggeredRules.addAll(existingTriggeredPolicyRule);
cr.situationsNeedUpdate = !Objects.equals(cr.oldPolicySituations, cr.newPolicySituations);
// hope hashCode is computed well
cr.rulesNeedUpdate = !Objects.equals(cr.oldTriggeredRules, cr.newTriggeredRules);
return cr;
}
use of com.evolveum.midpoint.model.api.context.PolicyRuleExternalizationOptions in project midpoint by Evolveum.
the class ApprovalSchemaBuilder method processFragmentGroup.
private void processFragmentGroup(List<Fragment> fragments, ApprovalSchemaType resultingSchemaType, SchemaAttachedPolicyRulesType attachedRules, ModelInvocationContext<?> ctx, OperationResult result) throws SchemaException {
Fragment firstFragment = fragments.get(0);
appendAddOnFragments(fragments);
List<ApprovalStageDefinitionType> fragmentStageDefs = cloneAndMergeStages(fragments);
if (fragmentStageDefs.isEmpty()) {
// probably shouldn't occur
return;
}
fragmentStageDefs.sort(Comparator.comparing(this::getNumber, Comparator.nullsLast(naturalOrder())));
RelationResolver relationResolver = primaryChangeAspect.createRelationResolver(firstFragment.target, result);
ReferenceResolver referenceResolver = primaryChangeAspect.createReferenceResolver(ctx.modelContext, ctx.task, result);
int from = getStages(resultingSchemaType).size() + 1;
int i = from;
for (ApprovalStageDefinitionType stageDef : fragmentStageDefs) {
// to avoid ID collision
stageDef.asPrismContainerValue().setId(null);
stageDef.setNumber(i++);
approvalSchemaHelper.prepareStage(stageDef, relationResolver, referenceResolver);
resultingSchemaType.getStage().add(stageDef);
}
if (firstFragment.policyRule != null) {
List<EvaluatedPolicyRuleType> rules = new ArrayList<>();
firstFragment.policyRule.addToEvaluatedPolicyRuleBeans(rules, new PolicyRuleExternalizationOptions(FULL, false, true), null, ctx.prismContext);
for (EvaluatedPolicyRuleType rule : rules) {
SchemaAttachedPolicyRuleType attachedRule = new SchemaAttachedPolicyRuleType();
attachedRule.setStageMin(from);
attachedRule.setStageMax(i - 1);
attachedRule.setRule(rule);
attachedRules.getEntry().add(attachedRule);
}
}
}
Aggregations