Search in sources :

Example 51 with LensProjectionContext

use of com.evolveum.midpoint.model.impl.lens.LensProjectionContext in project midpoint by Evolveum.

the class DependencyProcessor method createAnotherContext.

private <F extends ObjectType> LensProjectionContext createAnotherContext(LensContext<F> context, LensProjectionContext origProjectionContext, int determinedOrder) throws PolicyViolationException {
    ResourceShadowDiscriminator origDiscr = origProjectionContext.getResourceShadowDiscriminator();
    ResourceShadowDiscriminator discr = new ResourceShadowDiscriminator(origDiscr.getResourceOid(), origDiscr.getKind(), origDiscr.getIntent(), origDiscr.isThombstone());
    discr.setOrder(determinedOrder);
    LensProjectionContext otherCtx = createAnotherContext(context, origProjectionContext, discr);
    return otherCtx;
}
Also used : LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator)

Example 52 with LensProjectionContext

use of com.evolveum.midpoint.model.impl.lens.LensProjectionContext in project midpoint by Evolveum.

the class DependencyProcessor method sortProjectionsToWaves.

public <F extends ObjectType> void sortProjectionsToWaves(LensContext<F> context) throws PolicyViolationException {
    // Create a snapshot of the projection collection at the beginning of computation.
    // The collection may be changed during computation (projections may be added). We do not want to process
    // these added projections. They are already processed inside the computation.
    // This also avoids ConcurrentModificationException
    LensProjectionContext[] projectionArray = context.getProjectionContexts().toArray(new LensProjectionContext[0]);
    // Reset incomplete flag for those contexts that are not yet computed
    for (LensProjectionContext projectionContext : context.getProjectionContexts()) {
        if (projectionContext.getWave() < 0) {
            projectionContext.setWaveIncomplete(true);
        }
    }
    for (LensProjectionContext projectionContext : projectionArray) {
        determineProjectionWave(context, projectionContext, null, null);
        projectionContext.setWaveIncomplete(false);
    }
    if (LOGGER.isTraceEnabled()) {
        StringBuilder sb = new StringBuilder();
        for (LensProjectionContext projectionContext : context.getProjectionContexts()) {
            sb.append("\n");
            sb.append(projectionContext.getResourceShadowDiscriminator());
            sb.append(": ");
            sb.append(projectionContext.getWave());
        }
        LOGGER.trace("Projections sorted to waves (projection wave {}, execution wave {}):{}", new Object[] { context.getProjectionWave(), context.getExecutionWave(), sb.toString() });
    }
}
Also used : LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext)

Example 53 with LensProjectionContext

use of com.evolveum.midpoint.model.impl.lens.LensProjectionContext in project midpoint by Evolveum.

the class AssignmentProcessor method removeIgnoredContexts.

public <F extends ObjectType> void removeIgnoredContexts(LensContext<F> context) {
    Collection<LensProjectionContext> projectionContexts = context.getProjectionContexts();
    Iterator<LensProjectionContext> projectionIterator = projectionContexts.iterator();
    while (projectionIterator.hasNext()) {
        LensProjectionContext projectionContext = projectionIterator.next();
        if (projectionContext.getSynchronizationPolicyDecision() == SynchronizationPolicyDecision.IGNORE) {
            projectionIterator.remove();
        }
    }
}
Also used : LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext)

Example 54 with LensProjectionContext

use of com.evolveum.midpoint.model.impl.lens.LensProjectionContext in project midpoint by Evolveum.

the class AssignmentProcessor method propagateLegalDecisionToHigherOrders.

private <F extends ObjectType> void propagateLegalDecisionToHigherOrders(LensContext<F> context, LensProjectionContext refProjCtx) {
    ResourceShadowDiscriminator refDiscr = refProjCtx.getResourceShadowDiscriminator();
    if (refDiscr == null) {
        return;
    }
    for (LensProjectionContext aProjCtx : context.getProjectionContexts()) {
        ResourceShadowDiscriminator aDiscr = aProjCtx.getResourceShadowDiscriminator();
        if (aDiscr != null && refDiscr.equivalent(aDiscr) && (refDiscr.getOrder() < aDiscr.getOrder())) {
            aProjCtx.setLegal(refProjCtx.isLegal());
            aProjCtx.setLegalOld(refProjCtx.isLegalOld());
            aProjCtx.setExists(refProjCtx.isExists());
        }
    }
}
Also used : LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator)

Example 55 with LensProjectionContext

use of com.evolveum.midpoint.model.impl.lens.LensProjectionContext in project midpoint by Evolveum.

