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);
}
}
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");
}
}
}
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();
}
}
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);
}
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);
}
Aggregations