Search in sources :

Example 36 with DvText

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

the class CanonicalXMLTest method marshalInline.

@Test
public void marshalInline() {
    Folder folder = new Folder();
    folder.setName(new DvText("folder name"));
    folder.addItem(new PartyRef());
    CanonicalXML canonicalXML = new CanonicalXML();
    String inline = canonicalXML.marshalInline(folder, new QName(null, "folder"));
    System.out.println(inline);
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) QName(javax.xml.namespace.QName) CompositionTestDataCanonicalXML(org.ehrbase.test_data.composition.CompositionTestDataCanonicalXML) Folder(com.nedap.archie.rm.directory.Folder) DvText(com.nedap.archie.rm.datavalues.DvText) Test(org.junit.Test)

Example 37 with DvText

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

the class FeederAuditDetailsAttributesTest method toMap.

@Test
public void toMap() throws Exception {
    String value = IOUtils.toString(CompositionTestDataCanonicalJson.FEEDER_AUDIT_DETAILS.getStream(), UTF_8);
    CanonicalJson cut = new CanonicalJson();
    Composition composition = cut.unmarshal(value, Composition.class);
    assertNotNull(composition);
    assertNotNull(composition.getFeederAudit().getFeederSystemAudit().getOtherDetails());
    // with real data
    FeederAuditDetailsAttributes attributes = new FeederAuditDetailsAttributes(composition.getFeederAudit().getFeederSystemAudit());
    Map<String, Object> map = attributes.toMap();
    assertNotNull(map);
    assertNotNull(map.get("other_details[openEHR-EHR-ITEM_TREE.generic.v1]"));
    // valid fabricated data without brackets
    FeederAuditDetails details = new FeederAuditDetails();
    ItemSingle single = new ItemSingle("test", new DvCodedText("text", new CodePhrase("string")), new Element("node", new DvText("name"), null));
    details.setOtherDetails(single);
    details.setSystemId("system");
    attributes = new FeederAuditDetailsAttributes(details);
    map = attributes.toMap();
    assertNotNull(map.get("other_details[test]"));
    // valid fabricated data with brackets
    details = new FeederAuditDetails();
    single = new ItemSingle("[test]", new DvCodedText("text", new CodePhrase("string")), new Element("node", new DvText("name"), null));
    details.setOtherDetails(single);
    details.setSystemId("system");
    attributes = new FeederAuditDetailsAttributes(details);
    map = attributes.toMap();
    assertNotNull(map.get("other_details[test]"));
    // invalid data with one [
    details = new FeederAuditDetails();
    single = new ItemSingle("[test", new DvCodedText("text", new CodePhrase("string")), new Element("node", new DvText("name"), null));
    details.setOtherDetails(single);
    details.setSystemId("system");
    attributes = new FeederAuditDetailsAttributes(details);
    assertThrows(IllegalArgumentException.class, attributes::toMap);
    // invalid data with one ]
    details = new FeederAuditDetails();
    single = new ItemSingle("test]", new DvCodedText("text", new CodePhrase("string")), new Element("node", new DvText("name"), null));
    details.setOtherDetails(single);
    details.setSystemId("system");
    attributes = new FeederAuditDetailsAttributes(details);
    assertThrows(IllegalArgumentException.class, attributes::toMap);
}
Also used : CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) CompositionTestDataCanonicalJson(org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson) Composition(com.nedap.archie.rm.composition.Composition) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) Element(com.nedap.archie.rm.datastructures.Element) DvText(com.nedap.archie.rm.datavalues.DvText) FeederAuditDetails(com.nedap.archie.rm.archetyped.FeederAuditDetails) ItemSingle(com.nedap.archie.rm.datastructures.ItemSingle) Test(org.junit.Test)

Example 38 with DvText

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

the class CanonicalJsonMarshallingTest method MarshalEmptyDvText.

@Test
public void MarshalEmptyDvText() {
    DvText dvText = new DvText("");
    CanonicalJson cut = new CanonicalJson();
    String actual = cut.marshal(dvText);
    assertThat(actual).isEqualToIgnoringWhitespace("{\n" + "  \"_type\" : \"DV_TEXT\",\n" + "  \"value\" : \"\"\n" + "}");
}
Also used : DvText(com.nedap.archie.rm.datavalues.DvText) Test(org.junit.Test)

Example 39 with DvText

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

the class LinksEncodingTest method testFromDbTwoLinks.

public void testFromDbTwoLinks() {
    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);
    Link link2 = new Link(new DvText("something2"), new DvText("something else2"), new DvEHRURI("ehr://target2"));
    List<Link> list2 = new ArrayList<Link>();
    list2.add(link);
    list2.add(link2);
    String encoded2 = encoding.toDB(list2);
    List<Link> result2 = encoding.fromDB(encoded2);
    assertEquals(list2, result2);
}
Also used : DvEHRURI(com.nedap.archie.rm.datavalues.DvEHRURI) ArrayList(java.util.ArrayList) Link(com.nedap.archie.rm.archetyped.Link) DvText(com.nedap.archie.rm.datavalues.DvText)

Example 40 with DvText

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

the class DefaultRestFolderDAO method setName.

@Override
public void setName(String name) {
    directoryEndpoint.syncFromDb();
    getFolder().setName(new DvText(name));
    directoryEndpoint.saveToDb();
}
Also used : 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