Search in sources :

Example 6 with AbstractRoleType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType in project midpoint by Evolveum.

the class AssociationFromLinkExpressionEvaluator method getLegacyRole.

@NotNull
private AbstractRoleType getLegacyRole(ExpressionEvaluationContext context) throws ExpressionEvaluationException {
    @SuppressWarnings("unchecked") TypedValue<AbstractRoleType> orderOneObjectTypedValue = context.getVariables().get(ExpressionConstants.VAR_THIS_OBJECT);
    if (orderOneObjectTypedValue == null || orderOneObjectTypedValue.getValue() == null) {
        throw new ExpressionEvaluationException("No order one object variable in " + context.getContextDescription() + "; the expression may be used in a wrong place. It is only supposed to work in a role.");
    }
    Object orderOneObject = orderOneObjectTypedValue.getValue();
    if (orderOneObject instanceof AbstractRoleType) {
        return (AbstractRoleType) orderOneObject;
    } else {
        throw new ExpressionEvaluationException("Order one object variable in " + context.getContextDescription() + " 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.");
    }
}
Also used : AbstractRoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType) PrismObject(com.evolveum.midpoint.prism.PrismObject) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with AbstractRoleType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType 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 8 with AbstractRoleType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType in project midpoint by Evolveum.

the class LifecycleUtil method getForcedAssignmentSpecification.

public static <R extends AbstractRoleType> VirtualAssignmenetSpecification<R> getForcedAssignmentSpecification(LifecycleStateModelType lifecycleStateModel, String targetLifecycleState, PrismContext prismContext) throws SchemaException {
    LifecycleStateType stateDefinition = findStateDefinition(lifecycleStateModel, targetLifecycleState);
    if (stateDefinition == null) {
        return null;
    }
    VirtualAssignmentSpecificationType virtualAssignmentSpecificationType = stateDefinition.getForcedAssignment();
    if (virtualAssignmentSpecificationType == null) {
        return null;
    }
    SearchFilterType filter = virtualAssignmentSpecificationType.getFilter();
    if (filter == null) {
        return null;
    }
    QName targetType = virtualAssignmentSpecificationType.getTargetType();
    Class<R> targetClass = (Class<R>) AbstractRoleType.class;
    if (targetType != null) {
        targetClass = (Class<R>) prismContext.getSchemaRegistry().getCompileTimeClassForObjectType(targetType);
    }
    VirtualAssignmenetSpecification<R> virtualAssignmenetSpecification = new VirtualAssignmenetSpecification();
    virtualAssignmenetSpecification.setType(targetClass);
    ObjectFilter objectFilter = prismContext.getQueryConverter().parseFilter(filter, targetClass);
    virtualAssignmenetSpecification.setFilter(objectFilter);
    return virtualAssignmenetSpecification;
}
Also used : LifecycleStateType(com.evolveum.midpoint.xml.ns._public.common.common_3.LifecycleStateType) VirtualAssignmentSpecificationType(com.evolveum.midpoint.xml.ns._public.common.common_3.VirtualAssignmentSpecificationType) SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) QName(javax.xml.namespace.QName) VirtualAssignmenetSpecification(com.evolveum.midpoint.schema.VirtualAssignmenetSpecification) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter)

Example 9 with AbstractRoleType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType in project midpoint by Evolveum.

the class RAbstractRole method copyFromJAXB.

public static <T extends AbstractRoleType> void copyFromJAXB(AbstractRoleType jaxb, RAbstractRole<T> repo, RepositoryContext repositoryContext, IdGeneratorResult generatorResult) throws DtoTranslationException {
    RFocus.copyFromJAXB(jaxb, repo, repositoryContext, generatorResult);
    repo.setRequestable(jaxb.isRequestable());
    repo.setDisplayName(RPolyString.copyFromJAXB(jaxb.getDisplayName()));
    repo.setIdentifier(jaxb.getIdentifier());
    repo.setRiskLevel(jaxb.getRiskLevel());
    for (AssignmentType inducement : jaxb.getInducement()) {
        RAssignment rInducement = new RAssignment(repo, RAssignmentOwner.ABSTRACT_ROLE);
        RAssignment.copyFromJAXB(inducement, rInducement, jaxb, repositoryContext, generatorResult);
        repo.getAssignments().add(rInducement);
    }
    for (ExclusionPolicyConstraintType exclusion : jaxb.getExclusion()) {
        RExclusion rExclusion = new RExclusion(repo);
        RExclusion.copyFromJAXB(exclusion, rExclusion, jaxb, repositoryContext, generatorResult);
        repo.getExclusion().add(rExclusion);
    }
    for (ObjectReferenceType approverRef : jaxb.getApproverRef()) {
        RObjectReference ref = RUtil.jaxbRefToRepo(approverRef, repositoryContext.prismContext, repo, RReferenceOwner.ROLE_APPROVER);
        if (ref != null) {
            repo.getApproverRef().add(ref);
        }
    }
    //PrismObjectDefinition<AbstractRoleType> roleDefinition = jaxb.asPrismObject().getDefinition();
    repo.setApprovalProcess(jaxb.getApprovalProcess());
    repo.setOwnerRef(RUtil.jaxbRefToEmbeddedRepoRef(jaxb.getOwnerRef(), repositoryContext.prismContext));
}
Also used : RAssignment(com.evolveum.midpoint.repo.sql.data.common.container.RAssignment) ExclusionPolicyConstraintType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExclusionPolicyConstraintType) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) RExclusion(com.evolveum.midpoint.repo.sql.data.common.container.RExclusion)

