SharedObjectsUpdaterInputOutputTTClass.php 1.72 KB
<?php

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

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

	/*
	 * @brief translate input data from AMDA shared objects updater 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 shared objects updater request
	 */
	public function getOutput($data)
	{
		$result  = array('success' => $data->getSuccess());
		if ($result['success']) {
			$result['file'] = $data->getOutputDir()."/".$data->getOutputFileName();
		}
		return $result;
	}
} 

?>