use of com.evolveum.midpoint.repo.common.expression.ExpressionVariables in project midpoint by Evolveum.
the class AddAssociationAspect method isAssociationRelevant.
//endregion
private boolean isAssociationRelevant(PcpAspectConfigurationType config, AssociationAdditionType itemToApprove, ResourceShadowDiscriminator rsd, ModelContext<?> modelContext, Task task, OperationResult result) {
LOGGER.trace(" - considering: {}", itemToApprove);
ExpressionVariables variables = new ExpressionVariables();
variables.addVariableDefinition(SchemaConstants.C_ASSOCIATION, itemToApprove.getAssociation());
variables.addVariableDefinition(SchemaConstants.C_SHADOW_DISCRIMINATOR, rsd);
boolean applicable = primaryChangeAspectHelper.evaluateApplicabilityCondition(config, modelContext, itemToApprove, variables, this, task, result);
LOGGER.trace(" - result: applicable = {}", applicable);
return applicable;
}
use of com.evolveum.midpoint.repo.common.expression.ExpressionVariables in project midpoint by Evolveum.
the class AccCertUpdateHelper method computeDelegateTo.
private List<ObjectReferenceType> computeDelegateTo(DelegateWorkItemActionType delegateAction, AccessCertificationWorkItemType workItem, AccessCertificationCaseType aCase, AccessCertificationCampaignType campaign, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
List<ObjectReferenceType> rv = new ArrayList<>();
rv.addAll(CloneUtil.cloneCollectionMembers(delegateAction.getApproverRef()));
if (!delegateAction.getApproverExpression().isEmpty()) {
ExpressionVariables variables = new ExpressionVariables();
variables.addVariableDefinition(ExpressionConstants.VAR_WORK_ITEM, workItem);
variables.addVariableDefinition(ExpressionConstants.VAR_CERTIFICATION_CASE, aCase);
variables.addVariableDefinition(ExpressionConstants.VAR_CAMPAIGN, campaign);
for (ExpressionType expression : delegateAction.getApproverExpression()) {
rv.addAll(expressionHelper.evaluateRefExpressionChecked(expression, variables, "computing delegates", task, result));
}
}
return rv;
}
use of com.evolveum.midpoint.repo.common.expression.ExpressionVariables in project midpoint by Evolveum.
the class AccCertReviewersHelper method getReviewersForCase.
public List<ObjectReferenceType> getReviewersForCase(AccessCertificationCaseType _case, AccessCertificationCampaignType campaign, AccessCertificationReviewerSpecificationType reviewerSpec, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException {
if (reviewerSpec == null) {
// TODO issue a warning here?
return Collections.emptyList();
}
List<ObjectReferenceType> reviewers = new ArrayList<>();
if (Boolean.TRUE.equals(reviewerSpec.isUseTargetOwner())) {
cloneAndMerge(reviewers, getTargetObjectOwners(_case, task, result));
}
if (Boolean.TRUE.equals(reviewerSpec.isUseTargetApprover())) {
cloneAndMerge(reviewers, getTargetObjectApprovers(_case, task, result));
}
if (Boolean.TRUE.equals(reviewerSpec.isUseObjectOwner())) {
cloneAndMerge(reviewers, getObjectOwners(_case, task, result));
}
if (Boolean.TRUE.equals(reviewerSpec.isUseObjectApprover())) {
cloneAndMerge(reviewers, getObjectApprovers(_case, task, result));
}
if (reviewerSpec.getUseObjectManager() != null) {
cloneAndMerge(reviewers, getObjectManagers(_case, reviewerSpec.getUseObjectManager(), task, result));
}
for (ExpressionType reviewerExpression : reviewerSpec.getReviewerExpression()) {
ExpressionVariables variables = new ExpressionVariables();
variables.addVariableDefinition(ExpressionConstants.VAR_CERTIFICATION_CASE, _case);
variables.addVariableDefinition(ExpressionConstants.VAR_CAMPAIGN, campaign);
variables.addVariableDefinition(ExpressionConstants.VAR_REVIEWER_SPECIFICATION, reviewerSpec);
List<ObjectReferenceType> refList = expressionHelper.evaluateRefExpressionChecked(reviewerExpression, variables, "reviewer expression", task, result);
cloneAndMerge(reviewers, refList);
}
resolveRoleReviewers(reviewers, task, result);
if (reviewers.isEmpty()) {
cloneAndMerge(reviewers, reviewerSpec.getDefaultReviewerRef());
}
cloneAndMerge(reviewers, reviewerSpec.getAdditionalReviewerRef());
resolveRoleReviewers(reviewers, task, result);
return reviewers;
}
use of com.evolveum.midpoint.repo.common.expression.ExpressionVariables in project midpoint by Evolveum.
the class MappingEvaluator method createFocusMapping.
public <V extends PrismValue, D extends ItemDefinition, F extends FocusType, T extends FocusType> Mapping<V, D> createFocusMapping(final MappingFactory mappingFactory, final LensContext<F> context, final MappingType mappingType, ObjectType originObject, ObjectDeltaObject<F> focusOdo, PrismObject<T> defaultTargetObject, AssignmentPathVariables assignmentPathVariables, Integer iteration, String iterationToken, PrismObject<SystemConfigurationType> configuration, XMLGregorianCalendar now, String contextDesc, final Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException {
if (!Mapping.isApplicableToChannel(mappingType, context.getChannel())) {
LOGGER.trace("Mapping {} not applicable to channel {}, skipping.", mappingType, context.getChannel());
return null;
}
StringPolicyResolver stringPolicyResolver = new StringPolicyResolver() {
private ItemPath outputPath;
private ItemDefinition outputDefinition;
@Override
public void setOutputPath(ItemPath outputPath) {
this.outputPath = outputPath;
}
@Override
public void setOutputDefinition(ItemDefinition outputDefinition) {
this.outputDefinition = outputDefinition;
}
@Override
public StringPolicyType resolve() {
// TODO need to switch to ObjectValuePolicyEvaluator
if (outputDefinition.getName().equals(PasswordType.F_VALUE)) {
ValuePolicyType passwordPolicy = credentialsProcessor.determinePasswordPolicy(context.getFocusContext(), task, result);
if (passwordPolicy == null) {
return null;
}
return passwordPolicy.getStringPolicy();
}
if (mappingType.getExpression() != null) {
List<JAXBElement<?>> evaluators = mappingType.getExpression().getExpressionEvaluator();
if (evaluators != null) {
for (JAXBElement jaxbEvaluator : evaluators) {
Object object = jaxbEvaluator.getValue();
if (object instanceof GenerateExpressionEvaluatorType && ((GenerateExpressionEvaluatorType) object).getValuePolicyRef() != null) {
ObjectReferenceType ref = ((GenerateExpressionEvaluatorType) object).getValuePolicyRef();
try {
ValuePolicyType valuePolicyType = mappingFactory.getObjectResolver().resolve(ref, ValuePolicyType.class, null, "resolving value policy for generate attribute " + outputDefinition.getName() + " value", task, new OperationResult("Resolving value policy"));
if (valuePolicyType != null) {
return valuePolicyType.getStringPolicy();
}
} catch (CommonException ex) {
throw new SystemException(ex.getMessage(), ex);
}
}
}
}
}
return null;
}
};
ExpressionVariables variables = new ExpressionVariables();
FOCUS_VARIABLE_NAMES.forEach(name -> variables.addVariableDefinition(name, focusOdo));
variables.addVariableDefinition(ExpressionConstants.VAR_ITERATION, iteration);
variables.addVariableDefinition(ExpressionConstants.VAR_ITERATION_TOKEN, iterationToken);
variables.addVariableDefinition(ExpressionConstants.VAR_CONFIGURATION, configuration);
Collection<V> targetValues = computeTargetValues(mappingType.getTarget(), defaultTargetObject, variables, mappingFactory.getObjectResolver(), contextDesc, task, result);
Mapping.Builder<V, D> mappingBuilder = mappingFactory.<V, D>createMappingBuilder(mappingType, contextDesc).sourceContext(focusOdo).targetContext(defaultTargetObject.getDefinition()).variables(variables).originalTargetValues(targetValues).originType(OriginType.USER_POLICY).originObject(originObject).stringPolicyResolver(stringPolicyResolver).rootNode(focusOdo).now(now);
mappingBuilder = LensUtil.addAssignmentPathVariables(mappingBuilder, assignmentPathVariables);
Mapping<V, D> mapping = mappingBuilder.build();
ItemPath itemPath = mapping.getOutputPath();
if (itemPath == null) {
// no output element, i.e. this is a "validation mapping"
return mapping;
}
if (defaultTargetObject != null) {
Item<V, D> existingTargetItem = (Item<V, D>) defaultTargetObject.findItem(itemPath);
if (existingTargetItem != null && !existingTargetItem.isEmpty() && mapping.getStrength() == MappingStrengthType.WEAK) {
LOGGER.trace("Mapping {} is weak and target already has a value {}, skipping.", mapping, existingTargetItem);
return null;
}
}
return mapping;
}
use of com.evolveum.midpoint.repo.common.expression.ExpressionVariables in project midpoint by Evolveum.
the class ProjectionValuesProcessor method evaluateIterationCondition.
private <F extends ObjectType> boolean evaluateIterationCondition(LensContext<F> context, LensProjectionContext accountContext, int iteration, String iterationToken, boolean beforeIteration, Task task, OperationResult result) throws ExpressionEvaluationException, SchemaException, ObjectNotFoundException {
ResourceObjectTypeDefinitionType accDef = accountContext.getResourceObjectTypeDefinitionType();
if (accDef == null) {
return true;
}
IterationSpecificationType iterationType = accDef.getIteration();
ExpressionVariables variables = createExpressionVariables(context, accountContext);
return LensUtil.evaluateIterationCondition(context, accountContext, iterationType, iteration, iterationToken, beforeIteration, expressionFactory, variables, task, result);
}
Aggregations