Search in sources :

Example 1 with TransformationMetadataType

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

the class TransformationBuiltinMapping method applyForTransformation.

/**
 * Transformation merges the acquisitions into single yield.
 */
@Override
public void applyForTransformation(@NotNull TransformationalMetadataComputation computation) {
    List<PrismValue> input = computation.getInputValues();
    LOGGER.trace("Computing transformation metadata during value transformation. Input values:\n{}", lazy(() -> dumpInput(input)));
    MappingTransformationType mappingTransformation = new MappingTransformationType(prismContext).mappingSpecification(computation.getMappingSpecification());
    List<QName> sourceNames = computation.getSourceNames();
    if (computation.getInputValues().size() < sourceNames.size()) {
        throw new IllegalStateException("Couldn't compute transformational metadata: there are less values (" + computation.getInputValues().size() + ") than sources (" + sourceNames.size() + ") in " + computation.getContextDescription());
    }
    for (int i = 0; i < sourceNames.size(); i++) {
        MappingSourceType source = new MappingSourceType(prismContext);
        QName sourceName = sourceNames.get(i);
        if (sourceName != null) {
            source.setName(sourceName.getLocalPart());
        }
        PrismValue inputValue = computation.getInputValues().get(i);
        if (inputValue != null) {
            PrismValue inputValueClone = inputValue.clone();
            markNotTransient(inputValueClone);
            source.setValue(new RawType(inputValueClone, null, prismContext));
        }
        mappingTransformation.getSource().add(source);
    }
    TransformationMetadataType transformation = new TransformationMetadataType(prismContext).mappingTransformation(mappingTransformation);
    LOGGER.trace("Output: transformation:\n{}", lazy(() -> transformation.asPrismContainerValue().debugDump()));
    computation.getOutputMetadataValueBean().setTransformation(transformation);
}
Also used : TransformationMetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.TransformationMetadataType) MappingTransformationType(com.evolveum.midpoint.xml.ns._public.common.common_3.MappingTransformationType) QName(javax.xml.namespace.QName) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType) PrismValue(com.evolveum.midpoint.prism.PrismValue) MappingSourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.MappingSourceType)

Aggregations

PrismValue (com.evolveum.midpoint.prism.PrismValue)1 MappingSourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.MappingSourceType)1 MappingTransformationType (com.evolveum.midpoint.xml.ns._public.common.common_3.MappingTransformationType)1 TransformationMetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.TransformationMetadataType)1 RawType (com.evolveum.prism.xml.ns._public.types_3.RawType)1 QName (javax.xml.namespace.QName)1