WSInputOutputTTClass.php 1.85 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(WSConfigClass::getWsResultDir());
		$processData->setOutputFileName($input['outputFileName']);
		$outputFormat = empty($input['outputFormat']) ? 'VOTABLE' : $input['outputFormat'];
		switch ($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::SPASE);
				break;
			default:
				throw new Exception('Unknown output format');
		}
		$processData->setType($function);
		$processData->setCmd("ttConversion");

		$this->processData = $processData;

		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']) {
			$result['file'] = $data->getOutputDir()."/".$data->getOutputFileName();
		}
		return $result;
	}
} 

?>