Search in sources :

Example 81 with ActivationType

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

the class TestActivationComputerDefault method testGetDraftAdministrativeEnabled.

@Test
public void testGetDraftAdministrativeEnabled() {
    // GIVEN
    Clock clock = createClock(YEAR_START);
    ActivationComputer activationComputer = createActivationComputer(clock);
    ActivationType activationType = createActivationType(ActivationStatusType.DISABLED, SPRING_EQUINOX, AUTUMN_EQUINOX);
    // WHEN
    ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(SchemaConstants.LIFECYCLE_DRAFT, activationType, createLifecycleModel());
    // THEN
    assertEquals("Unexpected effective status", ActivationStatusType.DISABLED, effectiveStatus);
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) ActivationStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType) Test(org.testng.annotations.Test)

Example 82 with ActivationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType 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 83 with ActivationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType 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)

Example 84 with ActivationType

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

the class AbstractModelIntegrationTest method getActivation.

protected ActivationType getActivation(PrismObject<? extends ObjectType> obj) {
    ObjectType objectType = obj.asObjectable();
    ActivationType activation;
    if (objectType instanceof ShadowType) {
        activation = ((ShadowType) objectType).getActivation();
    } else if (objectType instanceof UserType) {
        activation = ((UserType) objectType).getActivation();
    } else {
        throw new IllegalArgumentException("Cannot get activation from " + obj);
    }
    assertNotNull("No activation in " + obj, activation);
    return activation;
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)

Example 85 with ActivationType

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

the class AbstractModelIntegrationTest method createAccount.

protected PrismObject<ShadowType> createAccount(PrismObject<ResourceType> resource, String name, boolean enabled) throws SchemaException {
    PrismObject<ShadowType> shadow = getShadowDefinition().instantiate();
    ShadowType shadowType = shadow.asObjectable();
    ObjectReferenceType resourceRef = new ObjectReferenceType();
    resourceRef.setOid(resource.getOid());
    shadowType.setResourceRef(resourceRef);
    ResourceSchema refinedSchema = ResourceSchemaFactory.getCompleteSchema(resource);
    ResourceObjectTypeDefinition objectClassDefinition = refinedSchema.findDefaultOrAnyObjectTypeDefinition(ShadowKindType.ACCOUNT);
    shadowType.setObjectClass(objectClassDefinition.getTypeName());
    shadowType.setKind(ShadowKindType.ACCOUNT);
    ResourceAttributeContainer attrCont = ShadowUtil.getOrCreateAttributesContainer(shadow, objectClassDefinition);
    ResourceAttributeDefinition<?> idSecondaryDef = objectClassDefinition.getSecondaryIdentifiers().iterator().next();
    ResourceAttribute icfsNameAttr = idSecondaryDef.instantiate();
    icfsNameAttr.setRealValue(name);
    attrCont.add(icfsNameAttr);
    ActivationType activation = new ActivationType();
    shadowType.setActivation(activation);
    if (enabled) {
        activation.setAdministrativeStatus(ActivationStatusType.ENABLED);
    } else {
        activation.setAdministrativeStatus(ActivationStatusType.DISABLED);
    }
    return shadow;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)

Aggregations

ActivationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)76 Test (org.testng.annotations.Test)48 ActivationStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType)40 AbstractUnitTest (com.evolveum.midpoint.tools.testng.AbstractUnitTest)13 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)11 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)10 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)9 Task (com.evolveum.midpoint.task.api.Task)9 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)8 PrismObject (com.evolveum.midpoint.prism.PrismObject)7 MetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType)7 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)7 LockoutStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType)6 ActivationCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)6 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)6 ActivationStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)5 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)4 TimeIntervalStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType)4 ActivationLockoutStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationLockoutStatusCapabilityType)4 QName (javax.xml.namespace.QName)4