Search in sources :

Example 6 with TimeIntervalStatusType

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

the class AbstractActivationComputerTest method testCompute.

protected void testCompute(String lifecycleState, XMLGregorianCalendar now, ActivationStatusType administrativeStatus, XMLGregorianCalendar validFrom, XMLGregorianCalendar validTo, ActivationStatusType expectedEffective, TimeIntervalStatusType expectedValidity) throws SchemaException, IOException {
    // GIVEN
    Clock clock = createClock(now);
    ActivationComputer activationComputer = createActivationComputer(clock);
    ActivationType activationType = createActivationType(administrativeStatus, validFrom, validTo);
    // WHEN
    activationComputer.computeEffective(lifecycleState, activationType, createLifecycleModel());
    // THEN
    assertEquals("Unexpected effective status", expectedEffective, activationType.getEffectiveStatus());
    assertEquals("Unexpected validity status", expectedValidity, activationType.getValidityStatus());
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)

Example 7 with TimeIntervalStatusType

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

the class ActivationComputer method getEffectiveStatus.

public ActivationStatusType getEffectiveStatus(String lifecycleStatus, ActivationType activationType, TimeIntervalStatusType validityStatus, LifecycleStateModelType stateModel) {
    ActivationStatusType forcedLifecycleActivationStatus = getForcedLifecycleActivationStatus(lifecycleStatus, stateModel);
    if (forcedLifecycleActivationStatus != null) {
        return forcedLifecycleActivationStatus;
    }
    if (activationType == null) {
        return ActivationStatusType.ENABLED;
    }
    ActivationStatusType administrativeStatus = activationType.getAdministrativeStatus();
    if (administrativeStatus != null) {
        // Explicit administrative status overrides everything
        return administrativeStatus;
    }
    if (validityStatus == null) {
        // No administrative status, no validity. Return default.
        return ActivationStatusType.ENABLED;
    }
    switch(validityStatus) {
        case AFTER:
        case BEFORE:
            return ActivationStatusType.DISABLED;
        case IN:
            return ActivationStatusType.ENABLED;
    }
    // This should not happen
    return null;
}
Also used : ActivationStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType)

Example 8 with TimeIntervalStatusType

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

the class ActivationComputer method computeEffective.

public void computeEffective(String lifecycleStatus, ActivationType activationType, XMLGregorianCalendar referenceTime, LifecycleStateModelType stateModel) {
    ActivationStatusType effectiveStatus = getForcedLifecycleActivationStatus(lifecycleStatus, stateModel);
    ActivationStatusType administrativeStatus = activationType.getAdministrativeStatus();
    if (effectiveStatus == null && administrativeStatus != null) {
        // Explicit administrative status overrides everything
        effectiveStatus = administrativeStatus;
    }
    TimeIntervalStatusType validityStatus = getValidityStatus(activationType);
    if (effectiveStatus == null) {
        if (validityStatus == null) {
            // No administrative status, no validity. Defaults to enabled.
            effectiveStatus = ActivationStatusType.ENABLED;
        } else {
            switch(validityStatus) {
                case AFTER:
                case BEFORE:
                    effectiveStatus = ActivationStatusType.DISABLED;
                    break;
                case IN:
                    effectiveStatus = ActivationStatusType.ENABLED;
                    break;
            }
        }
    }
    activationType.setEffectiveStatus(effectiveStatus);
    activationType.setValidityStatus(validityStatus);
}
Also used : TimeIntervalStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType) ActivationStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType)

Aggregations

ActivationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)5 ActivationStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType)4 TimeIntervalStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType)4 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)2 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1