use of com.nedap.archie.rm.archetyped.Link 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");
}
}
}
use of com.nedap.archie.rm.archetyped.Link 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);
}
use of com.nedap.archie.rm.archetyped.Link 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);
}
use of com.nedap.archie.rm.archetyped.Link 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);
}
use of com.nedap.archie.rm.archetyped.Link in project openEHR_SDK by ehrbase.
the class LinksAttributes method toMap.
public List<Map<String, Object>> toMap() {
List<Map<String, Object>> links = new ArrayList<>();
for (Link link : linkList) {
Map<String, Object> valuemap = PathMap.getInstance();
valuemap.put(TAG_CLASS, new SimpleClassName(link).toString());
valuemap.put("meaning", link.getMeaning());
valuemap.put("type", link.getType());
valuemap.put("target", link.getTarget());
links.add(valuemap);
}
return links;
}
Aggregations