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);
}
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;
}
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);
}
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;
}
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();
}
Aggregations