WSInputOutputTTClass.php 2.26 KB
<?php

/**
 * @class WSInputOutputTTClass
 * @brief 
 * @details
*/
//TODO not finished and not used for the moment 
class WSInputOutputTTClass extends IHMInputOutputTTClass
{
 
/*
	* @brief Constructor
*/
	function __construct()
	{
		 
	}

/*
	* @brief translate input data from IHM client to AMDA_Integration module for a tt process request
*/
	public function getInputData($input, $function, $requestId="")
	{
		if (isset($this->processData))
			unset($this->processData);

		$processData = new TTRequestDataClass();
		$processData->setInputFileName($input['inputFile']);
		$processData->setInputFileFormat(TTRequestFileFormatEnum::INTERNAL);
		$processData->setOutputDir(IHMConfigClass::getDownloadTmpPath());
		$processData->setOutputFileName($input['outputFileName']);
		$outputFormat = empty($input['outputFormat']) ? 'VOTABLE' : $input['outputFormat'];
		switch (strtolower($outputFormat)) {
			case 'ascii':
				$processData->setOutputFileFormat(TTRequestFileFormatEnum::ASCII);
				break;
			case 'votable':
				$processData->setOutputFileFormat(TTRequestFileFormatEnum::VOTABLE);
				break;
			case 'internal':
				$processData->setOutputFileFormat(TTRequestFileFormatEnum::INTERNAL);
				break;
			case 'hpevent':
				$processData->setOutputFileFormat(TTRequestFileFormatEnum::SPACE);
				break;
			default:
				throw new Exception('Unknown output format');
		}
		$processData->setType($function);
		$processData->setCmd("ttConversion");

		$this->processData = $processData;

		$this->postProcessTT = new PostProcessTTClass();
		$this->postProcessTT->setOutputDirAlias(IHMConfigClass::getDownloadTmpPath());
		$this->postProcessTT->setPostCmd("mv \"".IHMConfigClass::getDownloadTmpPath().$input['outputFileName']."\" \"".WSConfigClass::getWsResultDir().$input['outputFileName']."\"");

		return $this->processData;
	}

/*
	* @brief translate output data from AMDA_Integration module to IHM client  request
*/
	public function getOutput($data)
	{
		$result  = array('success' => $data->getSuccess());
		if ($result['success']) {
			$cmd = $this->postProcessTT->getPostCmd();
                        system($cmd);
			$result['file'] = WSConfigClass::getWsResultDir()."/".$data->getOutputFileName();
		}
		return $result;
	}
} 

?>