Search in sources :

Example 1 with VariableBindingDefinitionType

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

the class ObjectTemplateProcessor method getUpdatedFocusOdo.

private <F extends FocusType> ObjectDeltaObject<F> getUpdatedFocusOdo(LensContext<F> context, ObjectDeltaObject<F> focusOdo, Map<ItemPath, DeltaSetTriple<? extends ItemValueWithOrigin<?, ?>>> outputTripleMap, ObjectTemplateMappingType mappingType, String contextDesc) throws ExpressionEvaluationException, PolicyViolationException, SchemaException {
    ObjectDeltaObject<F> focusOdoCloned = null;
    for (VariableBindingDefinitionType source : mappingType.getSource()) {
        if (source.getPath() == null) {
            continue;
        }
        ItemPath path = stripFocusVariableSegment(source.getPath().getItemPath());
        if (path.startsWithVariable()) {
            continue;
        }
        DeltaSetTriple<? extends ItemValueWithOrigin<?, ?>> triple = DeltaSetTriple.find(outputTripleMap, path);
        if (triple == null) {
            continue;
        }
        if (focusOdoCloned == null) {
            LOGGER.trace("Cloning and updating focusOdo because of chained mappings; chained source path: {}", path);
            focusOdoCloned = focusOdo.clone();
        } else {
            LOGGER.trace("Updating focusOdo because of chained mappings; chained source path: {}", path);
        }
        Class<F> focusClass = context.getFocusContext().getObjectTypeClass();
        ItemDefinition<?> itemDefinition = getObjectDefinition(focusClass).findItemDefinition(path);
        // TODO not much sure about the parameters
        ItemDelta itemDelta = LensUtil.consolidateTripleToDelta(path, (DeltaSetTriple) triple, itemDefinition, getAprioriItemDelta(focusOdo.getObjectDelta(), path), focusOdo.getNewObject(), null, null, true, true, false, " updating chained source (" + path + ") in " + contextDesc, true);
        LOGGER.trace("Updating focus ODO with delta:\n{}", itemDelta.debugDumpLazily());
        focusOdoCloned.update(itemDelta);
    }
    return focusOdoCloned != null ? focusOdoCloned : focusOdo;
}
Also used : VariableBindingDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.VariableBindingDefinitionType) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 2 with VariableBindingDefinitionType

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

the class ObjectTemplateProcessor method collectMappings.

private List<ObjectTemplateMappingType> collectMappings(ObjectTemplateType objectTemplateType) {
    List<ObjectTemplateMappingType> mappings = new ArrayList<ObjectTemplateMappingType>();
    mappings.addAll(objectTemplateType.getMapping());
    for (ObjectTemplateItemDefinitionType templateItemDefType : objectTemplateType.getItem()) {
        for (ObjectTemplateMappingType mapping : templateItemDefType.getMapping()) {
            VariableBindingDefinitionType target = mapping.getTarget();
            if (target == null) {
                target = new VariableBindingDefinitionType();
                target.setPath(templateItemDefType.getRef());
                mapping.setTarget(target);
            } else if (target.getPath() == null) {
                target = target.clone();
                target.setPath(templateItemDefType.getRef());
                mapping.setTarget(target);
            }
            mappings.add(mapping);
        }
    }
    return mappings;
}
Also used : VariableBindingDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.VariableBindingDefinitionType) ObjectTemplateMappingType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateMappingType) ArrayList(java.util.ArrayList) ObjectTemplateItemDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateItemDefinitionType)

Example 3 with VariableBindingDefinitionType

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

the class VariableBindingDefinitionTypePanel method initLayout.

private void initLayout() {
    ItemPathPanel pathPanel = new ItemPathPanel(ID_PATH_PANEL, createPathModel()) {

        @Override
        protected void onUpdate(ItemPathDto itemPathDto) {
            ItemPath newPath = getModelObject().toItemPath();
            ItemPathType newPathtype = null;
            if (newPath != null) {
                newPathtype = new ItemPathType(newPath);
            }
            VariableBindingDefinitionType var = VariableBindingDefinitionTypePanel.this.getModelObject();
            if (var == null) {
                var = new VariableBindingDefinitionType();
                VariableBindingDefinitionTypePanel.this.getModel().setObject(var);
            }
            VariableBindingDefinitionTypePanel.this.getModelObject().setPath(newPathtype);
        }
    };
    pathPanel.setOutputMarkupId(true);
    add(pathPanel);
}
Also used : VariableBindingDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.VariableBindingDefinitionType) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) ItemPathPanel(com.evolveum.midpoint.gui.api.component.path.ItemPathPanel) ItemPathDto(com.evolveum.midpoint.gui.api.component.path.ItemPathDto) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 4 with VariableBindingDefinitionType

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

