Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local build #586

Closed
wants to merge 9 commits into from
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 }}
29 changes: 29 additions & 0 deletions .github/workflows/push.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 }}
7 changes: 5 additions & 2 deletions bmm/src/main/java/org/openehr/bmm/core/BmmContainerType.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
* Author: Claude Nanjo
*/

import org.openehr.bmm.persistence.validation.BmmDefinitions;

import java.util.List;

/**
Expand All @@ -36,7 +38,7 @@ public class BmmContainerType extends BmmType {
private BmmGenericClass containerType;

/**
*
* The type of the contained item
*/
private BmmUnitaryType baseType;

Expand Down Expand Up @@ -90,7 +92,8 @@ public void setBaseType(BmmUnitaryType baseType) {
*/
@Override
public String getTypeName() {
return containerType.getName() + "<" + baseType.getTypeName() + ">";
return containerType.getName() +
BmmDefinitions.GENERIC_LEFT_DELIMITER + baseType.getTypeName() + BmmDefinitions.GENERIC_RIGHT_DELIMITER;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.openehr.bmm.core;

import com.nedap.archie.base.MultiplicityInterval;

/**
* Subtype of BMM_CONTAINER_PROPERTY that represents an indexed container type based on one of the inbuilt types
* Hash &lt;&gt;.
*/
public class BmmIndexedContainerProperty extends BmmProperty<BmmIndexedContainerType> {

/**
* We have to replicate cardinality here from BmmContainerProperty since we are inheriting from
* BmmProperty &lt;BmmIndexedContainerType&gt; (which creates correct typing of the 'type' property) not BmmContainerProperty
*/
private MultiplicityInterval cardinality;

public BmmIndexedContainerProperty (String aName, BmmIndexedContainerType aType, String aDocumentation, boolean isMandatoryFlag, boolean isComputedFlag) {
super(aName, aType, aDocumentation, isMandatoryFlag, isComputedFlag);
cardinality = MultiplicityInterval.createOpen();
}

public MultiplicityInterval getCardinality() {
return cardinality;
}
public void setCardinality(MultiplicityInterval cardinality) {
this.cardinality = cardinality;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.openehr.bmm.core;

import org.openehr.bmm.persistence.validation.BmmDefinitions;

public class BmmIndexedContainerType extends BmmContainerType {

/**
* The type of the index
*/
private BmmSimpleType indexType;
public BmmIndexedContainerType (BmmUnitaryType aBaseType, BmmSimpleType anIndexType, BmmGenericClass aContainerClass) {
super (aBaseType, aContainerClass);
indexType = anIndexType;
}
public BmmSimpleType getIndexType() { return indexType; }

@Override
public String getTypeName() {
return getContainerType().getName() +
BmmDefinitions.GENERIC_LEFT_DELIMITER +
indexType.getTypeName() + BmmDefinitions.GENERIC_SEPARATOR +
getBaseType().getTypeName() +
BmmDefinitions.GENERIC_RIGHT_DELIMITER;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.openehr.bmm.v2.persistence;

import com.nedap.archie.base.Interval;
import com.nedap.archie.base.MultiplicityInterval;
import org.openehr.bmm.core.*;
import org.openehr.bmm.v2.validation.converters.BmmClassProcessor;

public class PBmmIndexedContainerProperty extends PBmmProperty<PBmmIndexedContainerType> {

/**
* We have to replicate cardinality here from PBmmContainerProperty since we are inheriting from
* PBmmProperty<PBmmIndexedContainerType> (which creates correct typing of typeDef) not PBmmContainerProperty
*/
private Interval<Integer> cardinality;

public Interval<Integer> getCardinality() {
return cardinality;
}
public void setCardinality(Interval<Integer> cardinality) {
this.cardinality = cardinality;
}
public PBmmIndexedContainerProperty() {
super();
}
@Override
public BmmIndexedContainerProperty createBmmProperty(BmmClassProcessor classProcessor, BmmClass bmmClass) {
PBmmIndexedContainerType typeRef = getTypeRef();
if (typeRef != null) {
BmmIndexedContainerType bmmType = (BmmIndexedContainerType) typeRef.createBmmType(classProcessor, bmmClass);
BmmIndexedContainerProperty bmmProperty = new BmmIndexedContainerProperty(getName(), bmmType, getDocumentation(), nullToFalse(isMandatory()), nullToFalse(isComputed()));
if (getCardinality() != null) {
bmmProperty.setCardinality(new MultiplicityInterval(getCardinality()));
}
populateImBooleans(bmmProperty);
return bmmProperty;
}
throw new RuntimeException("BmmTypeCreate failed for type " + typeRef + " of property "
+ getName() + " in class " + bmmClass.getName());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package org.openehr.bmm.v2.persistence;

import org.openehr.bmm.core.*;
import org.openehr.bmm.persistence.validation.BmmDefinitions;
import org.openehr.bmm.v2.validation.converters.BmmClassProcessor;

import java.util.ArrayList;
import java.util.List;

public class PBmmIndexedContainerType extends PBmmContainerType {

private String indexType;

public String getIndexType() {
return indexType;
}

public void setIndexType(String indexType) {
this.indexType = indexType;
}

@Override
public BmmIndexedContainerType createBmmType(BmmClassProcessor processor, BmmClass classDefinition) {
BmmClass containerClassDef = processor.getClassDefinition (getContainerType());
BmmClass indexClassDef = processor.getClassDefinition (indexType);
PBmmUnitaryType containedType = getTypeRef(); //get the actual typeref for conversion
if (containerClassDef instanceof BmmGenericClass &&
indexClassDef instanceof BmmSimpleClass &&
containedType != null)
{
BmmType containedBmmType = containedType.createBmmType(processor, classDefinition);
if (containedBmmType instanceof BmmUnitaryType) {
return new BmmIndexedContainerType((BmmUnitaryType) containedBmmType,
((BmmSimpleClass) indexClassDef).getType(),
(BmmGenericClass) containerClassDef);
}
}

throw new RuntimeException("BmmClass " + containerClassDef.getName() + " is not defined in this model or not an indexed container type");
}
@Override
public String asTypeString() {
return getContainerType() + BmmDefinitions.GENERIC_LEFT_DELIMITER +
indexType + BmmDefinitions.GENERIC_SEPARATOR + getTypeRef().asTypeString() +
BmmDefinitions.GENERIC_RIGHT_DELIMITER;
}
@Override
public List<String> flattenedTypeList() {
List<String> result = new ArrayList<>();
result.add(getContainerType());
result.add(indexType);
if (getTypeRef() != null) {
result.addAll(getTypeRef().flattenedTypeList());
}
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class BmmTypeNaming extends ClassNameIdResolver {
put("BMM_INCLUDE_SPEC", BmmIncludeSpec.class).
put("P_BMM_CLASS", PBmmClass.class).
put("P_BMM_CONTAINER_PROPERTY", PBmmContainerProperty.class).
put("P_BMM_INDEXED_CONTAINER_PROPERTY", PBmmIndexedContainerProperty.class).
put("P_BMM_ENUMERATION", PBmmEnumeration.class).
put("P_BMM_ENUMERATION_STRING", PBmmEnumerationString.class).
put("P_BMM_ENUMERATION_INTEGER", PBmmEnumerationInteger.class).
Expand All @@ -33,6 +34,7 @@ public class BmmTypeNaming extends ClassNameIdResolver {
put("P_BMM_GENERIC_TYPE", PBmmGenericType.class).
put("P_BMM_OPEN_TYPE", PBmmOpenType.class).
put("P_BMM_CONTAINER_TYPE", PBmmContainerType.class).
put("P_BMM_INDEXED_CONTAINER_TYPE", PBmmIndexedContainerType.class).
put("P_BMM_PACKAGE", PBmmPackage.class).
put("P_BMM_PROPERTY", PBmmProperty.class).
put("P_BMM_SCHEMA", PBmmSchema.class).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ public void parseTestBmmRoundTrip() throws Exception{
parseRoundTrip("/testbmm/TestBmm1.bmm");
}

@Test
public void parseS2BmmRoundTrip() throws Exception{
parseRoundTrip("/s2/s2_base_070.bmm");
parseRoundTrip("/s2/s2_base_data_types_070.bmm");
parseRoundTrip("/s2/s2_base_resource_070.bmm");
parseRoundTrip("/s2/s2_care_ehr_065.bmm");
parseRoundTrip("/s2/s2_care_entry_065.bmm");
}
@Test
public void parseOpenEHRRoundTrip() throws Exception{
parseRoundTrip("/openehr/openehr_basic_types_102.bmm");
Expand All @@ -32,6 +40,7 @@ public void parseOpenEHRRoundTrip() throws Exception{
parseRoundTrip("/openehr/openehr_primitive_types_102.bmm");
parseRoundTrip("/openehr/openehr_rm_102.bmm");
parseRoundTrip("/openehr/openehr_structures_102.bmm");
parseRoundTrip("/openehr/openehr_base_110.bmm");
}

public void parseRoundTrip(String name) throws Exception {
Expand Down
Loading
Loading