Search in sources :

Example 6 with PrismReferenceValue

use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.

the class AssignmentProcessor method addReferences.

private void addReferences(Collection<PrismReferenceValue> extractedReferences, Collection<PrismReferenceValue> references) {
    for (PrismReferenceValue reference : references) {
        boolean found = false;
        for (PrismReferenceValue exVal : extractedReferences) {
            if (exVal.getOid().equals(reference.getOid()) && ObjectTypeUtil.relationsEquivalent(exVal.getRelation(), reference.getRelation())) {
                found = true;
                break;
            }
        }
        if (!found) {
            // using copyObject=false instead of calling canonicalize()
            PrismReferenceValue ref = reference.clone(false);
            if (ref.getRelation() != null && QNameUtil.isUnqualified(ref.getRelation())) {
                ref.setRelation(new QName(SchemaConstants.NS_ORG, ref.getRelation().getLocalPart(), SchemaConstants.PREFIX_NS_ORG));
            }
            extractedReferences.add(ref);
        }
    }
}
Also used : PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) QName(javax.xml.namespace.QName)

Example 7 with PrismReferenceValue

use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.

the class RoleMemberPanel method createReferenceValuesList.

private List<PrismReferenceValue> createReferenceValuesList() {
    List<PrismReferenceValue> referenceValuesList = new ArrayList<>();
    if (relations != null && relations.size() > 0) {
        for (RelationTypes relation : relations) {
            PrismReferenceValue rv = new PrismReferenceValue(getModelObject().getOid());
            rv.setRelation(relation.getRelation());
            referenceValuesList.add(rv);
        }
    } else {
        PrismReferenceValue rv = new PrismReferenceValue(getModelObject().getOid());
        referenceValuesList.add(rv);
    }
    return referenceValuesList;
}
Also used : RelationTypes(com.evolveum.midpoint.web.component.assignment.RelationTypes) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ArrayList(java.util.ArrayList)

Example 8 with PrismReferenceValue

use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.

the class PrismAsserts method assertHasTargetName.

public static void assertHasTargetName(PrismContainerValue<?> pcv, ItemPath path) {
    for (PrismValue value : getValues(pcv, path)) {
        PrismReferenceValue prv = (PrismReferenceValue) value;
        assertHasTargetName(prv);
    }
}
Also used : PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) PrismValue(com.evolveum.midpoint.prism.PrismValue)

Example 9 with PrismReferenceValue

use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.

the class PrismAsserts method assertHasNoTargetName.

public static void assertHasNoTargetName(PrismContainerValue<?> pcv, ItemPath path) {
    for (PrismValue value : getValues(pcv, path)) {
        PrismReferenceValue prv = (PrismReferenceValue) value;
        assertHasNoTargetName(prv);
    }
}
Also used : PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) PrismValue(com.evolveum.midpoint.prism.PrismValue)

Example 10 with PrismReferenceValue

use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.

the class TestAssignmentProcessor2 method test050JackDeputyOfBarbossa.

/**
	 *                MMR1 -----------I------------------------------*
	 *                 ^                                             |
	 *                 |                                             I
	 *                 |                                             V
	 *                MR1 -----------I-------------*-----> MR3      MR4
	 *                 ^        MR2 --I---*        |        |        |
	 *                 |         ^        I        I        I        I
	 *                 |         |        V        V        V        V
	 *                 R1 --I--> R2       O3       R4       R5       R6
	 *                 ^
	 *                 |
	 *                 |
	 *  jack --D--> barbossa
	 *
	 *  (D = deputy assignment)
	 *
	 */
