private List<ReferenceDelta> filterParentRefDeltas(Collection<? extends ItemDelta> modifications) { boolean containsAdd = false, containsDelete = false, containsReplace = false; List<ReferenceDelta> deltas = new ArrayList<>(); if (modifications == null) { return deltas; } for (ItemDelta delta : modifications) { if (!QNameUtil.match(ObjectType.F_PARENT_ORG_REF, delta.getElementName())) { // TODO is this OK? continue; } if (delta.isAdd()) { containsAdd = true; } if (delta.isDelete()) { containsDelete = true; } if (delta.isReplace()) { if (containsReplace) { throw new IllegalStateException("Unsupported combination of parentOrgRef operations: more REPLACE ItemDeltas"); } containsReplace = true; } deltas.add((ReferenceDelta) delta); } if (containsReplace && (containsAdd || containsDelete)) { throw new IllegalStateException("Unsupported combination of parentOrgRef operations: REPLACE with either ADD or DELETE"); } return deltas; }
if (itemDelta.isReplace()) { for (PrismValue prismValue : itemDelta.getValuesToReplace()) { body.append(" --- REPLACE: ");
private boolean isSideEffectDelta(ItemDelta<?, ?> modification) { if (modification.getPath().containsNameExactly(ObjectType.F_METADATA) || (modification.getPath().containsNameExactly(FocusType.F_ASSIGNMENT) && modification.getPath().containsNameExactly(ActivationType.F_EFFECTIVE_STATUS))) { return true; } else if (modification.getPath().containsNameExactly(FocusType.F_ASSIGNMENT) && modification.getPath().containsNameExactly(AssignmentType.F_ACTIVATION) && modification.isReplace() && (modification instanceof ContainerDelta<?>)) { Collection<PrismContainerValue<ActivationType>> valuesToReplace = ((ContainerDelta<ActivationType>)modification).getValuesToReplace(); if (valuesToReplace != null && valuesToReplace.size() == 1) { PrismContainerValue<ActivationType> cval = valuesToReplace.iterator().next(); if (cval.getItems().size() == 1) { Item<?, ?> item = cval.getItems().iterator().next(); if (ActivationType.F_EFFECTIVE_STATUS.equals(item.getElementName())) { return true; } } } } return false; }
ItemDelta<?, ?> modification = iterator.next(); if (path.equivalent(modification.getPath())) { if (modification.isReplace()) { throw new UnsupportedOperationException("Cannot factor out values for replace item delta. Path = " + path + ", modification = " + modification);
private void handleBasicOrEmbedded(Object bean, ItemDelta delta, Attribute attribute) { Class outputType = getRealOutputType(attribute); PrismValue anyPrismValue = delta.getAnyValue(); Object value; if (delta.isDelete() || (delta.isReplace() && (anyPrismValue == null || anyPrismValue.isEmpty()))) { value = null; } else { value = anyPrismValue.getRealValue(); } value = prismEntityMapper.map(value, outputType); try { PropertyUtils.setSimpleProperty(bean, attribute.getName(), value); } catch (Exception ex) { throw new SystemException("Couldn't set simple property for '" + attribute.getName() + "'", ex); } }
@Override public void assertsAfterClockworkRun(Task rootTask, List<Task> wfSubtasks, OperationResult result) throws Exception { ModelContext taskModelContext = wfTaskUtil.getModelContext(rootTask, result); assertEquals("There is wrong number of modifications left in primary focus delta", 2, taskModelContext.getFocusContext().getPrimaryDelta().getModifications().size()); Iterator<? extends ItemDelta> it = taskModelContext.getFocusContext().getPrimaryDelta().getModifications().iterator(); ItemDelta addRoleDelta = null, activationChange = null; while (it.hasNext()) { ItemDelta mod = it.next(); if (mod.isAdd()) { addRoleDelta = mod; } else if (mod.isReplace()) { activationChange = mod; } } assertNotNull("role add delta was not found", addRoleDelta); assertEquals("role add delta contains wrong number of values", 1, addRoleDelta.getValuesToAdd().size()); assertNotNull("activation change delta was not found", activationChange); }
private void handleOneToMany(Collection collection, ItemDelta delta, Attribute attribute, Object bean, PrismObject prismObject, PrismIdentifierGenerator idGenerator) { Class outputType = getRealOutputType(attribute); Item item = prismObject.findItem(delta.getPath()); // handle replace if (delta.isReplace()) { Collection<PrismEntityPair<?>> valuesToReplace = processDeltaValues(delta.getValuesToReplace(), outputType, delta, bean); replaceValues(collection, valuesToReplace, item, idGenerator); return; } // handle add if (delta.isAdd()) { Collection<PrismEntityPair<?>> valuesToAdd = processDeltaValues(delta.getValuesToAdd(), outputType, delta, bean); addValues(collection, valuesToAdd, idGenerator); } // handle delete if (delta.isDelete()) { Collection<PrismEntityPair<?>> valuesToDelete = processDeltaValues(delta.getValuesToDelete(), outputType, delta, bean); valuesToDelete.stream().forEach(pair -> { if (pair.getRepository() instanceof EntityState) { ((EntityState) pair.getRepository()).setTransient(false); } }); deleteValues(collection, valuesToDelete, item); } }
@Override public void assertsAfterClockworkRun(Task rootTask, List<Task> wfSubtasks, OperationResult result) throws Exception { ModelContext taskModelContext = wfTaskUtil.getModelContext(rootTask, result); assertEquals("There is wrong number of modifications left in primary focus delta", 1, taskModelContext.getFocusContext().getPrimaryDelta().getModifications().size()); ItemDelta givenNameDelta = (ItemDelta) taskModelContext.getFocusContext().getPrimaryDelta().getModifications().iterator().next(); assertNotNull("givenName delta is incorrect (not a replace delta)", givenNameDelta.isReplace()); assertEquals("givenName delta is incorrect (wrong value)", "JACK", ((PrismPropertyValue<PolyString>) givenNameDelta.getValuesToReplace().iterator().next()).getValue().getOrig()); PrismObject<UserType> jack = repositoryService.getObject(UserType.class, USER_JACK_OID, null, result); assertNotAssignedRole(jack, ROLE_R2_OID); assertEquals("Wrong given name before change", "Jack", jack.asObjectable().getGivenName().getOrig()); }
private static void convertToLegacy( ItemDeltaItem<PrismContainerValue<AssignmentType>, PrismContainerDefinition<AssignmentType>> idi) { if (idi == null || idi.getDelta() == null || idi.getSubItemDeltas() != null) { return; } // Legacy approach (when adding/removing assignments) was: itemOld+itemNew = value, delta = null // This was recently changed, to provide precise information (add = null->itemNew, delete = itemOld->null). // However, to not break scripts before 3.6 release we provide imitation of old behavior here. // (Moreover, for magic assignment the delta is not correct anyway.) if (idi.getDelta().isAdd() || idi.getDelta().isReplace()) { idi.setItemOld(idi.getItemNew().clone()); } else { idi.setItemNew(idi.getItemOld().clone()); } idi.setDelta(null); }
delta.getModifications().size(), newObject.toString(), delta.debugDump(3)); ItemDelta id = (ItemDelta) delta.getModifications().iterator().next(); if (id.isReplace()) { LOGGER.debug("{}", id.getValuesToReplace().iterator().next());
public void applyAttributesDefinition(ProvisioningContext ctx, ObjectDelta<ShadowType> delta) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ExpressionEvaluationException { if (delta.isAdd()) { applyAttributesDefinition(ctx, delta.getObjectToAdd()); } else if (delta.isModify()) { for (ItemDelta<?, ?> itemDelta : delta.getModifications()) { if (SchemaConstants.PATH_ATTRIBUTES.equivalent(itemDelta.getParentPath())) { applyAttributeDefinition(ctx, delta, itemDelta); } else if (SchemaConstants.PATH_ATTRIBUTES.equivalent(itemDelta.getPath())) { if (itemDelta.isAdd()) { for (PrismValue value : itemDelta.getValuesToAdd()) { applyAttributeDefinition(ctx, value); } } if (itemDelta.isReplace()) { for (PrismValue value : itemDelta.getValuesToReplace()) { applyAttributeDefinition(ctx, value); } } } } } }
if (itemDelta.isReplace()) { LOGGER.trace("Non-tolerant item with resulting REPLACE delta => doing nothing"); } else {
if (aprioriItemDelta != null && aprioriItemDelta.isReplace()) {