Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
wolandscat authored Apr 1, 2024
2 parents ca42c1a + f5d640e commit da70a65
Show file tree
Hide file tree
Showing 10 changed files with 2,365 additions and 15 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Gradle Build & Test

on:
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up GraalVM JDK 17
uses: graalvm/setup-graalvm@v1
with:
java-version: '17'
distribution: 'graalvm-community'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Gradle Build
uses: gradle/gradle-build-action@v2.8.0
with:
arguments: build
env:
ORG_GRADLE_PROJECT_mavenUser: ${{ github.actor }}
ORG_GRADLE_PROJECT_mavenPassword: ${{ secrets.GITHUB_TOKEN }}
ORG_GRADLE_PROJECT_snapshotsRepoURL: https://maven.pkg.github.com/${{ github.repository }}
ORG_GRADLE_PROJECT_releasesRepoURL: https://maven.pkg.github.com/${{ github.repository }}
30 changes: 30 additions & 0 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build & Release

on:
push:
branches: [ "master" ]

permissions:
contents: read
packages: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up GraalVM JDK 17
uses: graalvm/setup-graalvm@v1
with:
java-version: '17'
distribution: 'graalvm-community'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Gradle Build
uses: gradle/gradle-build-action@v2.8.0
with:
arguments: build publish
env:
ORG_GRADLE_PROJECT_mavenUser: ${{ github.actor }}
ORG_GRADLE_PROJECT_mavenPassword: ${{ secrets.GITHUB_TOKEN }}
ORG_GRADLE_PROJECT_snapshotsRepoURL: https://maven.pkg.github.com/${{ github.repository }}
ORG_GRADLE_PROJECT_releasesRepoURL: https://maven.pkg.github.com/${{ github.repository }}
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ public ArchieModelNamingStrategy(boolean standardCompliantExpressionNames) {
this.standardsCompliantExpressionNames = standardCompliantExpressionNames;
}

