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);
}
}
}
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);
}
}
}
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);
}
Aggregations