use of com.evolveum.midpoint.util.LocalizableMessageBuilder in project midpoint by Evolveum.
the class ModelHelper method determineRootCaseName.
/**
* Determines the root task name (e.g. "Workflow for adding XYZ (started 1.2.2014 10:34)")
* TODO allow change processor to influence this name
*/
private LocalizableMessage determineRootCaseName(ModelInvocationContext<?> ctx) {
String operationKey;
ModelElementContext<?> focusContext = ctx.modelContext.getFocusContext();
if (focusContext != null && focusContext.getPrimaryDelta() != null && focusContext.getPrimaryDelta().getChangeType() != null) {
switch(focusContext.getPrimaryDelta().getChangeType()) {
case ADD:
operationKey = CREATION_OF_KEY;
break;
case DELETE:
operationKey = DELETION_OF_KEY;
break;
case MODIFY:
operationKey = CHANGE_OF_KEY;
break;
default:
throw new IllegalStateException();
}
} else {
operationKey = CHANGE_OF_KEY;
}
ObjectType focus = ctx.getFocusObjectNewOrOld();
String time = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(Locale.getDefault()).format(ZonedDateTime.now());
return new LocalizableMessageBuilder().key(APPROVING_AND_EXECUTING_KEY + operationKey).arg(ObjectTypeUtil.createDisplayInformation(asPrismObject(focus), false)).arg(time).build();
}
use of com.evolveum.midpoint.util.LocalizableMessageBuilder in project midpoint by Evolveum.
the class StateConstraintEvaluator method createBuiltInMessage.
@NotNull
private <AH extends AssignmentHolderType> LocalizableMessage createBuiltInMessage(String keyPrefix, JAXBElement<StatePolicyConstraintType> constraintElement, PolicyRuleEvaluationContext<AH> ctx, boolean assignmentTarget, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {
StatePolicyConstraintType constraint = constraintElement.getValue();
List<Object> args = new ArrayList<>();
args.add(evaluatorHelper.createBeforeAfterMessage(ctx));
if (assignmentTarget) {
addAssignmentTargetArgument(args, ctx);
}
String keySuffix;
if (constraint.getName() != null) {
args.add(constraint.getName());
keySuffix = KEY_NAMED;
} else {
keySuffix = KEY_UNNAMED;
}
LocalizableMessage builtInMessage = new LocalizableMessageBuilder().key(keyPrefix + keySuffix).args(args).build();
return evaluatorHelper.createLocalizableMessage(constraintElement, ctx, builtInMessage, result);
}
use of com.evolveum.midpoint.util.LocalizableMessageBuilder in project midpoint by Evolveum.
the class PolicySituationConstraintEvaluator method createMessage.
private LocalizableMessage createMessage(Collection<EvaluatedPolicyRule> sourceRules, JAXBElement<PolicySituationPolicyConstraintType> constraintElement, PolicyRuleEvaluationContext<?> ctx, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {
// determine if there's a single message that could be retrieved
List<TreeNode<LocalizableMessage>> messageTrees = sourceRules.stream().flatMap(r -> r.extractMessages().stream()).collect(Collectors.toList());
LocalizableMessage builtInMessage;
if (messageTrees.size() == 1) {
builtInMessage = messageTrees.get(0).getUserObject();
} else {
builtInMessage = new LocalizableMessageBuilder().key(SchemaConstants.DEFAULT_POLICY_CONSTRAINT_KEY_PREFIX + CONSTRAINT_KEY).build();
}
return evaluatorHelper.createLocalizableMessage(constraintElement, ctx, builtInMessage, result);
}
use of com.evolveum.midpoint.util.LocalizableMessageBuilder in project midpoint by Evolveum.
the class PolicySituationConstraintEvaluator method createShortMessage.
private LocalizableMessage createShortMessage(Collection<EvaluatedPolicyRule> sourceRules, JAXBElement<PolicySituationPolicyConstraintType> constraintElement, PolicyRuleEvaluationContext<?> ctx, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {
// determine if there's a single message that could be retrieved
List<TreeNode<LocalizableMessage>> messageTrees = sourceRules.stream().flatMap(r -> r.extractShortMessages().stream()).collect(Collectors.toList());
LocalizableMessage builtInMessage;
if (messageTrees.size() == 1) {
builtInMessage = messageTrees.get(0).getUserObject();
} else {
builtInMessage = new LocalizableMessageBuilder().key(SchemaConstants.DEFAULT_POLICY_CONSTRAINT_SHORT_MESSAGE_KEY_PREFIX + CONSTRAINT_KEY).build();
}
return evaluatorHelper.createLocalizableShortMessage(constraintElement, ctx, builtInMessage, result);
}
Aggregations