use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.
the class ContainerDelta method expand.
/**
* Post processing of delta to expand missing values from the object. E.g. a delete deltas may
* be "id-only" so they contain only id of the value to delete. In such case locate the full value
* in the object and fill it into the delta.
* This method may even delete in-only values that are no longer present in the object.
*/
public <O extends Objectable> void expand(PrismObject<O> object) throws SchemaException {
if (valuesToDelete != null) {
ItemPath path = this.getPath();
PrismContainer<Containerable> container = null;
if (object != null) {
container = object.findContainer(path);
}
Iterator<PrismContainerValue<V>> iterator = valuesToDelete.iterator();
while (iterator.hasNext()) {
PrismContainerValue<V> deltaCVal = iterator.next();
if ((deltaCVal.getItems() == null || deltaCVal.getItems().isEmpty())) {
Long id = deltaCVal.getId();
if (id == null) {
throw new IllegalArgumentException("No id and no items in value " + deltaCVal + " in delete set in " + this);
}
if (container != null) {
PrismContainerValue<Containerable> containerCVal = container.findValue(id);
if (containerCVal != null) {
for (Item<?, ?> containerItem : containerCVal.getItems()) {
deltaCVal.add(containerItem.clone());
}
continue;
}
}
// id-only value with ID that is not in the object any more: delete the value from delta
iterator.remove();
}
}
}
}
use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.
the class ItemDelta method applyDefinition.
public static void applyDefinition(Collection<? extends ItemDelta> deltas, PrismObjectDefinition definition) throws SchemaException {
for (ItemDelta itemDelta : deltas) {
ItemPath path = itemDelta.getPath();
ItemDefinition itemDefinition = definition.findItemDefinition(path, ItemDefinition.class);
if (itemDefinition == null) {
throw new SchemaException("Object type " + definition.getTypeName() + " doesn't contain definition for path " + new XPathHolder(path).getXPathWithDeclarations(false));
}
itemDelta.applyDefinition(itemDefinition);
}
}
use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.
the class ItemDelta method accept.
public static void accept(Collection<? extends ItemDelta> modifications, Visitor visitor, ItemPath path, boolean recursive) {
for (ItemDelta modification : modifications) {
ItemPath modPath = modification.getPath();
CompareResult rel = modPath.compareComplex(path);
if (rel == CompareResult.EQUIVALENT) {
modification.accept(visitor, null, recursive);
} else if (rel == CompareResult.SUBPATH) {
modification.accept(visitor, path.substract(modPath), recursive);
}
}
}
use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.
the class ObjectDelta method applyDefinition.
public void applyDefinition(PrismObjectDefinition<T> objectDefinition, boolean force) throws SchemaException {
if (objectToAdd != null) {
objectToAdd.applyDefinition(objectDefinition, force);
}
if (modifications != null) {
for (ItemDelta modification : modifications) {
ItemPath path = modification.getPath();
ItemDefinition itemDefinition = objectDefinition.findItemDefinition(path);
modification.applyDefinition(itemDefinition, force);
}
}
}
use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.
the class ObjectTypeUtil method isModificationOf.
//TODO: refactor after new schema
public static boolean isModificationOf(ItemDeltaType modification, QName elementName, ItemPathType path) {
// if (path == null && XPathHolder.isDefault(modification.getPath())) {
// return (elementName.equals(ObjectTypeUtil.getElementName(modification)));
// }
ItemPathType modificationPath = modification.getPath();
if (ItemPathUtil.isDefault(modificationPath)) {
throw new IllegalArgumentException("Path in the delta must not be null");
}
if (path == null) {
return false;
}
// XPathHolder modPath = new XPathHolder(modification.getPath());
ItemPath full = new ItemPath(path.getItemPath(), elementName);
ItemPathType fullPath = new ItemPathType(full);
return fullPath.equivalent(modificationPath);
// if (fullPath.equals(modificationPath)) {
// return (elementName.equals(getElementName(modification)));
// }
// return false;
}
Aggregations