Search in sources :

Example 1 with FocalMappingEvaluationRequest

use of com.evolveum.midpoint.model.impl.lens.projector.mappings.FocalMappingEvaluationRequest 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

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 PrismContext (com.evolveum.midpoint.prism.PrismContext)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 RepositoryService (com.evolveum.midpoint.repo.api.RepositoryService)1 GetOperationOptions.createReadOnlyCollection (com.evolveum.midpoint.schema.GetOperationOptions.createReadOnlyCollection)1 ResultHandler (com.evolveum.midpoint.schema.ResultHandler)1 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 com.evolveum.midpoint.util.exception (com.evolveum.midpoint.util.exception)1 Trace (com.evolveum.midpoint.util.logging.Trace)1 TraceManager (com.evolveum.midpoint.util.logging.TraceManager)1 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)1 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)1 List (java.util.List)1 BooleanUtils.isTrue (org.apache.commons.lang.BooleanUtils.isTrue)1