From 0c3bdb67bd2de0c9d612623bc11c78e1f234493f Mon Sep 17 00:00:00 2001 From: Jon Harper Date: Fri, 25 Sep 2020 14:10:14 +0200 Subject: [PATCH] Add alternative script for partial cgmes This is currently also done by update_cgmes.sh, need to decide what we want to do Signed-off-by: Jon Harper --- case-import-emulator/update_partial_cgmes.sh | 28 ++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 case-import-emulator/update_partial_cgmes.sh diff --git a/case-import-emulator/update_partial_cgmes.sh b/case-import-emulator/update_partial_cgmes.sh new file mode 100644 index 0000000..d401d22 --- /dev/null +++ b/case-import-emulator/update_partial_cgmes.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +cgmesPath=$1 +outputDir=$2 +version=001 + +caseDateIso=$(date -u +"%Y-%m-%dT%H:%M:%SZ") +caseDate=$(date -d $caseDateIso +"%Y%m%dT%H%MZ") + +tmpDir=$(mktemp -d) +cd $tmpDir + +cp $cgmesPath $tmpDir +zipFile=$(basename $1) +caseName=${zipFile%%.zip} +unzip *.zip >> /dev/null +for xmlFile in $(ls *.xml); do + sed -i -e "s/2017-10-02T09:30:00Z<\/md:Model.scenarioTime>/$caseDateIso<\/md:Model.scenarioTime>/g" $xmlFile + sed -i -e "s/.*<\/md:Model.version>/$version<\/md:Model.version>/g" $xmlFile + sed -i -e "s/.*<\/md:Model.created>/$caseDateIso<\/md:Model.created>/g" $xmlFile +done +rm $zipFile +newZipFile=${caseDate}_${zipFile#*_} +zip -j $newZipFile * >> /dev/null +rm -f $outputDir/${newZipFile} +mv ${newZipFile} $outputDir + +rm -rf $tmpDir