Example 10 with AbstractRoleType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType in project midpoint by Evolveum.

the class AutoAssignMappingCollector method collectAutoassignMappings.

<AH extends AssignmentHolderType> void collectAutoassignMappings(LensContext<AH> context, List<FocalMappingEvaluationRequest<?, ?>> mappings, OperationResult result) throws SchemaException {
    if (!autoassignEnabled(context.getSystemConfiguration())) {
        return;
    }
    ObjectQuery query = prismContext.queryFor(AbstractRoleType.class).item(SchemaConstants.PATH_AUTOASSIGN_ENABLED).eq(true).build();
    ResultHandler<AbstractRoleType> handler = (role, objectResult) -> {
        AutoassignSpecificationType autoassign = role.asObjectable().getAutoassign();
        if (autoassign == null) {
            return true;
        }
        if (!isTrue(autoassign.isEnabled())) {
            return true;
        }
        FocalAutoassignSpecificationType focalAutoassignSpec = autoassign.getFocus();
        if (focalAutoassignSpec == null) {
            return true;
        }
        if (!isApplicableFor(focalAutoassignSpec.getSelector(), context.getFocusContext(), objectResult)) {
            return true;
        }
        for (AutoassignMappingType autoMapping : focalAutoassignSpec.getMapping()) {
            AutoassignMappingType mapping = LensUtil.setMappingTarget(autoMapping, new ItemPathType(SchemaConstants.PATH_ASSIGNMENT));
            mappings.add(new AutoassignRoleMappingEvaluationRequest(mapping, role.asObjectable()));
            LOGGER.trace("Collected autoassign mapping {} from {}", mapping.getName(), role);
        }
        return true;
    };
    cacheRepositoryService.searchObjectsIterative(AbstractRoleType.class, query, handler, createReadOnlyCollection(), true, result);
}
Also used : ResultHandler(com.evolveum.midpoint.schema.ResultHandler) GetOperationOptions.createReadOnlyCollection(com.evolveum.midpoint.schema.GetOperationOptions.createReadOnlyCollection) LensUtil(com.evolveum.midpoint.model.impl.lens.LensUtil) AutoassignRoleMappingEvaluationRequest(com.evolveum.midpoint.model.impl.lens.projector.mappings.AutoassignRoleMappingEvaluationRequest) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Autowired(org.springframework.beans.factory.annotation.Autowired) Trace(com.evolveum.midpoint.util.logging.Trace) PrismObject(com.evolveum.midpoint.prism.PrismObject) com.evolveum.midpoint.util.exception(com.evolveum.midpoint.util.exception) BooleanUtils.isTrue(org.apache.commons.lang.BooleanUtils.isTrue) Component(org.springframework.stereotype.Component) List(java.util.List) LensContext(com.evolveum.midpoint.model.impl.lens.LensContext) FocalMappingEvaluationRequest(com.evolveum.midpoint.model.impl.lens.projector.mappings.FocalMappingEvaluationRequest) PrismContext(com.evolveum.midpoint.prism.PrismContext) LensFocusContext(com.evolveum.midpoint.model.impl.lens.LensFocusContext) Qualifier(org.springframework.beans.factory.annotation.Qualifier) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) AutoassignRoleMappingEvaluationRequest(com.evolveum.midpoint.model.impl.lens.projector.mappings.AutoassignRoleMappingEvaluationRequest)

Aggregations

AbstractRoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType)7 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)3 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)3 ShadowAssociationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType)3 QName (javax.xml.namespace.QName)3 RAssignment (com.evolveum.midpoint.repo.sql.data.common.container.RAssignment)2 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)2 OrgType (com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)2 ShadowDiscriminatorType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowDiscriminatorType)2 ShadowKindType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)2 RefinedObjectClassDefinition (com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition)1 CheckBoxPanel (com.evolveum.midpoint.gui.api.component.form.CheckBoxPanel)1 WrapperContext (com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext)1 AssignmentPathSegment (com.evolveum.midpoint.model.api.context.AssignmentPathSegment)1 LensContext (com.evolveum.midpoint.model.impl.lens.LensContext)1 LensFocusContext (com.evolveum.midpoint.model.impl.lens.LensFocusContext)1 LensUtil (com.evolveum.midpoint.model.impl.lens.LensUtil)1 AutoassignRoleMappingEvaluationRequest (com.evolveum.midpoint.model.impl.lens.projector.mappings.AutoassignRoleMappingEvaluationRequest)1 FocalMappingEvaluationRequest (com.evolveum.midpoint.model.impl.lens.projector.mappings.FocalMappingEvaluationRequest)1