use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.CompareResultType in project midpoint by Evolveum.
the class ModelController method compareObject.
@Override
public <T extends ObjectType> CompareResultType compareObject(PrismObject<T> provided, Collection<SelectorOptions<GetOperationOptions>> readOptions, ModelCompareOptions compareOptions, @NotNull List<ItemPath> ignoreItems, Task task, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
Validate.notNull(provided, "Object must not be null or empty.");
Validate.notNull(parentResult, "Operation result must not be null.");
OperationResult result = parentResult.createMinorSubresult(COMPARE_OBJECT);
result.addParam("oid", provided.getOid());
result.addParam("name", provided.getName());
result.addCollectionOfSerializablesAsParam("readOptions", readOptions);
result.addParam("compareOptions", compareOptions);
result.addCollectionOfSerializablesAsParam("ignoreItems", ignoreItems);
CompareResultType rv = new CompareResultType();
try {
boolean c2p = ModelCompareOptions.isComputeCurrentToProvided(compareOptions);
boolean p2c = ModelCompareOptions.isComputeProvidedToCurrent(compareOptions);
boolean returnC = ModelCompareOptions.isReturnCurrent(compareOptions);
boolean returnP = ModelCompareOptions.isReturnNormalized(compareOptions);
boolean ignoreOperational = ModelCompareOptions.isIgnoreOperationalItems(compareOptions);
if (!c2p && !p2c && !returnC && !returnP) {
return rv;
}
PrismObject<T> current = null;
if (c2p || p2c || returnC) {
current = fetchCurrentObject(provided.getCompileTimeClass(), provided.getOid(), provided.getName(), readOptions, task, result);
removeIgnoredItems(current, ignoreItems);
if (ignoreOperational) {
removeOperationalItems(current);
}
}
removeIgnoredItems(provided, ignoreItems);
if (ignoreOperational) {
removeOperationalItems(provided);
}
if (c2p) {
rv.setCurrentToProvided(DeltaConvertor.toObjectDeltaType(DiffUtil.diff(current, provided)));
}
if (p2c) {
rv.setProvidedToCurrent(DeltaConvertor.toObjectDeltaType(DiffUtil.diff(provided, current)));
}
if (returnC && current != null) {
rv.setCurrentObject(current.asObjectable());
}
if (returnP) {
rv.setNormalizedObject(provided.asObjectable());
}
} finally {
result.computeStatus();
result.cleanupResult();
}
return rv;
}
Aggregations