diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/Item.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/Item.java index 95a4b4e67e6..2c0180a1d4a 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/Item.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/Item.java @@ -445,7 +445,7 @@ public void merge(Item otherItem) throws SchemaException { public abstract Object find(ItemPath path); - public abstract PartiallyResolvedValue findPartial(ItemPath path); + public abstract PartiallyResolvedItem findPartial(ItemPath path); public Collection diff(Item other) { return diff(other, true, false); diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PartiallyResolvedValue.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PartiallyResolvedItem.java similarity index 85% rename from infra/prism/src/main/java/com/evolveum/midpoint/prism/PartiallyResolvedValue.java rename to infra/prism/src/main/java/com/evolveum/midpoint/prism/PartiallyResolvedItem.java index 642320eadab..c8d426fbaf3 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PartiallyResolvedValue.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PartiallyResolvedItem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2014 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,12 +21,12 @@ * @author semancik * */ -public class PartiallyResolvedValue { +public class PartiallyResolvedItem { private Item item; private ItemPath residualPath; - public PartiallyResolvedValue(Item item, ItemPath residualPath) { + public PartiallyResolvedItem(Item item, ItemPath residualPath) { super(); this.item = item; this.residualPath = residualPath; @@ -65,7 +65,7 @@ public boolean equals(Object obj) { return false; if (getClass() != obj.getClass()) return false; - PartiallyResolvedValue other = (PartiallyResolvedValue) obj; + PartiallyResolvedItem other = (PartiallyResolvedItem) obj; if (item == null) { if (other.item != null) return false; @@ -81,7 +81,7 @@ public boolean equals(Object obj) { @Override public String toString() { - return "PartiallyResolvedValue(item=" + item + ", residualPath=" + residualPath + ")"; + return "PartiallyResolvedItem(item=" + item + ", residualPath=" + residualPath + ")"; } } diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainer.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainer.java index d6fe8a1c7bd..a04f23eaa02 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainer.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainer.java @@ -352,9 +352,9 @@ public Object find(ItemPath path) { } @Override - public PartiallyResolvedValue findPartial(ItemPath path) { + public PartiallyResolvedItem findPartial(ItemPath path) { if (path == null || path.isEmpty()) { - return new PartiallyResolvedValue((Item)this, null); + return new PartiallyResolvedItem((Item)this, null); } IdItemPathSegment idSegment = ItemPath.getFirstIdSegment(path); diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainerValue.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainerValue.java index cecd3071711..6e90e7c0154 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainerValue.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismContainerValue.java @@ -532,7 +532,7 @@ public Object find(ItemPath path) { } @Override - public PartiallyResolvedValue findPartial(ItemPath path) { + public PartiallyResolvedItem findPartial(ItemPath path) { if (path == null || path.isEmpty()) { // Incomplete path return null; diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismProperty.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismProperty.java index 5115b55fb3b..c1de1129170 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismProperty.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismProperty.java @@ -22,6 +22,8 @@ import com.evolveum.midpoint.util.DebugDumpable; import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.util.PrettyPrinter; +import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.util.exception.SystemException; import com.evolveum.midpoint.util.logging.Trace; import com.evolveum.midpoint.util.logging.TraceManager; @@ -361,15 +363,17 @@ public Object find(ItemPath path) { } @Override - public PartiallyResolvedValue findPartial(ItemPath path) { + public PartiallyResolvedItem findPartial(ItemPath path) { if (path == null || path.isEmpty()) { - return new PartiallyResolvedValue((Item)this, null); + return new PartiallyResolvedItem((Item)this, null); } - if (!isSingleValue()) { - throw new IllegalStateException("Attempt to resolve sub-path '"+path+"' on multi-value property " + getElementName()); - } - PrismPropertyValue value = getValue(); - return value.findPartial(path); + for (PrismPropertyValue pvalue: getValues()) { + T value = pvalue.getValue(); + if (!(value instanceof Structured)) { + throw new IllegalArgumentException("Attempt to resolve sub-path '"+path+"' on non-structured property value "+pvalue); + } + } + return new PartiallyResolvedItem((Item)this, path); } public PropertyDelta diff(PrismProperty other) { diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismPropertyValue.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismPropertyValue.java index b7447603355..39322e49e47 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismPropertyValue.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismPropertyValue.java @@ -209,16 +209,8 @@ public Object find(ItemPath path) { } @Override - public PartiallyResolvedValue findPartial(ItemPath path) { - if (path == null || path.isEmpty()) { - return new PartiallyResolvedValue((Item)getParent(), null); - } - T value = getValue(); - if (value instanceof Structured) { - return new PartiallyResolvedValue((Item)getParent(), path); - } else { - throw new IllegalArgumentException("Attempt to resolve sub-path '"+path+"' on non-structured property value "+value); - } + public PartiallyResolvedItem findPartial(ItemPath path) { + throw new UnsupportedOperationException("Attempt to invoke findPartialItem on a property value"); } void checkValue() { diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismReference.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismReference.java index d598d31beab..3361507ab54 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismReference.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismReference.java @@ -175,9 +175,9 @@ public Object find(ItemPath path) { @Override - public PartiallyResolvedValue findPartial(ItemPath path) { + public PartiallyResolvedItem findPartial(ItemPath path) { if (path == null || path.isEmpty()) { - return new PartiallyResolvedValue((Item)this, null); + return new PartiallyResolvedItem((Item)this, null); } if (!isSingleValue()) { throw new IllegalStateException("Attempt to resolve sub-path '"+path+"' on multi-value reference " + getElementName()); diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismReferenceValue.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismReferenceValue.java index 6c9f5ed9549..f597236c677 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismReferenceValue.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismReferenceValue.java @@ -190,11 +190,11 @@ public Object find(ItemPath path) { } @Override - public PartiallyResolvedValue findPartial(ItemPath path) { + public PartiallyResolvedItem findPartial(ItemPath path) { if (path == null || path.isEmpty()) { - return new PartiallyResolvedValue((Item)getParent(), null); + return new PartiallyResolvedItem((Item)getParent(), null); } - return new PartiallyResolvedValue((Item)getParent(), path); + return new PartiallyResolvedItem((Item)getParent(), path); } private boolean compareLocalPart(QName a, QName b) { diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismValue.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismValue.java index bc1392ab609..2ef4a573f0c 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismValue.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/PrismValue.java @@ -252,7 +252,7 @@ public static Collection resetParentCollection(Collect public abstract Object find(ItemPath path); - public abstract PartiallyResolvedValue findPartial(ItemPath path); + public abstract PartiallyResolvedItem findPartial(ItemPath path); @Override public int hashCode() { diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/ObjectDelta.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/ObjectDelta.java index 1b74698191f..ceafd01a723 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/ObjectDelta.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/delta/ObjectDelta.java @@ -19,7 +19,7 @@ import com.evolveum.midpoint.prism.Item; import com.evolveum.midpoint.prism.ItemDefinition; import com.evolveum.midpoint.prism.Objectable; -import com.evolveum.midpoint.prism.PartiallyResolvedValue; +import com.evolveum.midpoint.prism.PartiallyResolvedItem; import com.evolveum.midpoint.prism.PathVisitable; import com.evolveum.midpoint.prism.PrismContainer; import com.evolveum.midpoint.prism.PrismContainerDefinition; @@ -269,7 +269,7 @@ private D findItemDelta(ItemPath propertyP public PartiallyResolvedDelta findPartial(ItemPath propertyPath) { if (changeType == ChangeType.ADD) { - PartiallyResolvedValue partialValue = objectToAdd.findPartial(propertyPath); + PartiallyResolvedItem partialValue = objectToAdd.findPartial(propertyPath); if (partialValue == null || partialValue.getItem() == null) { return null; } diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ItemDeltaItem.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ItemDeltaItem.java index 48d2350e476..f558963f271 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ItemDeltaItem.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ItemDeltaItem.java @@ -22,7 +22,7 @@ import com.evolveum.midpoint.prism.Item; import com.evolveum.midpoint.prism.ItemDefinition; -import com.evolveum.midpoint.prism.PartiallyResolvedValue; +import com.evolveum.midpoint.prism.PartiallyResolvedItem; import com.evolveum.midpoint.prism.PrismContainer; import com.evolveum.midpoint.prism.PrismProperty; import com.evolveum.midpoint.prism.PrismPropertyDefinition; @@ -181,7 +181,7 @@ public ItemDeltaItem findIdi(ItemPath path) { ItemPath subResidualPath = null; ItemPath newResolvePath = resolvePath.subPath(path); if (itemOld != null) { - PartiallyResolvedValue partialItemOld = itemOld.findPartial(path); + PartiallyResolvedItem partialItemOld = itemOld.findPartial(path); if (partialItemOld != null) { subItemOld = partialItemOld.getItem(); subResidualPath = partialItemOld.getResidualPath(); @@ -189,7 +189,7 @@ public ItemDeltaItem findIdi(ItemPath path) { } Item subItemNew = null; if (itemNew != null) { - PartiallyResolvedValue partialItemNew = itemNew.findPartial(path); + PartiallyResolvedItem partialItemNew = itemNew.findPartial(path); if (partialItemNew != null) { subItemNew = partialItemNew.getItem(); if (subResidualPath == null) { diff --git a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ObjectDeltaObject.java b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ObjectDeltaObject.java index f805f484efd..d5b802c90b6 100644 --- a/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ObjectDeltaObject.java +++ b/model/model-common/src/main/java/com/evolveum/midpoint/model/common/expression/ObjectDeltaObject.java @@ -20,7 +20,7 @@ import com.evolveum.midpoint.prism.Item; import com.evolveum.midpoint.prism.ItemDefinition; -import com.evolveum.midpoint.prism.PartiallyResolvedValue; +import com.evolveum.midpoint.prism.PartiallyResolvedItem; import com.evolveum.midpoint.prism.PrismContainerValue; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismValue; @@ -105,7 +105,7 @@ public ItemDeltaItem findIdi(ItemPath path) { Item subItemOld = null; ItemPath subResidualPath = null; if (oldObject != null) { - PartiallyResolvedValue partialOld = oldObject.findPartial(path); + PartiallyResolvedItem partialOld = oldObject.findPartial(path); if (partialOld != null) { subItemOld = partialOld.getItem(); subResidualPath = partialOld.getResidualPath(); @@ -113,7 +113,7 @@ public ItemDeltaItem findIdi(ItemPath path) { } Item subItemNew = null; if (newObject != null) { - PartiallyResolvedValue partialNew = newObject.findPartial(path); + PartiallyResolvedItem partialNew = newObject.findPartial(path); if (partialNew != null) { subItemNew = partialNew.getItem(); if (subResidualPath == null) { @@ -126,7 +126,7 @@ public ItemDeltaItem findIdi(ItemPath path) { if (delta != null) { if (delta.getChangeType() == ChangeType.ADD) { PrismObject objectToAdd = delta.getObjectToAdd(); - PartiallyResolvedValue partialValue = objectToAdd.findPartial(path); + PartiallyResolvedItem partialValue = objectToAdd.findPartial(path); if (partialValue != null && partialValue.getItem() != null) { Item item = partialValue.getItem(); itemDelta = item.createDelta(); @@ -135,8 +135,17 @@ public ItemDeltaItem findIdi(ItemPath path) { // No item for this path, itemDelta will stay empty. } } else if (delta.getChangeType() == ChangeType.DELETE) { - // TODO - throw new UnsupportedOperationException("delete"); + if (subItemOld != null) { + ItemPath subPath = subItemOld.getPath().remainder(path); + PartiallyResolvedItem partialValue = subItemOld.findPartial(subPath); + if (partialValue != null && partialValue.getItem() != null) { + Item item = partialValue.getItem(); + itemDelta = item.createDelta(); + itemDelta.addValuesToDelete(item.getClonedValues()); + } else { + // No item for this path, itemDelta will stay empty. + } + } } else if (delta.getChangeType() == ChangeType.MODIFY) { for (ItemDelta modification: delta.getModifications()) { CompareResult compareComplex = modification.getPath().compareComplex(path);