Skip to content

Commit 3ce7f86

Browse files
committed
Merge branch 'feature/mdd/automatic-schema-generation' into feature/ruby-lib
2 parents d962efd + a5c6e4e commit 3ce7f86

File tree

548 files changed

+11489
-8280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

548 files changed

+11489
-8280
lines changed

.github/workflows/generate-model.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ jobs:
5656
if: steps.filter.outputs.parsing_required == 'true'
5757
run: python workflow.py --stage parser_and_mv
5858

59+
- name: Run csv_parser to generate schemas.yaml
60+
working-directory: ./csv_parser
61+
run: python workflow.py --stage output_schemas_yaml
62+
63+
- name: Collect schemas.yaml and copy it to json_schema2xsd
64+
working-directory: ./csv_parser
65+
run: |
66+
cp ./out/schemas.yaml ./json_schema2xsd/src/main/resources/schemas.yaml
67+
5968
# TODO: Reactivate test case autogeneration
6069
# - name: Run test_case_generator and move the folder test-cases to src/main/resources/sample/test-cases
6170
# working-directory: ./csv_parser
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Generate schemas and relevant generator config files and java classes
2+
3+
on:
4+
workflow_dispatch: {}
5+
pull_request:
6+
branches:
7+
- '**'
8+
9+
jobs:
10+
generate-schemas:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.11'
21+
22+
- name: Install python requirements
23+
working-directory: ./csv_parser
24+
run: pip install -r ./requirements.txt
25+
26+
- name: Run csv_parser to generate schemas.yaml
27+
working-directory: ./csv_parser
28+
run: python workflow.py --stage output_schemas_yaml
29+
30+
- name: Collect schemas.yaml and copy it to automatic-schema-generator
31+
run: |
32+
cp ./csv_parser/out/schemas.yaml ./automatic-schema-generator/schemas.yaml
33+
34+
- name: Setup gomplate
35+
uses: jason-dour/action-setup-gomplate@v1.1.0
36+
with:
37+
gomplate-version: v4.2.0
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
- run: gomplate --version
41+
42+
- name: Run automatic-schema-generator and move generated files to corresponding locations
43+
working-directory: ./automatic-schema-generator
44+
run: |
45+
rm -r output || true
46+
chmod +x ./automatic-generator.sh
47+
./automatic-generator.sh
48+
cp -r output/generator ..
49+
cp -r output/edxl ../src/main/java/com/hubsante/model
50+
cp -r output/json-schema ../src/main/resources
51+
cp -r output/xsd ../src/main/resources
52+
53+
- name: Commit and push changes
54+
uses: stefanzweifel/git-auto-commit-action@v5
55+
with:
56+
commit_message: ⚙️ Auto-génération des schemas et fichiers de configuration
57+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# We will be using the file schemas.yaml as data source to use with gomplate in order to generate all the files
2+
# required for each schema
3+
4+
# generate base generator config files
5+
gomplate -f ./templates/schema.generator-config.json.tmpl -d config=./schemas.yaml -o ./output/generator/config
6+
7+
# generate usecase config files
8+
gomplate -f ./templates/schema.usecase.generator-config.json.tmpl -d config=./schemas.yaml -o ./output/generator/config
9+
10+
# generate wrapper config files
11+
gomplate -f ./templates/schema.wrapper.generator-config.json.tmpl -d config=./schemas.yaml -o ./output/generator/config
12+
13+
# generate ContentMessage class
14+
gomplate -f ./templates/ContentMessage.java.tmpl -d config=./schemas.yaml -o ./output/edxl/ContentMessage.java
15+
16+
# generate EDXL-DE json schema
17+
gomplate -f ./templates/EDXL-DE-full.schema.json.tmpl -d config=./schemas.yaml -o ./output/json-schema/EDXL-DE-full.schema.json
18+
19+
# generate RC-XML-ContentType xsd schema
20+
gomplate -f ./templates/RC-XML-ContentType.xsd.tmpl -d config=./schemas.yaml -o ./output/xsd/RC-XML-ContentType.xsd
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
/**
2+
* Copyright © 2023-2024 Agence du Numerique en Sante (ANS)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.hubsante.model.edxl;
17+
18+
import com.fasterxml.jackson.annotation.JsonSubTypes;
19+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
20+
21+
import com.hubsante.model.technical.Technical;
22+
import com.hubsante.model.technical.TechnicalWrapper;
23+
import com.hubsante.model.technical.noreq.TechnicalNoreq;
24+
import com.hubsante.model.technical.noreq.TechnicalNoreqWrapper;
25+
import com.hubsante.model.cisu.CreateCase;
26+
import com.hubsante.model.cisu.CreateCaseWrapper;
27+
import com.hubsante.model.health.CreateCaseHealth;
28+
import com.hubsante.model.health.CreateCaseHealthWrapper;
29+
import com.hubsante.model.health.CreateCaseHealthUpdate;
30+
import com.hubsante.model.health.CreateCaseHealthUpdateWrapper;
31+
import com.hubsante.model.emsi.Emsi;
32+
import com.hubsante.model.emsi.EmsiWrapper;
33+
import com.hubsante.model.resources.info.ResourcesInfo;
34+
import com.hubsante.model.resources.info.ResourcesInfoWrapper;
35+
import com.hubsante.model.resources.info.ResourcesEngagement;
36+
import com.hubsante.model.resources.info.ResourcesEngagementWrapper;
37+
import com.hubsante.model.resources.status.ResourcesStatus;
38+
import com.hubsante.model.resources.status.ResourcesStatusWrapper;
39+
import com.hubsante.model.resources.request.ResourcesRequest;
40+
import com.hubsante.model.resources.request.ResourcesRequestWrapper;
41+
import com.hubsante.model.resources.response.ResourcesResponse;
42+
import com.hubsante.model.resources.response.ResourcesResponseWrapper;
43+
import com.hubsante.model.rpis.Rpis;
44+
import com.hubsante.model.rpis.RpisWrapper;
45+
import com.hubsante.model.interventionreport.InterventionReport;
46+
import com.hubsante.model.interventionreport.InterventionReportWrapper;
47+
import com.hubsante.model.documentlink.DocumentLink;
48+
import com.hubsante.model.documentlink.DocumentLinkWrapper;
49+
import com.hubsante.model.geolocation.GeoPositionsUpdate;
50+
import com.hubsante.model.geolocation.GeoPositionsUpdateWrapper;
51+
import com.hubsante.model.geolocation.GeoResourcesRequest;
52+
import com.hubsante.model.geolocation.GeoResourcesRequestWrapper;
53+
import com.hubsante.model.geolocation.GeoResourcesDetails;
54+
import com.hubsante.model.geolocation.GeoResourcesDetailsWrapper;
55+
import com.hubsante.model.reference.Reference;
56+
import com.hubsante.model.reference.ReferenceWrapper;
57+
import com.hubsante.model.report.ErrorWrapper;
58+
import java.util.Map;
59+
import java.util.stream.Collectors;
60+
import java.util.stream.Stream;
61+
62+
@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION)
63+
@JsonSubTypes({
64+
@JsonSubTypes.Type(TechnicalWrapper.class),
65+
@JsonSubTypes.Type(TechnicalNoreqWrapper.class),
66+
@JsonSubTypes.Type(CreateCaseWrapper.class),
67+
@JsonSubTypes.Type(CreateCaseHealthWrapper.class),
68+
@JsonSubTypes.Type(CreateCaseHealthUpdateWrapper.class),
69+
@JsonSubTypes.Type(EmsiWrapper.class),
70+
@JsonSubTypes.Type(ResourcesInfoWrapper.class),
71+
@JsonSubTypes.Type(ResourcesEngagementWrapper.class),
72+
@JsonSubTypes.Type(ResourcesStatusWrapper.class),
73+
@JsonSubTypes.Type(ResourcesRequestWrapper.class),
74+
@JsonSubTypes.Type(ResourcesResponseWrapper.class),
75+
@JsonSubTypes.Type(RpisWrapper.class),
76+
@JsonSubTypes.Type(InterventionReportWrapper.class),
77+
@JsonSubTypes.Type(DocumentLinkWrapper.class),
78+
@JsonSubTypes.Type(GeoPositionsUpdateWrapper.class),
79+
@JsonSubTypes.Type(GeoResourcesRequestWrapper.class),
80+
@JsonSubTypes.Type(GeoResourcesDetailsWrapper.class),
81+
@JsonSubTypes.Type(ReferenceWrapper.class),
82+
@JsonSubTypes.Type(ErrorWrapper.class)
83+
})
84+
public class ContentMessage {
85+
86+
/** This equals override is used to avoid breaking the equals override in the messages without RC-DE headers
87+
* (in particular ErrorWrapper), as without the override the equality check would only pass when comparing
88+
* an object to itself, and we care about the actual values.
89+
**/
90+
@Override
91+
public boolean equals(Object o) {
92+
if (this == o) return true;
93+
return o != null && getClass() == o.getClass();
94+
}
95+
96+
// As this class has no fields, the hashcode is always 0
97+
@Override
98+
public int hashCode() {
99+
return 0;
100+
}
101+
102+
public static class UseCaseHelper {
103+
public static final Map<String,String> useCases = Stream.of(new String[][] {
104+
105+
{"technical", Technical.class.getCanonicalName()},
106+
{"technicalNoreq", TechnicalNoreq.class.getCanonicalName()},
107+
{"createCase", CreateCase.class.getCanonicalName()},
108+
{"createCaseHealth", CreateCaseHealth.class.getCanonicalName()},
109+
{"createCaseHealthUpdate", CreateCaseHealthUpdate.class.getCanonicalName()},
110+
{"emsi", Emsi.class.getCanonicalName()},
111+
{"resourcesInfo", ResourcesInfo.class.getCanonicalName()},
112+
{"resourcesEngagement", ResourcesEngagement.class.getCanonicalName()},
113+
{"resourcesStatus", ResourcesStatus.class.getCanonicalName()},
114+
{"resourcesRequest", ResourcesRequest.class.getCanonicalName()},
115+
{"resourcesResponse", ResourcesResponse.class.getCanonicalName()},
116+
{"rpis", Rpis.class.getCanonicalName()},
117+
{"interventionReport", InterventionReport.class.getCanonicalName()},
118+
{"documentLink", DocumentLink.class.getCanonicalName()},
119+
{"geoPositionsUpdate", GeoPositionsUpdate.class.getCanonicalName()},
120+
{"geoResourcesRequest", GeoResourcesRequest.class.getCanonicalName()},
121+
{"geoResourcesDetails", GeoResourcesDetails.class.getCanonicalName()},
122+
{"reference", Reference.class.getCanonicalName()},
123+
{"error", ErrorWrapper.class.getCanonicalName()}
124+
}).collect(Collectors.toMap(useCaseData -> useCaseData[0], useCaseData -> useCaseData[1]));
125+
}
126+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"inputSpec": "./input/EMSI.openapi.yaml",
3+
"outputDir": "classes/",
4+
"generatorName": "java",
5+
"templateDir": "templates/child-classes/",
6+
"globalProperties": {
7+
"models": "",
8+
"apis": false,
9+
"apiTests": false,
10+
"apiDocs": false,
11+
"modelDocs": false,
12+
"modelTests": false
13+
},
14+
"additionalProperties": {
15+
"library": "native",
16+
"modelPackage": "com.hubsante.model.emsi",
17+
"serializationLibrary": "jackson",
18+
"openApiNullable": true,
19+
"supportUrlQuery": false,
20+
"enablePostProcessFile": true
21+
}
22+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"inputSpec": "./input/EMSI.openapi.yaml",
3+
"outputDir": "classes/",
4+
"generatorName": "java",
5+
"templateDir": "templates/useCase/",
6+
"globalProperties": {
7+
"models": "emsi",
8+
"apis": false,
9+
"apiTests": false,
10+
"apiDocs": false,
11+
"modelDocs": false,
12+
"modelTests": false
13+
},
14+
"additionalProperties": {
15+
"library": "native",
16+
"modelPackage": "com.hubsante.model.emsi",
17+
"serializationLibrary": "jackson",
18+
"openApiNullable": true,
19+
"supportUrlQuery": false,
20+
"xmlns": "cisu:2.0:emsi",
21+
"enablePostProcessFile": true
22+
}
23+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"inputSpec": "./input/EMSI.openapi.yaml",
3+
"outputDir": "classes/",
4+
"generatorName": "java",
5+
"templateDir": "templates/wrapper/",
6+
"globalProperties": {
7+
"models": "emsiWrapper",
8+
"apis": false,
9+
"apiTests": false,
10+
"apiDocs": false,
11+
"modelDocs": false,
12+
"modelTests": false
13+
},
14+
"additionalProperties": {
15+
"library": "native",
16+
"modelPackage": "com.hubsante.model.emsi",
17+
"serializationLibrary": "jackson",
18+
"openApiNullable": true,
19+
"supportUrlQuery": false,
20+
"enablePostProcessFile": true
21+
}
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"inputSpec": "./input/GEO-POS.openapi.yaml",
3+
"outputDir": "classes/",
4+
"generatorName": "java",
5+
"templateDir": "templates/child-classes/",
6+
"globalProperties": {
7+
"models": "",
8+
"apis": false,
9+
"apiTests": false,
10+
"apiDocs": false,
11+
"modelDocs": false,
12+
"modelTests": false
13+
},
14+
"additionalProperties": {
15+
"library": "native",
16+
"modelPackage": "com.hubsante.model.geolocation",
17+
"serializationLibrary": "jackson",
18+
"openApiNullable": true,
19+
"supportUrlQuery": false,
20+
"enablePostProcessFile": true
21+
}
22+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"inputSpec": "./input/GEO-POS.openapi.yaml",
3+
"outputDir": "classes/",
4+
"generatorName": "java",
5+
"templateDir": "templates/useCase/",
6+
"globalProperties": {
7+
"models": "geoPositionsUpdate",
8+
"apis": false,
9+
"apiTests": false,
10+
"apiDocs": false,
11+
"modelDocs": false,
12+
"modelTests": false
13+
},
14+
"additionalProperties": {
15+
"library": "native",
16+
"modelPackage": "com.hubsante.model.geolocation",
17+
"serializationLibrary": "jackson",
18+
"openApiNullable": true,
19+
"supportUrlQuery": false,
20+
"xmlns": "cisu:2.0:geopositionsupdate",
21+
"enablePostProcessFile": true
22+
}
23+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"inputSpec": "./input/GEO-POS.openapi.yaml",
3+
"outputDir": "classes/",
4+
"generatorName": "java",
5+
"templateDir": "templates/wrapper/",
6+
"globalProperties": {
7+
"models": "geoPositionsUpdateWrapper",
8+
"apis": false,
9+
"apiTests": false,
10+
"apiDocs": false,
11+
"modelDocs": false,
12+
"modelTests": false
13+
},
14+
"additionalProperties": {
15+
"library": "native",
16+
"modelPackage": "com.hubsante.model.geolocation",
17+
"serializationLibrary": "jackson",
18+
"openApiNullable": true,
19+
"supportUrlQuery": false,
20+
"enablePostProcessFile": true
21+
}
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"inputSpec": "./input/GEO-REQ.openapi.yaml",
3+
"outputDir": "classes/",
4+
"generatorName": "java",
5+
"templateDir": "templates/child-classes/",
6+
"globalProperties": {
7+
"models": "",
8+
"apis": false,
9+
"apiTests": false,
10+
"apiDocs": false,
11+
"modelDocs": false,
12+
"modelTests": false
13+
},
14+
"additionalProperties": {
15+
"library": "native",
16+
"modelPackage": "com.hubsante.model.geolocation",
17+
"serializationLibrary": "jackson",
18+
"openApiNullable": true,
19+
"supportUrlQuery": false,
20+
"enablePostProcessFile": true
21+
}
22+
}

0 commit comments

Comments
 (0)