Search in sources :

Example 41 with ResourceShadowDiscriminator

use of com.evolveum.midpoint.schema.ResourceShadowDiscriminator in project midpoint by Evolveum.

the class ShadowDiscriminatorObjectDelta method createModificationReplaceProperty.

/**
     * Convenience method for quick creation of object deltas that replace a single object property. This is used quite often
     * to justify a separate method. 
     */
public static <O extends Objectable, X> ShadowDiscriminatorObjectDelta<O> createModificationReplaceProperty(Class<O> type, String resourceOid, ShadowKindType kind, String intent, ItemPath propertyPath, PrismContext prismContext, X... propertyValues) {
    ShadowDiscriminatorObjectDelta<O> objectDelta = new ShadowDiscriminatorObjectDelta<O>(type, ChangeType.MODIFY, prismContext);
    objectDelta.setDiscriminator(new ResourceShadowDiscriminator(resourceOid, kind, intent));
    fillInModificationReplaceProperty(objectDelta, propertyPath, propertyValues);
    return objectDelta;
}
Also used : ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator)

Example 42 with ResourceShadowDiscriminator

use of com.evolveum.midpoint.schema.ResourceShadowDiscriminator in project midpoint by Evolveum.

the class ChangeExecutor method prepareScripts.

private <F extends ObjectType, T extends ObjectType> OperationProvisioningScriptsType prepareScripts(PrismObject<T> changedObject, LensContext<F> context, LensElementContext<T> objectContext, ProvisioningOperationTypeType operation, ResourceType resource, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
    if (resource == null) {
        LOGGER.warn("Resource does not exist. Skipping processing scripts.");
        return null;
    }
    OperationProvisioningScriptsType resourceScripts = resource.getScripts();
    PrismObject<? extends ShadowType> resourceObject = (PrismObject<? extends ShadowType>) changedObject;
    PrismObject<F> user = null;
    if (context.getFocusContext() != null) {
        if (context.getFocusContext().getObjectNew() != null) {
            user = context.getFocusContext().getObjectNew();
        } else if (context.getFocusContext().getObjectOld() != null) {
            user = context.getFocusContext().getObjectOld();
        }
    }
    ResourceShadowDiscriminator discr = ((LensProjectionContext) objectContext).getResourceShadowDiscriminator();
    ExpressionVariables variables = Utils.getDefaultExpressionVariables(user, resourceObject, discr, resource.asPrismObject(), context.getSystemConfiguration(), objectContext);
    return evaluateScript(resourceScripts, discr, operation, null, variables, context, objectContext, task, result);
}
Also used : ExpressionVariables(com.evolveum.midpoint.repo.common.expression.ExpressionVariables) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator)

Example 43 with ResourceShadowDiscriminator

use of com.evolveum.midpoint.schema.ResourceShadowDiscriminator in project midpoint by Evolveum.

the class LensProjectionContext method getResourceObjectTypeDefinitionType.

public ResourceObjectTypeDefinitionType getResourceObjectTypeDefinitionType() {
    if (synchronizationPolicyDecision == SynchronizationPolicyDecision.BROKEN) {
        return null;
    }
    ResourceShadowDiscriminator discr = getResourceShadowDiscriminator();
    if (discr == null) {
        // maybe when an account is deleted
        return null;
    }
    if (resource == null) {
        return null;
    }
    ResourceObjectTypeDefinitionType def = ResourceTypeUtil.getResourceObjectTypeDefinitionType(resource, discr.getKind(), discr.getIntent());
    return def;
}
Also used : ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator)

Example 44 with ResourceShadowDiscriminator

use of com.evolveum.midpoint.schema.ResourceShadowDiscriminator in project midpoint by Evolveum.

the class LensProjectionContext method getHumanReadableName.

public String getHumanReadableName() {
    if (humanReadableName == null) {
        StringBuilder sb = new StringBuilder();
        sb.append("account(");
        String humanReadableAccountIdentifier = getHumanReadableIdentifier();
        if (StringUtils.isEmpty(humanReadableAccountIdentifier)) {
            sb.append("no ID");
        } else {
            sb.append("ID ");
            sb.append(humanReadableAccountIdentifier);
        }
        ResourceShadowDiscriminator discr = getResourceShadowDiscriminator();
        if (discr != null) {
            sb.append(", type '");
            sb.append(discr.getIntent());
            sb.append("', ");
            if (discr.getOrder() != 0) {
                sb.append("order ").append(discr.getOrder()).append(", ");
            }
        } else {
            sb.append(" (no discriminator) ");
        }
        sb.append(getResource());
        sb.append(")");
        humanReadableName = sb.toString();
    }
    return humanReadableName;
}
Also used : ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator)

Example 45 with ResourceShadowDiscriminator

use of com.evolveum.midpoint.schema.ResourceShadowDiscriminator in project midpoint by Evolveum.

the class LensUtil method setContextOid.

public static <T extends ObjectType, F extends ObjectType> void setContextOid(LensContext<F> context, LensElementContext<T> objectContext, String oid) {
    objectContext.setOid(oid);
    // Check if we need to propagate this oid also to higher-order contexts
    if (!(objectContext instanceof LensProjectionContext)) {
        return;
    }
    LensProjectionContext refProjCtx = (LensProjectionContext) objectContext;
    ResourceShadowDiscriminator refDiscr = refProjCtx.getResourceShadowDiscriminator();
    if (refDiscr == null) {
        return;
    }
    for (LensProjectionContext aProjCtx : context.getProjectionContexts()) {
        ResourceShadowDiscriminator aDiscr = aProjCtx.getResourceShadowDiscriminator();
        if (aDiscr != null && refDiscr.equivalent(aDiscr) && (refDiscr.getOrder() < aDiscr.getOrder())) {
            aProjCtx.setOid(oid);
        }
    }
}
Also used : ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator)

Aggregations

ResourceShadowDiscriminator (com.evolveum.midpoint.schema.ResourceShadowDiscriminator)78 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)41 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)34 Task (com.evolveum.midpoint.task.api.Task)30 Test (org.testng.annotations.Test)30 LensProjectionContext (com.evolveum.midpoint.model.impl.lens.LensProjectionContext)28 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)18 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)17 ResourceObjectShadowChangeDescription (com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription)17 ModelProjectionContext (com.evolveum.midpoint.model.api.context.ModelProjectionContext)11 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)10 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)10 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)9 ModelExecuteOptions (com.evolveum.midpoint.model.api.ModelExecuteOptions)9 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)9 AbstractInternalModelIntegrationTest (com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)8 MockLensDebugListener (com.evolveum.midpoint.model.impl.util.mock.MockLensDebugListener)8 PrismObject (com.evolveum.midpoint.prism.PrismObject)8 QName (javax.xml.namespace.QName)7 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)6