the class TestClockwork method test053ModifyUserBarbossaDisable.

/**
	 * User barbossa has a direct account assignment. This assignment has an expression for enabledisable flag.
	 * Let's disable user, the account should be disabled as well.
	 */
@Test
public void test053ModifyUserBarbossaDisable() throws Exception {
    final String TEST_NAME = "test053ModifyUserBarbossaDisable";
    displayTestTile(TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    LensContext<UserType> context = createUserLensContext();
    fillContextWithUser(context, USER_BARBOSSA_OID, result);
    fillContextWithAccount(context, ACCOUNT_HBARBOSSA_DUMMY_OID, task, result);
    addModificationToContextReplaceUserProperty(context, new ItemPath(UserType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS), ActivationStatusType.DISABLED);
    context.recompute();
    display("Input context", context);
    assertFocusModificationSanity(context);
    // WHEN
    displayWhen(TEST_NAME);
    clockwork.run(context, task, result);
    // THEN
    displayThen(TEST_NAME);
    display("Output context", context);
    assertTrue(context.getFocusContext().getPrimaryDelta().getChangeType() == ChangeType.MODIFY);
    assertSideEffectiveDeltasOnly(context.getFocusContext().getSecondaryDelta(), "user secondary delta", ActivationStatusType.DISABLED);
    assertFalse("No account changes", context.getProjectionContexts().isEmpty());
    Collection<LensProjectionContext> accountContexts = context.getProjectionContexts();
    assertEquals(1, accountContexts.size());
    LensProjectionContext accContext = accountContexts.iterator().next();
    assertNull(accContext.getPrimaryDelta());
    assertEquals(SynchronizationPolicyDecision.KEEP, accContext.getSynchronizationPolicyDecision());
    ObjectDelta<ShadowType> accountSecondaryDelta = accContext.getSecondaryDelta();
    assertEquals(ChangeType.MODIFY, accountSecondaryDelta.getChangeType());
    // originally here was 6 (TODO why now four?)
    assertEquals("Unexpected number of account secondary changes", 4, accountSecondaryDelta.getModifications().size());
    PrismAsserts.assertPropertyReplace(accountSecondaryDelta, new ItemPath(ShadowType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS), ActivationStatusType.DISABLED);
    PrismAsserts.assertPropertyReplace(accountSecondaryDelta, SchemaConstants.PATH_ACTIVATION_DISABLE_REASON, SchemaConstants.MODEL_DISABLE_REASON_MAPPED);
    ContainerDelta<TriggerType> triggerDelta = accountSecondaryDelta.findContainerDelta(ObjectType.F_TRIGGER);
    assertNotNull("No trigger delta in account secondary delta", triggerDelta);
    assertEquals("Wrong trigger delta size", 1, triggerDelta.getValuesToAdd().size());
    TriggerType triggerType = triggerDelta.getValuesToAdd().iterator().next().asContainerable();
    assertEquals("Wrong trigger URL", RecomputeTriggerHandler.HANDLER_URI, triggerType.getHandlerUri());
    XMLGregorianCalendar start = clock.currentTimeXMLGregorianCalendar();
    start.add(XmlTypeConverter.createDuration(true, 0, 0, 25, 0, 0, 0));
    XMLGregorianCalendar end = clock.currentTimeXMLGregorianCalendar();
    end.add(XmlTypeConverter.createDuration(true, 0, 0, 35, 0, 0, 0));
    TestUtil.assertBetween("Wrong trigger timestamp", start, end, triggerType.getTimestamp());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Aggregations

LensProjectionContext (com.evolveum.midpoint.model.impl.lens.LensProjectionContext)71 ResourceShadowDiscriminator (com.evolveum.midpoint.schema.ResourceShadowDiscriminator)28 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)24 Task (com.evolveum.midpoint.task.api.Task)19 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)18 Test (org.testng.annotations.Test)17 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)15 AbstractInternalModelIntegrationTest (com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)14 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)12 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)11 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)10 MockLensDebugListener (com.evolveum.midpoint.model.impl.util.mock.MockLensDebugListener)8 PrismObject (com.evolveum.midpoint.prism.PrismObject)8 ResourceObjectShadowChangeDescription (com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription)8 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)7 SynchronizationPolicyDecision (com.evolveum.midpoint.model.api.context.SynchronizationPolicyDecision)5 LensContext (com.evolveum.midpoint.model.impl.lens.LensContext)5 PrismReference (com.evolveum.midpoint.prism.PrismReference)5 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)5 GetOperationOptions (com.evolveum.midpoint.schema.GetOperationOptions)5