Search in sources :

Example 16 with ObjectTemplateType

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

the class PersonaProcessor method personaModify.

public <F extends FocusType, T extends FocusType> void personaModify(LensContext<F> context, PersonaKey key, PersonaConstruction<F> construction, PrismObject<T> existingPersona, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, PolicyViolationException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException {
    PrismObject<F> focus = context.getFocusContext().getObjectNew();
    LOGGER.debug("Modifying persona {} for {} using construction {}", key, focus, construction);
    PersonaConstructionType constructionType = construction.getConstructionType();
    ObjectReferenceType objectMappingRef = constructionType.getObjectMappingRef();
    ObjectTemplateType objectMappingType = objectResolver.resolve(objectMappingRef, ObjectTemplateType.class, null, "object mapping in persona construction in " + focus, task, result);
    ObjectDeltaObject<F> focusOdo = context.getFocusContext().getObjectDeltaObject();
    String contextDesc = "object mapping " + objectMappingType + " for persona construction for " + focus;
    XMLGregorianCalendar now = clock.currentTimeXMLGregorianCalendar();
    Collection<ItemDelta<?, ?>> itemDeltas = objectTemplateProcessor.processObjectMapping(context, objectMappingType, focusOdo, existingPersona, null, contextDesc, now, task, result);
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("itemDeltas:\n{}", DebugUtil.debugDump(itemDeltas));
    }
    ObjectDelta<T> targetDelta = existingPersona.createModifyDelta();
    for (ItemDelta itemDelta : itemDeltas) {
        targetDelta.addModification(itemDelta);
    }
    executePersonaDelta(targetDelta, task, result);
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ObjectTemplateType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType) PersonaConstructionType(com.evolveum.midpoint.xml.ns._public.common.common_3.PersonaConstructionType) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta)

Example 17 with ObjectTemplateType

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

the class SynchronizationServiceImpl method createLensContext.

@NotNull
private <F extends FocusType> LensContext<F> createLensContext(Class<F> focusClass, ResourceObjectShadowChangeDescription change, SynchronizationReactionType reactionDefinition, ObjectSynchronizationType synchronizationPolicy, SynchronizationSituation<F> situation, ModelExecuteOptions options, PrismObject<SystemConfigurationType> configuration, OperationResult parentResult) throws ObjectNotFoundException, SchemaException {
    LensContext<F> context = contextFactory.createSyncContext(focusClass, change);
    context.setLazyAuditRequest(true);
    context.setSystemConfiguration(configuration);
    context.setOptions(options);
    ResourceType resource = change.getResource().asObjectable();
    if (ModelExecuteOptions.isLimitPropagation(options)) {
        context.setTriggeredResource(resource);
    }
    context.rememberResource(resource);
    PrismObject<ShadowType> shadow = getShadowFromChange(change);
    if (InternalsConfig.consistencyChecks)
        shadow.checkConsistence();
    // Projection context
    ShadowKindType kind = getKind(shadow, synchronizationPolicy);
    String intent = getIntent(shadow, synchronizationPolicy);
    boolean thombstone = isThombstone(change);
    ResourceShadowDiscriminator descr = new ResourceShadowDiscriminator(resource.getOid(), kind, intent, thombstone);
    LensProjectionContext projectionContext = context.createProjectionContext(descr);
    projectionContext.setResource(resource);
    projectionContext.setOid(getOidFromChange(change));
    projectionContext.setSynchronizationSituationDetected(situation.getSituation());
    // insert object delta if available in change
    ObjectDelta<? extends ShadowType> delta = change.getObjectDelta();
    if (delta != null) {
        projectionContext.setSyncDelta((ObjectDelta<ShadowType>) delta);
    } else {
        projectionContext.setSyncAbsoluteTrigger(true);
    }
    // we insert account if available in change
    PrismObject<ShadowType> currentAccount = shadow;
    if (currentAccount != null) {
        projectionContext.setLoadedObject(currentAccount);
        if (!thombstone) {
            projectionContext.setFullShadow(true);
        }
        projectionContext.setFresh(true);
    }
    if (delta != null && delta.isDelete()) {
        projectionContext.setExists(false);
    } else {
        projectionContext.setExists(true);
    }
    projectionContext.setDoReconciliation(ModelExecuteOptions.isReconcile(options));
    // Focus context
    if (situation.getCurrentOwner() != null) {
        F focusType = situation.getCurrentOwner();
        LensFocusContext<F> focusContext = context.createFocusContext();
        PrismObject<F> focusOld = (PrismObject<F>) focusType.asPrismObject();
        focusContext.setLoadedObject(focusOld);
    }
    // Global stuff
    ObjectReferenceType objectTemplateRef = null;
    if (reactionDefinition.getObjectTemplateRef() != null) {
        objectTemplateRef = reactionDefinition.getObjectTemplateRef();
    } else if (synchronizationPolicy.getObjectTemplateRef() != null) {
        objectTemplateRef = synchronizationPolicy.getObjectTemplateRef();
    }
    if (objectTemplateRef != null) {
        ObjectTemplateType objectTemplate = repositoryService.getObject(ObjectTemplateType.class, objectTemplateRef.getOid(), null, parentResult).asObjectable();
        context.setFocusTemplate(objectTemplate);
    }
    return context;
}
Also used : ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ObjectTemplateType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) NotNull(org.jetbrains.annotations.NotNull)

Example 18 with ObjectTemplateType

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

the class TestParseObjectTemplate method assertObjectTemplatePrism.

