IHMInputOutputConvertTTClass.php 1.66 KB
<?php

/**
 * @class IHMInputOutputConvertTTClass
 * @brief 
 * @details
*/
class IHMInputOutputConvertTTClass implements InputOutputInterface
{
	private $processData = NULL;

 
	/*
	 * @brief Constructor
	 */
	function __construct()
	{
		 
	}

	/*
	 * @brief translate input data from AMDA IHM 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']);
		switch ($input['inputFormat']) {
			case 'ASCII':
				$processData->setInputFileFormat(TTRequestFileFormatEnum::ASCII);
				break;
			case 'VOTABLE':
				$processData->setInputFileFormat(TTRequestFileFormatEnum::VOTABLE);
				break;
			case 'INTERNAL':
				$processData->setInputFileFormat(TTRequestFileFormatEnum::INTERNAL);
				break;
			default:
				throw new Exception('Unknown input format');
		}
		$processData->setOutputDir($input['outputDir']);
		$processData->setOutputFileFormat(TTRequestFileFormatEnum::INTERNAL);
		$processData->setOutputFileName($input['outputFileName']);
		$processData->setType($function);
		$processData->setCmd("ttConversion");

		$this->processData = $processData;
	
		return $this->processData;
	}

	/*
	 * @brief translate output data from AMDA_Integration module to AMDA IHM request
	 */
	public function getOutput($data)
	{
		$result  = array('success' => $data->getSuccess());
		if ($result['success']) {
			$result['file'] = $data->getOutputDir()."/".$data->getOutputFileName();
		}
		return $result;
	}
} 

?>