Search in sources :

Example 1 with SynchronizationSituationDescriptionType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationDescriptionType in project midpoint by Evolveum.

the class SynchronizationUtils method createSynchronizationSituationDescriptionDelta.

public static List<PropertyDelta<?>> createSynchronizationSituationDescriptionDelta(PrismObject object, SynchronizationSituationType situation, XMLGregorianCalendar timestamp, String sourceChannel, boolean full) {
    SynchronizationSituationDescriptionType syncSituationDescription = new SynchronizationSituationDescriptionType();
    syncSituationDescription.setSituation(situation);
    syncSituationDescription.setChannel(sourceChannel);
    syncSituationDescription.setTimestamp(timestamp);
    syncSituationDescription.setFull(full);
    List<PropertyDelta<?>> deltas = new ArrayList<PropertyDelta<?>>();
    PropertyDelta syncSituationDelta = PropertyDelta.createDelta(new ItemPath(ShadowType.F_SYNCHRONIZATION_SITUATION_DESCRIPTION), object.getDefinition());
    syncSituationDelta.addValueToAdd(new PrismPropertyValue(syncSituationDescription));
    deltas.add(syncSituationDelta);
    List<PrismPropertyValue<SynchronizationSituationDescriptionType>> oldSituationDescriptions = getSituationFromSameChannel(object, sourceChannel);
    if (oldSituationDescriptions != null && !oldSituationDescriptions.isEmpty()) {
        syncSituationDelta = PropertyDelta.createDelta(new ItemPath(ShadowType.F_SYNCHRONIZATION_SITUATION_DESCRIPTION), object.getDefinition());
        syncSituationDelta.addValuesToDelete(oldSituationDescriptions);
        deltas.add(syncSituationDelta);
    }
    return deltas;
}
Also used : ArrayList(java.util.ArrayList) SynchronizationSituationDescriptionType(com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationDescriptionType) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Example 2 with SynchronizationSituationDescriptionType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationDescriptionType in project midpoint by Evolveum.

the class SynchronizationUtils method getSituationFromSameChannel.

private static List<PrismPropertyValue<SynchronizationSituationDescriptionType>> getSituationFromSameChannel(PrismObject prismObject, String channel) {
    ShadowType target = (ShadowType) prismObject.asObjectable();
    List<SynchronizationSituationDescriptionType> syncSituationDescriptions = ((ShadowType) target).getSynchronizationSituationDescription();
    List<PrismPropertyValue<SynchronizationSituationDescriptionType>> valuesToDelete = new ArrayList<PrismPropertyValue<SynchronizationSituationDescriptionType>>();
    if (syncSituationDescriptions == null || syncSituationDescriptions.isEmpty()) {
        return null;
    }
    for (SynchronizationSituationDescriptionType syncSituationDescription : syncSituationDescriptions) {
        if (StringUtils.isEmpty(syncSituationDescription.getChannel()) && StringUtils.isEmpty(channel)) {
            valuesToDelete.add(new PrismPropertyValue<SynchronizationSituationDescriptionType>(syncSituationDescription));
            continue;
        // return syncSituationDescription;
        }
        if ((StringUtils.isEmpty(syncSituationDescription.getChannel()) && channel != null) || (StringUtils.isEmpty(channel) && syncSituationDescription.getChannel() != null)) {
            // return null;
            continue;
        }
        if (syncSituationDescription.getChannel().equals(channel)) {
            valuesToDelete.add(new PrismPropertyValue<SynchronizationSituationDescriptionType>(syncSituationDescription));
            continue;
        // return syncSituationDescription;
        }
    }
    return valuesToDelete;
}
Also used : ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ArrayList(java.util.ArrayList) SynchronizationSituationDescriptionType(com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationDescriptionType) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Aggregations

PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)2 SynchronizationSituationDescriptionType (com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationDescriptionType)2 ArrayList (java.util.ArrayList)2 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)1