diff --git a/hl7templates/hl7templates-generator-jar/src/test/java/net/ihe/gazelle/tempgen/ehdsi/scripts/EHDSIFriendlyTransformer.java b/hl7templates/hl7templates-generator-jar/src/main/java/net/ihe/gazelle/tempgen/ehdsi/scripts/EHDSIFriendlyTransformer.java similarity index 80% rename from hl7templates/hl7templates-generator-jar/src/test/java/net/ihe/gazelle/tempgen/ehdsi/scripts/EHDSIFriendlyTransformer.java rename to hl7templates/hl7templates-generator-jar/src/main/java/net/ihe/gazelle/tempgen/ehdsi/scripts/EHDSIFriendlyTransformer.java index 4dad425df934109cb98f62bd7be328ab4a8a0e91..327f0f2ad9c4f4f0d48c061c07be0f964cf1f8a5 100644 --- a/hl7templates/hl7templates-generator-jar/src/test/java/net/ihe/gazelle/tempgen/ehdsi/scripts/EHDSIFriendlyTransformer.java +++ b/hl7templates/hl7templates-generator-jar/src/main/java/net/ihe/gazelle/tempgen/ehdsi/scripts/EHDSIFriendlyTransformer.java @@ -23,7 +23,21 @@ public class EHDSIFriendlyTransformer { public static ArrayList<Object> ml_objectsWithVocabularyToDelete = new ArrayList<>(); public static void main(String[] args) throws FileNotFoundException, JAXBException { - Decor dec = DecorMarshaller.loadDecor("/your/path/for/bbr.xml"); + + String bbrPath = "DEFINE_YOUR_DEFAULT_PATH_HERE"; + String outputBbrPath = "DEFINE_YOUR_OUT_PATH_HERE"; + + //Override input bbr path if exists as param + if(args.length>0){ + bbrPath = args[0]; + } + + //Override output bbr path if exists as param + if(args.length>1){ + outputBbrPath = args[1]; + } + + Decor dec = DecorMarshaller.loadDecor(bbrPath); DecorVisitor.INSTANCE.visitAndProcess(dec, new VSFriendlyProvider()); for (Object lo_vocabularyParent : ml_objectsWithVocabularyToDelete){ @@ -43,7 +57,7 @@ public class EHDSIFriendlyTransformer { log.error("Unchecked type of parent element : " + lo_vocabularyParent.getClass()); } } - DecorMarshaller.marshallDecor(dec, new FileOutputStream("/your/path/for/output/bbr-output.xml")); + DecorMarshaller.marshallDecor(dec, new FileOutputStream(outputBbrPath)); } } diff --git a/hl7templates/hl7templates-generator-jar/src/test/java/net/ihe/gazelle/tempgen/ehdsi/scripts/EHDSIPivotTransformer.java b/hl7templates/hl7templates-generator-jar/src/main/java/net/ihe/gazelle/tempgen/ehdsi/scripts/EHDSIPivotTransformer.java similarity index 100% rename from hl7templates/hl7templates-generator-jar/src/test/java/net/ihe/gazelle/tempgen/ehdsi/scripts/EHDSIPivotTransformer.java rename to hl7templates/hl7templates-generator-jar/src/main/java/net/ihe/gazelle/tempgen/ehdsi/scripts/EHDSIPivotTransformer.java diff --git a/hl7templates/hl7templates-generator-jar/src/test/java/net/ihe/gazelle/tempgen/ehdsi/scripts/VSFriendlyProvider.java b/hl7templates/hl7templates-generator-jar/src/main/java/net/ihe/gazelle/tempgen/ehdsi/scripts/VSFriendlyProvider.java similarity index 100% rename from hl7templates/hl7templates-generator-jar/src/test/java/net/ihe/gazelle/tempgen/ehdsi/scripts/VSFriendlyProvider.java rename to hl7templates/hl7templates-generator-jar/src/main/java/net/ihe/gazelle/tempgen/ehdsi/scripts/VSFriendlyProvider.java diff --git a/hl7templates/hl7templates-generator-jar/src/test/java/net/ihe/gazelle/tempgen/ehdsi/scripts/VSPivotImplProvider.java b/hl7templates/hl7templates-generator-jar/src/main/java/net/ihe/gazelle/tempgen/ehdsi/scripts/VSPivotImplProvider.java similarity index 100% rename from hl7templates/hl7templates-generator-jar/src/test/java/net/ihe/gazelle/tempgen/ehdsi/scripts/VSPivotImplProvider.java rename to hl7templates/hl7templates-generator-jar/src/main/java/net/ihe/gazelle/tempgen/ehdsi/scripts/VSPivotImplProvider.java diff --git a/hl7templates/hl7templates-generator-jar/src/test/java/net/ihe/gazelle/tempgen/ehdsi/scripts/VocabularyFriendlyProcessorPivot.java b/hl7templates/hl7templates-generator-jar/src/main/java/net/ihe/gazelle/tempgen/ehdsi/scripts/VocabularyFriendlyProcessorPivot.java similarity index 80% rename from hl7templates/hl7templates-generator-jar/src/test/java/net/ihe/gazelle/tempgen/ehdsi/scripts/VocabularyFriendlyProcessorPivot.java rename to hl7templates/hl7templates-generator-jar/src/main/java/net/ihe/gazelle/tempgen/ehdsi/scripts/VocabularyFriendlyProcessorPivot.java index 8ba3503053a194c454f225d588ad38bcde7138e0..94447382d23a5d2e6eb71318468dab03e4afc032 100644 --- a/hl7templates/hl7templates-generator-jar/src/test/java/net/ihe/gazelle/tempgen/ehdsi/scripts/VocabularyFriendlyProcessorPivot.java +++ b/hl7templates/hl7templates-generator-jar/src/main/java/net/ihe/gazelle/tempgen/ehdsi/scripts/VocabularyFriendlyProcessorPivot.java @@ -1,14 +1,7 @@ package net.ihe.gazelle.tempgen.ehdsi.scripts; import net.ihe.gazelle.tempapi.impl.VocabularyProcessorImpl; -import net.ihe.gazelle.tempmodel.org.decor.art.model.Attribute; -import net.ihe.gazelle.tempmodel.org.decor.art.model.RuleDefinition; import net.ihe.gazelle.tempmodel.org.decor.art.model.Vocabulary; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.Iterator; /** * diff --git a/hl7templates/hl7templates-generator-jar/src/test/java/net/ihe/gazelle/tempgen/ehdsi/scripts/VocabularyPivotProcessorPivot.java b/hl7templates/hl7templates-generator-jar/src/main/java/net/ihe/gazelle/tempgen/ehdsi/scripts/VocabularyPivotProcessorPivot.java similarity index 100% rename from hl7templates/hl7templates-generator-jar/src/test/java/net/ihe/gazelle/tempgen/ehdsi/scripts/VocabularyPivotProcessorPivot.java rename to hl7templates/hl7templates-generator-jar/src/main/java/net/ihe/gazelle/tempgen/ehdsi/scripts/VocabularyPivotProcessorPivot.java diff --git a/hl7templates/hl7templates-generator-jar/src/test/java/net/ihe/gazelle/tempgen/scripts/CCDAExtractor.java b/hl7templates/hl7templates-generator-jar/src/test/java/net/ihe/gazelle/tempgen/ehdsi/scripts/CCDAExtractor.java similarity index 96% rename from hl7templates/hl7templates-generator-jar/src/test/java/net/ihe/gazelle/tempgen/scripts/CCDAExtractor.java rename to hl7templates/hl7templates-generator-jar/src/test/java/net/ihe/gazelle/tempgen/ehdsi/scripts/CCDAExtractor.java index 0b770ec41dbb22ca545c9f9f8aae5f378baf2ff6..0cc5990ee2aab81dfb57bfb11e3fe47a83375f81 100644 --- a/hl7templates/hl7templates-generator-jar/src/test/java/net/ihe/gazelle/tempgen/scripts/CCDAExtractor.java +++ b/hl7templates/hl7templates-generator-jar/src/test/java/net/ihe/gazelle/tempgen/ehdsi/scripts/CCDAExtractor.java @@ -1,4 +1,4 @@ -package net.ihe.gazelle.tempgen.scripts; +package net.ihe.gazelle.tempgen.ehdsi.scripts; import java.io.FileInputStream; import java.io.FileNotFoundException; diff --git a/hl7templates/hl7templates-packager-jar/src/main/resources/assemble-scripts/eHDSIGeneration.sh b/hl7templates/hl7templates-packager-jar/src/main/resources/assemble-scripts/eHDSIGeneration.sh index ecf1e563b8766d26e91dec4b83d3c539aa934879..d23e5b5ca3b01f7cddea3f73a5c2a5551c8d1215 100755 --- a/hl7templates/hl7templates-packager-jar/src/main/resources/assemble-scripts/eHDSIGeneration.sh +++ b/hl7templates/hl7templates-packager-jar/src/main/resources/assemble-scripts/eHDSIGeneration.sh @@ -3,8 +3,8 @@ #################################### # DGSANTE Generation Script # Created by Achraf Achkari - 09 Nov 2021 -# Last revision - 09 Nov 2021 -# Version 1.0.0 +# Last revision - 21 Feb 2022 +# Version 1.1.0 ##################################### @@ -14,6 +14,42 @@ GREEN='\033[0;32m' ORANGE='\033[0;33m' NC='\033[0m' + +## FUNCTIONS DEFINITION + +function readBBR { + read -r bbrPath + isAbsPath=`echo "${bbrPath}" | grep ^/.* | wc -l` + if [ $isAbsPath -eq 0 ]; then + echo -e "${RED}[ ${bbrPath} ] is not an absolute path${NC}" + exit 1 + fi + if [ ! -f $bbrPath ]; then + echo -e "${RED}[ ${bbrPath} ] is not a file or doesn't exist !${NC}" + exit 1 + fi +} + +function friendly_trannsform { + bbrFriendlyOutput=`echo "$bbrPath" | sed --expression="s/.xml/-friendly.xml/g"` +# bbrOutput=`echo "$bbrPath" | sed --expression="s/.xml/-friendly.xml/g"` + packagerPath=`realpath ..` + packagerFolder=${packagerPath##*/} + if [ $packagerFolder == "hl7templates-packager-jar" ]; then + $mavenPath -f "$packagerPath/pom.xml" -Dtest=EHDSITransformers#transformBBRToFriendly test -DbbrPath="$bbrPath" -DbbrOutput="$bbrFriendlyOutput" + if [ $? == 0 ]; then + bbrPath=$bbrFriendlyOutput + echo -e "${GREEN}BBR Transformed to friendly at: ${bbrFriendlyOutput}${NC}" + else + echo -e "${ORANGE}Transformartion to frienly BBR Failed! Please provide Friendly manually, or contact support${NC}" + readBBR + fi + else + echo -e "${ORANGE}Could not found 'packager module' at $packagerPath, cannot perform transformation, please provide Friendly BBR manually${NC}" + readBBR + fi +} + #UNCOMENT THIS TO OVERRIDE DEFAULT JAVA VERSION USED BY SYSTEM #JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64" @@ -33,6 +69,8 @@ if [ -z "$javaVersion" ]; then exit 1 fi +## JAR DETECTION + # Try to get the jar of GOC automatically jarPath=`ls -l | grep -oh -e "[^ ]*-jar-with-dependencies\.jar"` @@ -54,6 +92,8 @@ else fi fi +## MAVEN VERIFICATION + #Try to use maven wrapper if [ -f ./classes/maven-wrapper/mvnw ];then mavenPath=$(realpath "./classes/maven-wrapper/mvnw") @@ -115,18 +155,10 @@ fi; echo -e "${GREEN}Using maven at: ${mavenPath}${NC}" +## BBR READING printf "Please enter a path to your BBR (Absolute Path) : " -read -r bbrPath -isAbsPath=`echo "${bbrPath}" | grep ^/.* | wc -l` -if [ $isAbsPath -eq 0 ]; then - echo -e "${RED}[ ${bbrPath} ] is not an absolute path${NC}" - exit 1 -fi -if [ ! -f $bbrPath ]; then - echo -e "${RED}[ ${bbrPath} ] is not a file or doesn't exist !${NC}" - exit 1 -fi +readBBR printf "Please choose the kind of validator you want to generate: \n" printf "\t 1- Pivot (L3)\n" @@ -153,6 +185,8 @@ case $choice in 3) echo -e "${GREEN}generation friendly${NC}" validator="friendly" + friendly_trannsform + echo -e "Friendly BBR Will be used for generation" ;; esac diff --git a/hl7templates/hl7templates-packager-jar/src/test/java/net/ihe/gazelle/lib/hl7templatespackager/peripherals/scripts/EHDSITransformers.java b/hl7templates/hl7templates-packager-jar/src/test/java/net/ihe/gazelle/lib/hl7templatespackager/peripherals/scripts/EHDSITransformers.java new file mode 100644 index 0000000000000000000000000000000000000000..654973db2a8fcc2bbd99b1a74695d8e8b52baa1f --- /dev/null +++ b/hl7templates/hl7templates-packager-jar/src/test/java/net/ihe/gazelle/lib/hl7templatespackager/peripherals/scripts/EHDSITransformers.java @@ -0,0 +1,31 @@ +package net.ihe.gazelle.lib.hl7templatespackager.peripherals.scripts; + +import net.ihe.gazelle.tempgen.ehdsi.scripts.EHDSIFriendlyTransformer; + +import org.junit.Ignore; +import org.junit.Test; + +import javax.xml.bind.JAXBException; +import java.io.IOException; + + +/** + * All methods in this class are ignore, as they are executed as scripts and not tests + */ +public class EHDSITransformers { + + @Test + public void transformBBRToFriendly() throws IOException, JAXBException { + String bbrPath = System.getProperty("bbrPath"); + String bbrOutput = System.getProperty("bbrOutput"); + if(bbrPath == null || "".equals(bbrPath) || bbrOutput == null || "".equals(bbrOutput)){ + throw new IOException("BBR File not set"); + } + System.out.println("Using BBR: "+bbrPath); + if(!bbrPath.endsWith(".xml")){ + throw new IOException("Invalid XML File"); + } + String[] args = new String[]{bbrPath, bbrOutput}; + EHDSIFriendlyTransformer.main(args); + } +}