private void assertObjectTemplatePrism(PrismObject<ObjectTemplateType> object, QName elementName) {
    assertEquals("Wrong oid", "10000000-0000-0000-0000-000000000002", object.getOid());
    PrismObjectDefinition<ObjectTemplateType> objectDefinition = object.getDefinition();
    assertNotNull("No object definition", objectDefinition);
    PrismAsserts.assertObjectDefinition(objectDefinition, elementName, ObjectTemplateType.COMPLEX_TYPE, ObjectTemplateType.class);
    assertEquals("Wrong class", ObjectTemplateType.class, object.getCompileTimeClass());
    assertEquals("Wrong object item name", elementName, object.getElementName());
    ObjectTemplateType objectType = object.asObjectable();
    assertNotNull("asObjectable resulted in null", objectType);
    assertPropertyValue(object, "name", PrismTestUtil.createPolyString("Default User Template"));
    assertPropertyDefinition(object, "name", PolyStringType.COMPLEX_TYPE, 0, 1);
    assertPropertyDefinition(object, "mapping", ObjectTemplateMappingType.COMPLEX_TYPE, 0, -1);
}
Also used : ObjectTemplateType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType)

Example 19 with ObjectTemplateType

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

the class ObjectTemplateProcessor method collectTripleFromTemplate.

private <F extends FocusType, T extends FocusType> XMLGregorianCalendar collectTripleFromTemplate(LensContext<F> context, ObjectTemplateType objectTemplateType, ObjectTemplateMappingEvaluationPhaseType phase, ObjectDeltaObject<F> focusOdo, PrismObject<T> target, Map<ItemPath, DeltaSetTriple<? extends ItemValueWithOrigin<?, ?>>> outputTripleMap, int iteration, String iterationToken, XMLGregorianCalendar now, String contextDesc, Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, PolicyViolationException {
    LOGGER.trace("Collecting triples from {}", objectTemplateType);
    XMLGregorianCalendar nextRecomputeTime = null;
    // Process includes
    for (ObjectReferenceType includeRef : objectTemplateType.getIncludeRef()) {
        PrismObject<ObjectTemplateType> includeObject = includeRef.asReferenceValue().getObject();
        if (includeObject == null) {
            ObjectTemplateType includeObjectType = modelObjectResolver.resolve(includeRef, ObjectTemplateType.class, null, "include reference in " + objectTemplateType + " in " + contextDesc, task, result);
            includeObject = includeObjectType.asPrismObject();
            // Store resolved object for future use (e.g. next waves).
            includeRef.asReferenceValue().setObject(includeObject);
        }
        LOGGER.trace("Including template {}", includeObject);
        ObjectTemplateType includeObjectType = includeObject.asObjectable();
        XMLGregorianCalendar includeNextRecomputeTime = collectTripleFromTemplate(context, includeObjectType, phase, focusOdo, target, outputTripleMap, iteration, iterationToken, now, "include " + includeObject + " in " + objectTemplateType + " in " + contextDesc, task, result);
        if (includeNextRecomputeTime != null) {
            if (nextRecomputeTime == null || nextRecomputeTime.compare(includeNextRecomputeTime) == DatatypeConstants.GREATER) {
                nextRecomputeTime = includeNextRecomputeTime;
            }
        }
    }
    // Process own mappings
    List<ObjectTemplateMappingType> mappings = collectMappings(objectTemplateType);
    List<ObjectTemplateMappingType> sortedMappings = sortMappingsByDependencies(mappings);
    XMLGregorianCalendar templateNextRecomputeTime = collectTripleFromMappings(sortedMappings, phase, context, objectTemplateType, focusOdo, target, outputTripleMap, iteration, iterationToken, now, contextDesc, task, result);
    if (templateNextRecomputeTime != null) {
        if (nextRecomputeTime == null || nextRecomputeTime.compare(templateNextRecomputeTime) == DatatypeConstants.GREATER) {
            nextRecomputeTime = templateNextRecomputeTime;
        }
    }
    return nextRecomputeTime;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ObjectTemplateMappingType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateMappingType) ObjectTemplateType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType)

Example 20 with ObjectTemplateType

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

the class SchemaTransformer method determineObjectTemplate.

public <O extends ObjectType> ObjectTemplateType determineObjectTemplate(PrismObject<O> object, AuthorizationPhaseType phase, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException {
    PrismObject<SystemConfigurationType> systemConfiguration = systemObjectCache.getSystemConfiguration(result);
    if (systemConfiguration == null) {
        return null;
    }
    ObjectPolicyConfigurationType objectPolicyConfiguration = ModelUtils.determineObjectPolicyConfiguration(object, systemConfiguration.asObjectable());
    if (objectPolicyConfiguration == null) {
        return null;
    }
    ObjectReferenceType objectTemplateRef = objectPolicyConfiguration.getObjectTemplateRef();
    if (objectTemplateRef == null) {
        return null;
    }
    PrismObject<ObjectTemplateType> template = cacheRepositoryService.getObject(ObjectTemplateType.class, objectTemplateRef.getOid(), null, result);
    return template.asObjectable();
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ObjectPolicyConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType) ObjectTemplateType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)

Aggregations

ObjectTemplateType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType)19 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)9 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)6 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)5 ObjectTemplateItemDefinitionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateItemDefinitionType)5 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)5 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)4 ObjectTemplateMappingType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateMappingType)4 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)3 ObjectPolicyConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType)3 ItemValueWithOrigin (com.evolveum.midpoint.model.impl.lens.ItemValueWithOrigin)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 DeltaSetTriple (com.evolveum.midpoint.prism.delta.DeltaSetTriple)2 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 Task (com.evolveum.midpoint.task.api.Task)2 PersonaConstructionType (com.evolveum.midpoint.xml.ns._public.common.common_3.PersonaConstructionType)2 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)2 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2