Skip to content

Commit

Permalink
Fix SimulationResultProcessedObjectType parsing
Browse files Browse the repository at this point in the history
1. Fixed null delta handling.
2. Temporarily disabled parsing of before/after full object state (until
it's implemented in the repository).
  • Loading branch information
mederly committed Dec 20, 2022
1 parent 3a3331a commit 18236e8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType;
import com.evolveum.prism.xml.ns._public.types_3.*;

import org.jetbrains.annotations.Nullable;

/**
* Converts between "XML" (i.e. XML/JSON/YAML/bean) and "native" (ObjectDelta and company) form.
*
Expand Down Expand Up @@ -85,6 +87,13 @@ public static <T extends Objectable> ObjectDelta<T> createObjectDelta(
return createObjectDelta(deltaBean);
}

@Contract("null -> null; !null -> !null")
public static <T extends Objectable> ObjectDelta<T> createObjectDeltaNullable(@Nullable ObjectDeltaType objectDeltaBean)
throws SchemaException {
return objectDeltaBean != null ?
createObjectDelta(objectDeltaBean) : null;
}

/**
* Object delta: XML -> native
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private ProcessedObject(
this.delta = delta;
}

public static <O extends ObjectType> ProcessedObject<O> parse(@NotNull SimulationResultProcessedObjectType bean)
public static <O extends ObjectType> ProcessedObject<O> parse(@NotNull SimulationResultProcessedObjectType bean)
throws SchemaException {
Class<?> type = PrismContext.get().getSchemaRegistry().determineClassForTypeRequired(bean.getType());
argCheck(ObjectType.class.isAssignableFrom(type), "Type is not an ObjectType: %s", type);
Expand All @@ -91,9 +91,9 @@ public static <O extends ObjectType> ProcessedObject<O> parse(@NotNull Simulati
bean.getName(),
MiscUtil.argNonNull(bean.getState(), () -> "No processing state in " + bean),
bean.getMetricIdentifier(),
(O) bean.getBefore(),
(O) bean.getAfter(),
DeltaConvertor.createObjectDelta(bean.getDelta()));
null, // (O) bean.getBefore(), // temporarily disabled
null, // (O) bean.getAfter(), // temporarily disabled
DeltaConvertor.createObjectDeltaNullable(bean.getDelta()));
}

public static <O extends ObjectType> ProcessedObject<?> create(
Expand Down

0 comments on commit 18236e8

Please sign in to comment.