WSInputOutputTTClass.php 2.47 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->processDatas))
			unset($this->processDatas);
			
		$final = "";
// 		if (is_dir(IHMConfigClass::getDownloadTmpPath())) {
// 			foreach (glob(IHMConfigClass::getDownloadTmpPath().'*.zip') as $filename)  unlink($filename);
// 			foreach (glob(IHMConfigClass::getDownloadTmpPath().'*.tar.gz') as $filename)  unlink($filename);
// 		}
		
		foreach($input->list as $ttId)
		{
			//create a list of data to treat
			$processData = new TTRequestDataClass();
			if (strpos($id,"sharedtimeTable_") === 0) {
				//Shared TimeTable
				$result = IHMSharedObjectsClass::getPath("timeTable", $ttId);
				if (!$result['success'])
					throw new Exception('Shared TimeTable '.$ttId.' not found');
				$ttName = $result['path'];
			}
			else {
				//User TimeTable
				$ttName = IHMConfigClass::getUserTTPath().$ttId.'.xml';
			}
			if (!file_exists($ttName))
				throw new Exception('TimeTable '.$ttId.' not found');
				
			$processData->setInputFileName($ttName);
			$processData->setInputFileFormat(TTRequestFileFormatEnum::INTERNAL);			 
			$processData->setOutputDir(WSConfigClass::getWSResultDir());
			
			$processData->setOutputFileFormat(TTRequestFileFormatEnum::VOTABLE);
			$outputName = $ttId.'.xml';

			$processData->setOutputFileName($outputName);

			$processData->setType($function);
			$processData->setCmd("ttConversion");
									
			$this->processDatas[] = $processData;
		}
		
		$this->postProcessTT = new PostProcessTTClass();
		$this->postProcessTT->setOutputDirAlias($this->processDatas[0]->getOutputDir());
 
		$this->postProcessTT->setOutputFileName($outputFileName);
		$this->postProcessTT->setOutputDir($this->processDatas[0]->getOutputDir());			

		return $this->processDatas;
	}

/*
	* @brief translate output data from AMDA_Integration module to IHM client  request
*/
	public function getOutput($data)
	{

			$result  = array('success'=>$data[0]->getSuccess(), 
				'download' => $this->postProcessTT->getOutputDirAlias().$data[0]->getOutputFileName());
	 		
		return $result;
	}
} 

?>