@Test(enabled = FIRST_PART)
public void test050JackDeputyOfBarbossa() throws Exception {
    final String TEST_NAME = "test050JackDeputyOfBarbossa";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestAssignmentProcessor.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    AssignmentType policyRuleAssignment = new AssignmentType(prismContext);
    PolicyRuleType rule = new PolicyRuleType(prismContext);
    rule.setName("barbossa-0");
    policyRuleAssignment.setPolicyRule(rule);
    @SuppressWarnings({ "unchecked", "raw" }) ObjectDelta<ObjectType> objectDelta = (ObjectDelta<ObjectType>) DeltaBuilder.deltaFor(UserType.class, prismContext).item(UserType.F_ASSIGNMENT).add(ObjectTypeUtil.createAssignmentTo(ROLE_R1_OID, ObjectTypes.ROLE, prismContext), policyRuleAssignment).asObjectDelta(USER_BARBOSSA_OID);
    executeChangesAssertSuccess(objectDelta, null, task, result);
    display("barbossa", getUser(USER_BARBOSSA_OID));
    objects.add(getUser(USER_BARBOSSA_OID).asObjectable());
    LensContext<UserType> context = createContextForAssignment(UserType.class, USER_JACK_OID, UserType.class, USER_BARBOSSA_OID, SchemaConstants.ORG_DEPUTY, null, result);
    // WHEN
    assignmentProcessor.processAssignmentsProjections(context, clock.currentTimeXMLGregorianCalendar(), task, result);
    // THEN
    display("Output context", context);
    display("Evaluated assignment triple", context.getEvaluatedAssignmentTriple());
    result.computeStatus();
    assertSuccess("Assignment processor failed (result)", result);
    Collection<EvaluatedAssignmentImpl<UserType>> evaluatedAssignments = assertAssignmentTripleSetSize(context, 0, 1, 0);
    EvaluatedAssignmentImpl<UserType> evaluatedAssignment = evaluatedAssignments.iterator().next();
    assertEquals("Wrong evaluatedAssignment.isValid", true, evaluatedAssignment.isValid());
    assertTargets(evaluatedAssignment, true, "R1 R2 O3 R4 R5 R6", null, null, null, null, null);
    assertTargets(evaluatedAssignment, false, "barbossa MR1 MR2 MR3 MR4 MMR1", null, null, null, null, null);
    assertMembershipRef(evaluatedAssignment, "");
    assertOrgRef(evaluatedAssignment, "O3");
    assertDelegation(evaluatedAssignment, "barbossa R1 R2 O3 R4 R5 R6");
    PrismReferenceValue barbossaRef = evaluatedAssignment.getDelegationRefVals().stream().filter(v -> USER_BARBOSSA_OID.equals(v.getOid())).findFirst().orElseThrow(() -> new AssertionError("No barbossa ref in delegation ref vals"));
    assertEquals("Wrong relation for barbossa delegation", SchemaConstants.ORG_DEPUTY, barbossaRef.getRelation());
    // Constructions are named "role-level". We expect e.g. that from R1 we get a construction induced with order=1 (R1-1).
    String expectedItems = "R1-1 R2-1 O3-1 R4-1 R5-1 R6-1 MR1-2 MR2-2 MR3-2 MR4-2 MMR1-3";
    assertConstructions(evaluatedAssignment, "Brethren_account_construction Undead_monkey_account_construction " + expectedItems, null, null, null, null, null);
    assertFocusMappings(evaluatedAssignment, expectedItems);
    assertFocusPolicyRules(evaluatedAssignment, "barbossa-0 " + expectedItems);
    // Rules for other targets are empty, which is very probably OK. All rules are bound to target "barbossa".
    // There is no alternative target, as barbossa does not induce anything.
    assertTargetPolicyRules(evaluatedAssignment, "barbossa-0 R1-1 R2-1 MR2-2 O3-1 MR1-2 MR3-2 R5-1 R4-1 MMR1-3 MR4-2 R6-1", "");
    assertAuthorizations(evaluatedAssignment, "R1 R2 O3 R4 R5 R6");
    assertGuiConfig(evaluatedAssignment, "R1 R2 O3 R4 R5 R6");
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) Test(org.testng.annotations.Test)

Aggregations

PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)126 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)64 Test (org.testng.annotations.Test)47 Task (com.evolveum.midpoint.task.api.Task)45 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)32 ReferenceDelta (com.evolveum.midpoint.prism.delta.ReferenceDelta)27 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)26 PrismObject (com.evolveum.midpoint.prism.PrismObject)25 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)25 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)24 ArrayList (java.util.ArrayList)22 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)21 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)20 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)16 PrismReference (com.evolveum.midpoint.prism.PrismReference)15 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)15 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)15 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)12 Collection (java.util.Collection)12 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)11