Collection oldValues = delta.getEstimatedOldValues(); if (oldValues == null) { return;
@Test public void testItemDeltaReplace() throws Exception { System.out.println("===[ testItemDeltaReplace ]===="); // GIVEN PrismObjectDefinition<UserType> userDef = getUserDefinition(); PropertyDelta<String> deltaBefore = getPrismContext().deltaFactory().property().createReplaceEmptyDelta(userDef, UserType.F_COST_CENTER); deltaBefore.setRealValuesToReplace("foo"); // WHEN Collection<ItemDeltaType> itemDeltaTypes = DeltaConvertor.toItemDeltaTypes(deltaBefore); // THEN System.out.println("Serialized"); System.out.println(itemDeltaTypes); // WHEN ItemDelta<?,?> deltaAfter = DeltaConvertor.createItemDelta(itemDeltaTypes.iterator().next(), userDef); // THEN System.out.println("Parsed"); System.out.println(deltaAfter.debugDump()); assertEquals("Deltas do not match", deltaBefore, deltaAfter); assertNull(deltaAfter.getEstimatedOldValues()); }
throw new SchemaException(e.getMessage() + " while converting property " + delta.getElementName(), e); addOldValues(delta, mod, delta.getEstimatedOldValues(), options); mods.add(mod); throw new SchemaException(e.getMessage() + " while converting property " + delta.getElementName(), e); addOldValues(delta, mod, delta.getEstimatedOldValues(), options); mods.add(mod); throw new SchemaException(e.getMessage() + " while converting property " + delta.getElementName(), e); addOldValues(delta, mod, delta.getEstimatedOldValues(), options); mods.add(mod);
if (deltaToMerge.getEstimatedOldValues() != null) { mergeOldValues(PrismValueCollectionsUtil.cloneValues(deltaToMerge.getEstimatedOldValues()));
if (itemDelta.getEstimatedOldValues() == null) { final String oid = objectDelta.getOid(); if (!originalObjectFetched && oid != null) {
public static <O extends ObjectType> void setDeltaOldValue(LensElementContext<O> ctx, ItemDelta<?,?> itemDelta) { if (itemDelta.getEstimatedOldValues() != null) { return; } if (ctx.getObjectOld() == null) { return; } Item<PrismValue, ItemDefinition> itemOld = ctx.getObjectOld().findItem(itemDelta.getPath()); if (itemOld != null) { //noinspection unchecked itemDelta.setEstimatedOldValues((Collection) PrismValueCollectionsUtil.cloneCollection(itemOld.getValues())); return; } // Here we need to distinguish whether the item is missing because it is not filled in (e.g. familyName in MID-4237) // or because it was not loaded (as for attributes or associations). if (!isItemLoadable(ctx.getObjectOld(), itemDelta.getPath())) { itemDelta.setEstimatedOldValues(emptySet()); return; } // get the old data from current object. Still better estimate than nothing if (ctx.getObjectCurrent() != null) { itemOld = ctx.getObjectCurrent().findItem(itemDelta.getPath()); if (itemOld != null) { //noinspection unchecked itemDelta.setEstimatedOldValues((Collection) PrismValueCollectionsUtil.cloneCollection(itemOld.getValues())); } } }
@SuppressWarnings("unchecked") private <V extends PrismValue, D extends ItemDefinition> SceneDeltaItemImpl createSceneDeltaItemCommon(ItemDelta<V, D> itemDelta, SceneImpl owningScene) throws SchemaException { String simpleName = itemDelta.getElementName() != null ? itemDelta.getElementName().getLocalPart() : ""; NameImpl name = new NameImpl(simpleName); if (itemDelta.getDefinition() != null) { name.setDisplayName(itemDelta.getDefinition().getDisplayName()); } name.setId(simpleName); name.setNamesAreResourceKeys(true); SceneDeltaItemImpl si = new SceneDeltaItemImpl(name); si.setSourceDelta(itemDelta); D def = itemDelta.getDefinition(); if (def != null) { Item<V,D> item = def.instantiate(); if (itemDelta.getEstimatedOldValues() != null) { item.addAll(CloneUtil.cloneCollectionMembers(itemDelta.getEstimatedOldValues())); } si.setSourceItem(item); si.setOperational(def.isOperational()); } ItemPath remainder = itemDelta.getPath().remainder(owningScene.getSourceRelPath()); if (remainder.startsWithNullId()) { remainder = remainder.rest(); } si.setSourceRelPath(remainder); return si; }