Search in sources :

Example 1 with AssignmentValueWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.AssignmentValueWrapper in project midpoint by Evolveum.

the class DirectAndIndirectAssignmentPanel method collectResources.

private void collectResources(EvaluatedAssignment<?> evaluatedAssignment, IModel<PrismContainerWrapper<AssignmentType>> parent, Set<AssignmentValueWrapper> assignmentValueWrapperSet, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException {
    DeltaSetTriple<EvaluatedResourceObjectConstruction> evaluatedConstructionsTriple = evaluatedAssignment.getEvaluatedConstructions(task, result);
    Collection<EvaluatedResourceObjectConstruction> evaluatedConstructions = evaluatedConstructionsTriple.getNonNegativeValues();
    for (EvaluatedResourceObjectConstruction construction : evaluatedConstructions) {
        if (!construction.isWeak()) {
            PrismContainerDefinition<AssignmentType> assignmentDef = getPrismContext().getSchemaRegistry().findContainerDefinitionByCompileTimeClass(AssignmentType.class);
            AssignmentType assignmentType = assignmentDef.instantiate().createNewValue().asContainerable();
            ObjectReferenceType targetRef = new ObjectReferenceType();
            targetRef.setOid(construction.getResource().getOid());
            targetRef.setType(ResourceType.COMPLEX_TYPE);
            targetRef.setTargetName(new PolyStringType(construction.getResource().getName()));
            assignmentType.setTargetRef(targetRef);
            ConstructionType constructionType = new ConstructionType();
            constructionType.setResourceRef(targetRef);
            constructionType.setKind(construction.getKind());
            constructionType.setIntent(construction.getIntent());
            assignmentType.setConstruction(constructionType);
            assignmentType.setDescription(construction.getResource().asObjectable().getDescription());
            ValueStatus status = evaluatedAssignment.getAssignment(true) == null ? ValueStatus.ADDED : ValueStatus.NOT_CHANGED;
            AssignmentValueWrapper assignmentValueWrapper = WebPrismUtil.createNewValueWrapper(parent.getObject(), assignmentType.asPrismContainerValue(), status, getPageBase());
            assignmentValueWrapper.setDirectAssignment(construction.isDirectlyAssigned());
            assignmentValueWrapper.setAssignmentParent(construction.getAssignmentPath());
            assignmentValueWrapperSet.add(assignmentValueWrapper);
        }
    }
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) AssignmentValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.AssignmentValueWrapper) EvaluatedResourceObjectConstruction(com.evolveum.midpoint.model.api.context.EvaluatedResourceObjectConstruction) ValueStatus(com.evolveum.midpoint.web.component.prism.ValueStatus)

Example 2 with AssignmentValueWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.AssignmentValueWrapper in project midpoint by Evolveum.

the class DirectAndIndirectAssignmentPanel method collectRoleAndOrgs.

private void collectRoleAndOrgs(EvaluatedAssignment<?> evaluatedAssignment, IModel<PrismContainerWrapper<AssignmentType>> parent, Set<AssignmentValueWrapper> assignmentValueWrapperSet) throws SchemaException {
    DeltaSetTriple<? extends EvaluatedAssignmentTarget> targetsTriple = evaluatedAssignment.getRoles();
    Collection<? extends EvaluatedAssignmentTarget> targets = targetsTriple.getNonNegativeValues();
    for (EvaluatedAssignmentTarget target : targets) {
        target.getTarget();
        if (ArchetypeType.class.equals(target.getTarget().getCompileTimeClass())) {
            continue;
        }
        if (target.appliesToFocusWithAnyRelation(getPageBase().getRelationRegistry())) {
            AssignmentType assignmentType = target.getAssignment().clone();
            assignmentType.setDescription(target.getTarget().asObjectable().getDescription());
            assignmentType.getTargetRef().setOid(target.getTarget().getOid());
            assignmentType.getTargetRef().setTargetName(new PolyStringType(target.getTarget().getName()));
            assignmentType.getTargetRef().setType(target.getTarget().getComplexTypeDefinition().getTypeName());
            ValueStatus status = evaluatedAssignment.getAssignment(true) == null ? ValueStatus.ADDED : ValueStatus.NOT_CHANGED;
            AssignmentValueWrapper assignmentValueWrapper = WebPrismUtil.createNewValueWrapper(parent.getObject(), assignmentType.asPrismContainerValue(), status, getPageBase());
            assignmentValueWrapper.setDirectAssignment(target.isDirectlyAssigned());
            assignmentValueWrapper.setAssignmentParent(target.getAssignmentPath());
            assignmentValueWrapperSet.add(assignmentValueWrapper);
        }
    }
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) EvaluatedAssignmentTarget(com.evolveum.midpoint.model.api.context.EvaluatedAssignmentTarget) AssignmentValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.AssignmentValueWrapper) ValueStatus(com.evolveum.midpoint.web.component.prism.ValueStatus)

Example 3 with AssignmentValueWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.AssignmentValueWrapper in project midpoint by Evolveum.

the class DirectAndIndirectAssignmentPanel method loadEvaluatedAssignments.

private List<PrismContainerValueWrapper<AssignmentType>> loadEvaluatedAssignments(IModel<PrismContainerWrapper<AssignmentType>> parent) throws SchemaException, ExpressionEvaluationException, CommunicationException, SecurityViolationException, ConfigurationException, ObjectNotFoundException, PolicyViolationException, ObjectAlreadyExistsException {
    if (!(getPageBase() instanceof PageAssignmentHolderDetails)) {
        return parent.getObject().getValues();
    }
    Task task = getPageBase().createSimpleTask(OPERATION_RECOMPUTE_ASSIGNMENTS);
    OperationResult result = new OperationResult(OPERATION_RECOMPUTE_ASSIGNMENTS);
    Set<AssignmentValueWrapper> assignmentValueWrapperSet = new LinkedHashSet<>();
    ObjectDelta<AH> delta = getObjectDelta(result);
    ModelContext<AH> modelContext = getPageBase().getModelInteractionService().previewChanges(Collections.singleton(delta), createPreviewAssignmentsOptions(), task, result);
    Collection<? extends EvaluatedAssignment<?>> evaluatedAssignments = modelContext.getNonNegativeEvaluatedAssignments();
    for (EvaluatedAssignment<?> evaluatedAssignment : evaluatedAssignments) {
        if (!evaluatedAssignment.isValid()) {
            continue;
        }
        collectRoleAndOrgs(evaluatedAssignment, parent, assignmentValueWrapperSet);
        collectResources(evaluatedAssignment, parent, assignmentValueWrapperSet, task, result);
    }
    return new ArrayList<>(assignmentValueWrapperSet);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) AssignmentValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.AssignmentValueWrapper) PageAssignmentHolderDetails(com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.PageAssignmentHolderDetails) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Aggregations

AssignmentValueWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.AssignmentValueWrapper)3 ValueStatus (com.evolveum.midpoint.web.component.prism.ValueStatus)2 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)2 PageAssignmentHolderDetails (com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.PageAssignmentHolderDetails)1 EvaluatedAssignmentTarget (com.evolveum.midpoint.model.api.context.EvaluatedAssignmentTarget)1 EvaluatedResourceObjectConstruction (com.evolveum.midpoint.model.api.context.EvaluatedResourceObjectConstruction)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1