use of com.evolveum.midpoint.model.api.context.EvaluatedResourceObjectConstruction 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.model.api.context.EvaluatedResourceObjectConstruction in project midpoint by Evolveum.
the class TestRbac method test763PreviewChanges.
/**
* MID-2850, MID-4119
*/
@Test
public void test763PreviewChanges() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
PrismObject<UserType> userBefore = getUser(USER_JACK_OID);
display("User jack before", userBefore);
assertAssignedRole(userBefore, ROLE_WEAK_GOSSIPER_OID);
assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME);
ObjectDelta<UserType> delta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, USER_JACK_OID);
// WHEN
when();
ModelContext<ObjectType> context = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), null, task, result);
// THEN
then();
assertSuccess(result);
displayDumpable("Preview context", context);
assertNotNull("Null focus context", context.getFocusContext());
assertEquals("Wrong number of projection contexts", 1, context.getProjectionContexts().size());
DeltaSetTriple<? extends EvaluatedAssignment<?>> evaluatedAssignmentTriple = context.getEvaluatedAssignmentTriple();
assertNotNull("null evaluatedAssignmentTriple", evaluatedAssignmentTriple);
assertTrue("Unexpected plus set in evaluatedAssignmentTriple", evaluatedAssignmentTriple.getPlusSet().isEmpty());
assertTrue("Unexpected minus set in evaluatedAssignmentTriple", evaluatedAssignmentTriple.getMinusSet().isEmpty());
Collection<? extends EvaluatedAssignment<?>> assignmentZeroSet = evaluatedAssignmentTriple.getZeroSet();
assertNotNull("null zero set in evaluatedAssignmentTriple", assignmentZeroSet);
assertEquals("Wrong size of zero set in evaluatedAssignmentTriple", 1, assignmentZeroSet.size());
EvaluatedAssignment<?> evaluatedAssignment = assignmentZeroSet.iterator().next();
displayDumpable("Evaluated weak assignment", evaluatedAssignment);
DeltaSetTriple<EvaluatedResourceObjectConstruction> evaluatedConstructions = evaluatedAssignment.getEvaluatedConstructions(task, result);
assertTrue("Unexpected plus set in evaluatedConstructions", evaluatedConstructions.getPlusSet().isEmpty());
assertTrue("Unexpected minus set in evaluatedConstructions", evaluatedConstructions.getMinusSet().isEmpty());
Collection<EvaluatedResourceObjectConstruction> constructionsZeroSet = evaluatedConstructions.getZeroSet();
assertEquals("Wrong size of zero set in evaluatedConstructions", 1, constructionsZeroSet.size());
EvaluatedResourceObjectConstruction evaluatedConstruction = constructionsZeroSet.iterator().next();
displayDumpable("Evaluated weak evaluatedConstruction", evaluatedConstruction);
assertTrue("Construction not weak", evaluatedConstruction.isWeak());
PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
display("User jack after", userAfter);
assertAssignedRole(userAfter, ROLE_WEAK_GOSSIPER_OID);
assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME);
}
Aggregations