Skip to content

Commit

Permalink
Fix another place when storing PCVs to traces
Browse files Browse the repository at this point in the history
Identified and fixed one more place where real values are obtained.
Traces with static-schema-less PCVs will be hopefully written
correctly now.
  • Loading branch information
mederly committed Mar 20, 2020
1 parent 0c8f92f commit ec31107
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
Expand Up @@ -13,6 +13,7 @@
import com.evolveum.midpoint.prism.path.ItemName;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.annotation.Experimental;
import com.evolveum.midpoint.util.exception.SchemaException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -231,6 +232,18 @@ public interface Item<V extends PrismValue, D extends ItemDefinition> extends It
@NotNull
Collection<?> getRealValues();

@Experimental
@NotNull
default Collection<Object> getRealValuesOrRawTypes(PrismContext prismContext) {
List<Object> rv = new ArrayList<>();
for (V value : getValues()) {
if (value != null) {
rv.add(value.getRealValueOrRawType(prismContext));
}
}
return rv;
}

/**
* Returns true if the item contains 0 or 1 values and (by definition) is not multivalued.
*/
Expand Down
Expand Up @@ -94,11 +94,11 @@ public String toString() {
'}';
}

public static ItemType fromItem(Item item) {
public static ItemType fromItem(Item item, PrismContext prismContext) {
if (item != null) {
ItemType rv = new ItemType();
rv.setName(item.getElementName());
rv.value.addAll(item.getRealValues());
rv.value.addAll(item.getRealValuesOrRawTypes(prismContext));
return rv;
} else {
return null;
Expand Down
Expand Up @@ -479,7 +479,7 @@ private void traceSources() throws SchemaException {
for (Source<?, ?> source : sources) {
MappingSourceEvaluationTraceType sourceTrace = new MappingSourceEvaluationTraceType(prismContext);
sourceTrace.setName(source.getName());
sourceTrace.setItemDeltaItem(source.toItemDeltaItemType());
sourceTrace.setItemDeltaItem(source.toItemDeltaItemType(prismContext));
trace.getSource().add(sourceTrace);
}
}
Expand Down
Expand Up @@ -10,6 +10,7 @@

import com.evolveum.midpoint.prism.Item;
import com.evolveum.midpoint.prism.ItemDefinition;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismValue;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.util.ItemDeltaItem;
Expand Down Expand Up @@ -90,14 +91,14 @@ public String debugDump(int indent) {
}

@NotNull
public ItemDeltaItemType toItemDeltaItemType() throws SchemaException {
public ItemDeltaItemType toItemDeltaItemType(PrismContext prismContext) throws SchemaException {
ItemDeltaItemType rv = new ItemDeltaItemType();
rv.setOldItem(ItemType.fromItem(getItemOld()));
rv.setOldItem(ItemType.fromItem(getItemOld(), prismContext));
ItemDelta<V, D> delta = getDelta();
if (delta != null) {
rv.getDelta().addAll(DeltaConvertor.toItemDeltaTypes(delta));
}
rv.setNewItem(ItemType.fromItem(getItemNew()));
rv.setNewItem(ItemType.fromItem(getItemNew(), prismContext));
return rv;
}
}

0 comments on commit ec31107

Please sign in to comment.