Mentions légales du service

Skip to content
Snippets Groups Projects
Commit fb5af1ce authored by Achraf Achkari's avatar Achraf Achkari
Browse files

Fix Generation Scripts

parent 3a0d3f96
No related branches found
No related tags found
1 merge request!15Release 3.0.2
Pipeline #338242 failed
#!/bin/bash
####################################
# SEQUOIA Generation & Adaptation Script
# Created by Achraf Achkari - 09 Nov 2021
# Last revision - 09 Nov 2021
# Version 1.0.0
#####################################
#Colors definitions for terminal
RED='\033[0;31m'
GREEN='\033[0;32m'
......@@ -11,6 +18,25 @@ MU3="HL7 - C-CDA R2.1 - Meaningful Use Stage 3"
USCDI="HL7 - C-CDA R2.1 - USCDI"
CCDA_R_1="HL7 - C-CDA R1.1"
#UNCOMENT THIS TO OVERRIDE DEFAULT JAVA VERSION USED BY SYSTEM
#JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"
######################################################################
##### Checking JAVA Version
if [ -z "$JAVA_HOME" ]; then
echo -e "${RED}Please set your JAVA_HOME before running the script${NC}"
exit 1
fi;
javaVersion=$($JAVA_HOME/bin/java -version 2>&1 | awk -F '"' '/version/ {print $2}' | grep -e "11\.[0-9]*.*")
if [ -z "$javaVersion" ]; then
echo -e "${RED}Invalid java version, needed 11${NC}"
exit 1
fi
# Try to get the jar of GOC automatically
jarPath=$(ls -l | grep -oh -e "[^ ]*-jar-with-dependencies\.jar")
......@@ -60,7 +86,7 @@ if [ -z "$mavenPath" ];then
echo -e "${RED}Wrong maven executable...${NC}"
exit 1
fi;
mvnVersion=$(mvn -v | sed -n 2p | grep -oh -e "3\.5\..*")
mvnVersion=$($mavenPath -v | sed -n 2p | grep -oh -e "3\.5\..*")
if [ -z "$mvnVersion" ];then
echo -e "${RED}Wrong maven version, please provide a [3.5.x] version...${NC}"
exit 1
......@@ -144,13 +170,13 @@ printf "Please enter workspace path (where you want to generate the validator):
read -r workspaceDir
if [ ! -d "$workspaceDir" ]; then
echo "${RED}The provided workspace is not a valid directory"
exit 0
exit 1
fi
isAbsPath=$(echo "${workspaceDir}" | grep -c "^/.*")
if [ "$isAbsPath" -eq 0 ]; then
echo -e "${RED}[ ${workspaceDir} ] is not an absolute path"
exit 0
exit 1
fi
_currDate=$(date +%Y-%m-%d-%H-%M-%S)
......@@ -163,9 +189,14 @@ fi;
echo -e "${GREEN}your validator will be generated in: ${workspaceDir}/${folderName}${NC}"
######## GENERATION COMMAND ########
java -jar "$absJarPath" -bbr "$bbrPath" -out "${workspaceDir}/${folderName}" -mvn "$mavenPath" -serviceName "$validator" -versionLabel "$versionLabel" -ignoreTemplateIdRequirements -ignoreCdaBasicRequirements
$JAVA_HOME/bin/java -jar "$absJarPath" -bbr "$bbrPath" -out "${workspaceDir}/${folderName}" -mvn "$mavenPath" -serviceName "$validator" -versionLabel "$versionLabel" -ignoreTemplateIdRequirements -ignoreCdaBasicRequirements
####################################
if [ $? -neq 0 ]; then
echo "${RED}Generation Failed${NC}"
exit 1
fi
echo -e "${GREEN}Validator generated successfully${NC}"
echo -e "${NC}Start SVS Adaptations..."
......@@ -188,7 +219,12 @@ if [ ! -x ./SEQUOIASVSAdaptation.sh ]; then
chmod +x SEQUOIASVSAdaptation.sh
fi;
./SEQUOIASVSAdaptation.sh "$workspaceDir/$folderName" $pathToResources
env JAVA_HOME=$JAVA_HOME M2_BIN=$mavenPath ./SEQUOIASVSAdaptation.sh "$workspaceDir/$folderName" $pathToResources
if [ $? -neq 0 ]; then
echo "${RED}Adaptations failed"
exit 1
fi
#Zip validator
#move to bin path
......
......@@ -10,6 +10,11 @@ USAGE_STRING="${RED}./sequoiaHack.sh <path_to_validator> [<path_to_resources>]${
pathToValidator=""
pathToResources=""
## Check if M2_HOME and JAVA_HOEM are set
if [ -z $JAVA_HOME ] || [ -z $M2_BIN ]; then
echo -e "${RED}JAVA_HOME or/and M2_BIN are not set properly${NC}"
exit 1
fi;
# Check number & types of parameters
if [ $# -gt 2 ] || [ $# -lt 1 ]; then
......@@ -80,7 +85,7 @@ done;
# Package validator
pathToValidatorJar=$(find $pathToValidator -type d -name "*-validator-jar" | grep -v ".*\/net\/.*")
cd $pathToValidatorJar
mvn clean package
env JAVA_HOME=$JAVA_HOME $M2_BIN clean package
# Replacing XSD
......
#!/bin/bash
####################################
# SEQUOIA Generation & Adaptation Script
# Created by Achraf Achkari - 09 Nov 2021
# Last revision - 09 Nov 2021
# Version 1.0.0
#####################################
#Colors definitions for terminal
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
NC='\033[0m'
#UNCOMENT THIS TO OVERRIDE DEFAULT JAVA VERSION USED BY SYSTEM
#JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"
######################################################################
##### Checking JAVA Version
if [ -z "$JAVA_HOME" ]; then
echo -e "${RED}Please set your JAVA_HOME before running the script${NC}"
exit 1
fi;
javaVersion=$($JAVA_HOME/bin/java -version 2>&1 | awk -F '"' '/version/ {print $2}' | grep -e "11\.[0-9]*.*")
if [ -z "$javaVersion" ]; then
echo -e "${RED}Invalid java version, needed 11${NC}"
exit 1
fi
# Try to get the jar of GOC automatically
jarPath=`ls -l | grep -oh -e "[^ ]*-jar-with-dependencies\.jar"`
......@@ -27,19 +54,64 @@ else
fi
fi
#Try to get maven path automatically
mavenPath=`mvn -v | sed -n 2p | grep -oh -e "/.*"`
if [ -z $mavenPath ];then
echo -e "${ORANGE}Could not detect a maven installation, please enter the absolute to the binary file of maven: ${NC}"
read -r mavenPath
testMaven=`${mavenPath} -v`
if [ -z $testMaven ];then
echo -e "${RED}Wrong maven executable...${NC}"
exit 1
fi
#Try to use maven wrapper
if [ -f ./classes/maven-wrapper/mvnw ];then
mavenPath=$(realpath "./classes/maven-wrapper/mvnw")
testMaven=$($mavenPath -v)
if [ ! -z "$testMaven" ]; then
echo -e "${GREEN}Using maven wrapper with version 5.3.4${NC}"
else
mavenPath=""
fi;
else
mavenPath="${mavenPath}/bin/mvn"
fi
mavenPath=""
fi;
if [ -z "$mavenPath" ];then
#Try to get maven path automatically
echo -e "${ORANGE}Could not find Maven Wrapper, trying to detect local installation automatically...${NC}"
mavenPath=$(mvn -v | sed -n 2p | grep -oh -e "/.*")
mvnVersion=$(echo "$mavenPath" |grep -oh -e "3\.5\..*")
if [ -z "$mavenPath" ] || [ -z "$mvnVersion" ];then
echo -e "${ORANGE}Could not detect the required maven installation [5.3.x], please enter the absolute to the binary file of maven: ${NC}"
read -r mavenPath
testMaven2=$($mavenPath -v)
if [ -z "$testMaven2" ];then
echo -e "${RED}Wrong maven executable...${NC}"
exit 1
fi;
mvnVersion=$($mavenPath -v | sed -n 2p | grep -oh -e "3\.5\..*")
if [ -z "$mvnVersion" ];then
echo -e "${RED}Wrong maven version, please provide a [3.5.x] version...${NC}"
exit 1
fi
else
echo -e "${GREEN}A valid maven version detect ${mvnVersion}, do you want to use it?${NC}"
printf "Press enter for yes, enter absolute path for maven binary to change it: "
read -r newMaven
if [ -z newMaven ]; then
mavenPath="${mavenPath}/bin/mvn"
else
if [ -f "$newMaven" ];then
testMaven3=$($newMaven -v)
if [ ! -z "$testMaven3"]; then
mavenVersion2=$($newMaven -v | sed -n 2p | grep -oh -e "3\.5\..*")
if [ ! -z "$mavenVersion2" ]; then
mavenPath="$newMaven"
else
echo "${RED}Wrong maven version, needed [3.5.x], try to re-install GOC, and use the wrapper${NC}"
exit 1
fi;
else
echo "${RED}Wrong maven path${NC}"
fi;
else
echo "${RED}File Not found!${NC}"
fi;
fi;
fi
fi;
echo -e "${GREEN}Using maven at: ${mavenPath}${NC}"
......@@ -107,7 +179,7 @@ fi;
echo -e "${GREEN}your validator will be generated in: ${workspaceDir}/${folderName}${NC}"
######## GENERATION COMMAND ########
java -jar $jarPath -bbr $bbrPath -out "${workspaceDir}/${folderName}" -mvn $mavenPath -serviceName $validator -HL7TEMP_CDACONFFOLDERNAME cdaepsos
#$JAVA_HOME/bin/java -jar $jarPath -bbr $bbrPath -out "${workspaceDir}/${folderName}" -mvn $mavenPath -serviceName $validator -HL7TEMP_CDACONFFOLDERNAME cdaepsos
####################################
#Replacing XSD
......@@ -130,7 +202,7 @@ echo "$pathToXSD"
XSDDirname=$(dirname "$pathToXSD")
echo "$XSDDirname"
rm -r "$pathToXSD"
cp -r "$pathToResources"/xsd "$XSDDirname"
cp -r "$pathToResources" "$XSDDirname"
#Zip validator
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment