Search in sources :

Example 1 with MappingStrengthType

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

the class MappingEditorDialog method initLayout.

public void initLayout(WebMarkupContainer content) {
    Form form = new Form(ID_MAIN_FORM);
    form.setOutputMarkupId(true);
    content.add(form);
    TextFormGroup name = new TextFormGroup(ID_NAME, new PropertyModel<String>(model, MappingTypeDto.F_MAPPING + ".name"), createStringResource("MappingEditorDialog.label.name"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    name.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    form.add(name);
    TextAreaFormGroup description = new TextAreaFormGroup(ID_DESCRIPTION, new PropertyModel<String>(model, MappingTypeDto.F_MAPPING + ".description"), createStringResource("MappingEditorDialog.label.description"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    description.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    form.add(description);
    CheckFormGroup authoritative = new CheckFormGroup(ID_AUTHORITATIVE, new PropertyModel<Boolean>(model, MappingTypeDto.F_MAPPING + ".authoritative"), createStringResource("MappingEditorDialog.label.authoritative"), "SchemaHandlingStep.mapping.tooltip.authoritative", true, ID_LABEL_SIZE, ID_INPUT_SIZE);
    authoritative.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    form.add(authoritative);
    CheckFormGroup exclusive = new CheckFormGroup(ID_EXCLUSIVE, new PropertyModel<Boolean>(model, MappingTypeDto.F_MAPPING + ".exclusive"), createStringResource("MappingEditorDialog.label.exclusive"), "SchemaHandlingStep.mapping.tooltip.exclusive", true, ID_LABEL_SIZE, ID_INPUT_SIZE);
    exclusive.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    form.add(exclusive);
    DropDownFormGroup strength = new DropDownFormGroup<>(ID_STRENGTH, new PropertyModel<MappingStrengthType>(model, MappingTypeDto.F_MAPPING + ".strength"), WebComponentUtil.createReadonlyModelFromEnum(MappingStrengthType.class), new EnumChoiceRenderer<MappingStrengthType>(this), createStringResource("MappingEditorDialog.label.strength"), "SchemaHandlingStep.mapping.tooltip.strength", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    strength.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    form.add(strength);
    MultiValueDropDownPanel channel = new MultiValueDropDownPanel<String>(ID_CHANNEL, new PropertyModel<List<String>>(model, MappingTypeDto.F_MAPPING + ".channel"), true, readOnlyModel) {

        @Override
        protected String createNewEmptyItem() {
            return "";
        }

        @Override
        protected IModel<List<String>> createChoiceList() {
            return new AbstractReadOnlyModel<List<String>>() {

                @Override
                public List<String> getObject() {
                    return WebComponentUtil.getChannelList();
                }
            };
        }

        @Override
        protected IChoiceRenderer<String> createRenderer() {
            return new StringChoiceRenderer("Channel.", "#");
        }
    };
    form.add(channel);
    MultiValueDropDownPanel exceptChannel = new MultiValueDropDownPanel<String>(ID_EXCEPT_CHANNEL, new PropertyModel<List<String>>(model, MappingTypeDto.F_MAPPING + ".exceptChannel"), true, readOnlyModel) {

        @Override
        protected String createNewEmptyItem() {
            return "";
        }

        @Override
        protected IModel<List<String>> createChoiceList() {
            return new AbstractReadOnlyModel<List<String>>() {

                @Override
                public List<String> getObject() {
                    return WebComponentUtil.getChannelList();
                }
            };
        }

        @Override
        protected IChoiceRenderer<String> createRenderer() {
            return new StringChoiceRenderer("Channel.", "#");
        }
    };
    form.add(exceptChannel);
    // TODO - create some nice ItemPathType editor in near future
    MultiValueTextPanel source = new MultiValueTextPanel<>(ID_SOURCE, new PropertyModel<List<String>>(model, MappingTypeDto.F_SOURCE), readOnlyModel, true);
    form.add(source);
    // TODO - create some nice ItemPathType editor in near future
    TextFormGroup target = new TextFormGroup(ID_TARGET, new PropertyModel<String>(model, MappingTypeDto.F_TARGET), createStringResource("MappingEditorDialog.label.target"), "SchemaHandlingStep.mapping.tooltip.target", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false, isTargetRequired);
    target.setOutputMarkupId(true);
    target.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    form.add(target);
    DropDownFormGroup<ExpressionUtil.ExpressionEvaluatorType> expressionType = new DropDownFormGroup<ExpressionUtil.ExpressionEvaluatorType>(ID_EXPRESSION_TYPE, new PropertyModel<ExpressionUtil.ExpressionEvaluatorType>(model, MappingTypeDto.F_EXPRESSION_TYPE), WebComponentUtil.createReadonlyModelFromEnum(ExpressionUtil.ExpressionEvaluatorType.class), new EnumChoiceRenderer<ExpressionUtil.ExpressionEvaluatorType>(this), createStringResource("MappingEditorDialog.label.expressionType"), "SchemaHandlingStep.mapping.tooltip.expressionType", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false) {

        @Override
        protected DropDownChoice createDropDown(String id, IModel<List<ExpressionUtil.ExpressionEvaluatorType>> choices, IChoiceRenderer<ExpressionUtil.ExpressionEvaluatorType> renderer, boolean required) {
            return new DropDownChoice<>(id, getModel(), choices, renderer);
        }
    };
    expressionType.getInput().add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            model.getObject().updateExpression();
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_EXPRESSION));
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_EXPRESSION_LANG));
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_EXPRESSION_POLICY_REF));
        }
    });
    expressionType.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    form.add(expressionType);
    DropDownFormGroup expressionLanguage = new DropDownFormGroup<>(ID_EXPRESSION_LANG, new PropertyModel<ExpressionUtil.Language>(model, MappingTypeDto.F_EXPRESSION_LANG), WebComponentUtil.createReadonlyModelFromEnum(ExpressionUtil.Language.class), new EnumChoiceRenderer<ExpressionUtil.Language>(this), createStringResource("MappingEditorDialog.label.language"), "SchemaHandlingStep.mapping.tooltip.expressionLanguage", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    expressionLanguage.setOutputMarkupId(true);
    expressionLanguage.setOutputMarkupPlaceholderTag(true);
    expressionLanguage.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return ExpressionUtil.ExpressionEvaluatorType.SCRIPT.equals(model.getObject().getExpressionType());
        }

        @Override
        public boolean isEnabled() {
            return !readOnlyModel.getObject();
        }
    });
    form.add(expressionLanguage);
    expressionLanguage.getInput().add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            model.getObject().updateExpressionLanguage();
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_EXPRESSION));
        }
    });
    DropDownFormGroup<ObjectReferenceType> expressionGeneratePolicy = new DropDownFormGroup<ObjectReferenceType>(ID_EXPRESSION_POLICY_REF, new PropertyModel<ObjectReferenceType>(model, MappingTypeDto.F_EXPRESSION_POLICY_REF), new AbstractReadOnlyModel<List<ObjectReferenceType>>() {

        @Override
        public List<ObjectReferenceType> getObject() {
            return WebModelServiceUtils.createObjectReferenceList(ValuePolicyType.class, getPageBase(), policyMap);
        }
    }, new ObjectReferenceChoiceRenderer(policyMap), createStringResource("MappingEditorDialog.label.passPolicyRef"), "SchemaHandlingStep.mapping.tooltip.expressionValuePolicyRef", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false) {

        @Override
        protected DropDownChoice createDropDown(String id, IModel<List<ObjectReferenceType>> choices, IChoiceRenderer<ObjectReferenceType> renderer, boolean required) {
            return new DropDownChoice<>(id, getModel(), choices, renderer);
        }
    };
    expressionGeneratePolicy.setOutputMarkupId(true);
    expressionGeneratePolicy.setOutputMarkupPlaceholderTag(true);
    expressionGeneratePolicy.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return ExpressionUtil.ExpressionEvaluatorType.GENERATE.equals(model.getObject().getExpressionType());
        }

        @Override
        public boolean isEnabled() {
            return !readOnlyModel.getObject();
        }
    });
    expressionGeneratePolicy.getInput().add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            model.getObject().updateExpressionGeneratePolicy();
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_EXPRESSION));
        }
    });
    form.add(expressionGeneratePolicy);
    AceEditorFormGroup expression = new AceEditorFormGroup(ID_EXPRESSION, new PropertyModel<String>(model, MappingTypeDto.F_EXPRESSION), createStringResource("MappingEditorDialog.label.expression"), "SchemaHandlingStep.mapping.tooltip.expression", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false, CODE_ROW_COUNT);
    expression.setOutputMarkupId(true);
    expression.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    form.add(expression);
    DropDownFormGroup<ExpressionUtil.ExpressionEvaluatorType> conditionType = new DropDownFormGroup<ExpressionUtil.ExpressionEvaluatorType>(ID_CONDITION_TYPE, new PropertyModel<ExpressionUtil.ExpressionEvaluatorType>(model, MappingTypeDto.F_CONDITION_TYPE), WebComponentUtil.createReadonlyModelFromEnum(ExpressionUtil.ExpressionEvaluatorType.class), new EnumChoiceRenderer<ExpressionUtil.ExpressionEvaluatorType>(this), createStringResource("MappingEditorDialog.label.conditionType"), "SchemaHandlingStep.mapping.tooltip.conditionType", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false) {

        @Override
        protected DropDownChoice createDropDown(String id, IModel<List<ExpressionUtil.ExpressionEvaluatorType>> choices, IChoiceRenderer<ExpressionUtil.ExpressionEvaluatorType> renderer, boolean required) {
            return new DropDownChoice<>(id, getModel(), choices, renderer);
        }
    };
    conditionType.getInput().add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            model.getObject().updateCondition();
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_CONDITION));
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_CONDITION_LANG));
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_CONDITION_POLICY_REF));
        }
    });
    form.add(conditionType);
    conditionType.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    DropDownFormGroup conditionLanguage = new DropDownFormGroup<>(ID_CONDITION_LANG, new PropertyModel<ExpressionUtil.Language>(model, MappingTypeDto.F_CONDITION_LANG), WebComponentUtil.createReadonlyModelFromEnum(ExpressionUtil.Language.class), new EnumChoiceRenderer<ExpressionUtil.Language>(this), createStringResource("MappingEditorDialog.label.language"), "SchemaHandlingStep.mapping.tooltip.conditionLanguage", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    conditionLanguage.setOutputMarkupId(true);
    conditionLanguage.setOutputMarkupPlaceholderTag(true);
    conditionLanguage.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return ExpressionUtil.ExpressionEvaluatorType.SCRIPT.equals(model.getObject().getConditionType());
        }

        @Override
        public boolean isEnabled() {
            return !readOnlyModel.getObject();
        }
    });
    conditionLanguage.getInput().add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            model.getObject().updateConditionLanguage();
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_CONDITION));
        }
    });
    form.add(conditionLanguage);
    DropDownFormGroup<ObjectReferenceType> conditionGeneratePolicy = new DropDownFormGroup<ObjectReferenceType>(ID_CONDITION_POLICY_REF, new PropertyModel<ObjectReferenceType>(model, MappingTypeDto.F_CONDITION_POLICY_REF), new AbstractReadOnlyModel<List<ObjectReferenceType>>() {

        @Override
        public List<ObjectReferenceType> getObject() {
            return WebModelServiceUtils.createObjectReferenceList(ValuePolicyType.class, getPageBase(), policyMap);
        }
    }, new ObjectReferenceChoiceRenderer(policyMap), createStringResource("MappingEditorDialog.label.passPolicyRef"), "SchemaHandlingStep.mapping.tooltip.conditionValuePolicyRef", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false) {

        @Override
        protected DropDownChoice createDropDown(String id, IModel<List<ObjectReferenceType>> choices, IChoiceRenderer<ObjectReferenceType> renderer, boolean required) {
            return new DropDownChoice<>(id, getModel(), choices, renderer);
        }
    };
    conditionGeneratePolicy.setOutputMarkupId(true);
    conditionGeneratePolicy.setOutputMarkupPlaceholderTag(true);
    conditionGeneratePolicy.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return ExpressionUtil.ExpressionEvaluatorType.GENERATE.equals(model.getObject().getConditionType());
        }

        @Override
        public boolean isEnabled() {
            return !readOnlyModel.getObject();
        }
    });
    conditionGeneratePolicy.getInput().add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            model.getObject().updateConditionGeneratePolicy();
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_CONDITION));
        }
    });
    form.add(conditionGeneratePolicy);
    AceEditorFormGroup condition = new AceEditorFormGroup(ID_CONDITION, new PropertyModel<String>(model, MappingTypeDto.F_CONDITION), createStringResource("MappingEditorDialog.label.condition"), "SchemaHandlingStep.mapping.tooltip.condition", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false, CODE_ROW_COUNT);
    condition.setOutputMarkupId(true);
    condition.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
    form.add(condition);
    Label channelTooltip = new Label(ID_T_CHANNEL);
    channelTooltip.add(new InfoTooltipBehavior(true));
    form.add(channelTooltip);
    Label exceptChannelTooltip = new Label(ID_T_EXCEPT_CHANNEL);
    exceptChannelTooltip.add(new InfoTooltipBehavior(true));
    form.add(exceptChannelTooltip);
    Label sourceTooltip = new Label(ID_T_SOURCE);
    sourceTooltip.add(new InfoTooltipBehavior(true));
    form.add(sourceTooltip);
    AjaxButton cancel = new AjaxButton(ID_BUTTON_CANCEL, createStringResource("MappingEditorDialog.button.cancel")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            cancelPerformed(target);
        }
    };
    form.add(cancel);
    AjaxSubmitButton save = new AjaxSubmitButton(ID_BUTTON_SAVE, createStringResource("MappingEditorDialog.button.apply")) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            savePerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(getPageBase().getFeedbackPanel(), getContent());
        }
    };
    save.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
    form.add(save);
}
Also used : IChoiceRenderer(org.apache.wicket.markup.html.form.IChoiceRenderer) ObjectReferenceChoiceRenderer(com.evolveum.midpoint.web.component.input.ObjectReferenceChoiceRenderer) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) ValuePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType) Form(org.apache.wicket.markup.html.form.Form) Label(org.apache.wicket.markup.html.basic.Label) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) MultiValueDropDownPanel(com.evolveum.midpoint.web.component.form.multivalue.MultiValueDropDownPanel) ArrayList(java.util.ArrayList) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) MultiValueTextPanel(com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextPanel) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) IModel(org.apache.wicket.model.IModel) MappingStrengthType(com.evolveum.midpoint.xml.ns._public.common.common_3.MappingStrengthType) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) StringChoiceRenderer(com.evolveum.midpoint.web.component.input.StringChoiceRenderer) ExpressionUtil(com.evolveum.midpoint.web.util.ExpressionUtil)

