private void collectAssignments(ContainerDelta<AssignmentType> assignmentDelta) throws SchemaException { if (assignmentDelta == null) { return; } collectAssignmentsDeltaSet(assignmentDelta.getValuesToReplace()); collectAssignmentsDeltaSet(assignmentDelta.getValuesToAdd()); collectAssignmentsDeltaSet(assignmentDelta.getValuesToDelete()); }
protected ContainerDelta<AssignmentType> createAssignmentModification(long id, boolean add) throws SchemaException { ContainerDelta<AssignmentType> assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); PrismContainerValue<AssignmentType> cval = prismContext.itemFactory().createContainerValue(); cval.setId(id); if (add) { assignmentDelta.addValueToAdd(cval); } else { assignmentDelta.addValueToDelete(cval); } return assignmentDelta; }
@SafeVarargs public static <O extends Objectable, C extends Containerable> void fillInModificationDeleteContainer( ObjectDelta<O> objectDelta, ItemPath propertyPath, PrismContainerValue<C>... containerValues) { ContainerDelta<C> containerDelta = objectDelta.createContainerModification(propertyPath); if (containerValues != null && containerValues.length > 0) { containerDelta.addValuesToDelete(containerValues); } }
public static ContainerDelta<?> assertContainerDeleteGetContainerDelta(ObjectDelta<?> objectDelta, ItemPath propertyPath) { ContainerDelta<?> delta = objectDelta.findContainerDelta(propertyPath); assertNotNull("Container delta for "+propertyPath+" not found",delta); assert !delta.isEmpty() : "Container delta for "+propertyPath+" is empty"; assert delta.getValuesToDelete() != null : "Container delta for "+propertyPath+" has null values to delete"; assert !delta.getValuesToDelete().isEmpty() : "Container delta for "+propertyPath+" has empty values to delete"; return delta; }
public static ContainerDelta<?> assertContainerAddGetContainerDelta(ObjectDelta<?> objectDelta, ItemPath propertyPath) { ContainerDelta<?> delta = objectDelta.findContainerDelta(propertyPath); assertNotNull("Container delta for "+propertyPath+" not found",delta); assert !delta.isEmpty() : "Container delta for "+propertyPath+" is empty"; assert delta.getValuesToAdd() != null : "Container delta for "+propertyPath+" has null values to add"; assert !delta.getValuesToAdd().isEmpty() : "Container delta for "+propertyPath+" has empty values to add"; return delta; }
@Test public void testAddDeltaNoAssignmentAddAssignmentDifferentNoIdSwallow() throws Exception { final String TEST_NAME="testAddDeltaNoAssignmentAddAssignmentDifferentNoIdSwallow"; displayTestTitle(TEST_NAME); // GIVEN //Delta 1 PrismObject<UserType> user = createUserFoo(); ObjectDelta<UserType> userDelta1 = DeltaFactory.Object.createAddDelta(user); //Delta 2 PrismContainerValue<AssignmentType> assignmentValue2 = getPrismContext().itemFactory().createContainerValue(); // null container ID assignmentValue2.setPropertyRealValue(AssignmentType.F_DESCRIPTION, ASSIGNMENT_ABRAKADABRA_DESCRIPTION, PrismTestUtil.getPrismContext()); ContainerDelta<AssignmentType> containerDelta2 = ContainerDeltaImpl.createDelta(UserType.F_ASSIGNMENT,getUserTypeDefinition()); containerDelta2.addValueToAdd(assignmentValue2); // WHEN userDelta1.swallow(containerDelta2); // THEN System.out.println("Delta after swallow:"); System.out.println(userDelta1.debugDump()); assertEquals("Wrong OID", USER_FOO_OID, userDelta1.getOid()); ContainerDelta<AssignmentType> containerDeltaAfter = userDelta1.findContainerDelta(UserType.F_ASSIGNMENT); assertNotNull("No assignment delta", containerDeltaAfter); PrismAsserts.assertNoDelete(containerDeltaAfter); PrismAsserts.assertNoReplace(containerDeltaAfter); Collection<PrismContainerValue<AssignmentType>> valuesToAdd = containerDeltaAfter.getValuesToAdd(); assertEquals("Unexpected number of values to add", 1, valuesToAdd.size()); assertTrue("Value "+assignmentValue2+" missing ", valuesToAdd.contains(assignmentValue2)); }
private <C extends Containerable> void visualizeContainerDelta(ContainerDelta<C> delta, SceneImpl scene, VisualizationContext context, Task task, OperationResult result) { if (delta.isEmpty()) { return; if (delta.getDefinition() != null && delta.getDefinition().isOperational() && !context.isIncludeOperationalItems()) { return; if (!delta.isReplace()) { valuesToAdd = delta.getValuesToAdd(); valuesToDelete = delta.getValuesToDelete(); } else { valuesToAdd = new ArrayList<>(); valuesToDelete = new ArrayList<>(); Collection<PrismContainerValue<C>> oldValues = delta.getEstimatedOldValues(); for (PrismContainerValue<C> newValue : delta.getValuesToReplace()) { if (oldValues == null || !oldValues.contains(newValue)) { // TODO containsEquivalentValue instead? valuesToAdd.add(newValue); if (!delta.getValuesToReplace().contains(oldValue)) { // TODO containsEquivalentValue instead? valuesToDelete.add(oldValue);
if (assignmentDelta.getValuesToAdd() != null) { for (PrismContainerValue<AssignmentType> assignmentContainerValue: assignmentDelta.getValuesToAdd()) { applyAssignmentValueMetadataAdd(context, assignmentContainerValue, "MOD/add", now, task, result); if (assignmentDelta.getValuesToReplace() != null) { for (PrismContainerValue<AssignmentType> assignmentContainerValue: assignmentDelta.getValuesToReplace()) { applyAssignmentValueMetadataAdd(context, assignmentContainerValue, "MOD/replace", now, task, result);
private <C extends Containerable, O extends ObjectType> AccessDecision determineContainerDeltaDecision(ContainerDelta<C> cdelta, PrismObject<O> currentObject, ItemDecisionFunction itemDecitionFunction) { AccessDecision decision = null; ItemPath path = cdelta.getPath(); Collection<PrismContainerValue<C>> valuesToAdd = cdelta.getValuesToAdd(); if (valuesToAdd != null) { for (PrismContainerValue<C> cval: valuesToAdd) { Collection<PrismContainerValue<C>> valuesToDelete = cdelta.getValuesToDelete(); if (valuesToDelete != null) { for (PrismContainerValue<C> cval: valuesToDelete) { Collection<PrismContainerValue<C>> valuesToReplace = cdelta.getValuesToReplace(); if (valuesToReplace != null) { for (PrismContainerValue<C> cval: valuesToReplace) {
+ assignmentToFind + ", objectDelta=" + focusDelta); if (assignmentDelta.isReplace()) { swallowIntoValues(asContainerables(assignmentDelta.getValuesToReplace()), assignmentToFind, modifications); } else if (assignmentDelta.isAdd()) { swallowIntoValues(asContainerables(assignmentDelta.getValuesToAdd()), assignmentToFind, modifications); } else {
public ContainerDeltaAsserter<C,RA> assertNoValuesToAdd() { Collection<PrismContainerValue<C>> valuesToAdd = containerDelta.getValuesToAdd(); assertNull("Unexpected values to add in "+desc()+": "+valuesToAdd, valuesToAdd); return this; }
/** * Breaks user assignment delta in the context by inserting some empty value. This may interfere with comparing the values to * existing user values. */ protected <F extends FocusType> void breakAssignmentDelta(ObjectDelta<F> userDelta) throws SchemaException { ContainerDelta<?> assignmentDelta = userDelta.findContainerDelta(UserType.F_ASSIGNMENT); PrismContainerValue<?> assignmentDeltaValue = null; if (assignmentDelta.getValuesToAdd() != null) { assignmentDeltaValue = assignmentDelta.getValuesToAdd().iterator().next(); } if (assignmentDelta.getValuesToDelete() != null) { assignmentDeltaValue = assignmentDelta.getValuesToDelete().iterator().next(); } PrismContainer<ActivationType> activationContainer = assignmentDeltaValue.findOrCreateContainer(AssignmentType.F_ACTIVATION); PrismContainerValue<ActivationType> emptyValue = prismContext.itemFactory().createContainerValue(); activationContainer.add(emptyValue); }
@SafeVarargs static <O extends Objectable, C extends Containerable> void fillInModificationAddContainer( ObjectDelta<O> objectDelta, ItemPath propertyPath, PrismContext prismContext, C... containerables) throws SchemaException { ContainerDelta<C> containerDelta = objectDelta.createContainerModification(propertyPath); if (containerables != null) { for (C containerable: containerables) { prismContext.adopt(containerable, objectDelta.getObjectTypeClass(), propertyPath); PrismContainerValue<C> prismContainerValue = containerable.asPrismContainerValue(); containerDelta.addValueToAdd(prismContainerValue); } } }
protected ContainerDelta<AssignmentType> createAssignmentModification(AssignmentType assignmentType, boolean add) throws SchemaException { ContainerDelta<AssignmentType> assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition()); if (add) { assignmentDelta.addValueToAdd(assignmentType.asPrismContainerValue()); } else { assignmentDelta.addValueToDelete(assignmentType.asPrismContainerValue()); } PrismContainerDefinition<AssignmentType> assignmentDef = getUserDefinition().findContainerDefinition(UserType.F_ASSIGNMENT); assignmentDelta.applyDefinition(assignmentDef); return assignmentDelta; }
assocDelta.addValueToAdd(cValue); } else if (changeType == ModificationType.DELETE) { if (!isToBeDeleted(existingDelta, valueMatcher, value)){ LOGGER.trace("Adding association value to delete {} ", cValue); assocDelta.addValueToDelete(cValue); assocDelta.setValueToReplace(cValue); } else { throw new IllegalArgumentException("Unknown change type " + changeType);
public ContainerDeltaAsserter<C,RA> assertNoValuesToDelete() { Collection<PrismContainerValue<C>> valuesToDelete = containerDelta.getValuesToDelete(); assertNull("Unexpected values to delete in "+desc()+": "+valuesToDelete, valuesToDelete); return this; }
associationDelta.addValuesToDelete(associationValue.clone()); associationDelta.addValuesToAdd(associationValue.clone()); LOGGER.trace("Resulting association delta for {}:\n{}", subjectItemPath, associationDelta.debugDump(1)); if (!associationDelta.isEmpty()) { entitlementConverter.collectEntitlementsAsObjectOperation(ctx, roMap, associationDelta, subjectShadowBefore, subjectShadowAfter, parentResult);
public ContainerDeltaAsserter<C,RA> assertNoValuesToReplace() { Collection<PrismContainerValue<C>> valuesToReplace = containerDelta.getValuesToReplace(); assertNull("Unexpected values to replace in "+desc()+": "+valuesToReplace, valuesToReplace); return this; }
private <F extends AssignmentHolderType> void createAssignmentDelta(LensContext<F> context, LensProjectionContext accountContext) throws SchemaException{ Class<F> focusClass = context.getFocusClass(); ContainerDelta<AssignmentType> assignmentDelta = prismContext.deltaFactory().container() .createDelta(AssignmentHolderType.F_ASSIGNMENT, focusClass); AssignmentType assignment = new AssignmentType(); ConstructionType constructionType = new ConstructionType(); constructionType.setResourceRef(ObjectTypeUtil.createObjectRef(accountContext.getResource(), prismContext)); assignment.setConstruction(constructionType); assignmentDelta.addValueToAdd(assignment.asPrismContainerValue()); PrismContainerDefinition<AssignmentType> containerDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(focusClass).findContainerDefinition(AssignmentHolderType.F_ASSIGNMENT); assignmentDelta.applyDefinition(containerDefinition); context.getFocusContext().swallowToProjectionWaveSecondaryDelta(assignmentDelta); }
private ObjectDelta<UserType> createDeltaForFindItem(boolean containerReplace) throws SchemaException { ObjectDelta<UserType> userDelta = PrismTestUtil.getPrismContext().deltaFactory().object() .createModificationAddProperty(UserType.class, USER_FOO_OID, UserType.F_LOCALITY, "Caribbean"); userDelta.addModificationReplaceProperty(UserType.F_GIVEN_NAME, "Guybrush"); ContainerDelta<ActivationType> activationDelta = userDelta.createContainerModification(UserType.F_ACTIVATION); PrismContainerValue<ActivationType> activationCVal = getPrismContext().itemFactory().createContainerValue(); if (containerReplace) { activationDelta.addValueToReplace(activationCVal); } else { activationDelta.addValueToAdd(activationCVal); } PrismProperty<Boolean> enabledProperty = activationCVal.createProperty(ActivationType.F_ENABLED); enabledProperty.setRealValue(Boolean.TRUE); PrismProperty<XMLGregorianCalendar> validFromProperty = activationCVal.createProperty(ActivationType.F_VALID_FROM); validFromProperty.setRealValue(XmlTypeConverter.createXMLGregorianCalendar(20016, 5, 16, 19, 8, 33)); userDelta.addModification(activationDelta); return userDelta; }