Search in sources :

Example 11 with DvText

use of com.nedap.archie.rm.datavalues.DvText 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 12 with DvText

use of com.nedap.archie.rm.datavalues.DvText in project openEHR_SDK by ehrbase.

the class LocatableMarshalPostprocessor method process.

/**
 * {@inheritDoc}
 */
@Override
public void process(String term, Locatable rmObject, Map<String, Object> values, Context<Map<String, Object>> context) {
    if (RmConstants.ELEMENT.equals(context.getNodeDeque().peek().getRmType()) || !context.getFlatHelper().skip(context)) {
        addValue(values, term + PATH_DIVIDER + "_uid", null, Optional.of(rmObject).map(Locatable::getUid).map(ObjectId::getValue).orElse(null));
        if (rmObject.getLinks() != null) {
            IntStream.range(0, rmObject.getLinks().size()).forEach(i -> {
                Link link = rmObject.getLinks().get(i);
                String termLoop = term + PATH_DIVIDER + "_link:" + i;
                addValue(values, termLoop, "meaning", Optional.of(link).map(Link::getMeaning).map(DvText::getValue).orElse(null));
                addValue(values, termLoop, "type", Optional.of(link).map(Link::getType).map(DvText::getValue).orElse(null));
                addValue(values, termLoop, "target", Optional.of(link).map(Link::getTarget).map(DvEHRURI::getValue).orElse(null));
            });
        }
        if (rmObject.getFeederAudit() != null) {
            callMarshal(term, "_feeder_audit", rmObject.getFeederAudit(), values, context, context.getNodeDeque().peek().findChildById("feeder_audit").orElse(FlatHelper.buildDummyChild("feeder_audit", context.getNodeDeque().peek())));
        }
        if (Optional.ofNullable(rmObject.getName()).map(DvText::getValue).filter(n -> !Objects.equals(context.getNodeDeque().peek().getName(), n)).isPresent()) {
            handleRmAttribute(term, rmObject.getName(), values, context, "name");
        }
    }
}
Also used : IntStream(java.util.stream.IntStream) Context(org.ehrbase.serialisation.walker.Context) FlatHelper(org.ehrbase.serialisation.walker.FlatHelper) DvText(com.nedap.archie.rm.datavalues.DvText) ObjectId(com.nedap.archie.rm.support.identification.ObjectId) DvEHRURI(com.nedap.archie.rm.datavalues.DvEHRURI) Objects(java.util.Objects) PATH_DIVIDER(org.ehrbase.webtemplate.parser.OPTParser.PATH_DIVIDER) Map(java.util.Map) RmConstants(org.ehrbase.util.rmconstants.RmConstants) Locatable(com.nedap.archie.rm.archetyped.Locatable) Optional(java.util.Optional) Link(com.nedap.archie.rm.archetyped.Link) ObjectId(com.nedap.archie.rm.support.identification.ObjectId) DvEHRURI(com.nedap.archie.rm.datavalues.DvEHRURI) Link(com.nedap.archie.rm.archetyped.Link) DvText(com.nedap.archie.rm.datavalues.DvText)

Example 13 with DvText

use of com.nedap.archie.rm.datavalues.DvText in project openEHR_SDK by ehrbase.

the class DvTextAdapter method write.

@Override
public void write(JsonWriter writer, DvText dvalue) throws IOException {
    if (dvalue == null) {
        writer.nullValue();
        return;
    }
    if (adapterType == I_DvTypeAdapter.AdapterType.PG_JSONB) {
        TermMappingAdapter termMappingAdapter = new TermMappingAdapter();
        writer.beginObject();
        writer.name("value").value(dvalue.getValue());
        writer.name(I_DvTypeAdapter.TAG_CLASS_RAW_JSON).value(new SnakeCase(DvText.class.getSimpleName()).camelToUpperSnake());
        termMappingAdapter.write(writer, dvalue.getMappings());
        writer.endObject();
    } else if (adapterType == I_DvTypeAdapter.AdapterType.RAW_JSON) {
        writer.beginObject();
        writer.name(I_DvTypeAdapter.TAG_CLASS_RAW_JSON).value(new ObjectSnakeCase(dvalue).camelToUpperSnake());
        writer.name("value").value(dvalue.getValue());
        writer.endObject();
    }
}
Also used : SnakeCase(org.ehrbase.serialisation.util.SnakeCase) ObjectSnakeCase(org.ehrbase.serialisation.util.ObjectSnakeCase) ObjectSnakeCase(org.ehrbase.serialisation.util.ObjectSnakeCase) DvText(com.nedap.archie.rm.datavalues.DvText)

Example 14 with DvText

use of com.nedap.archie.rm.datavalues.DvText in project openEHR_SDK by ehrbase.

the class LinksEncodingTest method testToDb.

public void testToDb() {
    LinksEncoding encoding = new LinksEncoding();
    Link link = new Link(new DvText("something"), new DvText("something else"), new DvEHRURI("ehr://target"));
    String encoded = encoding.toDB(Collections.singletonList(link));
    assertNotNull(encoded);
}
Also used : DvEHRURI(com.nedap.archie.rm.datavalues.DvEHRURI) Link(com.nedap.archie.rm.archetyped.Link) DvText(com.nedap.archie.rm.datavalues.DvText)

Example 15 with DvText

use of com.nedap.archie.rm.datavalues.DvText in project openEHR_SDK by ehrbase.

the class LinksEncodingTest method testFromDbOneLink.

public void testFromDbOneLink() {
    LinksEncoding encoding = new LinksEncoding();
    Link link = new Link(new DvText("something"), new DvText("something else"), new DvEHRURI("ehr://target"));
    List<Link> list = Collections.singletonList(link);
    String encoded = encoding.toDB(list);
    assertNotNull(encoded);
    List<Link> result1 = encoding.fromDB(encoded);
    assertEquals(list, result1);
}
Also used : DvEHRURI(com.nedap.archie.rm.datavalues.DvEHRURI) Link(com.nedap.archie.rm.archetyped.Link) DvText(com.nedap.archie.rm.datavalues.DvText)

Aggregations

DvText (com.nedap.archie.rm.datavalues.DvText)50 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)16 Test (org.junit.Test)14 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)11 PartySelf (com.nedap.archie.rm.generic.PartySelf)11 Composition (com.nedap.archie.rm.composition.Composition)10 PartyRef (com.nedap.archie.rm.support.identification.PartyRef)9 TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)9 ArrayList (java.util.ArrayList)9 CanonicalJson (org.ehrbase.serialisation.jsonencoding.CanonicalJson)9 EhrStatus (com.nedap.archie.rm.ehr.EhrStatus)8 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)8 HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)8 UUID (java.util.UUID)8 Participation (com.nedap.archie.rm.generic.Participation)6 Optional (java.util.Optional)6 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)6 Folder (com.nedap.archie.rm.directory.Folder)5 PartyProxy (com.nedap.archie.rm.generic.PartyProxy)5 URI (java.net.URI)5