'LocalParams.xml', 'remoteParam' => 'RemoteParams.xml',
'remoteSimuParam' => 'RemoteParams.xml', 'derivedParam' => 'WsParams.xml', 'myDataParam' => 'WsParams.xml',
'timeTable' => 'Tt.xml', 'catalog' => 'Tt.xml', 'alias' => 'Alias.xml',
'myData' => 'Files.xml',
'request' => 'Request.xml', 'condition' => 'Request.xml',
'bkgWorks' => 'jobs.xml');
private $user, $amdaStat;
public function __construct()
{
if (!defined('NEWKERNEL_DEBUG') || !NEWKERNEL_DEBUG)
$this->amdaStat = new AmdaStats();
}
private function getUrlDirs($url) {
//TODO replace by ftp php class methods: ftp_nlist() etc
require_once "simple_html_dom.php";
$url = html_entity_decode($url);
$trimmed_url = trim($url);
if (strrpos($trimmed_url, "/") == strlen($trimmed_url) - 1) {
if (file_exists("temp.html")) unlink("temp.html");
exec("wget -O temp.html ".$url);
$html = file_get_html('temp.html');
$dirs = $html->find('a[href]');
foreach ($dirs as $dir) {
$name = $dir->innertext; //$dir->href;
$isLeaf = strrpos($name, "/") !== strlen($name) - 1;
$childrenToReturn[] = array('text' => $name, 'id' => $trimmed_url.$name,
'nodeType' => 'url', 'leaf' => $isLeaf);
}
}
return $childrenToReturn;
}
/*****************************************************************
* PUBLIC FUNCTIONS
*****************************************************************/
/*
* $obj = { id: node.id, nodeType: node.nodeType }
*/
public function getTree($obj) {
$node = $obj->node;
// to correct 'restricted' parameters
if (strpos($node, restricted) !== false) {
$node = str_replace(restricted,"",$node);
}
$nodeType = $obj->nodeType;
$remoteBase = false;
$isRemoteDataSet = false;
if ($nodeType == 'url')
{
$url = $node == 'root' ? $obj->baseId : $node;
return $this->getUrlDirs($url);
}
if ($obj->baseId) $remoteBase = true;
if ($node == 'root' && $remoteBase) $node = $obj->baseId;
if ($node == 'root' && !$remoteBase)
{
$json_o = json_decode(file_get_contents(DATAPATH.$nodeType.'.json'));
$childrenToReturn = $json_o->nodes;
}
else
{
$Dom = new DomDocument("1.0");
switch ($nodeType)
{
case 'sharedtimeTable':
$xmlName = SHAREDPATH.'/WS/Tt.xml';
break;
case 'bkgWorks':
$xmlName = USERJOBDIR.$this->xmlFiles[$nodeType];
break;
case 'source':
$xmlName = DATAPATH.'RemoteData/'.$obj->baseId.'/base.xml';
break;
case 'destination':
$xmlName = USERWSDIR.'RemoteParams.xml';
break;
default:
$xmlName = USERWSDIR.$this->xmlFiles[$nodeType];
}
if ($remoteBase)
{
$nodeType = 'remoteParam';
}
$Dom->load($xmlName);
if ($node == "myRemoteSimuData-treeRootNode")
$node = "myRemoteData-treeRootNode";
$nodeToOpen = $Dom->getElementById($node);
$children = $nodeToOpen->childNodes;
foreach ($children as $child)
if ($child->nodeType == XML_ELEMENT_NODE) {
$isLeaf = true;
if ($child->hasChildNodes())
foreach ($child->childNodes as $grandChild)
if ($grandChild -> nodeType == XML_ELEMENT_NODE) {
$isLeaf = false;
break;
}
if ($child->tagName == 'folder') $isLeaf = false;
//TODO MAKE PROPERLY as function of nodetype !!!!
$info = '';
$id = $child->getAttribute('xml:id');
$name = $child->getAttribute('name');
$help = $child->getAttribute('att');
if ($child->hasAttribute('dataStart')) $dataStart = $child->getAttribute('dataStart');
if ($child->hasAttribute('dataStop')) $dataStop = $child->getAttribute('dataStop');
$specialNode = false;
$isParameter = false;
$skip = false;
$isAddable = false;
$isSimulation = false;
$rank = null;
switch ($nodeType)
{
case 'bkgWorks':
$specialNode = true;
$status = $child->getAttribute('status');
// if ($status == 'done') continue;
$childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType, 'leaf' => $isLeaf,
'pid' => $child->getAttribute('pid'), 'status' => $status,
'jobType' => $child->getAttribute('jobType'), 'info' => $child->getAttribute('info'));
break;
case 'condition':
$objectMgr = new RequestMgr();
$info = $objectMgr->getObject($id)->expression;
break;
case 'request':
$objectMgr = new RequestMgr();
$objplot = $objectMgr->getObject($id);
for ($i=0; $i < count($objplot->children); $i++) {
for ($j=0; $j < count($objplot->children[$i]->children); $j++) {
$info = $info.' '.$objplot->children[$i]->children[$j]->name;
}
}
break;
case 'alias':
$info = $id;
$id = 'alias_'.$id;
if ($isLeaf) $isParameter = true;
break;
case 'timeTable':
case 'sharedtimeTable':
if ($isLeaf) $info = $child->getAttribute('intervals').' intervals';
break;
case 'derivedParam':
$info = $child->getAttribute('buildchain');
if ($isLeaf) $isParameter = true;
break;
case 'localParam':
$globalStart = null;
$globalStop = null;
$timeRestriction = false;
$specialNode = true;
$isParameter = false;
$needsArgs = false;
$isSpectra = false;
$isStack = false;
if ($child->hasAttribute('desc')) $info = $child->getAttribute('desc');
if ($child->hasAttribute('sampling'))
{
$info = "Sampling: ".$child->getAttribute('sampling')."
";
if ($child->getAttribute('dataStart') == 'depending on mission')
{
$info .= "Time Range: ".$child->getAttribute('dataStart')."
";
}
else
{
$info .= "Time Range: ".$child->getAttribute('dataStart')."-".$child->getAttribute('dataStop')."
";
}
if ($child->getAttribute('restricted') > 1) {
$restricted = $child->getAttribute('restricted');
$info .= "Time Restriction: -$restricted days
";
}
$info .= "Source: ".$child->getAttribute('dataSource');
}
if ($child->hasAttribute('units')) $info = $child->getAttribute('units');
if ($child->tagName == 'parameter')
{
$isParameter = true;
$isScatter = true;
if ($child->parentNode->hasAttribute('dataStart'))
{
$globalStart = $child->parentNode->getAttribute('dataStart');
$globalStop = $child->parentNode->getAttribute('dataStop');
}
if ($child->parentNode->getAttribute('restricted') > 1 )
{
$timeRestriction = true;
}
}
if ($child->tagName == 'component')
{
$isParameter = true;
$isScatter = true;
if ($child->parentNode->parentNode->hasAttribute('dataStart'))
{
$globalStart = $child->parentNode->parentNode->getAttribute('dataStart');
$globalStop = $child->parentNode->parentNode->getAttribute('dataStop');
}
if ($child->parentNode->parentNode->getAttribute('restricted') > 1)
{
$timeRestriction = true;
}
}
if ($child->tagName == 'parameter' && $child->hasChildNodes()) $isScatter = false;
if ($child->tagName == 'parameter' && $child->hasAttribute('display_type')) {
if ($child->getAttribute('display_type') == 'spectrogram') {
$needsArgs = true;
$isSpectra = true;
$isScatter = false;
}
else if ($child->getAttribute('display_type') == 'stack') {
$isStack = true;
$isScatter = false;
}
}
if ($isParameter)
{
if ($child->tagName == 'parameter' && $child->childNodes->length == 1)
{
$needsArgs = true;
}
if (substr($id,0,4) == 'bt96' || substr($id,0,6) == 'ba2000'|| substr($id,0,5) == 'bcain' || substr($id,0,7) == 'bmorsch' )
{
$needsArgs = true;
}
if ($id == 'mex_n_sw' || $id == 'mex_v_sw')
{
$not_yet = true;
}
if (substr($id,0,3) == 'ros')
{
if ( !(strpos($id,'_r_') || strpos($id,'_xyz_') || strpos($id,'_cg_')
|| strpos($id,'_sc_') || strpos($id,'_aux_')) )
{
$not_yet = true;
}
}
$objectMgr = new AliasMgr();
$alias = $objectMgr->getAlias($id);
$childrenToReturn[] = array('text' => $name,'alias' => $alias,
'id' => $id,'nodeType' => $nodeType, 'info' => $info,
'globalStart' => $globalStart, 'globalStop' => $globalStop, 'timeRestriction' => $timeRestriction,
'leaf' => $isLeaf, 'isParameter' => $isParameter, 'isScatter' => $isScatter,
'isSpectra' => $isSpectra,'isStack' => $isStack, 'needsArgs' => $needsArgs, 'help' => $help, 'notyet' => $not_yet);
}
else
{
if ($child->tagName == 'mission')
{
$disable = ($child->getAttribute('available') != "1");
$rank = $child->getAttribute('rank');
}
else
{
$disable = $child->getAttribute('restricted');
}
if ($disable)
{
if ($disable == 1) {
$info .= "
Restricted access";
}
else {
$disable = false;
}
}
$childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType, 'info' => $info,
'leaf' => false, 'help' => $help, 'disable' => $disable, 'rank' => $rank);
}
break;
case 'remoteSimuParam' :
$isSimulation = true;
if ($id == 'spase://IMPEX/SimulationModel/FMI/GUMICS' ) {
$isLeaf = false;
$isAddable = true;
}
if ($child->tagName == 'dataCenter') {
if ($child->getAttribute('isSimulation')) break;
else {
$skip = true;
break;
}
}
if ($child->tagName == 'simulationRegion')
{
$rank = $child->getAttribute('rank');
}
case 'remoteParam' :
if ($child->getAttribute('isSimulation') && $child->tagName == 'dataCenter') {
$skip = true;
break;
}
$isDeletable = $child->hasAttribute('isDeletable');
$specialNode = true;
$isParameter = false;
$isSpectra = false;
switch ($id)
{
case 'CDAWEB' :
case 'OMNIWEB' :
$isLeaf = false;
break;
case 'THEMIS' :
$rank = 5;
break;
case 'MAPSKP' :
$rank = 9;
break;
case 'VEXGRAZ' :
$rank = 2;
break;
default:
}
$info = $child->getAttribute('desc');
// if ($info && !$isSimulation) {
$info = str_replace(';', "
Time Range: ", $info);
// }
if ($child->tagName == 'dataset') {
/*if ($child->hasAttribute('dataStart') && $child->hasAttribute('dataStop'))
$info .= "Time Range: ".$child->getAttribute('dataStart')."-".$child->getAttribute('dataStop')."
"; */
// $info .= "Time Range: ".$dataStart"-".$dataStop."
";
}
if (($child->tagName == 'parameter') || ($child->tagName == 'component')) {
$isParameter = true;
$isScatter = true;
}
$needsArgs = $child->hasAttribute('needsArgs');
if (($child->tagName == 'parameter' && $child->hasChildNodes()) || $needsArgs) $isScatter = false;
if ($remoteBase) {
if ($child->tagName == 'dataset') $isRemoteDataSet = true;
}
if ($isParameter) {
$disable = $child->parentNode->getAttribute('disabled');
$objectMgr = new AliasMgr();
$alias = $objectMgr->getAlias($id);
if ($child->hasAttribute('display_type')
&& $child->getAttribute('display_type') == 'spectrogram'){
$needsArgs = true;
$isScatter = false;
$isSpectra = true;
}
$childrenToReturn[] = array('text' => $name,'alias' => $alias,
'id' => $id,'nodeType' => $nodeType, 'info' => $info, 'help' => $help,
'leaf' => $isLeaf, 'disable' => $disable, 'isParameter' => $isParameter,
'isScatter' => $isScatter, 'isSpectra' => $isSpectra, 'needsArgs' => $needsArgs);
}
else {
if ($child->tagName == 'dataCenter')
$restricted = ($child->getAttribute('available') != "1");
else
$restricted = false;
if ($id == 'CDAWEB' || $id == 'THEMIS'|| $id == 'MAPSKP' || $id == 'VEXGRAZ')
$restricted = FALSE;
if ($restricted)
$info .= "
Open soon !";
if ($child->tagName == 'dataset')
$nonavailable = ($child->getAttribute('disabled'));
else
$nonavailable = false;
if ($nonavailable)
$info .= "
Not available yet";
if ($child->getAttribute('url'))
$info .= "
".$child->getAttribute('url');
if ($child->hasAttribute('obsolete')) {
$info = $child->getAttribute('desc');
$obsolete = true;
}
else
$obsolete = false;
$disable = $restricted || $nonavailable || $obsolete;
$childrenToReturn[] = array('text' => $name, 'id' => $id,'nodeType' => $nodeType, 'isAddable' => $isAddable,
'info' => $info, 'leaf' => false, 'isRemoteDataSet' => $isRemoteDataSet, 'disable' => $disable,
'isSimulation' => $isSimulation, 'rank' => $rank, 'isDeletable' => $isDeletable, 'help' => $help);
}
break;
case 'myData' :
$info = $child->hasAttribute('info') ? $child->getAttribute('info') : $child->nodeValue;
// $info = str_replace("\n","
",$info);
break;
case 'myDataParam' :
$globalStart = null;
$globalStop = null;
$specialNode = true;
$size = $child->getAttribute('size');
$isScatter = $size == 1;
$mask = $child->getAttribute('mask');
$isSpectra = false;
if ($isLeaf) {
$isParameter = true;
$info = "Size: ".$size."
".$child->getAttribute('desc')."
Mask: ".$mask;
$isSpectra = $child->getAttribute('plottype') === 'Spectra';
}
if ($child->hasAttribute('desc')) {
$globalStart = substr(str_replace('-','/',$child->getAttribute('desc')), 0, 16);
$globalStop = substr(str_replace( '-','/',$child->getAttribute('desc')), 17, 22);
}
$childrenToReturn[] = array('text' => $name, 'size' => $size, 'id' => $id,
'globalStart' => $globalStart, 'globalStop' => $globalStop,
'nodeType' => $nodeType, 'info' => $info, 'isScatter' => $isScatter, 'leaf' => $isLeaf,
'isParameter' => $isParameter, 'linkedMask' => $mask, 'isSpectra' => $isSpectra);
break;
default:
}
if (!$specialNode && !$skip) {
if ($child->hasAttribute('desc'))
$info = $child->getAttribute('desc');
$childrenToReturn[] = array('text' => $name, 'id' => $id, 'nodeType' => $nodeType, 'info' => $info,
'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter);
}
}
// if $childrenToReturn we have to return []
if ($childrenToReturn == null) {
$childrenToReturn = array('nodeType' => $nodeType, 'text' => null);
}
}
return $childrenToReturn;
}
public function saveTree($obj)
{
$paramMgr = new ParamMgr();
return $paramMgr->saveTree($obj);
}
public function doNothing($obj)
{
return array("res" => 'ok');
}
public function deleteFromTree($obj)
{
$paramMgr = new ParamMgr();
return $paramMgr->deleteFromTree($obj);
}
/*
* temporary object fromUpload
*/
public function getUploadedObject($name, $format, $nodeType)
{
switch ($nodeType)
{
case 'timeTable' :
$objectMgr = new TimeTableMgr();
break;
case 'myDataParam' :
$objectMgr = new FilesMgr();
break;
default:
return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
}
return $objectMgr -> getUploadedObject($name, $format, true);
}
/*
* fill ascii file into grid
*/
public function getAsciiFile($obj)
{
$objectMgr = new FilesMgr();
return $objectMgr -> getAsciiFile($obj->fileName);
}
public function getParamInfo($object)
{
$objectMgr = new FilesMgr();
return $objectMgr -> getParamInfo($object);
}
/*
* temporary object from Search
*/
public function getTmpObject($folderId, $name, $nodeType) {
switch ($nodeType) {
case 'timeTable' :
$objectMgr = new TimeTableMgr();
break;
default:
return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
}
return $objectMgr -> getTmpObject($folderId, $name, true);
}
public function getObject($id, $nodeType) {
switch ($nodeType) {
case 'myDataParam':
case 'derivedParam' :
$objectMgr = new DerivedParamMgr($nodeType);
break;
case 'timeTable' :
case 'sharedtimeTable' :
$objectMgr = new TimeTableMgr();
break;
case 'condition' :
case 'request' :
$objectMgr = new RequestMgr($nodeType);
break;
case 'bkgWorks' :
require_once(INTEGRATION_SRC_DIR."RequestManager.php");
return $this->executeRequest($id, FunctionTypeEnumClass::PROCESSGETINFO);
break;
case 'myData' :
$objectMgr = new FilesMgr();
break;
default:
return array("error" => $nodeType." NOT_IMPLEMENTED_YET");
}
return $objectMgr -> getObject($id, $nodeType);
}
/*
* $obj = { id: node.id, leaf: node.leaf, nodeType: node.nodeType }
*/
public function deleteObject($obj) {
switch ($obj->nodeType) {
case 'myDataParam' :
case 'derivedParam' :
$objectMgr = new DerivedParamMgr($obj->nodeType);
break;
case 'timeTable' :
$objectMgr = new TimeTableMgr();
break;
case 'condition' :
case 'request' :
$objectMgr = new RequestMgr($obj->nodeType);
break;
case 'alias' :
$objectMgr = new AliasMgr();
$obj->id = substr($obj->id,strlen('alias_'));
break;
case 'bkgWorks' :
require_once(INTEGRATION_SRC_DIR."RequestManager.php");
return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSDELETE);
case 'myData' :
$objectMgr = new FilesMgr();
break;
default:
return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
}
return $objectMgr -> deleteObject($obj);
}
/*
* $obj = { id: node.id, old_name: node.text, name: value, parent : node.parentNode.id, leaf: node.leaf, nodeType: node.nodeType }
*/
public function renameObject($obj) {
switch ($obj->nodeType) {
case 'myDataParam' :
case 'derivedParam' :
$objectMgr = new DerivedParamMgr($obj->nodeType);
break;
case 'timeTable' :
$objectMgr = new TimeTableMgr();
break;
case 'condition' :
case 'request' :
$objectMgr = new RequestMgr($obj->nodeType);
break;
case 'alias' :
$objectMgr = new AliasMgr();
break;
default:
return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
}
return $objectMgr -> renameObject($obj);
}
/*
* $obj = { name: obj.name, obj.nodeType, obj.leaf (??), OBJ DEPENDENT ATTRIBUTES }
*/
public function createObject($obj, $folder) {
switch ($obj->nodeType) {
case 'myDataParam' :
case 'derivedParam' :
if ($obj->nodeType == 'derivedParam' && $this->amdaStat->success)
$this->amdaStat->addTask('create', $this->user, null);
$objectMgr = new DerivedParamMgr($obj->nodeType);
break;
case 'timeTable' :
$objectMgr = new TimeTableMgr();
break;
case 'condition' :
case 'request' :
$objectMgr = new RequestMgr($obj->nodeType);
break;
case 'alias' :
$objectMgr = new AliasMgr();
break;
default:
return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
}
return $objectMgr -> createObject($obj, $folder);
}
/*
* $obj = { id:obj.id, name: obj.name, obj.nodeType, obj.leaf (??), OBJ DEPENDENT ATTRIBUTES }
*/
public function modifyObject($obj) {
switch ($obj->nodeType) {
case 'myDataParam' :
case 'derivedParam' :
$objectMgr = new DerivedParamMgr($obj->nodeType);
break;
case 'timeTable' :
$objectMgr = new TimeTableMgr();
break;
case 'condition' :
case 'request' :
$objectMgr = new RequestMgr($obj->nodeType);
break;
default:
return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
}
return $objectMgr -> modifyObject($obj);
}
/*
* {obj.name, obj.nodeType, obj.leaf}
*/
public function validNameObject($obj) {
switch ($obj->nodeType) {
case 'myDataParam' :
case 'derivedParam' :
$objectMgr = new DerivedParamMgr($obj->nodeType);
break;
case 'timeTable' :
$objectMgr = new TimeTableMgr();
break;
case 'condition' :
case 'request' :
$objectMgr = new RequestMgr($obj->nodeType);
break;
default:
return array("error" => $obj->nodeType." NOT_IMPLEMENTED_YET");
}
return $objectMgr -> validNameObject($obj);
}
/*
* Get Jobs en cours
*/
public function getJobs()
{
require_once(INTEGRATION_SRC_DIR."RequestManager.php");
return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSRUNNINGINFO);
}
/* AKKA-KERNEL-INT
Move user check from RequestMgr.php to AmdaAction.php
*/
private function checkUser($obj)
{
if (defined('NEWKERNEL_DEBUG') && NEWKERNEL_DEBUG)
{
$this->user = NEWKERNEL_DEBUG_USER;
return array('success' => true);
}
if (isset($obj->username) && isset($obj->password) && isset($obj->sessionID))
{
//$dd = new WSUserMgr();
//$dd->init($obj->username,$obj->password,$obj->sessionID);
return array('success' => false, "message" => "AKKA-KERNEL-INT - WS support not implemented");
}
else
$dd = new UserMgr();
//TODO error handling
if (($res = $dd -> ddCheckUser()) != 0)
{
if ($res == 156)
return array('success' => false, 'message' => 'Your AMDA session is expired.
Login please!');
return array('success' => false, 'message' => 'ddLogin error: '.$res);
}
if ($dd->user == 'impex')
{
//if ($dd->getWsSize() > DISK_QUOTA * 100)
// error_log('Natacha! It is time to CLEAN UP IMPEX WS!',1,'nbourrel@irap.omp.eu');
return array('success' => false, "message" => "AKKA-KERNEL-INT - WS support for IMPEx not implemented");
}
else
{
// check disk space
if ($dd->getWsSize() > DISK_QUOTA)
return array('success' => false, 'message' => 'Please clean up your workspace.
No more space is available');
}
$this->user = $dd->user;
return array('success' => true, 'userHost' => $dd -> getIPclient());
}
private function executeRequest($obj, $function)
{
$res = $this->checkUser($obj);
if (!$res['success'])
return $res;
$requestManager = new RequestManagerClass();
try {
$res = $requestManager->runIHMRequest($this->user, $res['userHost'], $function, $obj);
} catch (Exception $e) {
return array('success' => false, 'message' => 'Exception detected : '.$e->getMessage());
}
return $res;
}
/*
* Main EXECUTE PROCEDURE
*/
public function execute($node, $obj)
{
require_once(INTEGRATION_SRC_DIR."RequestManager.php");
if (isset($obj->action))
return $this->executeRequest($obj, FunctionTypeEnumClass::ACTION);
else
return $this->executeRequest($obj, FunctionTypeEnumClass::PARAMS);
}
/*
* Generate derived parameter compilation
*/
public function compilParam($obj)
{
require_once(INTEGRATION_SRC_DIR."RequestManager.php");
return $this->executeRequest($obj, FunctionTypeEnumClass::PARAMSGEN);
}
/*
* Delete derived parameter compilation
*/
public function compilParamDelete($obj)
{
require_once(INTEGRATION_SRC_DIR."RequestManager.php");
$res = $this->checkUser($obj);
if (!$res['success'])
return $res;
IHMConfigClass::setUserName($this->user);
$libParamPath = IHMConfigClass::getCompilationPath()."lib/".$obj->paramId.".so";
if (file_exists($libParamPath))
unlink($libParamPath);
return array("success" => true);
}
/*
* kill plot process by tabID
*/
public function killPlotRequest($obj)
{
$objectMgr = new RequestMgr('request');
if (count($obj->tabId) > 1)
{
return $objectMgr->killMultiPlot($obj->tabId);
}
else
{
return $objectMgr->killPlot($obj->tabId);
}
}
/*
* merge time tables
*/
public function merge($obj) {
if ($this->amdaStat->success)
$this->amdaStat->addTask('ttoper', $this->user, null);
$objectMgr = new TimeTableMgr();
return $objectMgr -> merge($obj);
}
/*
* intersect time tables
*/
public function intersect($obj) {
if ($this->amdaStat->success)
$this->amdaStat->addTask('ttoper', $this->user, null);
$objectMgr = new TimeTableMgr();
$result = $objectMgr -> intersect($obj);
return $result;
}
public function initTTCache()
{
$cacheMgr = new TimeTableCacheMgr();
return $cacheMgr->initTTCache();
}
public function initTTCacheFromTT($id, $type)
{
$cacheMgr = new TimeTableCacheMgr();
return $cacheMgr->initFromTT($id, $type);
}
public function initTTCacheFromTmpObject($folderId, $name)
{
$cacheMgr = new TimeTableCacheMgr();
return $cacheMgr->initFromTmpObject($folderId, $name);
}
public function initTTCacheFromUploadedFile($name, $format)
{
$cacheMgr = new TimeTableCacheMgr();
return $cacheMgr->initFromUploadedFile($name, $format);
}
public function readTTCacheIntervals($o)
{
$cacheMgr = new TimeTableCacheMgr();
return $cacheMgr->getIntervals($o->start,$o->limit,$o->sort,$o->filter);
}
public function saveTTCacheIntervalsInTT($o)
{
$cacheMgr = new TimeTableCacheMgr();
return $cacheMgr->saveInTT($o->ttId,$o->action,$o->cacheToken);
}
public function addTTCacheInterval($o)
{
$cacheMgr = new TimeTableCacheMgr();
return $cacheMgr->addInterval($o->index, $o->start, $o->stop);
}
public function removeTTCacheIntervalFromId($id)
{
$cacheMgr = new TimeTableCacheMgr();
return $cacheMgr->removeIntervalFromId($id);
}
public function modifyTTCacheInterval($o)
{
$cacheMgr = new TimeTableCacheMgr();
return $cacheMgr->modifyIntervalFromId($o->cacheId, $o->start, $o->stop);
}
public function operationTTCacheIntervals($extendTime, $shiftTime)
{
$cacheMgr = new TimeTableCacheMgr();
return $cacheMgr->operationIntervals($extendTime, $shiftTime);
}
public function mergeTTCacheIntervals()
{
$cacheMgr = new TimeTableCacheMgr();
return $cacheMgr->mergeIntervals();
}
public function getTTCacheStatistics()
{
$cacheMgr = new TimeTableCacheMgr();
return $cacheMgr->getStatistics();
}
public function getTTCacheStatus()
{
$cacheMgr = new TimeTableCacheMgr();
return $cacheMgr->getStatus();
}
/*
* Send a feedback
*
*/
public function sendFeedback($feed)
{
$feedMgr = new FeedbackMgr();
return $feedMgr->addFeedback($feed->user, $feed->interface, $feed->subject, $feed->userText, $feed->userAgent, $feed->attach);
}
/*
* Save state
*
*/
public function saveState($datas)
{
$myStateMgr = new StateMgr();
return $myStateMgr->saveState($datas);
}
/*
* Load state
*
*/
public function loadState($o)
{
$myStateMgr = new StateMgr();
return $myStateMgr->loadState();
}
/*
* SAMP
*/
public function sendToSAMP($o)
{
if ($this->amdaStat->success)
$this->amdaStat->addTask('samp', $this->user, null);
$objectMgr = new RequestMgr();
$res = $objectMgr->generateVOTableFromDownloadResult($o->folderId, $o->downId,true,true);
if ($res['success'])
{
foreach ($res['files'] as $key => $value)
$res['files'][$key] = str_replace(BASE_PATH,"",$value);
}
return $res;
}
/*
* HST Images
*/
public function getHstImagesUrl($o)
{
if ($this->amdaStat->success)
$this->amdaStat->addTask('images', $this->user, null);
$myHstMgr = new HstMgr();
$res = $myHstMgr->getImagesUrl($o->startTime, $o->stopTime, $o->planet);
//if ($domRes->length <= 0)
// return array('success' => false, 'message' => 'Cannot find HST Images for this request.');
return array('success' => true, 'result' => $res);
}
public function getAPISImagesUrl($o)
{
if ($this->amdaStat->success)
$this->amdaStat->addTask('images', $this->user, null);
$apisMgr = new APISMgr();
$res = $apisMgr->get($o->target, $o->startTime, $o->stopTime, $o->datasets);
return $res;
}
/*
* Filters
*/
public function loadFilterList($o)
{
$filtersMgr = new FiltersMgr();
$res = $filtersMgr->loadList();
return $res;
}
public function loadFilters($o)
{
$filtersMgr = new FiltersMgr();
if (isset($o->id))
$res = $filtersMgr->loadFilter($o->id);
else
$res = $filtersMgr->loadAll();
return $res;
}
public function saveFilter($o)
{
$filtersMgr = new FiltersMgr();
return $filtersMgr->save($o);
}
public function createFilter($o)
{
$filtersMgr = new FiltersMgr();
return $filtersMgr->create($o);
}
public function destroyFilter($o)
{
$filtersMgr = new FiltersMgr();
$res = $filtersMgr->delete($o);
return;
}
public function getCrtFilterId()
{
$filtersMgr = new FiltersMgr();
$res = $filtersMgr->getCrtId();
return $res;
}
public function getCrtFilterResult()
{
$filtersMgr = new FiltersMgr();
return $filtersMgr->getCrtResult();
}
public function setCrtFilterId($o)
{
$filtersMgr = new FiltersMgr();
return $filtersMgr->setCrtId($o->id);
}
public function resetFilter()
{
$filtersMgr = new FiltersMgr();
$res = $filtersMgr->reset();
return $res;
}
public function logout($isGuest)
{
if ($isGuest) {
$guestMgr = new Guest($this->user);
$guestMgr->deleteGuest();
}
else {
$myBaseMgr = new BaseManager();
$myBaseMgr->delSimuFiles('mysimudata');
$myBaseMgr->delSimuFiles('mywsrdata');
$jobsMgr = new JobsMgr();
$jobsMgr->deleteTmp();
}
return;
}
public function getInfo($obj)
{
if (file_exists(HELPPATH.$obj->name))
{
$content = file_get_contents(HELPPATH.$obj->name);
return array('success' => true, 'result' => $content);
}
return array('success' => false);
}
public function getUserInfo()
{
$dd = new UserMgr();
return $dd->getUserInfo();
}
public function convertWS()
{
$dd = new UserMgr();
return $dd->convertWS();
}
// $obj ={"Object":"Earth","RunCount":"2",
// "SW_Density_value":"10","SW_Density_weight":"1","SW_Density_scale":"7","SW_Temperature_value":"100", ....}
public function getRun($obj)
{
$myBestRunsMgr = new BestRunsMgr();
$res = $myBestRunsMgr->getRun($obj);
return $res;
}
//$obj = array of IDs
public function addRun($obj)
{
$myBestRunsMgr = new BestRunsMgr();
$myBestRunsMgr->init();
$myBestRunsMgr->addRuns($obj);
$res = array('success' => true,'addedRuns' => $obj);
return $res;
}
//AKKA - New action to clean user WS
public function cleanUserWS()
{
require_once(INTEGRATION_SRC_DIR."RequestManager.php");
return $this->executeRequest($obj, FunctionTypeEnumClass::PROCESSCLEAN);
}
public function deleteSpecialInfo($name)
{
if (file_exists(USERDIR.$name))
unlink(USERDIR.$name);
return array('success' => true);
}
}
?>