diff --git a/src/InputOutput/IHMImpl/Params/DownloadImpl/IHMInputOutputParamsDownloadClass.php b/src/InputOutput/IHMImpl/Params/DownloadImpl/IHMInputOutputParamsDownloadClass.php index 5d3e810..294e385 100644 --- a/src/InputOutput/IHMImpl/Params/DownloadImpl/IHMInputOutputParamsDownloadClass.php +++ b/src/InputOutput/IHMImpl/Params/DownloadImpl/IHMInputOutputParamsDownloadClass.php @@ -1,6 +1,7 @@ <?php define ("DOWNLOAD_RESULT_FILE_KEY","download"); +define ("DOWNLOAD_SAMP_RESULT_FILE_KEY","download-samp"); /** * @class IHMInputOutputParamsDownloadClass @@ -22,6 +23,16 @@ class IHMInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClas $paramsNode = $requestNode->getParamsNode(); + //Send to SAMP + $this->sendToSamp = isset($input->sendToSamp) ? $input->sendToSamp : FALSE; + if ($this->sendToSamp) { + $input->disablebatch = FALSE; + $input->timeformat = 'YYYY-MM-DDThh:mm:ss'; + $input->fileformat = 'vot'; + $input->compression = ''; + $input->fileprefix = 'amda-samp'; + } + //unmarshall time definition $this->unmarshallTimeDefinition($input, 0); @@ -188,13 +199,21 @@ class IHMInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClas throw new Exception('Compression type not implemented.'); } - $resultFile = "result_".$this->requestID; - $this->paramsData->addWaitingResult(DOWNLOAD_RESULT_FILE_KEY, $resultFile); + if (!$this->sendToSamp) { + $resultFile = "result_".$this->requestID; + $this->paramsData->addWaitingResult(DOWNLOAD_RESULT_FILE_KEY, $resultFile); - $postProcessCmd = "mv ".$resultFilePrefix."*"; + $postProcessCmd = "mv ".$resultFilePrefix."*"; - $postProcessCmd .= $extension; - $postProcessCmd .= " ".$resultFile.$extension; + $postProcessCmd .= $extension; + $postProcessCmd .= " ".$resultFile.$extension; + } + else { + $resultFile = $input->fileprefix.".list"; + $this->paramsData->addWaitingResult(DOWNLOAD_SAMP_RESULT_FILE_KEY, $resultFile); + + $postProcessCmd = "ls ".$input->fileprefix."* > ".$resultFile; + } $this->paramsData->setPostCmd($postProcessCmd); @@ -209,7 +228,10 @@ class IHMInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClas */ protected function marshallResult($data) { - return $this->commonMarshallResult($data,DOWNLOAD_RESULT_FILE_KEY); + if ($this->sendToSamp) + return $this->commonMarshallResult($data,DOWNLOAD_SAMP_RESULT_FILE_KEY); + else + return $this->commonMarshallResult($data,DOWNLOAD_RESULT_FILE_KEY); } } ?> diff --git a/src/InputOutput/IHMImpl/Params/IHMInputOutputParamsAbstractClass.php b/src/InputOutput/IHMImpl/Params/IHMInputOutputParamsAbstractClass.php index 0555c92..1d199d9 100644 --- a/src/InputOutput/IHMImpl/Params/IHMInputOutputParamsAbstractClass.php +++ b/src/InputOutput/IHMImpl/Params/IHMInputOutputParamsAbstractClass.php @@ -15,6 +15,7 @@ abstract class IHMInputOutputParamsAbstractClass implements InputOutputInterface protected $requestID = ""; protected $requestDirPrefix = ""; private $input = null; + protected $sendToSamp = FALSE; /* * @brief Constructor @@ -116,13 +117,20 @@ abstract class IHMInputOutputParamsAbstractClass implements InputOutputInterface */ protected function addToJobsFile($data,$resultKey) { + $waitingResult = $data->getWaitingResult($resultKey); + if ($this->sendToSamp && ($data->getStatus() == ProcessStatusEnumClass::DONE)) { + $waitingResult = explode("\n", file_get_contents(IHMConfigClass::getRequestPath()."/".$this->getWorkingDirName()."/".$waitingResult)); + $waitingResult = implode(',', $waitingResult); + $waitingResult = rtrim($waitingResult, ','); + } + return $this->jobsManager->addJob( $this->input, $data->getId(), $this->getWorkingDirName(), $data->getStatus() == ProcessStatusEnumClass::RUNNING, $data->getStart(), - $data->getWaitingResult($resultKey), + $waitingResult, $data->getErrorCode()); } diff --git a/src/InputOutput/IHMImpl/Tools/IHMJobsManagerClass.php b/src/InputOutput/IHMImpl/Tools/IHMJobsManagerClass.php index d1fa227..6b409be 100644 --- a/src/InputOutput/IHMImpl/Tools/IHMJobsManagerClass.php +++ b/src/InputOutput/IHMImpl/Tools/IHMJobsManagerClass.php @@ -224,6 +224,13 @@ class IHMJobsManagerClass { if (isset($request_obj->compression)) $compression = strtolower($request_obj->compression); } + $sendToSamp = $job->getAttribute('sendToSamp'); + if (empty($sendToSamp)) { + $sendToSamp = false; + } + else { + $sendToSamp = ($sendToSamp == "true"); + } } return array( 'success' => true, @@ -237,7 +244,9 @@ class IHMJobsManagerClass { 'folder' => $folder, 'result' => $result, 'format' => $format, - 'compression' => $compression); + 'compression' => $compression, + 'sendToSamp' => $sendToSamp, + ); } /* @@ -307,6 +316,11 @@ class IHMJobsManagerClass { //to know if know if it's an immediate job or not $newJob->setAttribute('immediate', !$running); + $sendToSamp = isset($obj->sendToSamp) ? $obj->sendToSamp : FALSE; + if ($sendToSamp) { + $newJob->setAttribute('sendToSamp', "true"); + } + if ($running) { $rootJobNode = $this->jobXml->getElementById($this->bkgRootNode[$obj->nodeType]); -- libgit2 0.21.2