diff --git a/js/app/AmdaApp.js b/js/app/AmdaApp.js
index 2cb777b..d0d70b8 100755
--- a/js/app/AmdaApp.js
+++ b/js/app/AmdaApp.js
@@ -180,7 +180,6 @@ Ext.define('amdaApp.AmdaApp', {
},
ready : function ()
{
- //AKKA - Clean user WS
AmdaAction.cleanUserWS(function(res,e){},this);
}
},
@@ -587,12 +586,14 @@ Ext.define('amdaApp.AmdaApp', {
'MB rests');
}
- if (isFirstVisit && !isGuest) {
- if (isSpecialInfo) {
- myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.info.id, true, function(module) {
- module.createWindow(isSpecialInfo, 'Welcome to AMDA', true);
- });
- } else {
+ if (isFirstVisit && !isGuest) {
+
+ if (isMigration) { // isSpecialInfo
+ myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.info.id, true, function(module) {
+ module.createWindow(isSpecialInfo, 'Welcome on AMDA', true);
+ });
+ }
+ else {
myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.help.id, true, function(module) {
module.createWindow();
});
@@ -601,7 +602,7 @@ Ext.define('amdaApp.AmdaApp', {
else {
if (isSpecialInfo && !isNewInfo) {
myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.info.id, true, function(module) {
- module.createWindow(isSpecialInfo, 'Welcome to AMDA', true);
+ module.createWindow(isSpecialInfo, 'Welcome on AMDA', true);
});
}
}
diff --git a/js/app/controllers/AboutModule.js b/js/app/controllers/AboutModule.js
index a7235ff..a8fc414 100644
--- a/js/app/controllers/AboutModule.js
+++ b/js/app/controllers/AboutModule.js
@@ -7,92 +7,121 @@
* This Module describe new functionalities of AMDA-NG4
* @author CDA
* @version $Id: AboutModule.js 2397 2014-06-03 10:21:28Z elena $
- * TODO Do we need real Module ???
*/
-Ext.define('amdaDesktop.AboutModule', {
-
- extend: 'amdaDesktop.AmdaModule',
+Ext.define('amdaDesktop.AboutModule',
+{
+ extend: 'amdaDesktop.AmdaModule',
+ contentId : 'infoUI',
+ file : 'releaseNotes.' + AMDAVERSION,
- contentId : 'infoUI',
- file : 'releaseNotes.' + AMDAVERSION,
-
- createWindow : function(file, title, specialInfo)
- {
- var desktop = myDesktopApp.getDesktop();
- var win = desktop.getWindow(this.id);
- var theTitle = title ? title : this.title;
-
- if (!AMDAVERSION) this.file = 'about';
-
- var theFile = file ? file : this.file;
- if (!win) {
- win = desktop.createWindow({
- id: this.id,
- title: theTitle,
- file : theFile,
- width: 650,
- height: 570,
- autoScroll : true,
- minimizable: false,
- maximizable: false,
- bodyStyle: 'background:#ffffee; padding:15px 15px 15px 15px;',
- bodyCls : 'infoWindow',
- loader : {
- url : helpDir + theFile,
- loadMask : false,
- autoLoad : true // important
- },
- iconCls: this.icon,
- animCollapse:false,
- constrainHeader:true
- });
+ createWindow : function(file, title, specialInfo)
+ {
+ var desktop = myDesktopApp.getDesktop();
+ var win = desktop.getWindow(this.id);
+ var theTitle = title ? title : this.title;
+
+ if (!AMDAVERSION) this.file = 'about';
+
+ var theFile = file ? file : this.file;
+ if (!win) {
+ win = desktop.createWindow({
+ id: this.id,
+ title: theTitle,
+ file : theFile,
+ width: 650,
+ height: 570,
+ autoScroll : true,
+ minimizable: false,
+ maximizable: false,
+ bodyStyle: 'background:#ffffee; padding:15px 15px 15px 15px;',
+ bodyCls : 'infoWindow',
+ loader : {
+ url : helpDir + theFile,
+ loadMask : false,
+ autoLoad : true // important
+ },
+ iconCls: this.icon,
+ animCollapse:false,
+ constrainHeader:true
+ });
- if (specialInfo) {
- win.add({ xtype: 'toolbar',
- items: [ {
- text: 'AMDA\'s ABCs',
- scope : this,
- handler: function() {
- myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.help.id, true, function (module) {
- module.createWindow();
- });
- }
- },'-',
- '->', '-',
- {
- text: 'Stop showing this window on next login',
- scope : this,
- handler: function() {
- AmdaAction.deleteSpecialInfo(win.file);
- Ext.MessageBox.show({title:'Warning',
- msg: 'OK. Close the window right now?',
- width: 300,
- buttons: Ext.MessageBox.OKCANCEL,
- fn : function(btn) {
- if (btn == 'cancel') return;
- win.close();
- },
- icon: Ext.MessageBox.WARNING,
- scope : this
- });
- }
- }
- ]});
- }
-
- win.show();
- }
- else if (win.file === theFile) {
- win.toFront();
- }
- else {
- win.loader.url = helpDir + theFile;
- win.loader.load();
- win.setTitle(theTitle);
- win.file = theFile;
- win.toFront();
- }
- }
-
+ if (specialInfo) {
+ win.add({ xtype: 'toolbar',
+ items: [ {
+ text: 'AMDA\'s ABCs',
+ scope : this,
+ handler: function() {
+ myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.help.id, true, function (module) {
+ module.createWindow();
+ });
+ }
+ },'-',
+ '->', '-',
+ {
+ text: 'Stop showing this window on next login',
+ scope : this,
+ handler: function() {
+ AmdaAction.deleteSpecialInfo(win.file);
+ Ext.MessageBox.show({title:'Warning',
+ msg: 'OK. Close the window right now?',
+ width: 300,
+ buttons: Ext.MessageBox.OKCANCEL,
+ fn : function(btn) {
+ if (btn == 'cancel') return;
+ win.close();
+ },
+ icon: Ext.MessageBox.WARNING,
+ scope : this
+ });
+ }
+ }
+ ]});
+ }
+
+ if (isMigration && isOldWS) {
+ win.on({
+ show : function(){
+ Ext.Msg.show({
+ title:'Welcome on new AMDA',
+ msg: 'It is your first visit of the new version of AMDA.
'+
+ 'Do you want to copy here your workspace from the old AMDA ?',
+ buttons: Ext.Msg.YESNO,
+ icon: Ext.Msg.QUESTION,
+ fn : function (btn) {
+ if (btn == 'yes') {
+ loadMask.show();
+ AmdaAction.convertWS(function(res,e){
+ var explorerModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id);
+ explorerModule.filtersStore.reload();
+ loadMask.hide();
+
+ if (res.success == true) {
+ myDesktopApp.infoMsg('Your Wokspace has been copied
' +
+ 'Note :
Plot Requests have not been copied - too many modifs!
' +
+ 'Derived params made from Remote params have not been copied
' + res.msg);
+ }
+ else {
+ myDesktopApp.errorMsg(res.error);
+ }
+ });
+ }
+ }
+ });
+ }
+ });
+ }
+ win.show();
+ }
+ else if (win.file === theFile) {
+ win.toFront();
+ }
+ else {
+ win.loader.url = helpDir + theFile;
+ win.loader.load();
+ win.setTitle(theTitle);
+ win.file = theFile;
+ win.toFront();
+ }
+ }
});
diff --git a/php/classes/UserMgr.php b/php/classes/UserMgr.php
index 28778e2..ad5c224 100644
--- a/php/classes/UserMgr.php
+++ b/php/classes/UserMgr.php
@@ -25,6 +25,7 @@ class UserMgr
protected $amdaClient; //client to dd webservice
public $isFirst = false;
+ public $isOldWS = true;
public $isNewInfo = false;
public $isSpecialInfo = null;
@@ -488,32 +489,36 @@ unlink(USERWSDIR.'RemoteParams.xml');
/*****************************************************************
* PUBLIC FUNCTIONS
*****************************************************************/
-// // migration from old to new AMDA
-// public function convertWS() {
-//
-// $convert = new UserWsTransfer($this->user);
-//
-// $res = $convert->checkWS();
-// if (!$res['success']) return $res;
-//
-// $res = $convert->transferDerived();
-// $msg = $res['msg'];
-//
-// $res = $convert->transferTimeTables();
-// $msg .= $res['msg'];
-//
-// $res = $convert->transferConditions();
-// $msg .= $res['msg'];
-//
+ // migration from old to new AMDA
+ public function convertWS()
+ {
+ $convert = new UserWsTransfer($this->user);
+
+ $res = $convert->checkWS();
+ if (!$res['success']) return $res;
+
+ $res = $convert->transferMyData();
+ $msg = $res['msg'];
+
+ $res = $convert->transferDerived();
+ $msg .= $res['msg'];
+
+ $res = $convert->transferTimeTables();
+ $msg .= $res['msg'];
+
+ $res = $convert->transferConditions();
+ $msg .= $res['msg'];
+
// $res = $convert->transferRequests();
// $msg .= $res['msg'];
-//
-// $res = $convert->transferMyData();
-// $msg .= $res['msg'];
-//
-// error_log('Transfer workspace from old AMDA for '.$this->user, 1, 'amda@irap.omp.eu');
-// return array('success' => true, 'msg' => $msg);
-// }
+
+ $res = $convert->transferFilters();
+ $msg .= $res['msg'];
+
+
+ // error_log('Transfer workspace from old AMDA for '.$this->user, 1, 'amda@irap.omp.eu');
+ return array('success' => true, 'msg' => $msg);
+ }
public function setPath()
{
@@ -522,9 +527,9 @@ unlink(USERWSDIR.'RemoteParams.xml');
$this->userdir = USERPATH."/".$this->user."/";
}
// for testing purposes
- else if (defined('TRANSFERUSER')) {
- $this->userdir = BASE_PATH."test/".TRANSFERUSER."/";
- }
+// else if (defined('TRANSFERUSER')) {
+// $this->userdir = BASE_PATH."test/".TRANSFERUSER."/";
+// }
else if (isset($this->user)) {
$this->userdir = USERPATH."/".$this->user."/";
}
@@ -569,7 +574,12 @@ unlink(USERWSDIR.'RemoteParams.xml');
if (!$this->createDir()) {
die("Login for ".$this->user." failed: Can't create WS dirs");
}
- $this->isFirst = true;
+ $this->isFirst = true;
+ $convert = new UserWsTransfer($this->user);
+
+ $res = $convert->checkWS();
+ if (!$res['success'])
+ $this->isOldWS = false;
}
if (file_exists($this->userdir.'newLogin')) {
@@ -657,6 +667,7 @@ unlink(USERWSDIR.'RemoteParams.xml');
{
if (file_exists(USERWSDIR.'LocalParams.xml'))
unlink(USERWSDIR.'LocalParams.xml');
+
if (!copy(LocalData.'/LocalParams.xml', USERWSDIR.'LocalParams.xml'))
die("Login for ".$this->user." failed: Can't copy LocalParams.xml");
diff --git a/php/classes/UserWsTransfer.php b/php/classes/UserWsTransfer.php
index a8def38..27cb24d 100644
--- a/php/classes/UserWsTransfer.php
+++ b/php/classes/UserWsTransfer.php
@@ -1,624 +1,512 @@
ws = new DomDocument("1.0");
- $this->wsDir = OLDUSERPATH.TRANSFERUSER.'/WS/';
-
- $this->ws_deleted = array();
- }
-
- public function checkWS() {
-
- // old ws
- if (!is_dir(OLDUSERPATH.TRANSFERUSER)) {
- error_log('no '.TRANSFERUSER.' at old AMDA',1,email);
- return array('success' => false, 'error' => 'Sorry, it seems you have no account at old AMDA');
- }
-
- if (!file_exists($this->wsDir.'ws.xml')) {
- error_log('no ws.xml for '.TRANSFERUSER,1,email);
- return array('success' => false, 'error' => 'Sorry, we failed to find your workspace at old AMDA');
- }
-
- if (!$this->ws->load($this->wsDir.'ws.xml')) {
- error_log('cannot load ws.xml for '.TRANSFERUSER,1,email);
- return array('success' => false, 'error' => 'Sorry, we failed to access your workspace at old AMDA');
- }
-
- return array('success' => true);
-
- }
-
- public function hasAlias($expression) {
+ function __construct($user)
+ {
+ define('OLDUSERPATH', 'http://cdpp1.irap.omp.eu/AMDA-NG/data/');
+ // define('OLDUSERPATH', 'http://amda-dev.irap.omp.eu/~budnik/AMDA-NG4/trunk/data/');
+ define('NEWUSERPATH', '/home/budnik/AMDA/AMDA_IHM/data/');
+ define('TRANSFERUSER', $user);
+ define('CONVERSIONDIR', '/home/budnik/AMDA/AMDA_Migration/conversion/');
+
+ $this->oldWs = new DomDocument("1.0");
+ $this->newWs = new DomDocument("1.0");
+
+ $this->oldWsDir = OLDUSERPATH.TRANSFERUSER.'/WS/';
+ $this->newWsDir = NEWUSERPATH.TRANSFERUSER.'/WS/';
+
+ if (!is_dir(NEWUSERPATH.TRANSFERUSER.'/WS'))
+ mkdir(NEWUSERPATH.TRANSFERUSER.'/WS', 0775);
+
+ $this->ws_deleted = array();
+ $this->wsd_deleted = array();
+ $this->getModified();
+ }
+
+ private function getObsolete() {
+
+ $deletedXML = new DomDocument("1.0");
+ $deletedXML->load(CONVERSIONDIR."Deleted.xml");
+ $deletedNodes = $deletedXML->getElementsByTagName('deleted');
+
+ $deleted = array();
+ foreach ($deletedNodes as $node)
+ $deleted[] = $node->getAttribute('xml:id');
+
+ return $deleted;
+ }
+
+ private function getNotready() {
+
+ $deletedXML = new DomDocument("1.0");
+ $deletedXML->load(CONVERSIONDIR."NotReady.xml");
+ $deletedNodes = $deletedXML->getElementsByTagName('deleted');
+
+ $notready = array();
+ foreach ($deletedNodes as $node)
+ $notready[] = $node->getAttribute('xml:id');
+
+ return $notready;
+ }
+
+ private function deleteParam($exp, $deleted)
+ {
+ $toDelete = false;
+
+ foreach ($deleted as $item) {
+ if (strpos($exp, $item) !== false) {
+ $toDelete = true;
+ break;
+ }
+ }
+
+ return $toDelete;
+ }
+
+ private function getWs($exp)
+ {
+ $ws = array();
+
+ if (strpos($exp, 'ws_') !== false) {
+ $arr = $this->delimitIt($exp);
+ foreach ($arr as $item) {
+ if (strpos($item, 'ws_') !== false)
+ $ws[] = substr($item,3);
+ }
+ return $ws;
+ }
+ return false;
+ }
+
+ private function delimitIt($chain) {
- return (strpos($expression, "#") !== false);
-
- }
-
-
- public function replaceAliases($expression){
-
- $aliasXML = new DomDocument("1.0");
- $aliasXML->load($this->wsDir.'alias.xml');
- $aliases_ = $aliasXML->getElementsByTagName('alias');
-
- if ($aliases_->length == 0) return $expression;
-
- $aliases = array();
- foreach ($aliases_ as $alias) {
- $aliases["#".$alias->getAttribute("name")] = $alias->nodeValue;
- }
-// sort in desc order by key (alias itself)
- krsort($aliases, SORT_NATURAL);
-
- foreach ($aliases as $alias => $param) {
-
- if (!$this->hasAlias($expression))
- break;
- if (strpos($expression, $alias) !== false) {
- $newExp = str_replace($alias, $param, $expression);
- $expression = $newExp;
- }
- }
- return $expression;
- }
-
-//duplication of FilesMgr method
- public function getSampling($fileName, $format) {
-
- if ($format === 'cdf') {
- copy($fileName, "temp.cdf");
- exec('cdfsamplingfromdata ', $result);
- unlink("temp.cdf");
- $minSamp = $result[count($result)-1];
- }
- else if ($format === 'cef') {
- exec('cefsampling '.$fileName, $result);
- $minSamp = $result[count($result)-1];
- }
- else $minSamp = null;
-//TODO if min & max
- return $minSamp;
-
- }
-
-
- public function deleteParam($exp, $isPlot) {
-
- $deletedXML = new DomDocument("1.0");
-
- if ($isPlot) $deletedXML->load(CONVERSIONDIR.'Plot_Deleted.xml');
- else $deletedXML->load(CONVERSIONDIR.'Deleted.xml');
+ $delimiter = '[]+,/*()^<>&|=[-]+';
+ $array = split($delimiter,$chain);
+ if (trim(end($array)) == "") array_pop($array);
- $deletedNodes = $deletedXML->getElementsByTagName('deleted');
- $toDelete = false;
-
- if (strpos($exp, "CDAWEB") !== false)
- return true;
-
-
- foreach ($deletedNodes as $item) {
- if (strpos($exp, $item->getAttribute('xml:id')) !== false) {
- $toDelete = true;
- break;
- }
- }
-
- return $toDelete;
-}
-
- public function updateParams($expression, $isPlot){
+ return $array;
+ }
+ private function getModified()
+ {
+ $convertXML = new DomDocument("1.0");
+ $modifiedFile = CONVERSIONDIR.'Modified.xml';
+
+ if (!$convertXML->load($modifiedFile))
+ error_log('ERROR loading '.$modifiedFile,1,email);
+ $convertedNodes = $convertXML->getElementsByTagName('param_convert');
+
+ foreach ($convertedNodes as $item) {
+ $pairs[$item->getAttribute('oldid')] = $item->getAttribute('xml:id');
+ }
+ krsort($pairs, SORT_NATURAL);
+
+ $this->pairs = $pairs;
+ }
+
+ private function updateParams($expression)
+ {
+ $newExp = strtr($expression, $this->pairs);
+ $expression = $newExp;
+
+ return $expression;
+ }
+
+ //duplication of FilesMgr method
+ public function getSampling($fileName, $format) {
+
+ if ($format === 'cdf') {
+ copy($fileName, "temp.cdf");
+ exec('cdfsamplingfromdata ', $result);
+ unlink("temp.cdf");
+ $minSamp = $result[count($result)-1];
+ }
+ else if ($format === 'cef') {
+ exec('cefsampling '.$fileName, $result);
+ $minSamp = $result[count($result)-1];
+ }
+ else $minSamp = null;
+ //TODO if min & max
+ return $minSamp;
+ }
+
+ protected function createDom()
+ {
+ $types = array('param' => 'derived', 'mydata' => 'myData');
+
+ $rootElement = $this->newWs->createElement('ws');
+ foreach ($types as $key => $value)
+ {
+ $contentId = $value.'Param-treeRootNode';
+ $contentTag = $key.'List';
+ $typeElement = $this->newWs->createElement($contentTag);
+ $typeElement->setAttribute('xml:id', $contentId);
+ $rootElement->appendChild($typeElement);
+ }
+
+ $this->newWs->appendChild($rootElement);
+ // $this->newWs->save($this->newWsDir.'WsParams.xml');
+ }
+
+ public function checkWS()
+ {
+ // old ws
+ if (!curl_init(OLDUSERPATH.TRANSFERUSER)) {
+ error_log('no '.TRANSFERUSER.' at old AMDA',1,email);
+ return array('success' => false, 'error' => 'Sorry, it seems you have no account at old AMDA');
+ }
+
+ if (!curl_init($this->oldWsDir)) {
+ error_log('no ws.xml for '.TRANSFERUSER,1,email);
+ return array('success' => false, 'error' => 'Sorry, we failed to find your workspace at old AMDA');
+ }
+
+ return array('success' => true);
+ }
+
+ public function transferDerived()
+ {
+ $msg = 'WS (Derived) Params:
';
+
+ if (!$this->oldWs->load($this->oldWsDir.'WsParams.xml')) {
+ error_log('cannot load WsParams.xml for '.TRANSFERUSER,1,email);
+ return array('success' => false, 'error' => 'Sorry, we failed to get your WsParams from old AMDA');
+ }
+
+ if (!file_exists($this->newWsDir.'WsParams.xml'))
+ $this->createDom();
+ else
+ $this->newWs->load($this->newWsDir.'WsParams.xml');
+
+ $deleted = $this->getObsolete();
+ $notready = $this->getNotready();
+
+ $wsParamNode = $this->newWs->getElementsByTagName('paramList')->item(0);
+
+ $wsParamsOld = $this->oldWs->getElementsByTagName('param');
+
+ if ($wsParamsOld->length == 0) {
+ return array('success' => true, 'msg' => 'No parameters');
+ }
+
+ $paramXml = new DomDocument("1.0");
+ $msg .= 'Not copied :
';
+
+ foreach ($wsParamsOld as $param) {
+ $id = $param->getAttribute('xml:id');
+ $name = $param->getAttribute('name');
+
+ $expression = $param->getAttribute('buildchain');
+
+ if ($this->deleteParam($expression,$deleted)) {
+ $msg .= ''.$name.' : obsolete
'.$expression.'
';
+ // error_log( 'For INFO : DELETED '.$expression,1,email);
+ $this->ws_deleted[] = $name;
+ continue;
+ }
+
+ if ($this->deleteParam($expression,$notready)) {
+ $msg .= ''.$name.' : not ready yet
'.$expression.'
';
+ // error_log( 'For INFO : DELETED '.$expression,1,email);
+ $this->ws_deleted[] = $name;
+ continue;
+ }
+
+ if (!empty($this->wsd_deleted))
+ if ($this->deleteParam($expression,$this->wsd_deleted)) {
+ $msg .= ''.$name.' : uses obsolete myData param
'.$expression.'
';
+ // error_log( 'For INFO : DELETED '.$expression,1,email);
+ $this->ws_deleted[] = $name;
+ continue;
+ }
+
+ if ($this->deleteParam($expression,array("CDAWEB","MAPSKP","VEXGRAZ","IMPEX"))) {
+ $msg .= ''.$name.' : uses remote params
'.$expression.'
';
+ $this->ws_deleted[] = $name;
+ continue;
+ }
+
+ $expressionUpdated = $this->updateParams($expression);
+ $wsParamNode->appendChild($this->newWs->importNode($param));
+
+ $paramXml->load($this->oldWsDir.$id.'.xml');
+ $expressionNode = $paramXml->getElementsByTagName('buildchain')->item(0);
+ $expressionNode->nodeValue = $expressionUpdated;
+ $paramXml->save($this->newWsDir.$id.'.xml');
+ }
+
+ // check of 'ws bricks' were deleted
+ $newParams = $this->newWs->getElementsByTagName('param');
+ $xp = new domxpath($this->newWs);
+ $paramsToRemove = array();
+
+ foreach ($newParams as $param) {
+ $id = $param->getAttribute('xml:id');
+ $name = $param->getAttribute('name');
+
+ $expression = $param->getAttribute('buildchain');
+ if ($wsParams = $this->getWs($expression)) {
+ foreach ($wsParams as $wsParam) {
+ $res = $xp->query("//param[@name='".trim($wsParam)."']");
+ if ($res->length == 0) {
+ unlink($this->newWsDir.$id.'.xml');
+ $paramsToRemove[] = $param;
+ $this->ws_deleted[] = $name;
+ $msg .= ''.$name.' : uses obsolete / not ready ws param :
'.$expression.'
';
+ }
+ }
+ }
+ }
+
+ foreach ($paramsToRemove as $paramToRemove) {
+ $paramToRemove->parentNode->removeChild($paramToRemove);
+ }
+
+ $this->newWs->save($this->newWsDir.'WsParams.xml');
+ $copied = $newParams->length - count($paramsToRemove);
+
+ $msg .= '
Copied : '.$copied.' derived parameters
';
+ return array('success' => true, 'msg' => $msg);
+ }
+
+ public function transferTimeTables()
+ {
+ $msg = 'Time Tables:
';
+
+ // get old time tab list
+ $this->newWs->load($this->oldWsDir.'Tt.xml');
+ $timeTabs = $this->newWs->getElementsByTagName('timetab');
+ if ($timeTabs->length == 0) {
+ $msg .= 'No time tables';
+ return array('success' => true, 'msg' => $msg);
+ }
+
+ $oldTtDir = OLDUSERPATH.TRANSFERUSER."/TT/";
+ $newTtDir = NEWUSERPATH.TRANSFERUSER."/TT/";
+ foreach ($timeTabs as $tab) {
+ $id = $tab->getAttribute('xml:id');
+ copy($oldTtDir.$id.'.xml', $newTtDir.$id.'.xml');
+ }
+
+ $this->newWs->save($this->newWsDir.'Tt.xml');
+ $msg .= 'Copied : '.$timeTabs->length.' time tables
';
+ return array('success' => true, 'msg' => $msg);
+ }
- $convertXML = new DomDocument("1.0");
-
- if ($isPlot) $fileNames = glob(CONVERSIONDIR.'*_convertPlot.xml');
- else $fileNames = glob(CONVERSIONDIR.'*_convert.xml');
-
-
- foreach ($fileNames as $file) {
-
- if (!$convertXML->load($file))
- error_log('ERROR loading '.$file,1,email);
- $convertedNodes = $convertXML->getElementsByTagName('param_convert');
+ public function transferConditions()
+ {
+ $msg = 'DataMining Requests
';
+
+ $oldRequestXml = new DomDocument("1.0");
+ $newRequestXml = new DomDocument("1.0");
+
+ if (!$oldRequestXml->load($this->oldWsDir.'Request.xml')){
+ $msg .= ' cannot copy
';
+ return array('success' => true, 'msg' => $msg);
+ }
+
+ $condNodes = $oldRequestXml->getElementsByTagName('condition');
+ if ($condNodes->length == 0) {
+ $msg .= ' no DataMining requests to copy
';
+ return array('success' => true, 'msg' => $msg);
+ }
+ $newRequestXml->load($this->newWsDir.'Request.xml');
+ $conditionRoot = $newRequestXml->getElementsByTagName('conditionList')->item(0);
+
+ $condDir = OLDUSERPATH.TRANSFERUSER."/REQ/";
+
+ $deleted = $this->getObsolete();
+ $notready = $this->getNotready();
+
+ foreach ($condNodes as $condNode) {
+ $id = $condNode->getAttribute('xml:id');
+ $name = $condNode->getAttribute('name');
+ $cond = file($condDir.$id, FILE_IGNORE_NEW_LINES);
+
+ $condObj = json_decode($cond[0]);
+ $expression = $condObj->expression;
+ if ($this->deleteParam($expression, $deleted)) {
+ $msg .= ''.$name.' : obsolete
'.$expression.'
';
+ $cond_deleted[] = $name;
+ continue;
+ }
+
+ if ($this->deleteParam($expression,$notready)) {
+ $msg .= ''.$name.' : not ready yet
'.$expression.'
';
+ // error_log( 'For INFO : DELETED '.$expression,1,email);
+ $cond_deleted[] = $name;
+ continue;
+ }
+
+ if (!empty($this->wsd_deleted))
+ if ($this->deleteParam($expression,$this->wsd_deleted)) {
+ $msg .= ''.$name.' : uses obsolete myData param
'.$expression.'
';
+ // error_log( 'For INFO : DELETED '.$expression,1,email);
+ $cond_deleted[] = $name;
+ continue;
+ }
+
+ if (!empty($this->ws_deleted))
+ if ($this->deleteParam($expression,$this->ws_deleted)) {
+ $msg .= ''.$name.' : uses obsolete Derived param
'.$expression.'
';
+ // error_log( 'For INFO : DELETED '.$expression,1,email);
+ $cond_deleted[] = $name;
+ continue;
+ }
+
+ if ($this->deleteParam($expression,array("CDAWEB","MAPSKP","VEXGRAZ","IMPEX"))) {
+ $msg .= ''.$name.' : uses remote params
'.$expression.'
';
+ $cond_deleted[] = $name;
+ continue;
+ }
+
+ $expressionUpdated = $this->updateParams($expression);
+ $condObj->expression = $expressionUpdated;
+ file_put_contents(NEWUSERPATH.TRANSFERUSER."/REQ/".$id, json_encode($condObj));
+ $conditionRoot->appendChild($newRequestXml->importNode($condNode));
+ }
+
+ $newRequestXml->save($this->newWsDir.'Request.xml');
+ $msg .= '
';
+
+ return array('success' => true, 'msg' => $msg);
+ }
- foreach ($convertedNodes as $item) {
- $pairs[$item->getAttribute('oldid')] = $item->getAttribute('xml:id');
- }
- krsort($pairs, SORT_NATURAL);
- $newExp = strtr($expression, $pairs);
- $expression = $newExp;
-
- }
-
- return $expression;
- }
-
- public function convertArgs($parId, $args){
- //TODO arguments.php via Ext.Direct call
- $cmd = 'php '.BASE_PATH.'php/arguments.php "'.$parId.'"';
-
- $arguments = explode(",", $args);
- $newArgs = array();
-
- $res = exec($cmd);
-
-//TODO just main arguments....
- foreach ($arguments as $item) {
- if (strpos($item, "/") !== false)
- $arg = substr($item,1,strlen($item));
- switch ($arg) {
- case "black" :
- case "blue" :
- case "green" :
- case "red" :
- $newArgs[] = "Color=".$arg;
- break;
-
- case "gsm" :
- case "sm" : if (strpos($res, $arg) !== false)
- $newArgs[] = "RefFrame=".strtoupper($arg);
- break;
-
- case "log" :
- case "lin" : if (strpos($res, $arg) !== false)
- $newArgs[] = "Scale=".$arg;
- break;
- case "cyl" :
- $newArgs[] = "OrbitPresentation=".strtoupper($arg);
- break;
- default :
-
- }
- }
-
- if (count($arguments) === 0) return "select...";
-
- if (count($arguments) > 1) return implode("&",$newArgs);
-
- return $newArgs;
- }
-
- public function createFolders($listName, $nodeType){
- // create folders
- $folders = $this->ws->getElementsByTagName($listName)->item(0)->getElementsByTagName('level1');
- $obj = new stdClass();
- foreach ($folders as $folder) {
- $obj->leaf = false;
- $obj->old_name = "new Folder";
- $obj->name = $folder->getAttribute('name');
- $obj->parent = $nodeType."-treeRootNode";
- $obj->nodeType = $nodeType;
-
- $this->Mgr->renameObject($obj);
- }
- }
-
- public function transferDerived() {
-
- $msg = 'WS (Derived) Params:
';
- // derived parameters
- $this->Mgr = new DerivedParamMgr('derivedParam');
- $this->createFolders('paramList','derivedParam');
-
- // get old params
- $wsParams = $this->ws->getElementsByTagName('param');
- if ($wsParams->length == 0) {
- return array('success' => true, 'msg' => 'No parameters');
- }
- $obj = new stdClass();
- foreach ($wsParams as $param) {
- $obj->name = $param->getElementsByTagName('name')->item(0)->nodeValue;
- $expression = $param->getElementsByTagName('buildchain')->item(0)->nodeValue;
-
- if ($this->hasAlias($expression)) {
- $newExp = $this->replaceAliases($expression);
- $expression = $newExp;
- }
- if ($this->deleteParam($expression)) {
- $msg .= 'deleted name:'.$obj->name.'; expression: '.$expression.'
';
- // error_log( 'For INFO : DELETED '.$expression,1,email);
- $this->ws_deleted[] = $obj->name;
- continue;
- }
-
- $obj->buildchain = $this->updateParams($expression);
- $obj->timestep = $param->getElementsByTagName('timestep')->item(0)->nodeValue;
- $obj->units = $param->getElementsByTagName('units')->item(0)->nodeValue;
- $obj->description = $param->getElementsByTagName('description')->item(0)->nodeValue;
- $obj->ytitle = "";
- $obj->nodeType = "derivedParam";
- $obj->leaf = true;
-
- $this->Mgr->objectDom = new DomDocument("1.0");
- if ($param->parentNode->tagName === 'level1') {
- $folder_id = $param->parentNode->getAttribute('id');
- $this->Mgr->createObject($obj, $folder_id);
- }
- else {
- $this->Mgr->createObject($obj);
- }
- }
- $msg .= ' ok
';
- return array('success' => true, 'msg' => $msg);
- }
-
- public function transferTimeTables() {
-
- $msg = 'Time Tables:
';
- // time tables
- $this->Mgr = new TimeTableMgr();
- $this->createFolders('timetabList','timeTable');
- $TTdir = OLDUSERPATH.TRANSFERUSER."/TT/";
- // get old time tabs
- $timeTabs = $this->ws->getElementsByTagName('timetab');
-
- if ($timeTabs->length == 0) {
- return array('success' => true, 'msg' => 'No time tables');
- }
-
- $obj = new stdClass();
-
- $ttXML = new DomDocument("1.0");
- foreach ($timeTabs as $item) {
-
- $obj->name = $item->getElementsByTagName('name')->item(0)->nodeValue;
- $obj->created = $item->getElementsByTagName('created')->item(0)->nodeValue;
- $obj->description = $item->getElementsByTagName('condition')->item(0)->nodeValue;
- $obj->history = 'From old AMDA';
- $obj->nodeType = "timeTable";
- $obj->leaf = true;
-// intervals
- if (!$ttXML->load($TTdir.$obj->name.".xml")) {
- $msg .= 'failed to copy '.$obj->name.'
';
- continue;
- }
-
- $intervals = $ttXML->getElementsByTagName("Interval");
- $ints = array();
-
- foreach ($intervals as $interval){
- $int = new stdClass();
- $int->start = $interval->getElementsByTagName("Start")->item(0)->nodeValue;
- $int->stop = $interval->getElementsByTagName("Stop")->item(0)->nodeValue;
- $ints[] = $int;
- }
- $obj->nbIntervals = $intervals->length;
-
- $this->Mgr->objectDom = new DomDocument("1.0");
- if ($item->parentNode->tagName === 'level1') {
- $folder_id = $item->parentNode->getAttribute('id');
- $res = $this->Mgr->createObject($obj, $folder_id);
- }
- else {
- $res = $this->Mgr->createObject($obj);
- }
-
- if ($res['id']) {
- $res = $this->Mgr->saveIntervals($res['id'],$ints,'create');
- if (!$res['success'])
- $msg .= 'failed copy Time Table '. $obj->name.'
';
- }
- else {
- $msg .= 'failed copy Time Table '. $obj->name.'
';
- }
-
- }
-
- $msg .= ' ok
';
-
- return array('success' => true, 'msg' => $msg);
- }
-
- public function transferConditions() {
-
- $msg = 'Conditions:
';
- // conditons
- $this->Mgr = new RequestMgr('condition');
- $condDir = OLDUSERPATH.TRANSFERUSER."/REQ/";
- // get old conditions
- $conditions = glob($condDir."*.cond");
-
- if (count($conditions) == 0) {
- return array('success' => true, 'msg' => 'No conditions');
- }
-
- $obj = new stdClass();
- foreach ($conditions as $item) {
- $cond = file($item, FILE_IGNORE_NEW_LINES);
- $obj->name = substr(basename($item), 0, -5);
- $expression = $cond[0];
-
- if ($this->hasAlias($expression)) {
- $newExp = $this->replaceAliases($expression);
- $expression = $newExp;
- }
-
- if ($this->deleteParam($expression)) {
- $msg .= 'deleted name:'.$obj->name.'; expression:'.$expression.'
';
- continue;
- }
-
- $obj->expression = $this->updateParams($expression);
- $obj->sampling = $cond[1];
- $obj->gap = $cond[2];
- $obj->description = "From old AMDA";
- $obj->timesrc = "Interval";
-
- if ($cond[3]) {
- $obj->startDate = str_replace(":", "-", substr($cond[3],0,10))."T".substr($cond[3],11,8);
- $obj->durationDay = "0".substr($cond[4],0,3);
- $obj->durationHour = substr($cond[4],4,2);
- $obj->durationMin = substr($cond[4],7,2);
- $obj->durationSec = substr($cond[4],10,2);
- }
- else {
- $timestamp = mktime(0, 0, 0, date("m"), date("d")-1, date("Y"));
- $obj->startDate = date('Y-m-d\TH:i:s',$timestamp);
- $obj->durationDay = "0001";
- $obj->durationHour = "00";
- $obj->durationMin = "00";
- $obj->durationSec = "00";
- }
-
- $obj->nodeType = "condition";
- $obj->leaf = true;
-
- $this->Mgr->createObject($obj);
- }
-
- $msg .= ' ok
';
-
- return array('success' => true, 'msg' => $msg);
- }
-
- public function transferRequests() {
-
- $msg = 'Requests:
';
- // requests
- $this->Mgr = new RequestMgr('request');
- $reqDir = OLDUSERPATH.TRANSFERUSER."/REQ/";
- // get old requests
- $requests = glob($reqDir."*.xml");
-
- if (count($requests) == 0) {
- return array('success' => true, 'msg' => 'No requests');
- }
-
- $reqXML = new DomDocument("1.0");
-
- $obj = new stdClass();
- foreach ($requests as $item) {
-
- if (!$reqXML->load($item)) {
- $msg .= 'failed to copy '.substr(basename($item), 0, -4).'
';
- }
- $obj->name = substr(basename($item), 0, -4);
- $obj->tabId = 1;
- $obj->outputName = '';
- $obj->orientation = strtoupper($reqXML->getElementsByTagName('orientation')->item(0)->nodeValue);
- $obj->format = 'PNG';
- $obj->title = '';
- $obj->description = 'From old AMDA';
- $obj->charSize = 1.3;
- $obj->thickness = 1;
- $obj->ppp = 3000;
- $obj->forcedLayout = false;
- $obj->forcedMulti = false;
- $obj->timesrc = 'Interval';
- $start = $reqXML->getElementsByTagName('StartTime')->item(0)->nodeValue;
- $obj->startDate = str_replace(":", "-", substr($start,0,10))."T".substr($start,11,8);
- $tint = $reqXML->getElementsByTagName('TimeInt')->item(0)->nodeValue;
- $obj->durationDay = "0".substr($tint,0,3);
- $obj->durationHour = substr($tint,4,2);
- $obj->durationMin = substr($tint,7,2);
- $obj->durationSec = substr($tint,10,2);
-// Panels
-
- $obj->children = array();
- $panels = array();
-
- $params = $reqXML->getElementsByTagName('param');
- foreach ($params as $param) {
-
- $parId = $param->getAttribute('xml:id');
-
-//check deleted ws_
- if ($this->ws_deleted && strtolower(substr($parId,0,3) == "ws_")) {
- foreach ($this->ws_deleted as $item) {
- if ($item === $parId) {
- $msg .= 'ws param deleted '.$parId.'
';
- continue 2;
- }
- }
- }
-
- if (substr($parId,0,3) == "WS_")
- $parId = strtolower($parId);
-
- if ($this->deleteParam($parId, true)) {
- $msg .= 'param deleted '.$parId.'
';
- continue;
- }
- $newParId = $this->updateParams($parId, true);
- $panelNumber = $param->getAttribute('panel');
-//print_r($obj->name." ".$panelNumber.PHP_EOL);
-// no such panel -> create
- if (!$panels[$panelNumber]) {
- $aPanel = new stdClass();
- $aPanel->name = 'Panel '.$panelNumber;
- $aPanel->leaf = false;
- $aPanel->text = 'Panel '.$panelNumber;
- $aPanel->width = $param->getAttribute('width');
- $aPanel->height = $param->getAttribute('height');
- $aPanel->xTitle = "";
- $aPanel->xRangeMin = $param->getAttribute('xmin');
- $aPanel->xRangeMax = $param->getAttribute('xmax');
- $aPanel->y1Title = "";
- $aPanel->y1RangeMin = $param->getAttribute('ymin');
- $aPanel->y1RangeMax = $param->getAttribute('ymax');
- $aPanel->y2Title = "";
- $aPanel->y2RangeMin = 0;
- $aPanel->y2RangeMax = 0;
- $aPanel->plotType = "TIME";
- $panels[$panelNumber] = $aPanel;
-
- $panels[$panelNumber]->children = array();
- }
-// add parameter to the panel
- $aParameter = new stdClass();
- $aParameter->name = $newParId;
- $aParameter->text = $newParId;
- $aParameter->leaf = true;
- $aParameter->yaxe = false;
-//TODO if we need to check this reallY???
- $aParameter->isScatter = false;
- $aParameter->needsArgs = false;
- if ($param->getAttribute('args') === "")
- $aParameter->paramArgs = "select...";
- else
- $aParameter->paramArgs = $this->convertArgs($newParId, $param->getAttribute('args'));
-
- $panels[$panelNumber]->children[] = $aParameter;
- }
-// if there are unordered keys json_encode interprate array as object....
- $obj->children = array_values($panels);
- $obj->nodeType = "request";
- $obj->leaf = true;
-
- $this->Mgr->createObject($obj).PHP_EOL;
- }
-
- $msg .= ' ok
';
-
- return array('success' => true, 'msg' => $msg);
- }
-
- public function transferMyData() {
-
- $msg = 'My Data:
';
-// start with copying DATA dir as it is
-
- foreach (glob(OLDUSERPATH.TRANSFERUSER.'/DATA/*') as $item) {
- if (!copy($item, USERDATADIR.basename($item))) {
- error_log('can\'t copy '.$item,1,email);
- $msg .= 'failed copy file '.basename($item).'
';
- }
- }
-
- $filesXml = new DomDocument("1.0");
-
- if (!$filesXml->load($this->wsDir.'files.xml')) $msg .= 'no files.xml
';
- else {
-
- $fileMgr = new FilesMgr();
- $filesXmlNew = new DomDocument("1.0");
- $root = $filesXmlNew->createElement('ws');
- $filesXmlNew->appendChild($root);
-
- $list = $filesXmlNew->createElement("fileList");
- $list->setAttribute("xml:id", "myData-treeRootNode");
- $root->appendChild($list);
-
- $files = $filesXml->getElementsByTagName("file");
-
- $folders = $filesXml->getElementsByTagName("level1");
-
- if ($folders->length > 0)
- foreach ($folders as $folder) {
- $newFolder = $filesXmlNew->createElement("folder");
- $newFolder->setAttribute("xml:id", $folder->getAttribute("id"));
- $newFolder->setAttribute("name", $folder->getAttribute("id"));
- $list->appendChild($newFolder);
- }
-
- foreach ($files as $file) {
- $newFile = $filesXmlNew->createElement("file", $file->getAttribute("title"));
- $newFile->setAttribute("xml:id", $file->getAttribute("id"));
- $newFile->setAttribute("name", $file->getAttribute("id"));
- $format = $file->getElementsByTagName("format")->item(0)->nodeValue;
- $newFile->setAttribute("format", $format);
- $newFile->setAttribute("uploaded", $file->getElementsByTagName("uploaded")->item(0)->nodeValue);
- $newFile->setAttribute("start", $file->getAttribute("start"));
- $newFile->setAttribute("stop", $file->getAttribute("stop"));
-// no sampling for cdf in old amda
- $minSampling = $file->getAttribute("sampling");
- $maxSampling = $file->getAttribute("maxsampling");
-
- if (!$minSampling) {
- $minSampling = $this->getSampling(USERDATADIR.$file->getAttribute("id"), $format);
- $maxSampling = $minSampling;
- }
-
- $newFile->setAttribute("minsampling", $minSampling);
- $newFile->setAttribute("maxsampling", $maxSampling);
-//TODO check mask
- $newFile->setAttribute("mask", $file->getAttribute("id"));
-
- if ($file->parentNode->tagName == 'level1')
- $filesXmlNew->getElementById($file->parentNode->getAttribute("id"))->appendChild($newFile);
- else
- $list->appendChild($newFile);
- }
- $filesXmlNew->save(USERWSDIR."Files.xml");
- }
-// mydata parameters
- $this->Mgr = new DerivedParamMgr('mydataParam');
- $this->createFolders('mydataList','mydataParam');
- //TODO folders are they OK?
- // get old params
- $wsdParams = $this->ws->getElementsByTagName('mydata');
-
- //TODO vi ??
- // $obj = new stdClass();
- foreach ($wsdParams as $item) {
- $obj = new stdClass();
- $obj->name = $item->getElementsByTagName('name')->item(0)->nodeValue;
- $obj->nodeType = "myDataParam";
- $obj->leaf = true;
- $obj->desc = $item->getAttribute('desc');
- $obj->file = $item->getAttribute('fileOrig');
- $obj->mask = $item->getAttribute('fileMask');
- $obj->fillvalue = $item->getAttribute('dataFillValue');
- $obj->minsampling = $item->getAttribute('dataSampling');
- $obj->maxsampling = $item->getAttribute('maxSampling');
- $obj->format = $item->getAttribute('fileFormat');
- $obj->type = $item->getAttribute('dataType');
- $obj->size = $item->getAttribute('dataSize');
- $obj->ytitle = $item->getAttribute('yTitle');
- $obj->realvar = $item->getAttribute('realName');
- $obj->units = $item->getAttribute('dataUnits');
- $obj->legend = $item->getAttribute('dataLegend');
-
- $this->Mgr->objectDom = new DomDocument("1.0");
- if ($item->parentNode->tagName === 'level1') {
- $folder_id = $item->parentNode->getAttribute('id');
- $this->Mgr->createObject($obj, $folder_id);
- }
- else {
- $this->Mgr->createObject($obj);
- }
- }
-
- $msg .= ' ok
';
-
- return array('success' => true, 'msg' => $msg);
- }
+ public function transferMyData()
+ {
+ $msg = 'My Data:
';
+
+ if (!$this->oldWs->load($this->oldWsDir.'WsParams.xml')) {
+ error_log('cannot load WsParams.xml for '.TRANSFERUSER,1,email);
+ return array('success' => false, 'error' => 'Sorry, we failed to get your MyData Params from old AMDA');
+ }
+
+ if (!file_exists($this->newWsDir.'WsParams.xml'))
+ $this->createDom();
+ else
+ $this->newWs->load($this->newWsDir.'WsParams.xml');
+
+ $BaseXml = new DomDocument("1.0");
+ $FilesXml = new DomDocument("1.0");
+
+ // get old params
+ $wsdParamsOld = $this->oldWs->getElementsByTagName('mydata');
+
+ if ($wsdParamsOld->length == 0) {
+ return array('success' => true, 'msg' => 'No parameters');
+ }
+
+ if (!$BaseXml->load(OLDUSERPATH.TRANSFERUSER.'/DATA/base.xml')) {
+ return array('success' => false, 'msg' => 'base description corrupted');
+ }
+
+ if (!$FilesXml->load($this->oldWsDir.'Files.xml')) {
+ return array('success' => false, 'msg' => 'files description corrupted');
+ }
+
+ $this->newWs->load($this->newWsDir.'WsParams.xml');
+ $paramDom = new DomDocument("1.0");
+
+ foreach ($wsdParamsOld as $wsdParamOld) {
+ $format = $wsdParamOld->getAttribute('format');
+ $name = $wsdParamOld->getAttribute('name');
+ $id = $wsdParamOld->getAttribute('xml:id');
+ $mask = $wsdParamOld->getAttribute('mask');
+ if ($format == 'cef') {
+ $deletedVi[] = $mask;
+ $msg .= ''.$name.' : CEF format is not implemented
';
+ $this->wsd_deleted[] = 'wsd_'.$name;
+ }
+ else {
+ $desc = $wsdParamOld->getAttribute('desc');
+ $start = substr($desc,0,16).':00';
+ $stop = substr($desc,17).':00';
+ $wsdParamOld->setAttribute('desc', $start.'-'.$stop);
+
+ $this->newWs->getElementsByTagName('mydataList')->item(0)->appendChild($this->newWs->importNode($wsdParamOld));
+
+ $paramDom->load($this->oldWsDir.$id.'.xml');
+ $descNode = $paramDom->getElementsByTagName('desc')->item(0);
+ $descNode->nodeValue = $start.'-'.$stop;
+ $paramDom->save($this->newWsDir.$id.'.xml');
+
+ $fileFormat[$mask] = $format === 'txt' ? 'ASCII' : strtoupper($format);
+ }
+ }
+
+ $this->newWs->save($this->newWsDir.'WsParams.xml');
+
+ // First delete CEF files
+ $xpBase = new domxpath($BaseXml);
+ foreach ($deletedVi as $vi) {
+ $maskNode = $xpBase->query("//mask[.='".$vi."']");
+ if ( $maskNode->length == 0 )
+ error_log('No '.$vi.' in '.TRANSFERUSER.'/DATA/base.xml',1,email);
+ else {
+ $viNode = $maskNode->item(0)->parentNode;
+ $files = $viNode->getElementsByTagName('file');
+ foreach ($files as $file) {
+ $deletedFiles[] = $file->getAttribute('name');
+ }
+ $viNode->parentNode->removeChild($viNode);
+ }
+ }
+ // Then modify base.xml : xml:id => id
+ $viNodes = $BaseXml->getElementsByTagName('vi');
+ foreach ($viNodes as $viNode) {
+ $id = $viNode->getAttribute('xml:id');
+ $viNode->removeAttribute('xml:id');
+ $viNode->setAttribute('id',$id);
+ $mask = $viNode->getElementsByTagName('mask')->item(0)->nodeValue;
+ $viNode->setAttribute('format', $fileFormat[$mask]);
+
+ }
+
+ $BaseXml->save(NEWUSERPATH.TRANSFERUSER.'/DATA/base.xml');
+
+ $filesNodes = $FilesXml->getElementsByTagName('file');
+ foreach ($filesNodes as $file) {
+ $fileName = $file->getAttribute('name');
+ if (!in_array($fileName,$deletedFiles)) {
+ copy(OLDUSERPATH.TRANSFERUSER.'/DATA/'.$fileName,NEWUSERPATH.TRANSFERUSER.'/DATA/'.$fileName);
+ }
+ }
+
+ foreach ($deletedVi as $vi) {
+ $node = $FilesXml->getElementById($vi);
+ if ($node)
+ $node->parentNode->removeChild($node);
+ }
+
+ $FilesXml->save($this->newWsDir.'Files.xml');
+ $msg .= ' ok
';
+
+ return array('success' => true, 'msg' => $msg);
+ }
+
+ public function transferFilters()
+ {
+ $msg = 'Filters:
';
+
+ if (!curl_init($this->oldWsDir.'Filters.xml')) {
+ return array('success' => true, 'msg' => 'No filters at old AMDA');
+ }
+
+ $filterXml = new DomDocument("1.0");
+ if (!$filterXml->load($this->oldWsDir.'Filters.xml')) {
+ return array('success' => false, 'error' => 'Cannot load filters from old AMDA');
+ }
+
+ $filterXml->save($this->newWsDir.'Filters.xml');
+ return array('success' => true, 'msg' => 'Filters have been copied');
+ }
}
?>
\ No newline at end of file
--
libgit2 0.21.2