Example 2 with MappingStrengthType

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

the class ConsolidationProcessor method consolidateValuesToModifyDelta.

private <F extends FocusType> ObjectDelta<ShadowType> consolidateValuesToModifyDelta(LensContext<F> context, LensProjectionContext projCtx, boolean addUnchangedValues, Task task, OperationResult result) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, PolicyViolationException {
    // "Squeeze" all the relevant mappings into a data structure that we can process conveniently. We want to have all the
    // (meta)data about relevant for a specific attribute in one data structure, not spread over several account constructions.
    Map<QName, DeltaSetTriple<ItemValueWithOrigin<PrismPropertyValue<?>, PrismPropertyDefinition<?>>>> squeezedAttributes = sqeeze(projCtx, construction -> (Collection) construction.getAttributeMappings());
    projCtx.setSqueezedAttributes(squeezedAttributes);
    Map<QName, DeltaSetTriple<ItemValueWithOrigin<PrismContainerValue<ShadowAssociationType>, PrismContainerDefinition<ShadowAssociationType>>>> squeezedAssociations = sqeeze(projCtx, construction -> construction.getAssociationMappings());
    projCtx.setSqueezedAssociations(squeezedAssociations);
    // So, we do it here - once and for all.
    if (!squeezedAssociations.isEmpty()) {
        fillInAssociationNames(squeezedAssociations);
    }
    MappingExtractor<PrismPropertyValue<QName>, PrismPropertyDefinition<QName>, F> auxiliaryObjectClassExtractor = construction -> {
        PrismValueDeltaSetTripleProducer<PrismPropertyValue<QName>, PrismPropertyDefinition<QName>> prod = new PrismValueDeltaSetTripleProducer<PrismPropertyValue<QName>, PrismPropertyDefinition<QName>>() {

            @Override
            public QName getMappingQName() {
                return ShadowType.F_AUXILIARY_OBJECT_CLASS;
            }

            @Override
            public PrismValueDeltaSetTriple<PrismPropertyValue<QName>> getOutputTriple() {
                PrismValueDeltaSetTriple<PrismPropertyValue<QName>> triple = new PrismValueDeltaSetTriple<>();
                if (construction.getAuxiliaryObjectClassDefinitions() != null) {
                    for (RefinedObjectClassDefinition auxiliaryObjectClassDefinition : construction.getAuxiliaryObjectClassDefinitions()) {
                        triple.addToZeroSet(new PrismPropertyValue<QName>(auxiliaryObjectClassDefinition.getTypeName()));
                    }
                }
                return triple;
            }

            @Override
            public MappingStrengthType getStrength() {
                return MappingStrengthType.STRONG;
            }

            @Override
            public PrismValueDeltaSetTripleProducer<PrismPropertyValue<QName>, PrismPropertyDefinition<QName>> clone() {
                return this;
            }

            @Override
            public boolean isExclusive() {
                return false;
            }

            @Override
            public boolean isAuthoritative() {
                return true;
            }

            @Override
            public boolean isSourceless() {
                return false;
            }
        };
        Collection<PrismValueDeltaSetTripleProducer<PrismPropertyValue<QName>, PrismPropertyDefinition<QName>>> col = new ArrayList<>(1);
        col.add(prod);
        return col;
    };
    Map<QName, DeltaSetTriple<ItemValueWithOrigin<PrismPropertyValue<QName>, PrismPropertyDefinition<QName>>>> squeezedAuxiliaryObjectClasses = sqeeze(projCtx, auxiliaryObjectClassExtractor);
    projCtx.setSqueezedAuxiliaryObjectClasses(squeezedAuxiliaryObjectClasses);
    ResourceShadowDiscriminator discr = projCtx.getResourceShadowDiscriminator();
    ObjectDelta<ShadowType> objectDelta = new ObjectDelta<ShadowType>(ShadowType.class, ChangeType.MODIFY, prismContext);
    objectDelta.setOid(projCtx.getOid());
    // Let's be very very lazy about fetching the account from the resource.
    if (!projCtx.hasFullShadow() && (hasActiveWeakMapping(squeezedAttributes, projCtx) || hasActiveWeakMapping(squeezedAssociations, projCtx) || (hasActiveStrongMapping(squeezedAttributes, projCtx) || hasActiveStrongMapping(squeezedAssociations, projCtx)))) {
        // Full account was not yet loaded. This will cause problems as
        // the weak mapping may be applied even though it should not be
        // applied
        // and also same changes may be discarded because of unavailability
        // of all
        // account's attributes.Therefore load the account now, but with
        // doNotDiscovery options..
        // We also need to get account if there are strong mappings. Strong mappings
        // should always be applied. So reading the account now will indirectly
        // trigger reconciliation which makes sure that the strong mappings are
        // applied.
        // By getting accounts from provisioning, there might be a problem with
        // resource availability. We need to know, if the account was read full
        // or we have only the shadow from the repository. If we have only
        // shadow, the weak mappings may applied even if they should not be. 
        contextLoader.loadFullShadow(context, projCtx, "weak or strong mapping", task, result);
        if (projCtx.getSynchronizationPolicyDecision() == SynchronizationPolicyDecision.BROKEN) {
            return null;
        }
    }
    boolean completeAccount = projCtx.hasFullShadow();
    ObjectDelta<ShadowType> existingDelta = projCtx.getDelta();
    // AUXILIARY OBJECT CLASSES
    ItemPath auxiliaryObjectClassItemPath = new ItemPath(ShadowType.F_AUXILIARY_OBJECT_CLASS);
    PrismPropertyDefinition<QName> auxiliaryObjectClassPropertyDef = projCtx.getObjectDefinition().findPropertyDefinition(auxiliaryObjectClassItemPath);
    PropertyDelta<QName> auxiliaryObjectClassAPrioriDelta = null;
    RefinedResourceSchema refinedSchema = projCtx.getRefinedResourceSchema();
    List<QName> auxOcNames = new ArrayList<>();
    List<RefinedObjectClassDefinition> auxOcDefs = new ArrayList<>();
    ObjectDelta<ShadowType> projDelta = projCtx.getDelta();
    if (projDelta != null) {
        auxiliaryObjectClassAPrioriDelta = projDelta.findPropertyDelta(auxiliaryObjectClassItemPath);
    }
    for (Entry<QName, DeltaSetTriple<ItemValueWithOrigin<PrismPropertyValue<QName>, PrismPropertyDefinition<QName>>>> entry : squeezedAuxiliaryObjectClasses.entrySet()) {
        DeltaSetTriple<ItemValueWithOrigin<PrismPropertyValue<QName>, PrismPropertyDefinition<QName>>> ivwoTriple = entry.getValue();
        LOGGER.trace("CONSOLIDATE auxiliary object classes ({})", new Object[] { discr });
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Auxiliary object class triple:\n{}", ivwoTriple.debugDump());
        }
        for (ItemValueWithOrigin<PrismPropertyValue<QName>, PrismPropertyDefinition<QName>> ivwo : ivwoTriple.getAllValues()) {
            QName auxObjectClassName = ivwo.getItemValue().getValue();
            if (auxOcNames.contains(auxObjectClassName)) {
                continue;
            }
            auxOcNames.add(auxObjectClassName);
            RefinedObjectClassDefinition auxOcDef = refinedSchema.getRefinedDefinition(auxObjectClassName);
            if (auxOcDef == null) {
                LOGGER.error("Auxiliary object class definition {} for {} not found in the schema, but it should be there, dumping context:\n{}", auxObjectClassName, discr, context.debugDump());
                throw new IllegalStateException("Auxiliary object class definition " + auxObjectClassName + " for " + discr + " not found in the context, but it should be there");
            }
            auxOcDefs.add(auxOcDef);
        }
        ItemDelta<PrismPropertyValue<QName>, PrismPropertyDefinition<QName>> itemDelta = LensUtil.consolidateTripleToDelta(auxiliaryObjectClassItemPath, ivwoTriple, auxiliaryObjectClassPropertyDef, auxiliaryObjectClassAPrioriDelta, projCtx.getObjectNew(), null, null, addUnchangedValues, completeAccount, false, discr.toHumanReadableDescription(), false);
        PropertyDelta<QName> propDelta = (PropertyDelta) itemDelta;
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Auxiliary object class delta:\n{}", propDelta.debugDump());
        }
        if (!propDelta.isEmpty()) {
            objectDelta.addModification(propDelta);
        }
    }
    RefinedObjectClassDefinition structuralObjectClassDefinition = projCtx.getStructuralObjectClassDefinition();
    if (structuralObjectClassDefinition == null) {
        LOGGER.error("Structural object class definition for {} not found in the context, but it should be there, dumping context:\n{}", discr, context.debugDump());
        throw new IllegalStateException("Structural object class definition for " + discr + " not found in the context, but it should be there");
    }
    RefinedObjectClassDefinition rOcDef = new CompositeRefinedObjectClassDefinitionImpl(structuralObjectClassDefinition, auxOcDefs);
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("Object class definition for {} consolidation:\n{}", discr, rOcDef.debugDump());
    }
    // with the data in ItemValueWithOrigin triples.
    for (Map.Entry<QName, DeltaSetTriple<ItemValueWithOrigin<PrismPropertyValue<?>, PrismPropertyDefinition<?>>>> entry : squeezedAttributes.entrySet()) {
        QName attributeName = entry.getKey();
        DeltaSetTriple<ItemValueWithOrigin<PrismPropertyValue<?>, PrismPropertyDefinition<?>>> triple = entry.getValue();
        PropertyDelta<?> propDelta = consolidateAttribute(rOcDef, discr, existingDelta, projCtx, addUnchangedValues, completeAccount, attributeName, (DeltaSetTriple) triple);
        if (propDelta != null) {
            objectDelta.addModification(propDelta);
        }
    }
    // ASSOCIATIONS
    for (Entry<QName, DeltaSetTriple<ItemValueWithOrigin<PrismContainerValue<ShadowAssociationType>, PrismContainerDefinition<ShadowAssociationType>>>> entry : squeezedAssociations.entrySet()) {
        QName associationName = entry.getKey();
        DeltaSetTriple<ItemValueWithOrigin<PrismContainerValue<ShadowAssociationType>, PrismContainerDefinition<ShadowAssociationType>>> triple = entry.getValue();
        ContainerDelta<ShadowAssociationType> containerDelta = consolidateAssociation(rOcDef, discr, existingDelta, projCtx, addUnchangedValues, completeAccount, associationName, triple);
        if (containerDelta != null) {
            objectDelta.addModification(containerDelta);
        }
    }
    return objectDelta;
}
Also used : PrismValue(com.evolveum.midpoint.prism.PrismValue) Construction(com.evolveum.midpoint.model.impl.lens.Construction) ChangeType(com.evolveum.midpoint.prism.delta.ChangeType) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Autowired(org.springframework.beans.factory.annotation.Autowired) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) com.evolveum.midpoint.common.refinery(com.evolveum.midpoint.common.refinery) LensContext(com.evolveum.midpoint.model.impl.lens.LensContext) PrismValueDeltaSetTriple(com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple) Map(java.util.Map) PrismValueDeltaSetTripleProducer(com.evolveum.midpoint.model.common.mapping.PrismValueDeltaSetTripleProducer) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) PrismProperty(com.evolveum.midpoint.prism.PrismProperty) Mapping(com.evolveum.midpoint.model.common.mapping.Mapping) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) InternalsConfig.consistencyChecks(com.evolveum.midpoint.schema.internals.InternalsConfig.consistencyChecks) Collection(java.util.Collection) Task(com.evolveum.midpoint.task.api.Task) MatchingRuleRegistry(com.evolveum.midpoint.prism.match.MatchingRuleRegistry) ObjectUtils(org.apache.commons.lang.ObjectUtils) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) List(java.util.List) FocusType(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType) Entry(java.util.Map.Entry) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) QName(javax.xml.namespace.QName) MappingStrengthType(com.evolveum.midpoint.xml.ns._public.common.common_3.MappingStrengthType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDefinition(com.evolveum.midpoint.prism.ItemDefinition) Trace(com.evolveum.midpoint.util.logging.Trace) HashMap(java.util.HashMap) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) ArrayList(java.util.ArrayList) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) DeltaSetTriple(com.evolveum.midpoint.prism.delta.DeltaSetTriple) PrismContext(com.evolveum.midpoint.prism.PrismContext) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) ItemValueWithOrigin(com.evolveum.midpoint.model.impl.lens.ItemValueWithOrigin) ContainerDelta(com.evolveum.midpoint.prism.delta.ContainerDelta) LensUtil(com.evolveum.midpoint.model.impl.lens.LensUtil) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) Iterator(java.util.Iterator) ShadowAssociationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType) PrismObject(com.evolveum.midpoint.prism.PrismObject) SynchronizationPolicyDecision(com.evolveum.midpoint.model.api.context.SynchronizationPolicyDecision) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) LensProjectionContext(com.evolveum.midpoint.model.impl.lens.LensProjectionContext) Component(org.springframework.stereotype.Component) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) LayerType(com.evolveum.midpoint.xml.ns._public.common.common_3.LayerType) PrismReference(com.evolveum.midpoint.prism.PrismReference) Comparator(java.util.Comparator) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) PrismValueDeltaSetTriple(com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple) DeltaSetTriple(com.evolveum.midpoint.prism.delta.DeltaSetTriple) ArrayList(java.util.ArrayList) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) MappingStrengthType(com.evolveum.midpoint.xml.ns._public.common.common_3.MappingStrengthType) ItemValueWithOrigin(com.evolveum.midpoint.model.impl.lens.ItemValueWithOrigin) Collection(java.util.Collection) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) Map(java.util.Map) HashMap(java.util.HashMap) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) PrismValueDeltaSetTripleProducer(com.evolveum.midpoint.model.common.mapping.PrismValueDeltaSetTripleProducer) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ShadowAssociationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) PrismValueDeltaSetTriple(com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple) QName(javax.xml.namespace.QName) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

