Skip to content

Commit

Permalink
Merge branch 'release/v2.15.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
bot committed Jul 24, 2024
2 parents bf3730c + c69259d commit 13df044
Show file tree
Hide file tree
Showing 30 changed files with 511 additions and 469 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.15.0]
### Added
### Fixed
- Fix flat format parsing of `ObjectVersionId` ([622](https://github.com/ehrbase/openEHR_SDK/pull/622))

## [2.14.0]
### Changed
- Bumped libraries
Expand Down Expand Up @@ -422,3 +427,4 @@ Note: version releases in the 0.x.y range may introduce breaking changes.
[2.12.0]: https://github.com/ehrbase/openEHR_SDK/compare/v2.11.0...v2.12.0
[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 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.14.0</version>
<version>2.15.0</version>
</parent>

<artifactId>aql</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions 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.14.0</version>
<version>2.15.0</version>
<packaging>pom</packaging>

<name>openEHR SDK</name>
Expand Down Expand Up @@ -356,7 +356,7 @@
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.19.7</version>
<version>1.20.0</version>
<scope>test</scope>
</dependency>
<dependency>
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.14.0</version>
<version>2.15.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.14.0</version>
<version>2.15.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

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.14.0</version>
<version>2.15.0</version>
</parent>

<artifactId>generator-commons</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions 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.14.0</version>
<version>2.15.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -38,7 +38,7 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.9.6</version>
<version>3.9.8</version>
<scope>provided</scope>
</dependency>
</dependencies>
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.14.0</version>
<version>2.15.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.14.0</version>
<version>2.15.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.14.0</version>
<version>2.15.0</version>
<relativePath>./bom/pom.xml</relativePath>
</parent>

<groupId>org.ehrbase.openehr.sdk</groupId>
<artifactId>sdk-parent</artifactId>
<version>2.14.0</version>
<version>2.15.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.14.0</version>
<version>2.15.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.14.0</version>
<version>2.15.0</version>
</parent>

<artifactId>serialisation</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@
import com.nedap.archie.rm.datavalues.DvCodedText;
import com.nedap.archie.rm.datavalues.DvText;
import com.nedap.archie.rm.support.identification.HierObjectId;
import com.nedap.archie.rm.support.identification.ObjectVersionId;
import java.util.ArrayList;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.ehrbase.openehr.sdk.serialisation.walker.Context;
import org.ehrbase.openehr.sdk.serialisation.walker.FlatHelper;
import org.ehrbase.openehr.sdk.serialisation.walker.defaultvalues.DefaultValues;
import org.ehrbase.openehr.sdk.util.rmconstants.RmConstants;
import org.ehrbase.openehr.sdk.webtemplate.model.WebTemplateNode;
import org.ehrbase.openehr.sdk.webtemplate.path.flat.FlatPathDto;

public class LocatableUnmarshalPostprocessor extends AbstractUnmarshalPostprocessor<Locatable> {
Expand All @@ -48,54 +51,16 @@ public void process(
Set<String> consumedPaths,
Context<Map<FlatPathDto, String>> context) {

if (RmConstants.ELEMENT.equals(context.getNodeDeque().peek().getRmType())
|| !context.getFlatHelper().skip(context)) {

setValue(
term + PATH_DIVIDER + "_uid",
null,
values,
s -> rmObject.setUid(new HierObjectId(s)),
String.class,
consumedPaths);

Map<Integer, Map<FlatPathDto, String>> links = extractMultiValued(term, "_link", values);

if (rmObject.getLinks() == null) {
rmObject.setLinks(new ArrayList<>());
}

rmObject.getLinks()
.addAll(links.entrySet().stream()
.map(e -> DefaultValues.createLink(e.getValue(), term + "/_link:" + e.getKey()))
.collect(Collectors.toList()));

consumeAllMatching(term + PATH_DIVIDER + "_link", values, consumedPaths, false);

Map<FlatPathDto, String> feederAuditValues = FlatHelper.filter(values, term + "/_feeder_audit", false);

if (!feederAuditValues.isEmpty()) {

rmObject.setFeederAudit(new FeederAudit());
handleRmAttribute(
term, rmObject.getFeederAudit(), feederAuditValues, consumedPaths, context, "feeder_audit");
}

Map<FlatPathDto, String> nameValues = FlatHelper.filter(values, term + "/_name", false);
if (!nameValues.isEmpty()) {
final DvText name;
boolean isDvCodedText = nameValues.keySet().stream()
.anyMatch(e -> "code".equals(e.getLast().getAttributeName())
&& "_name".equals(e.getLast().getName()));

if (isDvCodedText) {
name = new DvCodedText();
} else {
name = new DvText();
}
rmObject.setName(name);
handleRmAttribute(term, rmObject.getName(), nameValues, consumedPaths, context, "name");
}
String rmType = Optional.ofNullable(context.getNodeDeque().peek())
.map(WebTemplateNode::getRmType)
.orElse(null);

if (RmConstants.ELEMENT.equals(rmType) || !context.getFlatHelper().skip(context)) {

setUID(term, rmObject, values, consumedPaths);
setName(term, rmObject, values, consumedPaths, context);
setLinks(term, rmObject, values, consumedPaths);
setFeederAudit(term, rmObject, values, consumedPaths, context);
}
}

Expand All @@ -104,4 +69,69 @@ public void process(
public Class<Locatable> getAssociatedClass() {
return Locatable.class;
}

private void setUID(String term, Locatable rmObject, Map<FlatPathDto, String> values, Set<String> consumedPaths) {
setValue(
term + PATH_DIVIDER + "_uid",
null,
values,
value -> rmObject.setUid(
StringUtils.countMatches(value, "::") == 2
? new ObjectVersionId(value)
: new HierObjectId(value)),
String.class,
consumedPaths);
}

private void setName(
String term,
Locatable rmObject,
Map<FlatPathDto, String> values,
Set<String> consumedPaths,
Context<Map<FlatPathDto, String>> context) {

Map<FlatPathDto, String> nameValues = FlatHelper.filter(values, term + "/_name", false);
if (!nameValues.isEmpty()) {
boolean isDvCodedText = nameValues.keySet().stream().anyMatch(e -> {
FlatPathDto last = e.getLast();
return "code".equals(last.getAttributeName()) && "_name".equals(last.getName());
});

rmObject.setName(isDvCodedText ? new DvCodedText() : new DvText());
handleRmAttribute(term, rmObject.getName(), nameValues, consumedPaths, context, "name");
}
}

private void setLinks(String term, Locatable rmObject, Map<FlatPathDto, String> values, Set<String> consumedPaths) {

Map<Integer, Map<FlatPathDto, String>> links = extractMultiValued(term, "_link", values);

if (rmObject.getLinks() == null) {
rmObject.setLinks(new ArrayList<>());
}

rmObject.getLinks()
.addAll(links.entrySet().stream()
.map(e -> DefaultValues.createLink(e.getValue(), term + "/_link:" + e.getKey()))
.toList());

consumeAllMatching(term + PATH_DIVIDER + "_link", values, consumedPaths, false);
}

private void setFeederAudit(
String term,
Locatable rmObject,
Map<FlatPathDto, String> values,
Set<String> consumedPaths,
Context<Map<FlatPathDto, String>> context) {

Map<FlatPathDto, String> feederAuditValues = FlatHelper.filter(values, term + "/_feeder_audit", false);

if (!feederAuditValues.isEmpty()) {

rmObject.setFeederAudit(new FeederAudit());
handleRmAttribute(
term, rmObject.getFeederAudit(), feederAuditValues, consumedPaths, context, "feeder_audit");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
import org.ehrbase.openehr.sdk.serialisation.xmlencoding.CanonicalXML;
import org.ehrbase.openehr.sdk.test_data.folder.FolderTestDataCanonicalJson;
import org.ehrbase.openehr.sdk.test_data.folder.FolderTestDataCanonicalXML;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

public class FolderSerializerTest {
class FolderSerializerTest {

@Test
public void marshalBasicJsonFolder() throws IOException {
void marshalBasicJsonFolder() throws IOException {

String value = IOUtils.toString(FolderTestDataCanonicalJson.SIMPLE_EMPTY_FOLDER.getStream(), UTF_8);
CanonicalJson canonicalJson = new CanonicalJson();
Expand All @@ -49,7 +49,7 @@ public void marshalBasicJsonFolder() throws IOException {
}

@Test
public void unmarshalBasicJsonFolder() throws IOException {
void unmarshalBasicJsonFolder() throws IOException {

String value = IOUtils.toString(FolderTestDataCanonicalJson.SIMPLE_EMPTY_FOLDER.getStream(), UTF_8);

Expand All @@ -60,8 +60,8 @@ public void unmarshalBasicJsonFolder() throws IOException {
}

@Test
@Ignore("Possible bug at Archie with missing XMLRootElement annotation for folders.")
public void marshalBasicXmlFolder() throws IOException {
@Disabled("Possible bug at Archie with missing XMLRootElement annotation for folders.")
void marshalBasicXmlFolder() throws IOException {

String value = IOUtils.toString(FolderTestDataCanonicalXML.SIMPLE_EMPTY_FOLDER.getStrean(), UTF_8);

Expand Down
Loading

0 comments on commit 13df044

Please sign in to comment.