Search in sources :

Example 11 with ObjectTemplateType

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);
            }
        }
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ObjectTemplateType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) ObjectTemplateItemDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateItemDefinitionType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 12 with 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;
        }
    };
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectTemplateConfigTypeReferenceDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectTemplateConfigTypeReferenceDto) Task(com.evolveum.midpoint.task.api.Task) ObjectTemplateType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 13 with ObjectTemplateType

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;
}
Also used : ObjectTemplateType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType) RObjectTemplateType(com.evolveum.midpoint.repo.sql.data.common.enums.RObjectTemplateType)

Example 14 with ObjectTemplateType

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 "";
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ObjectTemplateType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 15 with ObjectTemplateType

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);
}
Also used : QName(javax.xml.namespace.QName) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) ObjectDeltaObject(com.evolveum.midpoint.repo.common.expression.ObjectDeltaObject) 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)

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