#!/bin/bash #Colors definitions for terminal RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' NC='\033[0m' # Try to get the jar of GOC automatically jarPath=`ls -l | grep -oh -e "[^ ]*-jar-with-dependencies\.jar"` if [ -z $jarPath ]; then echo -e "${ORANGE}Could not detect the JAR of GOC, please provide the path manually${NC}" read -r jarPath else absJarPath=`realpath $jarPath` echo -e "${GREEN}A GOC JAR has been detected at: (${jarPath}) want you to use it?${NC}" printf "hit enter for yes, enter an other path to change it: " read -r newJarPath if [ ! -z $newJarPath ]; then isAbsPath=`echo "${newJarPath}" | grep ^/.* | wc -l` if [ $isAbsPath -eq 0 ]; then echo -e "${RED}[ ${newJarPath} ] is not an absolute path${NC}" exit 1 fi absJarPath=$newJarPath 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 else mavenPath="${mavenPath}/bin/mvn" fi echo -e "${GREEN}Using maven at: ${mavenPath}${NC}" 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 printf "Please choose the kind of validator you want to generate: \n" printf "\t 1- Pivot (L3)\n" printf "\t 2- Scanned (L1)\n" printf "\t 3- Friendly\n" printf "your choice: " read -r choice if [ $choice -gt 3 -o $choice -lt 1 ]; then echo "${RED}Wrong choice, please repeat and choose between 1 and 3${NC}" exit 1 fi case $choice in 1) echo -e "${GREEN}generating pivot${NC}" validator="pivot" ;; 2) echo -e "${GREEN}generation scanned${NC}" validator="scanned" ;; 3) echo -e "${GREEN}generation friendly${NC}" validator="friendly" ;; esac 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 fi isAbsPath=`echo "${workspaceDir}" | grep ^/.* | wc -l` if [ $isAbsPath -eq 0 ]; then echo -e "${RED}[ ${workspaceDir} ] is not an absolute path" exit 0 fi _currDate=`date +%Y-%m-%d-%H-%M-%S` printf "Please enter the folder name of your validator: (output-${validator}-${_currDate})?" read -r folderName if [ -z $folderName ]; then folderName="output-${validator}-${_currDate}" fi; echo -e "${GREEN}your validator will be generated in: ${workspaceDir}/${folderName}${NC}" java -jar $jarPath -bbr $bbrPath -out "${workspaceDir}/${folderName}" -mvn $mavenPath -serviceName $validator -HL7TEMP_CDACONFFOLDERNAME cdaepsos