Search in sources :

Example 1 with RMUnmarshaller

use of org.ehrbase.serialisation.flatencoding.std.umarshal.rmunmarshaller.RMUnmarshaller in project openEHR_SDK by ehrbase.

the class StdToCompositionWalker method preHandle.

@Override
protected void preHandle(Context<Map<FlatPathDto, String>> context) {
    // Handle if at an End-Node
    if (!isRaw(context) && !visitChildren(context.getNodeDeque().peek()) && !context.getFlatHelper().skip(context)) {
        if (context.getRmObjectDeque().peek().getClass().isAssignableFrom(DvCodedText.class) && context.getObjectDeque().peek().keySet().stream().anyMatch(k -> "other".equals(k.getLast().getAttributeName()))) {
            replaceRmObject(context, new DvText());
        }
        RMUnmarshaller rmUnmarshaller = findRMUnmarshaller(context.getRmObjectDeque().peek().getClass());
        String namePath = buildNamePathWithElementHandling(context);
        rmUnmarshaller.handle(namePath, context.getRmObjectDeque().peek(), context.getObjectDeque().peek(), context, consumedPaths);
    }
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) ToCompositionWalker(org.ehrbase.serialisation.walker.ToCompositionWalker) DefaultRMUnmarshaller(org.ehrbase.serialisation.flatencoding.std.umarshal.rmunmarshaller.DefaultRMUnmarshaller) Element(com.nedap.archie.rm.datastructures.Element) StringUtils(org.apache.commons.lang3.StringUtils) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ArrayList(java.util.ArrayList) WebTemplateSkeletonBuilder(org.ehrbase.building.webtemplateskeletnbuilder.WebTemplateSkeletonBuilder) HashSet(java.util.HashSet) Map(java.util.Map) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) Entry(com.nedap.archie.rm.composition.Entry) UnmarshalPostprocessor(org.ehrbase.serialisation.flatencoding.std.umarshal.postprocessor.UnmarshalPostprocessor) DV_TEXT(org.ehrbase.util.rmconstants.RmConstants.DV_TEXT) Context(org.ehrbase.serialisation.walker.Context) ReflectionHelper(org.ehrbase.util.reflection.ReflectionHelper) ELEMENT(org.ehrbase.util.rmconstants.RmConstants.ELEMENT) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) DvText(com.nedap.archie.rm.datavalues.DvText) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) WebTemplateInput(org.ehrbase.webtemplate.model.WebTemplateInput) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) Set(java.util.Set) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) DefaultValues(org.ehrbase.serialisation.walker.defaultvalues.DefaultValues) DV_CODED_TEXT(org.ehrbase.util.rmconstants.RmConstants.DV_CODED_TEXT) Collectors(java.util.stream.Collectors) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) UnmarshalException(org.ehrbase.serialisation.exception.UnmarshalException) JacksonUtil(org.ehrbase.serialisation.jsonencoding.JacksonUtil) Objects(java.util.Objects) WebTemplate(org.ehrbase.webtemplate.model.WebTemplate) List(java.util.List) WebTemplateUtils(org.ehrbase.webtemplate.util.WebTemplateUtils) RMObject(com.nedap.archie.rm.RMObject) Optional(java.util.Optional) RMUnmarshaller(org.ehrbase.serialisation.flatencoding.std.umarshal.rmunmarshaller.RMUnmarshaller) NodeId(org.ehrbase.serialisation.walker.NodeId) WebTemplateNode(org.ehrbase.webtemplate.model.WebTemplateNode) PartyRelated(com.nedap.archie.rm.generic.PartyRelated) Collections(java.util.Collections) Filter(org.ehrbase.webtemplate.filter.Filter) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) DefaultRMUnmarshaller(org.ehrbase.serialisation.flatencoding.std.umarshal.rmunmarshaller.DefaultRMUnmarshaller) RMUnmarshaller(org.ehrbase.serialisation.flatencoding.std.umarshal.rmunmarshaller.RMUnmarshaller) DvText(com.nedap.archie.rm.datavalues.DvText)

Example 2 with RMUnmarshaller

use of org.ehrbase.serialisation.flatencoding.std.umarshal.rmunmarshaller.RMUnmarshaller in project openEHR_SDK by ehrbase.

the class DvOrderedPostprocessor method handleBorder.

private void handleBorder(Map<FlatPathDto, String> values, Set<String> consumedPaths, Context<Map<FlatPathDto, String>> context, String borderName, Consumer<DvOrdered> borderConsumer, String term) {
    Map<FlatPathDto, String> borderValues = FlatHelper.filter(values, term + PATH_DIVIDER + borderName, false);
    if (!borderValues.isEmpty()) {
        DvOrdered lower = WebTemplateSkeletonBuilder.build(context.getNodeDeque().peek(), false, DvOrdered.class);
        borderConsumer.accept(lower);
        RMUnmarshaller rmUnmarshaller = findRMUnmarshaller(lower.getClass());
        rmUnmarshaller.handle(term + PATH_DIVIDER + borderName, lower, borderValues, context, consumedPaths);
    }
}
Also used : StdToCompositionWalker.findRMUnmarshaller(org.ehrbase.serialisation.flatencoding.std.umarshal.StdToCompositionWalker.findRMUnmarshaller) RMUnmarshaller(org.ehrbase.serialisation.flatencoding.std.umarshal.rmunmarshaller.RMUnmarshaller) DvOrdered(com.nedap.archie.rm.datavalues.quantity.DvOrdered) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto)

Aggregations

RMUnmarshaller (org.ehrbase.serialisation.flatencoding.std.umarshal.rmunmarshaller.RMUnmarshaller)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 RMObject (com.nedap.archie.rm.RMObject)1 Composition (com.nedap.archie.rm.composition.Composition)1 Entry (com.nedap.archie.rm.composition.Entry)1 Element (com.nedap.archie.rm.datastructures.Element)1 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)1 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)1 DvText (com.nedap.archie.rm.datavalues.DvText)1 DvOrdered (com.nedap.archie.rm.datavalues.quantity.DvOrdered)1 PartyRelated (com.nedap.archie.rm.generic.PartyRelated)1 TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1