use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class AssignmentTablePanel method removeResourceFromAccConstruction.
/**
* remove this method after model is updated - it has to remove resource
* from accountConstruction
*/
@Deprecated
private void removeResourceFromAccConstruction(AssignmentType assignment) {
ConstructionType accConstruction = assignment.getConstruction();
if (accConstruction == null || accConstruction.getResource() == null) {
return;
}
ObjectReferenceType ref = new ObjectReferenceType();
ref.setOid(assignment.getConstruction().getResource().getOid());
ref.setType(ResourceType.COMPLEX_TYPE);
assignment.getConstruction().setResourceRef(ref);
assignment.getConstruction().setResource(null);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class AssignmentTablePanel method handleAssignmentsWhenAdd.
public void handleAssignmentsWhenAdd(PrismObject<T> object, PrismContainerDefinition assignmentDef, List<AssignmentType> objectAssignments) throws SchemaException {
List<AssignmentEditorDto> assignments = getAssignmentModel().getObject();
for (AssignmentEditorDto assDto : assignments) {
if (!UserDtoStatus.ADD.equals(assDto.getStatus())) {
warn(getString("AssignmentTablePanel.message.illegalAssignmentState", assDto.getStatus()));
continue;
}
AssignmentType assignment = new AssignmentType();
PrismContainerValue value = assDto.getNewValue(getPageBase().getPrismContext());
assignment.setupContainerValue(value);
value.applyDefinition(assignmentDef, false);
objectAssignments.add(assignment.clone());
// todo remove this block [lazyman] after model is updated - it has
// to remove resource from accountConstruction
removeResourceFromAccConstruction(assignment);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class TestSchemaDelta method testDeleteInducementActivationSameNullIdApplyToObject.
@Test
public void testDeleteInducementActivationSameNullIdApplyToObject() throws Exception {
final String TEST_NAME = "testDeleteInducementActivationSameNullIdApplyToObject";
displayTestTile(TEST_NAME);
// GIVEN
PrismObject<RoleType> role = PrismTestUtil.parseObject(ROLE_CONSTRUCTION_FILE);
//Delta
ActivationType activationType = new ActivationType();
activationType.setAdministrativeStatus(ActivationStatusType.ENABLED);
// No container ID
ObjectDelta<RoleType> roleDelta = ObjectDelta.createModificationDeleteContainer(RoleType.class, ROLE_CONSTRUCTION_OID, new ItemPath(new NameItemPathSegment(RoleType.F_INDUCEMENT), new IdItemPathSegment(ROLE_CONSTRUCTION_INDUCEMENT_ID), new NameItemPathSegment(AssignmentType.F_ACTIVATION)), getPrismContext(), activationType);
// WHEN
roleDelta.applyTo(role);
// THEN
System.out.println("Role after delta application:");
System.out.println(role.debugDump());
assertEquals("Wrong OID", ROLE_CONSTRUCTION_OID, role.getOid());
PrismAsserts.assertPropertyValue(role, UserType.F_NAME, PrismTestUtil.createPolyString("Construction"));
PrismContainer<AssignmentType> inducementContainer = role.findContainer(RoleType.F_INDUCEMENT);
assertNotNull("No inducement", inducementContainer);
assertEquals("Unexpected number of inducement values", 1, inducementContainer.size());
PrismContainerValue<AssignmentType> inducementValue = inducementContainer.getValues().iterator().next();
AssignmentType inducement = inducementValue.asContainerable();
ActivationType activation = inducement.getActivation();
// activation should be gone (the error is that it is empty and not gone)
assertNull("Activation is not gone", activation);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class TestSchemaDelta method testDeleteInducementValidIdEmptyValueApplyToObject.
@Test
public void testDeleteInducementValidIdEmptyValueApplyToObject() throws Exception {
final String TEST_NAME = "testDeleteInducementValidIdEmptyValueApplyToObject";
displayTestTile(TEST_NAME);
// GIVEN
PrismObject<RoleType> role = PrismTestUtil.parseObject(ROLE_CONSTRUCTION_FILE);
//Delta
AssignmentType inducement = new AssignmentType();
inducement.setId(ROLE_CONSTRUCTION_INDUCEMENT_ID);
ObjectDelta<RoleType> roleDelta = ObjectDelta.createModificationDeleteContainer(RoleType.class, ROLE_CONSTRUCTION_OID, RoleType.F_INDUCEMENT, getPrismContext(), inducement);
// WHEN
roleDelta.applyTo(role);
// THEN
System.out.println("Role after delta application:");
System.out.println(role.debugDump());
assertEquals("Wrong OID", ROLE_CONSTRUCTION_OID, role.getOid());
PrismAsserts.assertPropertyValue(role, UserType.F_NAME, PrismTestUtil.createPolyString("Construction"));
PrismContainer<AssignmentType> assignment = role.findContainer(RoleType.F_INDUCEMENT);
assertNull("Unexpected inducement", assignment);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.
the class TestParseMetarole method assertMetaroleJaxb.
private void assertMetaroleJaxb(RoleType roleType, boolean isObject) throws SchemaException {
assertEquals("Wrong name", PrismTestUtil.createPolyStringType("Generic Metarole"), roleType.getName());
boolean found = false;
for (AssignmentType inducement : roleType.getInducement()) {
if (inducement.getId() == 2L) {
found = true;
PolicyRuleType rule = inducement.getPolicyRule();
assertNotNull("No constraints", rule.getPolicyConstraints());
assertEquals("Wrong # of assignment constraints", 1, rule.getPolicyConstraints().getAssignment().size());
assertTrue("Wrong (not empty) assignment constraints", rule.getPolicyConstraints().getAssignment().get(0).asPrismContainerValue().isEmpty());
break;
}
}
assertTrue("Assignment number 2 was not found", found);
}
Aggregations