private static HashMap<String, String> rulesArchieToStandardTypeNamesMap = new HashMap<>();
{
private static final HashMap<String, String> rulesArchieToStandardTypeNamesMap = new HashMap<>();
static {
rulesArchieToStandardTypeNamesMap.put("Operator", "EXPR_OPERATOR");
rulesArchieToStandardTypeNamesMap.put("UnaryOperator", "EXPR_UNARY_OPERATOR");
rulesArchieToStandardTypeNamesMap.put("BinaryOperator", "EXPR_BINARY_OPERATOR");
rulesArchieToStandardTypeNamesMap.put("Leaf", "EXPR_LITERAL");
rulesArchieToStandardTypeNamesMap.put("Leaf", "EXPR_LEAF");
rulesArchieToStandardTypeNamesMap.put("Function", "EXPR_FUNCTION");
rulesArchieToStandardTypeNamesMap.put("VariableReference", "EXPR_VARIABLE_REF");
rulesArchieToStandardTypeNamesMap.put("Constant", "EXPR_CONSTANT");
rulesArchieToStandardTypeNamesMap.put("Constant", "EXPR_LITERAL");
rulesArchieToStandardTypeNamesMap.put("Constraint", "EXPR_CONSTRAINT");
rulesArchieToStandardTypeNamesMap.put("ArchetypeIdConstraint", "EXPR_ARCHETYPE_ID_CONSTRAINT");
rulesArchieToStandardTypeNamesMap.put("ModelReference", "EXPR_ARCHETYPE_REF");
Expand Down
6 changes: 5 additions & 1 deletion aom/src/main/java/com/nedap/archie/rules/ExpressionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Created by pieter.bos on 27/10/15.
*/
public enum ExpressionType {
BOOLEAN, STRING, INTEGER, REAL, DATE, TIME, DATETIME, DURATION;
BOOLEAN, STRING, INTEGER, REAL, DATE, TIME, DATETIME, DURATION, C_STRING;

public static ExpressionType fromString(String string) {
switch(string) {
Expand All @@ -25,6 +25,8 @@ public static ExpressionType fromString(String string) {
return DATETIME;
case "Duration":
return DURATION;
case "CString":
return C_STRING;
}
return null;
}
Expand All @@ -47,6 +49,8 @@ public String toString() {
return "DateTime";
case DURATION:
return "Duration";
case C_STRING:
return "CString";
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public static void configureObjectMapper(ObjectMapper objectMapper, ArchieJackso
objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
objectMapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
objectMapper.enable(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS);
objectMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true);
if(!configuration.isSerializeEmptyCollections()) {
objectMapper.setDefaultPropertyInclusion(
JsonInclude.Value.construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,16 @@ public MultiplicityInterval(Integer lower, Boolean lowerIncluded, Boolean lowerU

@JsonCreator
public static MultiplicityInterval createFromString(String interval) {
Pattern pattern = Pattern.compile("(?<lower>[0-9]+)\\.\\.(?<upper>[0-9]+|\\*)");
Pattern pattern = Pattern.compile("(?<lower>[0-9]+)(\\.\\.(?<upper>[0-9]+|\\*))?");
Matcher matcher = pattern.matcher(interval);
if(!matcher.matches()) {
throw new IllegalArgumentException("Cannot parse interval " + interval);
}
String lower = matcher.group("lower");
String upper = matcher.group("upper");
if (upper == null) {
upper = lower;
}
MultiplicityInterval result = new MultiplicityInterval();
if(upper.equalsIgnoreCase("*")) {
result.setUpperUnbounded(true);
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ wrapper {

allprojects {
version = '3.9.1'
group = 'com.nedap.healthcare.archie'
group = 'io.graphitehealth.archie'

ext.gradleScriptDir = "${rootProject.projectDir}/gradle"
//archivesBaseName = 'archie'

Expand Down
12 changes: 4 additions & 8 deletions gradle/publish-maven.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@ if(gradle.ext.shouldSign) {
publishing {
repositories {
maven {
name = "ossrh"
// OSSRH URLS
def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
def snapshotsRepoUrl = 'ttps://oss.sonatype.org/content/repositories/snapshots/'
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl

credentials {
username = project.hasProperty('ossrhUsername') ? ossrhUsername : "Unknown user"
password = project.hasProperty('ossrhPassword') ? ossrhPassword : "Unknown password"
username mavenUser
password mavenPassword
}

url = version.endsWith('SNAPSHOT') ? snapshotsRepoURL : releasesRepoURL
}
}
}
Expand Down
33 changes: 33 additions & 0 deletions tools/src/test/java/com/nedap/archie/json/AOMJacksonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
import com.nedap.archie.rules.OperatorKind;
import com.nedap.archie.serializer.adl.ADLArchetypeSerializer;
import com.nedap.archie.testutil.TestUtil;
import org.junit.Ignore;
import org.junit.Test;
import org.openehr.referencemodels.BuiltinReferenceModels;
import org.threeten.extra.PeriodDuration;

import java.io.File;
import java.io.InputStream;
import java.nio.file.Files;
import java.time.Duration;
import java.time.Period;
import java.time.temporal.ChronoUnit;
Expand Down Expand Up @@ -269,4 +272,34 @@ public void rmOverlay() throws Exception {
" }\n" +
" },"));
}

@Test
public void parseS2AomJson() throws Exception {
try(InputStream stream = getClass().getResourceAsStream( "/S2/json/flat/s2-EHR-Action.medication.v1.2.2.json")) {

Archetype parsed = JacksonUtil.getObjectMapper(ArchieJacksonConfiguration.createStandardsCompliant()).readValue(stream, Archetype.class);
assertNotNull(parsed);
}
}

@Ignore // for local testing
@Test
public void parseS2AomJsonAll() throws Exception {

ObjectMapper mapper = JacksonUtil.getObjectMapper(ArchieJacksonConfiguration.createStandardsCompliant());

Files.find(new File("../../ADL-exported/S2-S2_demo/json/flat").toPath(),
1,
(file, att) -> file.toString().endsWith(".json"))
.forEach(file -> {
try (InputStream stream = Files.newInputStream(file)) {
Archetype parsed = mapper.readValue(stream, Archetype.class);
assertNotNull(parsed);
} catch (Exception e) {
System.out.println("Error parsing " + file.toString());
throw new RuntimeException(e);
}
});
}

}
Loading

0 comments on commit da70a65

Please sign in to comment.