com.evolveum.midpoint.common.refinery (com.evolveum.midpoint.common.refinery)1 SynchronizationPolicyDecision (com.evolveum.midpoint.model.api.context.SynchronizationPolicyDecision)1 Mapping (com.evolveum.midpoint.model.common.mapping.Mapping)1 PrismValueDeltaSetTripleProducer (com.evolveum.midpoint.model.common.mapping.PrismValueDeltaSetTripleProducer)1 Construction (com.evolveum.midpoint.model.impl.lens.Construction)1 ItemValueWithOrigin (com.evolveum.midpoint.model.impl.lens.ItemValueWithOrigin)1 LensContext (com.evolveum.midpoint.model.impl.lens.LensContext)1 LensProjectionContext (com.evolveum.midpoint.model.impl.lens.LensProjectionContext)1 LensUtil (com.evolveum.midpoint.model.impl.lens.LensUtil)1 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)1 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)1 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)1 PrismContext (com.evolveum.midpoint.prism.PrismContext)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 PrismProperty (com.evolveum.midpoint.prism.PrismProperty)1 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)1 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)1 PrismReference (com.evolveum.midpoint.prism.PrismReference)1 PrismValue (com.evolveum.midpoint.prism.PrismValue)1 ChangeType (com.evolveum.midpoint.prism.delta.ChangeType)1