use of com.nedap.archie.rm.RMObject in project openEHR_SDK by ehrbase.
the class CanonicalXML method marshalInline.
public String marshalInline(RMObject rmObject, QName qName) {
try {
JAXBElement<RMObject> root = new JAXBElement<>(qName, RMObject.class, rmObject);
Marshaller marshaller = JAXBUtil.getArchieJAXBContext().createMarshaller();
DOMResult res = new DOMResult();
marshaller.marshal(root, res);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
Node rootNode = res.getNode().getFirstChild();
NodeList childNodes = rootNode.getChildNodes();
StringWriter stringWriter = new StringWriter();
for (int i = 0; i < childNodes.getLength(); i++) {
transformer.transform(new DOMSource(childNodes.item(i)), new StreamResult(stringWriter));
}
return stringWriter.toString();
} catch (JAXBException | TransformerException e) {
throw new org.ehrbase.serialisation.exception.MarshalException(e.getMessage(), e);
}
}
use of com.nedap.archie.rm.RMObject in project openEHR_SDK by ehrbase.
the class FromCompositionWalker method extractPair.
protected ImmutablePair<T, RMObject> extractPair(Context<T> context, WebTemplateNode currentNode, Map<String, List<WebTemplateNode>> choices, WebTemplateNode childNode, Integer i) {
RMObject currentChild = null;
T childObject = null;
currentChild = (RMObject) extractRMChild(context.getRmObjectDeque().peek(), currentNode, childNode, choices.containsKey(childNode.getAqlPath()), i);
if (currentChild != null) {
childObject = extract(context, childNode, choices.containsKey(childNode.getAqlPath()), i);
}
ImmutablePair<T, RMObject> pair = new ImmutablePair<>(childObject, currentChild);
return pair;
}
use of com.nedap.archie.rm.RMObject in project openEHR_SDK by ehrbase.
the class FromCompositionWalker method extractRMChild.
protected Object extractRMChild(RMObject currentRM, WebTemplateNode currentNode, WebTemplateNode childNode, boolean isChoice, Integer count) {
ItemExtractor itemExtractor = new ItemExtractor(currentRM, currentNode, childNode, isChoice && count == null).invoke();
Object child = itemExtractor.getChild();
if (count != null && child instanceof List) {
child = ((List<RMObject>) child).get(count);
if (isChoice && !ARCHIE_RM_INFO_LOOKUP.getTypeInfo(childNode.getRmType()).getJavaClass().isAssignableFrom(child.getClass())) {
child = null;
}
}
child = wrap(child);
return child;
}
use of com.nedap.archie.rm.RMObject in project openEHR_SDK by ehrbase.
the class ToCompositionWalker method extractPair.
protected ImmutablePair<T, RMObject> extractPair(Context<T> context, WebTemplateNode currentNode, Map<String, List<WebTemplateNode>> choices, WebTemplateNode childNode, Integer i) {
RMObject currentChild = null;
T childObject = null;
childObject = extract(context, childNode, choices.containsKey(childNode.getAqlPath()), i);
if (childObject != null) {
boolean isChoice = choices.containsKey(childNode.getAqlPath());
if (currentNode.getRmType().equals("ELEMENT") && childNode.getRmType().equals("DV_CODED_TEXT") && childNode.getInputs().stream().anyMatch(in -> "other".equals(in.getSuffix()))) {
isChoice = true;
}
currentChild = (RMObject) extractRMChild(context.getRmObjectDeque().peek(), currentNode, childNode, isChoice, i);
}
return new ImmutablePair<>(childObject, currentChild);
}
use of com.nedap.archie.rm.RMObject in project openEHR_SDK by ehrbase.
the class DtoToCompositionWalker method postHandle.
@Override
protected void postHandle(Context<Map<String, Object>> context) {
super.postHandle(context);
RMObject rmObject = context.getRmObjectDeque().peek();
if (rmObject instanceof Activity) {
context.getObjectDeque().peek().entrySet().stream().filter(e -> e.getKey().endsWith("/action_archetype_id")).map(Map.Entry::getValue).map(String.class::cast).findAny().ifPresent(((Activity) rmObject)::setActionArchetypeId);
}
}
Aggregations