Skip to content

Commit

Permalink
Merge branch 'master' into roleconditions
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Jul 31, 2014
2 parents cccea5a + 641bed5 commit a33a8ab
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 43 deletions.
Expand Up @@ -445,7 +445,7 @@ public void merge(Item<V> otherItem) throws SchemaException {

public abstract Object find(ItemPath path);

public abstract <X extends PrismValue> PartiallyResolvedValue<X> findPartial(ItemPath path);
public abstract <X extends PrismValue> PartiallyResolvedItem<X> findPartial(ItemPath path);

public Collection<? extends ItemDelta> diff(Item<V> other) {
return diff(other, true, false);
Expand Down
@@ -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.
Expand All @@ -21,12 +21,12 @@
* @author semancik
*
*/
public class PartiallyResolvedValue<V extends PrismValue> {
public class PartiallyResolvedItem<V extends PrismValue> {

private Item<V> item;
private ItemPath residualPath;

public PartiallyResolvedValue(Item<V> item, ItemPath residualPath) {
public PartiallyResolvedItem(Item<V> item, ItemPath residualPath) {
super();
this.item = item;
this.residualPath = residualPath;
Expand Down Expand Up @@ -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;
Expand All @@ -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 + ")";
}

}
Expand Up @@ -352,9 +352,9 @@ public Object find(ItemPath path) {
}

@Override
public <X extends PrismValue> PartiallyResolvedValue<X> findPartial(ItemPath path) {
public <X extends PrismValue> PartiallyResolvedItem<X> findPartial(ItemPath path) {
if (path == null || path.isEmpty()) {
return new PartiallyResolvedValue<X>((Item<X>)this, null);
return new PartiallyResolvedItem<X>((Item<X>)this, null);
}

IdItemPathSegment idSegment = ItemPath.getFirstIdSegment(path);
Expand Down
Expand Up @@ -532,7 +532,7 @@ public Object find(ItemPath path) {
}

@Override
public <X extends PrismValue> PartiallyResolvedValue<X> findPartial(ItemPath path) {
public <X extends PrismValue> PartiallyResolvedItem<X> findPartial(ItemPath path) {
if (path == null || path.isEmpty()) {
// Incomplete path
return null;
Expand Down
Expand Up @@ -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;

Expand Down Expand Up @@ -361,15 +363,17 @@ public Object find(ItemPath path) {
}

@Override
public <X extends PrismValue> PartiallyResolvedValue<X> findPartial(ItemPath path) {
public <X extends PrismValue> PartiallyResolvedItem<X> findPartial(ItemPath path) {
if (path == null || path.isEmpty()) {
return new PartiallyResolvedValue<X>((Item<X>)this, null);
return new PartiallyResolvedItem<X>((Item<X>)this, null);
}
if (!isSingleValue()) {
throw new IllegalStateException("Attempt to resolve sub-path '"+path+"' on multi-value property " + getElementName());
}
PrismPropertyValue<T> value = getValue();
return value.findPartial(path);
for (PrismPropertyValue<T> 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<X>((Item<X>)this, path);
}

public PropertyDelta<T> diff(PrismProperty<T> other) {
Expand Down
Expand Up @@ -209,16 +209,8 @@ public Object find(ItemPath path) {
}

@Override
public <X extends PrismValue> PartiallyResolvedValue<X> findPartial(ItemPath path) {
if (path == null || path.isEmpty()) {
return new PartiallyResolvedValue<X>((Item<X>)getParent(), null);
}
T value = getValue();
if (value instanceof Structured) {
return new PartiallyResolvedValue<X>((Item<X>)getParent(), path);
} else {
throw new IllegalArgumentException("Attempt to resolve sub-path '"+path+"' on non-structured property value "+value);
}
public <X extends PrismValue> PartiallyResolvedItem<X> findPartial(ItemPath path) {
throw new UnsupportedOperationException("Attempt to invoke findPartialItem on a property value");
}

void checkValue() {
Expand Down
Expand Up @@ -175,9 +175,9 @@ public Object find(ItemPath path) {


@Override
public <X extends PrismValue> PartiallyResolvedValue<X> findPartial(ItemPath path) {
public <X extends PrismValue> PartiallyResolvedItem<X> findPartial(ItemPath path) {
if (path == null || path.isEmpty()) {
return new PartiallyResolvedValue<X>((Item<X>)this, null);
return new PartiallyResolvedItem<X>((Item<X>)this, null);
}
if (!isSingleValue()) {
throw new IllegalStateException("Attempt to resolve sub-path '"+path+"' on multi-value reference " + getElementName());
Expand Down
Expand Up @@ -190,11 +190,11 @@ public Object find(ItemPath path) {
}

@Override
public <X extends PrismValue> PartiallyResolvedValue<X> findPartial(ItemPath path) {
public <X extends PrismValue> PartiallyResolvedItem<X> findPartial(ItemPath path) {
if (path == null || path.isEmpty()) {
return new PartiallyResolvedValue<X>((Item<X>)getParent(), null);
return new PartiallyResolvedItem<X>((Item<X>)getParent(), null);
}
return new PartiallyResolvedValue<X>((Item<X>)getParent(), path);
return new PartiallyResolvedItem<X>((Item<X>)getParent(), path);
}

private boolean compareLocalPart(QName a, QName b) {
Expand Down
Expand Up @@ -252,7 +252,7 @@ public static <T extends PrismValue> Collection<T> resetParentCollection(Collect

public abstract Object find(ItemPath path);

public abstract <X extends PrismValue> PartiallyResolvedValue<X> findPartial(ItemPath path);
public abstract <X extends PrismValue> PartiallyResolvedItem<X> findPartial(ItemPath path);

@Override
public int hashCode() {
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -269,7 +269,7 @@ private <D extends ItemDelta, I extends Item> D findItemDelta(ItemPath propertyP

public <V extends PrismValue> PartiallyResolvedDelta<V> findPartial(ItemPath propertyPath) {
if (changeType == ChangeType.ADD) {
PartiallyResolvedValue<V> partialValue = objectToAdd.findPartial(propertyPath);
PartiallyResolvedItem<V> partialValue = objectToAdd.findPartial(propertyPath);
if (partialValue == null || partialValue.getItem() == null) {
return null;
}
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -181,15 +181,15 @@ public <X extends PrismValue> ItemDeltaItem<X> findIdi(ItemPath path) {
ItemPath subResidualPath = null;
ItemPath newResolvePath = resolvePath.subPath(path);
if (itemOld != null) {
PartiallyResolvedValue<X> partialItemOld = itemOld.findPartial(path);
PartiallyResolvedItem<X> partialItemOld = itemOld.findPartial(path);
if (partialItemOld != null) {
subItemOld = partialItemOld.getItem();
subResidualPath = partialItemOld.getResidualPath();
}
}
Item<X> subItemNew = null;
if (itemNew != null) {
PartiallyResolvedValue<X> partialItemNew = itemNew.findPartial(path);
PartiallyResolvedItem<X> partialItemNew = itemNew.findPartial(path);
if (partialItemNew != null) {
subItemNew = partialItemNew.getItem();
if (subResidualPath == null) {
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -105,15 +105,15 @@ public <V extends PrismValue> ItemDeltaItem<V> findIdi(ItemPath path) {
Item<V> subItemOld = null;
ItemPath subResidualPath = null;
if (oldObject != null) {
PartiallyResolvedValue<V> partialOld = oldObject.findPartial(path);
PartiallyResolvedItem<V> partialOld = oldObject.findPartial(path);
if (partialOld != null) {
subItemOld = partialOld.getItem();
subResidualPath = partialOld.getResidualPath();
}
}
Item<V> subItemNew = null;
if (newObject != null) {
PartiallyResolvedValue<V> partialNew = newObject.findPartial(path);
PartiallyResolvedItem<V> partialNew = newObject.findPartial(path);
if (partialNew != null) {
subItemNew = partialNew.getItem();
if (subResidualPath == null) {
Expand All @@ -126,7 +126,7 @@ public <V extends PrismValue> ItemDeltaItem<V> findIdi(ItemPath path) {
if (delta != null) {
if (delta.getChangeType() == ChangeType.ADD) {
PrismObject<T> objectToAdd = delta.getObjectToAdd();
PartiallyResolvedValue<V> partialValue = objectToAdd.findPartial(path);
PartiallyResolvedItem<V> partialValue = objectToAdd.findPartial(path);
if (partialValue != null && partialValue.getItem() != null) {
Item<V> item = partialValue.getItem();
itemDelta = item.createDelta();
Expand All @@ -135,8 +135,17 @@ public <V extends PrismValue> ItemDeltaItem<V> 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<V> partialValue = subItemOld.findPartial(subPath);
if (partialValue != null && partialValue.getItem() != null) {
Item<V> 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);
Expand Down

0 comments on commit a33a8ab

Please sign in to comment.