Skip to content

Commit

Permalink
Merge branch 'release/v2.16.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
bot committed Jul 29, 2024
2 parents 13df044 + 76ec36e commit 74053fe
Show file tree
Hide file tree
Showing 42 changed files with 1,760 additions and 400,169 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

Note: version releases in the 0.x.y range may introduce breaking changes.

## [2.16.0]
### Added
### Fixed
- Fix missing Base64 encoding og ´DV_MULTIMEDIA` `data` ([624](https://github.com/ehrbase/openEHR_SDK/pull/624))

## [2.15.0]
### Added
### Fixed
Expand Down Expand Up @@ -428,3 +433,4 @@ Note: version releases in the 0.x.y range may introduce breaking changes.
[2.13.0]: https://github.com/ehrbase/openEHR_SDK/compare/v2.12.0...v2.13.0
[2.14.0]: https://github.com/ehrbase/openEHR_SDK/compare/v2.13.0...v2.14.0
[2.15.0]: https://github.com/ehrbase/openEHR_SDK/compare/v2.14.0...v2.15.0
[2.16.0]: https://github.com/ehrbase/openEHR_SDK/compare/v2.15.0...v2.16.0
2 changes: 1 addition & 1 deletion aql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<parent>
<groupId>org.ehrbase.openehr.sdk</groupId>
<artifactId>sdk-parent</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</parent>

<artifactId>aql</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<artifactId>bom</artifactId>
<groupId>org.ehrbase.openehr.sdk</groupId>
<version>2.15.0</version>
<version>2.16.0</version>
<packaging>pom</packaging>

<name>openEHR SDK</name>
Expand Down
2 changes: 1 addition & 1 deletion client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<parent>
<groupId>org.ehrbase.openehr.sdk</groupId>
<artifactId>sdk-parent</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</parent>

<artifactId>client</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion example-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>sdk-parent</artifactId>
<groupId>org.ehrbase.openehr.sdk</groupId>
<version>2.15.0</version>
<version>2.16.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,24 @@ void testConformanceTemplate() throws IOException {
"BLOOD_PRESSURE_SIMPLE",
// DV_CODED_TEXT|name missing
"WORD_WITH_AND",
// deserialization: could no consume Parts
// deserialization: could not consume Parts
"IDCR_PROBLEM_LIST",
// deserialization: could no consume Parts
// deserialization: could not consume Parts
"EPISODE_OF_CARE",
// deserialization: could no consume Parts
// deserialization: could not consume Parts
"MINIMAL_EVALUATION",
// deserialization: could no consume Parts
// deserialization: could not consume Parts
"MINIMAL_INSTRUCTION",
// deserialization: could no consume Parts
// deserialization: could not consume Parts
"MINIMAL_ACTION_2",
// deserialization: could no consume Parts
// deserialization: could not consume Parts
"MINIMAL_ACTION",
// serialization: Unknown Ordinal with code kg
"NESTED",
// deserialization: could no consume Parts
"SECTION_CARDINALITY"
// deserialization: could not consume Parts
"SECTION_CARDINALITY",
// base64 data missing for DV_MULTIMEDIA
"EHRN_ABDM_OP_CONSULT_RECORD"
},
mode = EnumSource.Mode.EXCLUDE)
void testWalkAll(OperationalTemplateTestData template) throws IOException {
Expand Down
2 changes: 1 addition & 1 deletion generator-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.ehrbase.openehr.sdk</groupId>
<artifactId>sdk-parent</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</parent>

<artifactId>generator-commons</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion generator-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>sdk-parent</artifactId>
<groupId>org.ehrbase.openehr.sdk</groupId>
<version>2.15.0</version>
<version>2.16.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<parent>
<groupId>org.ehrbase.openehr.sdk</groupId>
<artifactId>sdk-parent</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</parent>

<artifactId>generator</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion opt-1.4/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<parent>
<groupId>org.ehrbase.openehr.sdk</groupId>
<artifactId>sdk-parent</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</parent>

<artifactId>opt-1.4</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
<parent>
<groupId>org.ehrbase.openehr.sdk</groupId>
<artifactId>bom</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
<relativePath>./bom/pom.xml</relativePath>
</parent>

<groupId>org.ehrbase.openehr.sdk</groupId>
<artifactId>sdk-parent</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
<packaging>pom</packaging>
<name>openEHR SDK</name>

Expand Down
2 changes: 1 addition & 1 deletion response-dto/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<parent>
<groupId>org.ehrbase.openehr.sdk</groupId>
<artifactId>sdk-parent</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</parent>

<artifactId>response-dto</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion serialisation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<parent>
<groupId>org.ehrbase.openehr.sdk</groupId>
<artifactId>sdk-parent</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</parent>

<artifactId>serialisation</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.ehrbase.openehr.sdk.serialisation.flatencoding.std.marshal.config;

import com.fasterxml.jackson.core.Base64Variants;
import com.nedap.archie.rm.datatypes.CodePhrase;
import com.nedap.archie.rm.datavalues.DvURI;
import com.nedap.archie.rm.datavalues.encapsulated.DvMultimedia;
Expand Down Expand Up @@ -91,7 +92,7 @@ public Map<String, Object> buildChildValues(
"data",
Optional.of(rmObject)
.map(DvMultimedia::getData)
.map(b -> new String(b, StandardCharsets.UTF_8))
.map(Base64Variants.MIME_NO_LINEFEEDS::encode)
.orElse(null));

addValue(result, currentTerm, "size", rmObject.getSize());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.ehrbase.openehr.sdk.serialisation.flatencoding.std.umarshal.rmunmarshaller;

import com.fasterxml.jackson.core.Base64Variants;
import com.nedap.archie.rm.datatypes.CodePhrase;
import com.nedap.archie.rm.datavalues.DvURI;
import com.nedap.archie.rm.datavalues.encapsulated.DvMultimedia;
Expand Down Expand Up @@ -114,7 +115,7 @@ public void handle(
currentValues,
codeString -> {
if (codeString != null) {
rmObject.setData(codeString.getBytes(StandardCharsets.UTF_8));
rmObject.setData(Base64Variants.MIME_NO_LINEFEEDS.decode(codeString));
}
},
String.class,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2024 vitasystems GmbH and Hannover Medical School.
*
* This file is part of project openEHR_SDK
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ehrbase.openehr.sdk.serialisation.jsonencoding;

import com.fasterxml.jackson.core.Base64Variants;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer;
import com.fasterxml.jackson.databind.deser.std.StringDeserializer;
import java.io.IOException;

/**
* Custom deserialize that explicitly uses Base64 decoding without a linefeed. This ensures that the JSON, XML and FLat
* formats are aligned.
*/
final class Base64Deserializer extends StdScalarDeserializer<byte[]> {

private final StringDeserializer stringDeserializer = new StringDeserializer();

Base64Deserializer() {
super(byte[].class);
}

@Override
public byte[] deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {

String encoded = stringDeserializer.deserialize(p, ctxt);
return Base64Variants.MIME_NO_LINEFEEDS.decode(encoded);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2024 vitasystems GmbH and Hannover Medical School.
*
* This file is part of project openEHR_SDK
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ehrbase.openehr.sdk.serialisation.jsonencoding;

import com.fasterxml.jackson.core.Base64Variants;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import java.io.IOException;

/**
* Custom serialize that explicitly uses Base64 encoding without a linefeed. This ensures that the JSON, XML and FLat
* formats are aligned.
*/
final class Base64Serializer extends StdSerializer<byte[]> {

Base64Serializer() {
super(byte[].class);
}

@Override
public void serialize(byte[] value, JsonGenerator gen, SerializerProvider provider) throws IOException {
gen.writeBinary(Base64Variants.MIME_NO_LINEFEEDS, value, 0, value.length);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ public class CanonicalJson implements RMDataFormat {
module.addSerializer(DvDateTime.class, new DateTimeSerializer());
module.addSerializer(DvTime.class, new TimeSerializer());
module.addSerializer(DvDate.class, new DateSerializer());
module.addSerializer(byte[].class, new Base64Serializer());
module.addDeserializer(DvDateTime.class, new DateTimeDeserializer());
module.addDeserializer(DvTime.class, new TimeDeserializer());
module.addDeserializer(DvDate.class, new DateDeserializer());
module.addDeserializer(byte[].class, new Base64Deserializer());
MARSHAL_OM.registerModule(module);

// Global configuration to not include empty lists in the JSON
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ public String marshal(RMObject rmObject, Boolean withHeader) {

StringWriter stringWriter = new StringWriter();
try {
Marshaller marshaller = JAXBUtil.getArchieJAXBContext().createMarshaller();
marshaller.setAdapter(DateTimeXmlAdapter.class, new SdkDateTimeXmlAdapter());
marshaller.setAdapter(DateXmlAdapter.class, new SdkDateXmlAdapter());
marshaller.setAdapter(TimeXmlAdapter.class, new SdkTimeXmlAdapter());
Marshaller marshaller = createMarshaller();

marshaller.setProperty("jaxb.fragment", !withHeader);
if (rmObject.getClass().getAnnotation(XmlRootElement.class) == null) {
QName qName = new QName(null, new SnakeCase(rmObject.getClass().getSimpleName()).camelToSnake());
Expand All @@ -97,15 +95,12 @@ public String marshal(RMObject rmObject, Boolean withHeader) {
public String marshalInline(RMObject rmObject, QName qName) {

try {
DOMResult res = new DOMResult();
JAXBElement<RMObject> root = new JAXBElement<>(qName, RMObject.class, rmObject);

Marshaller marshaller = JAXBUtil.getArchieJAXBContext().createMarshaller();
marshaller.setAdapter(DateTimeXmlAdapter.class, new SdkDateTimeXmlAdapter());
marshaller.setAdapter(DateXmlAdapter.class, new SdkDateXmlAdapter());
marshaller.setAdapter(TimeXmlAdapter.class, new SdkTimeXmlAdapter());

DOMResult res = new DOMResult();
Marshaller marshaller = createMarshaller();
marshaller.marshal(root, res);

TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
Expand All @@ -130,10 +125,8 @@ public String marshalInline(RMObject rmObject, QName qName) {
public <T extends RMObject> T unmarshal(String value, Class<T> clazz) {
T composition;
try {
Unmarshaller unmarshaller = JAXBUtil.getArchieJAXBContext().createUnmarshaller();
unmarshaller.setAdapter(DateTimeXmlAdapter.class, new SdkDateTimeXmlAdapter());
unmarshaller.setAdapter(DateXmlAdapter.class, new SdkDateXmlAdapter());
unmarshaller.setAdapter(TimeXmlAdapter.class, new SdkTimeXmlAdapter());
Unmarshaller unmarshaller = createUnmarshaller();

// Set the parentss XMLReader on the XMLFilter
SAXParserFactory spf = SAXParserFactory.newInstance();
// disable external entities
Expand All @@ -156,7 +149,23 @@ public <T extends RMObject> T unmarshal(String value, Class<T> clazz) {
return composition;
}

private class NamespaceFilter extends XMLFilterImpl {
private Marshaller createMarshaller() throws JAXBException {
Marshaller marshaller = JAXBUtil.getArchieJAXBContext().createMarshaller();
marshaller.setAdapter(DateTimeXmlAdapter.class, new SdkDateTimeXmlAdapter());
marshaller.setAdapter(DateXmlAdapter.class, new SdkDateXmlAdapter());
marshaller.setAdapter(TimeXmlAdapter.class, new SdkTimeXmlAdapter());
return marshaller;
}

private Unmarshaller createUnmarshaller() throws JAXBException {
Unmarshaller unmarshaller = JAXBUtil.getArchieJAXBContext().createUnmarshaller();
unmarshaller.setAdapter(DateTimeXmlAdapter.class, new SdkDateTimeXmlAdapter());
unmarshaller.setAdapter(DateXmlAdapter.class, new SdkDateXmlAdapter());
unmarshaller.setAdapter(TimeXmlAdapter.class, new SdkTimeXmlAdapter());
return unmarshaller;
}

private static class NamespaceFilter extends XMLFilterImpl {

@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
Expand All @@ -167,14 +176,13 @@ public void endElement(String uri, String localName, String qName) throws SAXExc
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {

AttributesImpl attributesImpl = new AttributesImpl(atts);

super.startElement(NAMESPACE, localName, qName, attributesImpl);
}

@Override
public void startPrefixMapping(String prefix, String uri) throws SAXException {
// remove default namespace http://schemas.openehr.org/v1
if (!prefix.equals("")) {
if (!prefix.isEmpty()) {
super.startPrefixMapping(prefix, uri);
}
}
Expand Down
Loading

0 comments on commit 74053fe

Please sign in to comment.