Search in sources :

Example 1 with RMJacksonConfiguration

use of com.nedap.archie.json.RMJacksonConfiguration in project openEHR_SDK by ehrbase.

the class JacksonUtil method getObjectMapper.

/**
 * Get an object mapper that works with Archie RM and AOM objects. It will be cached in a static variable for
 * performance reasons
 *
 * @return
 */
public static ObjectMapper getObjectMapper() {
    RMJacksonConfiguration configuration = new RMJacksonConfiguration();
    configuration.setAddExtraFieldsInArchetypeId(false);
    configuration.setTypePropertyName("_type");
    configuration.setSerializeEmptyCollections(true);
    return com.nedap.archie.json.JacksonUtil.getObjectMapper(configuration);
}
Also used : RMJacksonConfiguration(com.nedap.archie.json.RMJacksonConfiguration)

Example 2 with RMJacksonConfiguration

use of com.nedap.archie.json.RMJacksonConfiguration in project openEHR_SDK by ehrbase.

the class ItemStructureVisitorTest method ehrVisitorTest.

@Test
public void ehrVisitorTest() throws Throwable {
    String value = IOUtils.toString(ItemStruktureTestDataCanonicalJson.SIMPLE_EHR_OTHER_Details.getStream(), UTF_8);
    RMJacksonConfiguration configuration = new RMJacksonConfiguration();
    configuration.setTypePropertyName("_type");
    ObjectMapper objectMapper = JacksonUtil.getObjectMapper(configuration);
    ItemTree otherDetails = objectMapper.readValue(value, ItemTree.class);
    EhrStatus ehrStatus = new EhrStatus("ehr_status", new DvText("ehr_status"), new PartySelf(new PartyRef()), true, true, otherDetails);
    itemStructureVisitor.validate(ehrStatus);
    assertEquals(3, itemStructureVisitor.getElementOccurrences());
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) ItemTree(com.nedap.archie.rm.datastructures.ItemTree) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) RMJacksonConfiguration(com.nedap.archie.json.RMJacksonConfiguration) DvText(com.nedap.archie.rm.datavalues.DvText) PartySelf(com.nedap.archie.rm.generic.PartySelf) Test(org.junit.Test)

Aggregations

RMJacksonConfiguration (com.nedap.archie.json.RMJacksonConfiguration)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ItemTree (com.nedap.archie.rm.datastructures.ItemTree)1 DvText (com.nedap.archie.rm.datavalues.DvText)1 EhrStatus (com.nedap.archie.rm.ehr.EhrStatus)1 PartySelf (com.nedap.archie.rm.generic.PartySelf)1 PartyRef (com.nedap.archie.rm.support.identification.PartyRef)1 Test (org.junit.Test)1