Search in sources :

Example 1 with ShadowDiscriminatorType

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);
}
Also used : ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) QName(javax.xml.namespace.QName) RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) AbstractRoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType) ShadowAssociationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType) ShadowDiscriminatorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowDiscriminatorType)

Example 2 with ShadowDiscriminatorType

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);
}
Also used : QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) ResourceObjectDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectDefinition) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) AbstractRoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType) ShadowAssociationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType) ShadowDiscriminatorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowDiscriminatorType)

Example 3 with ShadowDiscriminatorType

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;
}
Also used : ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)

Example 4 with ShadowDiscriminatorType

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;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ShadowDiscriminatorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowDiscriminatorType)

Example 5 with ShadowDiscriminatorType

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;
    }
}
Also used : ProjectionMergeSituationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ProjectionMergeSituationType) ShadowDiscriminatorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowDiscriminatorType)

Aggregations

ShadowDiscriminatorType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowDiscriminatorType)4 ShadowKindType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)3 AbstractRoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType)2 OrgType (com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)2 ShadowAssociationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType)2 QName (javax.xml.namespace.QName)2 RefinedObjectClassDefinition (com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition)1 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)1 ResourceObjectDefinition (com.evolveum.midpoint.schema.processor.ResourceObjectDefinition)1 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)1 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)1 ProjectionMergeSituationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ProjectionMergeSituationType)1 ArrayList (java.util.ArrayList)1