the class TransformationalMetadataComputation method createMetadataComputationInput.

// Temporary implementation
private MetadataComputationInput createMetadataComputationInput(MetadataMappingBuilder<?, ?> builder, MetadataMappingType metadataMappingBean) {
    MetadataComputationInput metadataComputationInput = new MetadataComputationInput();
    for (PrismValue inputDataValue : inputValues) {
        Map<String, Collection<?>> metadataSourceMap = new HashMap<>();
        if (inputDataValue != null) {
            for (VariableBindingDefinitionType sourceDef : metadataMappingBean.getSource()) {
                ItemPath metadataSourcePath = getSourcePath(sourceDef);
                QName metadataSourceName = getSourceName(sourceDef, metadataSourcePath);
                List<PrismValue> metadataSourceValues = new ArrayList<>();
                for (PrismContainerValue<Containerable> metadataValue : inputDataValue.getValueMetadata().getValues()) {
                    Item<PrismValue, ItemDefinition> sourceItem = metadataValue.findItem(metadataSourcePath);
                    if (sourceItem != null) {
                        // noinspection unchecked
                        metadataSourceValues.addAll(sourceItem.clone().getRealValues());
                    }
                }
                metadataSourceMap.put(metadataSourceName.getLocalPart(), metadataSourceValues);
            }
            metadataComputationInput.add(inputDataValue, metadataSourceMap);
        }
    }
    return metadataComputationInput;
}
Also used : QName(javax.xml.namespace.QName) VariableBindingDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.VariableBindingDefinitionType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 5 with VariableBindingDefinitionType

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

the class MappingParser method parseTarget.

private void parseTarget() throws SchemaException {
    VariableBindingDefinitionType targetSpecification = m.mappingBean.getTarget();
    if (targetSpecification == null) {
        outputDefinition = m.defaultTargetDefinition;
        outputPath = m.defaultTargetPath;
    } else {
        ItemPathType itemPathType = targetSpecification.getPath();
        if (itemPathType == null) {
            outputDefinition = m.defaultTargetDefinition;
            outputPath = m.defaultTargetPath;
        } else {
            ItemPath path = itemPathType.getItemPath();
            outputDefinition = ExpressionUtil.resolveDefinitionPath(path, m.variables, m.targetContext, "target definition in " + m.getMappingContextDescription());
            if (outputDefinition == null) {
                throw new SchemaException("No target item that would conform to the path " + path + " in " + m.getMappingContextDescription());
            }
            outputPath = path.stripVariableSegment();
        }
    }
    if (m.valuePolicySupplier != null) {
        m.valuePolicySupplier.setOutputDefinition(outputDefinition);
        m.valuePolicySupplier.setOutputPath(outputPath);
    }
}
Also used : VariableBindingDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.VariableBindingDefinitionType) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

VariableBindingDefinitionType (com.evolveum.midpoint.xml.ns._public.common.common_3.VariableBindingDefinitionType)10 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)9 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)4 ExpressionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType)3 QName (javax.xml.namespace.QName)3 ExpressionEvaluationContext (com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext)2 ExpressionFactory (com.evolveum.midpoint.repo.common.expression.ExpressionFactory)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 MappingType (com.evolveum.midpoint.xml.ns._public.common.common_3.MappingType)2 ItemPathDto (com.evolveum.midpoint.gui.api.component.path.ItemPathDto)1 ItemPathPanel (com.evolveum.midpoint.gui.api.component.path.ItemPathPanel)1 Item (com.evolveum.midpoint.prism.Item)1 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)1 NameItemPathSegment (com.evolveum.midpoint.prism.path.NameItemPathSegment)1 VariableItemPathSegment (com.evolveum.midpoint.prism.path.VariableItemPathSegment)1 ItemDeltaItem (com.evolveum.midpoint.prism.util.ItemDeltaItem)1 MapXNode (com.evolveum.midpoint.prism.xnode.MapXNode)1 Source (com.evolveum.midpoint.repo.common.expression.Source)1 ValueSetDefinition (com.evolveum.midpoint.repo.common.expression.ValueSetDefinition)1 VariablesMap (com.evolveum.midpoint.schema.expression.VariablesMap)1