Search in sources :

Example 21 with AssignmentType

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);
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ConstructionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType)

Example 22 with AssignmentType

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);
    }
}
Also used : PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)

Example 23 with AssignmentType

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);
}
Also used : RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 24 with AssignmentType

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);
}
Also used : RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) Test(org.testng.annotations.Test)

Example 25 with AssignmentType

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);
}
Also used : PolicyRuleType(com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyRuleType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)

Aggregations

AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)115 Test (org.testng.annotations.Test)55 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)53 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)47 Task (com.evolveum.midpoint.task.api.Task)44 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)41 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)23 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)16 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)16 RoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)16 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)15 ItemDeltaItem (com.evolveum.midpoint.repo.common.expression.ItemDeltaItem)14 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)14 ObjectDeltaObject (com.evolveum.midpoint.repo.common.expression.ObjectDeltaObject)13 ArrayList (java.util.ArrayList)13 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)12 ConstructionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType)12 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)12 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)10 ActivationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)10