Skip to content

Commit

Permalink
Add backend support for "missing est. old values"
Browse files Browse the repository at this point in the history
ProcessedObject#fixEstimatedOldValuesInDelta can be called to provide
missing "estimated old values" in simulated deltas.

Related to MID-8536.
  • Loading branch information
mederly committed Apr 5, 2023
1 parent 3aefd8b commit 1d43489
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ public interface ProcessedObject<O extends ObjectType> extends DebugDumpable, Se
*/
@Nullable ObjectDelta<O> getDelta();

/**
* Resolves "estimated old values" for item deltas where they are not known.
*
* TEMPORARY; see MID-8536. This will be part of standard processing but because of code freeze doing it as separate code.
*/
void fixEstimatedOldValuesInDelta();

default O getAfterOrBefore() {
return MiscUtil.getFirstNonNull(getAfter(), getBefore());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,24 @@ public void applyDefinitions(@NotNull Task task, @NotNull OperationResult result
}
}

@Override
public void fixEstimatedOldValuesInDelta() {
if (!ObjectDelta.isModify(delta) || before == null) {
return;
}

for (ItemDelta<?, ?> modification : delta.getModifications()) {
if (modification.getEstimatedOldValues() == null) {
ItemPath path = modification.getPath();
var item = before.asPrismContainerValue().findItem(path);
//noinspection unchecked
modification.setEstimatedOldValues(
item != null ?
item.getClonedValues() : List.of());
}
}
}

class ProcessedObjectItemDeltaImpl<V extends PrismValue, D extends ItemDefinition<?>>
implements ItemDeltaDelegator<V, D>, ProcessedObjectItemDelta<V, D> {

Expand Down

0 comments on commit 1d43489

Please sign in to comment.