Search in sources :

Example 46 with ObjectType

use of com.evolveum.midpoint.xml.ns._public.common.common_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 47 with ObjectType

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

the class ObjectMerger method computeProjectionDeltas.

private <O extends ObjectType> void computeProjectionDeltas(final ObjectDelta<O> leftLinkDelta, ObjectDelta<O> rightLinkDelta, final PrismObject<O> objectLeft, final PrismObject<O> objectRight, MergeConfigurationType mergeConfiguration, final String mergeConfigurationName, final Task task, final OperationResult result) throws SchemaException, ConfigurationException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, SecurityViolationException {
    List<ShadowType> projectionsLeft = getProjections(objectLeft, task, result);
    List<ShadowType> projectionsRight = getProjections(objectRight, task, result);
    List<ShadowType> mergedProjections = new ArrayList<>();
    List<ShadowType> matchedProjections = new ArrayList<>();
    ProjectionMergeConfigurationType defaultProjectionMergeConfig = null;
    for (ProjectionMergeConfigurationType projectionMergeConfig : mergeConfiguration.getProjection()) {
        if (projectionMergeConfig.getProjectionDiscriminator() == null && projectionMergeConfig.getSituation() == null) {
            defaultProjectionMergeConfig = projectionMergeConfig;
        } else {
            takeProjections(projectionMergeConfig.getLeft(), mergedProjections, matchedProjections, projectionsLeft, projectionsLeft, projectionsRight, projectionMergeConfig);
            takeProjections(projectionMergeConfig.getRight(), mergedProjections, matchedProjections, projectionsRight, projectionsLeft, projectionsRight, projectionMergeConfig);
        }
    }
    LOGGER.trace("Merged projections (before default): {}", mergedProjections);
    LOGGER.trace("Matched projections (before default): {}", matchedProjections);
    if (defaultProjectionMergeConfig != null) {
        takeUnmatchedProjections(defaultProjectionMergeConfig.getLeft(), mergedProjections, matchedProjections, projectionsLeft);
        takeUnmatchedProjections(defaultProjectionMergeConfig.getRight(), mergedProjections, matchedProjections, projectionsRight);
    }
    LOGGER.trace("Merged projections: {}", mergedProjections);
    checkConflict(mergedProjections);
    for (ShadowType mergedProjection : mergedProjections) {
        PrismReferenceValue leftLinkRef = findLinkRef(objectLeft, mergedProjection);
        if (leftLinkRef == null) {
            PrismReferenceValue linkRefRight = findLinkRef(objectRight, mergedProjection);
            LOGGER.trace("Moving projection right->left: {}", mergedProjection);
            addUnlinkDelta(rightLinkDelta, linkRefRight);
            addLinkDelta(leftLinkDelta, linkRefRight);
        } else {
            LOGGER.trace("Projection already at the left: {}", mergedProjection);
        }
    }
    for (PrismReferenceValue leftLinkRef : getLinkRefs(objectLeft)) {
        if (!hasProjection(mergedProjections, leftLinkRef)) {
            LOGGER.trace("Removing left projection: {}", leftLinkRef);
            addUnlinkDelta(leftLinkDelta, leftLinkRef);
        } else {
            LOGGER.trace("Left projection stays: {}", leftLinkRef);
        }
    }
}
Also used : ProjectionMergeConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ProjectionMergeConfigurationType) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ArrayList(java.util.ArrayList)

Example 48 with ObjectType

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

the class ObjectMerger method computeItemDeltas.

private <O extends ObjectType> void computeItemDeltas(final ObjectDelta<O> leftObjectDelta, final PrismObject<O> objectLeft, final PrismObject<O> objectRight, final List<ItemPath> processedPaths, MergeConfigurationType mergeConfiguration, final String mergeConfigurationName, final Task task, final OperationResult result) throws SchemaException, ConfigurationException, ExpressionEvaluationException, ObjectNotFoundException {
    for (ItemRefMergeConfigurationType itemMergeConfig : mergeConfiguration.getItem()) {
        ItemPath itemPath = itemMergeConfig.getRef().getItemPath();
        processedPaths.add(itemPath);
        ItemDelta itemDelta = mergeItem(objectLeft, objectRight, mergeConfigurationName, itemMergeConfig, itemPath, task, result);
        LOGGER.trace("Item {} delta: {}", itemPath, itemDelta);
        if (itemDelta != null && !itemDelta.isEmpty()) {
            leftObjectDelta.addModification(itemDelta);
        }
    }
}
Also used : ItemRefMergeConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ItemRefMergeConfigurationType) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 49 with ObjectType

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

the class ObjectMerger method getProjections.

private <O extends ObjectType> List<ShadowType> getProjections(PrismObject<O> objectRight, Task task, OperationResult result) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
    if (!objectRight.canRepresent(FocusType.class)) {
        return new ArrayList<>(0);
    }
    List<ObjectReferenceType> linkRefs = ((FocusType) objectRight.asObjectable()).getLinkRef();
    List<ShadowType> projections = new ArrayList<>(linkRefs.size());
    for (ObjectReferenceType linkRef : linkRefs) {
        projections.add(getProjection(linkRef, task, result));
    }
    return projections;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) FocusType(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType) ArrayList(java.util.ArrayList)

Example 50 with ObjectType

use of com.evolveum.midpoint.xml.ns._public.common.common_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)

Aggregations

ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)371 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)321 Test (org.testng.annotations.Test)267 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)252 Task (com.evolveum.midpoint.task.api.Task)251 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)230 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)170 ArrayList (java.util.ArrayList)136 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)103 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)65 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)61 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)56 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)53 Holder (javax.xml.ws.Holder)51 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)50 QName (javax.xml.namespace.QName)46 PrismObject (com.evolveum.midpoint.prism.PrismObject)42 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)36 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)36 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)34