use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType in project midpoint by Evolveum.
the class SchemaTransformer method applyObjectTemplateToObject.
private <O extends ObjectType> void applyObjectTemplateToObject(PrismObject<O> object, ObjectTemplateType objectTemplateType, OperationResult result) throws ObjectNotFoundException, SchemaException {
if (objectTemplateType == null) {
return;
}
for (ObjectReferenceType includeRef : objectTemplateType.getIncludeRef()) {
PrismObject<ObjectTemplateType> subTemplate = cacheRepositoryService.getObject(ObjectTemplateType.class, includeRef.getOid(), null, result);
applyObjectTemplateToObject(object, subTemplate.asObjectable(), result);
}
for (ObjectTemplateItemDefinitionType templateItemDefType : objectTemplateType.getItem()) {
ItemPathType ref = templateItemDefType.getRef();
if (ref == null) {
throw new SchemaException("No 'ref' in item definition in " + objectTemplateType);
}
ItemPath itemPath = ref.getItemPath();
ItemDefinition itemDefFromObject = object.getDefinition().findItemDefinition(itemPath);
if (itemDefFromObject != null) {
applyObjectTemplateItem(itemDefFromObject, templateItemDefType, "item " + itemPath + " in " + object + " as specified in item definition in " + objectTemplateType);
} else {
OperationResult subResult = result.createMinorSubresult(SchemaTransformer.class.getName() + ".applyObjectTemplateToObject");
subResult.recordPartialError("No definition for item " + itemPath + " in " + object + " as specified in item definition in " + objectTemplateType);
continue;
}
Item<?, ?> item = object.findItem(itemPath);
if (item != null) {
ItemDefinition itemDef = item.getDefinition();
if (itemDef != itemDefFromObject) {
applyObjectTemplateItem(itemDef, templateItemDefType, "item " + itemPath + " in " + object + " as specified in item definition in " + objectTemplateType);
}
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType in project midpoint by Evolveum.
the class ObjectPolicyPanel method createObjectTemplateList.
protected IModel<List<ObjectTemplateConfigTypeReferenceDto>> createObjectTemplateList() {
return new AbstractReadOnlyModel<List<ObjectTemplateConfigTypeReferenceDto>>() {
@Override
public List<ObjectTemplateConfigTypeReferenceDto> getObject() {
List<PrismObject<ObjectTemplateType>> templateList = null;
List<ObjectTemplateConfigTypeReferenceDto> list = new ArrayList<>();
OperationResult result = new OperationResult(OPERATION_LOAD_ALL_OBJECT_TEMPLATES);
Task task = getPageBase().createSimpleTask(OPERATION_LOAD_ALL_OBJECT_TEMPLATES);
try {
templateList = getPageBase().getModelService().searchObjects(ObjectTemplateType.class, new ObjectQuery(), null, task, result);
result.recomputeStatus();
} catch (Exception e) {
result.recordFatalError("Could not get list of object templates", e);
LoggingUtils.logUnexpectedException(LOGGER, "Could not get list of object templates", e);
// TODO - show this error in GUI
}
if (templateList != null) {
ObjectTemplateType template;
for (PrismObject<ObjectTemplateType> obj : templateList) {
template = obj.asObjectable();
list.add(new ObjectTemplateConfigTypeReferenceDto(template.getOid(), WebComponentUtil.getName(template)));
}
}
return list;
}
};
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType in project midpoint by Evolveum.
the class RObjectTemplate method toJAXB.
@Override
public ObjectTemplateType toJAXB(PrismContext prismContext, Collection<SelectorOptions<GetOperationOptions>> options) throws DtoTranslationException {
ObjectTemplateType object = new ObjectTemplateType();
RUtil.revive(object, prismContext);
RObjectTemplate.copyToJAXB(this, object, prismContext, options);
return object;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType in project midpoint by Evolveum.
the class ObjectPolicyDialogDto method getObjectTemplateName.
private String getObjectTemplateName(String oid, PageBase page) {
Task task = page.createSimpleTask(OPERATION_LOAD_OBJECT_TEMPLATE);
OperationResult result = task.getResult();
PrismObject<ObjectTemplateType> templatePrism = WebModelServiceUtils.loadObject(ObjectTemplateType.class, oid, page, task, result);
if (templatePrism != null) {
return WebComponentUtil.getName(templatePrism);
}
return "";
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType in project midpoint by Evolveum.
the class PersonaProcessor method personaAdd.
public <F extends FocusType, T extends FocusType> void personaAdd(LensContext<F> context, PersonaKey key, PersonaConstruction<F> construction, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, PolicyViolationException, ObjectAlreadyExistsException, CommunicationException, ConfigurationException, SecurityViolationException {
PrismObject<F> focus = context.getFocusContext().getObjectNew();
LOGGER.debug("Adding 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);
QName targetType = constructionType.getTargetType();
PrismObjectDefinition<T> objectDef = prismContext.getSchemaRegistry().findObjectDefinitionByType(targetType);
PrismObject<T> target = objectDef.instantiate();
FocusTypeUtil.setSubtype(target, constructionType.getTargetSubtype());
// pretend ADD focusOdo. We need to push all the items through the object template
ObjectDeltaObject<F> focusOdo = new ObjectDeltaObject<>(null, focus.createAddDelta(), focus);
ObjectDelta<T> targetDelta = target.createAddDelta();
String contextDesc = "object mapping " + objectMappingType + " for persona construction for " + focus;
XMLGregorianCalendar now = clock.currentTimeXMLGregorianCalendar();
Collection<ItemDelta<?, ?>> itemDeltas = objectTemplateProcessor.processObjectMapping(context, objectMappingType, focusOdo, target, targetDelta, contextDesc, now, task, result);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("itemDeltas:\n{}", DebugUtil.debugDump(itemDeltas));
}
for (ItemDelta itemDelta : itemDeltas) {
itemDelta.applyTo(target);
}
LOGGER.trace("Creating persona:\n{}", target.debugDumpLazily());
executePersonaDelta(targetDelta, task, result);
link(context, target.asObjectable(), result);
}
Aggregations