Search in sources :

Example 31 with ObjectType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.

the class SchemaTransformer method applyObjectTemplateToDefinition.

public <O extends ObjectType> void applyObjectTemplateToDefinition(PrismObjectDefinition<O> objectDefinition, 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);
        applyObjectTemplateToDefinition(objectDefinition, 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 itemDef = objectDefinition.findItemDefinition(itemPath);
        if (itemDef != null) {
            applyObjectTemplateItem(itemDef, templateItemDefType, "item " + itemPath + " in object type " + objectDefinition.getTypeName() + " as specified in item definition in " + objectTemplateType);
        } else {
            OperationResult subResult = result.createMinorSubresult(SchemaTransformer.class.getName() + ".applyObjectTemplateToDefinition");
            subResult.recordPartialError("No definition for item " + itemPath + " in object type " + objectDefinition.getTypeName() + " as specified in item definition in " + objectTemplateType);
            continue;
        }
    }
}
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 32 with ObjectType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectType 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 33 with ObjectType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.

the class ObjectSelectionPanel method initLayout.

public void initLayout(PageBase pageBase) {
    Form searchForm = new Form(ID_SEARCH_FORM);
    searchForm.setOutputMarkupId(true);
    add(searchForm);
    searchForm.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return context.isSearchEnabled();
        }
    });
    BasicSearchPanel<ObjectSearchDto> basicSearch = new BasicSearchPanel<ObjectSearchDto>(ID_BASIC_SEARCH) {

        @Override
        protected IModel<String> createSearchTextModel() {
            return new PropertyModel<>(searchModel, ObjectSearchDto.F_SEARCH_TEXT);
        }

        @Override
        protected void searchPerformed(AjaxRequestTarget target) {
            ObjectSelectionPanel.this.searchPerformed(target);
        }

        @Override
        protected void clearSearchPerformed(AjaxRequestTarget target) {
            ObjectSelectionPanel.this.clearSearchPerformed(target);
        }
    };
    searchForm.add(basicSearch);
    add(context.createExtraContentContainer(ID_EXTRA_CONTENT_CONTAINER, this));
    List<IColumn<SelectableBean<ObjectType>, String>> columns = initColumns();
    ObjectDataProvider provider = new ObjectDataProvider(pageBase, this.objectType);
    provider.setQuery(context.getDataProviderQuery());
    provider.setOptions(context.getDataProviderOptions());
    TablePanel table = new TablePanel<>(ID_TABLE, provider, columns);
    table.setOutputMarkupId(true);
    addOrReplace(table);
    AjaxButton cancelButton = new AjaxButton(ID_BUTTON_CANCEL, createStringResource("chooseTypeDialog.button.cancel")) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            modalWindow.close(ajaxRequestTarget);
        }
    };
    add(cancelButton);
}
Also used : ObjectSearchDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectSearchDto) Form(org.apache.wicket.markup.html.form.Form) PropertyModel(org.apache.wicket.model.PropertyModel) ObjectDataProvider(com.evolveum.midpoint.web.component.data.ObjectDataProvider) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) BasicSearchPanel(com.evolveum.midpoint.web.component.BasicSearchPanel) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) TablePanel(com.evolveum.midpoint.web.component.data.TablePanel)

Example 34 with ObjectType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.

the class ObjectSelectionPanel method initColumns.

private List<IColumn<SelectableBean<ObjectType>, String>> initColumns() {
    List<IColumn<SelectableBean<ObjectType>, String>> columns = new ArrayList<>();
    IColumn column = new LinkColumn<SelectableBean<ObjectType>>(createStringResource("chooseTypeDialog.column.name"), context.getSortableProperty(), "value.name") {

        @Override
        public void onClick(AjaxRequestTarget target, IModel<SelectableBean<ObjectType>> rowModel) {
            ObjectType object = rowModel.getObject().getValue();
            context.chooseOperationPerformed(target, object);
        }
    };
    columns.add(column);
    return columns;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) IModel(org.apache.wicket.model.IModel) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) ArrayList(java.util.ArrayList) LinkColumn(com.evolveum.midpoint.web.component.data.column.LinkColumn)

Example 35 with ObjectType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectType in project midpoint by Evolveum.

the class PageRepositoryQuery method updateRequestWithMidpointQuery.

private void updateRequestWithMidpointQuery(RepositoryQueryDiagRequest request, QName objectType, String queryText, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
    PrismContext prismContext = getPrismContext();
    if (objectType == null) {
        objectType = ObjectType.COMPLEX_TYPE;
    }
    @SuppressWarnings("unchecked") Class<? extends ObjectType> clazz = (Class<? extends ObjectType>) prismContext.getSchemaRegistry().getCompileTimeClassForObjectType(objectType);
    if (clazz == null) {
        throw new SchemaException("Couldn't find compile-time class for object type of " + objectType);
    }
    QueryType queryType = prismContext.parserFor(queryText).xml().parseRealValue(QueryType.class);
    request.setType(clazz);
    ObjectQuery objectQuery = QueryJaxbConvertor.createObjectQuery(clazz, queryType, prismContext);
    ObjectQuery queryWithExprEvaluated = ExpressionUtil.evaluateQueryExpressions(objectQuery, new ExpressionVariables(), getExpressionFactory(), getPrismContext(), "evaluate query expressions", task, result);
    request.setQuery(queryWithExprEvaluated);
}
Also used : ExpressionVariables(com.evolveum.midpoint.repo.common.expression.ExpressionVariables) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) PrismContext(com.evolveum.midpoint.prism.PrismContext) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Aggregations

ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)371 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)297 Test (org.testng.annotations.Test)264 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)253 Task (com.evolveum.midpoint.task.api.Task)252 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)223 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)155 ArrayList (java.util.ArrayList)123 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)100 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)58 Holder (javax.xml.ws.Holder)49 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)46 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)46 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)38 QName (javax.xml.namespace.QName)38 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)37 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)35 PrismObject (com.evolveum.midpoint.prism.PrismObject)33 ReferenceDelta (com.evolveum.midpoint.prism.delta.ReferenceDelta)33 ShadowDiscriminatorObjectDelta (com.evolveum.midpoint.common.refinery.ShadowDiscriminatorObjectDelta)32