diff --git a/php/RemoteDataCenter/cleanRemoteParams.php b/php/RemoteDataCenter/cleanRemoteParams.php new file mode 100644 index 0000000..e7d68d0 --- /dev/null +++ b/php/RemoteDataCenter/cleanRemoteParams.php @@ -0,0 +1,45 @@ +<?php +/* +* Executable to clean up Remote Params +*/ + + if (!function_exists('__autoload')) { + function __autoload($class_name) { + require_once $class_name . '.php'; + } + } + + $AMDA_IHM = getenv('AMDA_IHM'); + + require_once $AMDA_IHM."/php/config.php"; + + if (file_exists(DATAPATH."/RemoteData/Bases.xml")) { + + try { + $client = new SoapClient(DD_WSDL); + } + catch (SoapFault $exception) { + $msg = $exception->faultstring.PHP_EOL; + exit($msg); + } + + $basesDom = new DomDocument("1.0"); + $basesDom->load(DDSERVICE."/BASE/INFO/Bases.xml"); // Remote from DDBASE/INFO + foreach ($basesDom->getElementsByTagName("dataCenter") as $center) { + $id = $center->getAttribute("xml:id"); + if (is_dir(DATAPATH."/RemoteData/$id")) { + foreach (glob(DATAPATH."/RemoteData/$id/*") as $file) { + if (basename($file) == "base.xml") continue; + $ds = basename($file,".nc"); + if ($client->isRemoteViAdded($id, strtolower($ds))) continue; // VI exists; do nothing + + // vi was deleted in DDBASE; delete everything + unlink($file); + $paramId = strtolower($id)."_".strtolower($ds); + foreach (glob(DATAPATH."/RemoteData/PARAMS/$paramId*.xml") as $xml) unlink($xml); + foreach (glob(DATAPATH."/LocalData/ParamDef/$paramId*.xml") as $xml) unlink($xml); + } + } + } + } +?> diff --git a/update_amda/makeRemote b/update_amda/makeRemote index abb4813..dcb5818 100755 --- a/update_amda/makeRemote +++ b/update_amda/makeRemote @@ -53,11 +53,15 @@ # copy "DDBASE" Remote Params descriptions if [ -d "$RemoteData/PARAMS" ]; then + # remove PARAMS if no such VI in the database + php $AMDA_IHM/php/RemoteDataCenter/cleanRemoteParams.php + for param_def in $RemoteData/PARAMS/*.xml do xml=`basename $param_def` if [ ! -f "$PARAMS_LOCALDB_DIR/$xml" ]; then - cp $param_def $PARAMS_LOCALDB_DIR/ + #cp $param_def $PARAMS_LOCALDB_DIR/ + ln -s $param_def $PARAMS_LOCALDB_DIR/$xml fi done fi -- libgit2 0.21.2