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;
}
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() });
}
}
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();
}
}
}
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());
}
}
}
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());
}
Aggregations