use of com.evolveum.midpoint.xml.ns._public.common.common_3.MappingSourceType 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);
}
Aggregations