use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowDiscriminatorType in project midpoint by Evolveum.
the class AssociationFromLinkExpressionEvaluator method evaluate.
/* (non-Javadoc)
* @see com.evolveum.midpoint.common.expression.ExpressionEvaluator#evaluate(java.util.Collection, java.util.Map, boolean, java.lang.String, com.evolveum.midpoint.schema.result.OperationResult)
*/
@Override
public PrismValueDeltaSetTriple<PrismContainerValue<ShadowAssociationType>> evaluate(ExpressionEvaluationContext context) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException {
String desc = context.getContextDescription();
Object orderOneObject = context.getVariables().get(ExpressionConstants.VAR_ORDER_ONE_OBJECT);
if (orderOneObject == null) {
throw new ExpressionEvaluationException("No order one object variable in " + desc + "; the expression may be used in a wrong place. It is only supposed to work in a role.");
}
if (!(orderOneObject instanceof AbstractRoleType)) {
throw new ExpressionEvaluationException("Order one object variable in " + desc + " is not a role, it is " + orderOneObject.getClass().getName() + "; the expression may be used in a wrong place. It is only supposed to work in a role.");
}
AbstractRoleType thisRole = (AbstractRoleType) orderOneObject;
LOGGER.trace("Evaluating association from link on: {}", thisRole);
RefinedObjectClassDefinition rAssocTargetDef = (RefinedObjectClassDefinition) context.getVariables().get(ExpressionConstants.VAR_ASSOCIATION_TARGET_OBJECT_CLASS_DEFINITION);
if (rAssocTargetDef == null) {
throw new ExpressionEvaluationException("No association target object class definition variable in " + desc + "; the expression may be used in a wrong place. It is only supposed to create an association.");
}
ShadowDiscriminatorType projectionDiscriminator = evaluatorType.getProjectionDiscriminator();
if (projectionDiscriminator == null) {
throw new ExpressionEvaluationException("No projectionDiscriminator in " + desc);
}
ShadowKindType kind = projectionDiscriminator.getKind();
if (kind == null) {
throw new ExpressionEvaluationException("No kind in projectionDiscriminator in " + desc);
}
String intent = projectionDiscriminator.getIntent();
PrismContainer<ShadowAssociationType> output = outputDefinition.instantiate();
QName assocName = context.getMappingQName();
String resourceOid = rAssocTargetDef.getResourceType().getOid();
Collection<SelectorOptions<GetOperationOptions>> options = null;
// Always process the first role (myself) regardless of recursion setting
gatherAssociationsFromAbstractRole(thisRole, output, resourceOid, kind, intent, assocName, options, desc, context);
if (thisRole instanceof OrgType && matchesForRecursion((OrgType) thisRole)) {
gatherAssociationsFromAbstractRoleRecurse((OrgType) thisRole, output, resourceOid, kind, intent, assocName, options, desc, context);
}
return ItemDelta.toDeltaSetTriple(output, null);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowDiscriminatorType in project midpoint by Evolveum.
the class AssociationFromLinkExpressionEvaluator method evaluate.
@Override
public PrismValueDeltaSetTriple<PrismContainerValue<ShadowAssociationType>> evaluate(ExpressionEvaluationContext context, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException {
checkEvaluatorProfile(context);
String desc = context.getContextDescription();
AbstractRoleType thisRole = getRelevantRole(context);
LOGGER.trace("Evaluating association from link {} on: {}", expressionEvaluatorBean.getDescription(), thisRole);
// noinspection unchecked
TypedValue<ResourceObjectDefinition> rAssocTargetDefTypedValue = context.getVariables().get(ExpressionConstants.VAR_ASSOCIATION_TARGET_OBJECT_CLASS_DEFINITION);
if (rAssocTargetDefTypedValue == null || rAssocTargetDefTypedValue.getValue() == null) {
throw new ExpressionEvaluationException("No association target object class definition variable in " + desc + "; the expression may be used in a wrong place. It is only supposed to create an association.");
}
ResourceObjectDefinition associationTargetDef = (ResourceObjectDefinition) rAssocTargetDefTypedValue.getValue();
ShadowDiscriminatorType projectionDiscriminator = expressionEvaluatorBean.getProjectionDiscriminator();
if (projectionDiscriminator == null) {
throw new ExpressionEvaluationException("No projectionDiscriminator in " + desc);
}
ShadowKindType kind = projectionDiscriminator.getKind();
if (kind == null) {
throw new ExpressionEvaluationException("No kind in projectionDiscriminator in " + desc);
}
String intent = projectionDiscriminator.getIntent();
PrismContainer<ShadowAssociationType> output = outputDefinition.instantiate();
QName assocName = context.getMappingQName();
String resourceOid = associationTargetDef.getResourceOid();
List<String> candidateShadowOidList = new ArrayList<>();
// Always process the first role (myself) regardless of recursion setting
gatherCandidateShadowsFromAbstractRole(thisRole, candidateShadowOidList);
if (thisRole instanceof OrgType && matchesForRecursion((OrgType) thisRole)) {
gatherCandidateShadowsFromAbstractRoleRecurse((OrgType) thisRole, candidateShadowOidList, null, desc, context, result);
}
LOGGER.trace("Candidate shadow OIDs: {}", candidateShadowOidList);
selectMatchingShadows(candidateShadowOidList, output, resourceOid, kind, intent, assocName, context, result);
return ItemDeltaUtil.toDeltaSetTriple(output, null, prismContext);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowDiscriminatorType in project midpoint by Evolveum.
the class ResourceShadowDiscriminator method fromResourceShadowDiscriminatorType.
public static ResourceShadowDiscriminator fromResourceShadowDiscriminatorType(ShadowDiscriminatorType bean, boolean provideDefaultIntent) {
if (bean == null) {
return null;
}
// For compatibility. Otherwise the kind should be explicitly serialized.
ShadowKindType kind = ObjectUtils.defaultIfNull(bean.getKind(), ShadowKindType.ACCOUNT);
String intent = bean.getIntent() != null || !provideDefaultIntent ? bean.getIntent() : SchemaConstants.INTENT_DEFAULT;
ResourceShadowDiscriminator rsd = new ResourceShadowDiscriminator(bean.getResourceRef() != null ? bean.getResourceRef().getOid() : null, kind, intent, bean.getTag(), BooleanUtils.isTrue(bean.isTombstone()));
rsd.setObjectClass(bean.getObjectClassName());
if (bean.getDiscriminatorOrder() != null) {
rsd.setOrder(bean.getDiscriminatorOrder());
}
return rsd;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowDiscriminatorType in project midpoint by Evolveum.
the class ResourceShadowDiscriminator method toResourceShadowDiscriminatorType.
public ShadowDiscriminatorType toResourceShadowDiscriminatorType() {
ShadowDiscriminatorType bean = new ShadowDiscriminatorType();
bean.setIntent(intent);
bean.setKind(kind);
bean.setTag(tag);
ObjectReferenceType resourceRef = new ObjectReferenceType();
resourceRef.setOid(resourceOid);
resourceRef.setType(ResourceType.COMPLEX_TYPE);
bean.setResourceRef(resourceRef);
bean.setObjectClassName(objectClass);
bean.setTombstone(gone);
bean.setDiscriminatorOrder(order);
return bean;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowDiscriminatorType in project midpoint by Evolveum.
the class ObjectMerger method projectionMatches.
private boolean projectionMatches(ShadowType candidateProjection, List<ShadowType> projectionsLeft, List<ShadowType> projectionsRight, ProjectionMergeConfigurationType projectionMergeConfig) {
ShadowDiscriminatorType discriminatorType = projectionMergeConfig.getProjectionDiscriminator();
if (discriminatorType != null && !ShadowUtil.matchesPattern(candidateProjection, discriminatorType)) {
return false;
}
ProjectionMergeSituationType situationPattern = projectionMergeConfig.getSituation();
if (situationPattern != null) {
ProjectionMergeSituationType projectionSituation = determineSituation(candidateProjection, projectionsLeft, projectionsRight);
return situationPattern == projectionSituation;
} else {
return true;
}
}
Aggregations