Search in sources :

Example 1 with MergeDeltas

use of com.evolveum.midpoint.model.api.util.MergeDeltas in project midpoint by Evolveum.

the class ObjectMerger method computeMergeDeltas.

public <O extends ObjectType> MergeDeltas<O> computeMergeDeltas(Class<O> type, String leftOid, String rightOid, final String mergeConfigurationName, final Task task, final OperationResult result) throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException {
    final PrismObject<O> objectLeft = (PrismObject<O>) objectResolver.getObjectSimple(type, leftOid, null, task, result).asPrismObject();
    final PrismObject<O> objectRight = (PrismObject<O>) objectResolver.getObjectSimple(type, rightOid, null, task, result).asPrismObject();
    PrismObject<SystemConfigurationType> systemConfiguration = systemObjectCache.getSystemConfiguration(result);
    MergeConfigurationType mergeConfiguration = selectConfiguration(systemConfiguration, mergeConfigurationName);
    if (mergeConfiguration == null) {
        throw new ConfigurationException("No merge configuration defined");
    }
    // The "left" object is always the one that will be the result. We will use its OID.
    final ObjectDelta<O> leftObjectDelta = objectLeft.createModifyDelta();
    final ObjectDelta<O> leftLinkDelta = objectLeft.createModifyDelta();
    final ObjectDelta<O> rightLinkDelta = objectRight.createModifyDelta();
    final List<ItemPath> processedPaths = new ArrayList<>();
    computeItemDeltas(leftObjectDelta, objectLeft, objectRight, processedPaths, mergeConfiguration, mergeConfigurationName, task, result);
    computeDefaultDeltas(leftObjectDelta, objectLeft, objectRight, processedPaths, mergeConfiguration, mergeConfigurationName, task, result);
    computeProjectionDeltas(leftLinkDelta, rightLinkDelta, objectLeft, objectRight, mergeConfiguration, mergeConfigurationName, task, result);
    return new MergeDeltas<>(leftObjectDelta, leftLinkDelta, rightLinkDelta);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) MergeDeltas(com.evolveum.midpoint.model.api.util.MergeDeltas) ProjectionMergeConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ProjectionMergeConfigurationType) ItemRefMergeConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ItemRefMergeConfigurationType) MergeConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.MergeConfigurationType) ItemMergeConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ItemMergeConfigurationType) ArrayList(java.util.ArrayList) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

MergeDeltas (com.evolveum.midpoint.model.api.util.MergeDeltas)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)1 ItemMergeConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ItemMergeConfigurationType)1 ItemRefMergeConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ItemRefMergeConfigurationType)1 MergeConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.MergeConfigurationType)1 ProjectionMergeConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ProjectionMergeConfigurationType)1 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)1 ArrayList (java.util.ArrayList)1