Blame view

src/InputOutput/WSImpl/TimeTables/WSInputOutputTTClass.php 2.26 KB
738745d3   Elena.Budnik   draft for Web Ser...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?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="")
	{
6a8aef7f   Benjamin Renard   Add APIs getCatal...
25
26
		if (isset($this->processData))
			unset($this->processData);
738745d3   Elena.Budnik   draft for Web Ser...
27

6a8aef7f   Benjamin Renard   Add APIs getCatal...
28
29
30
		$processData = new TTRequestDataClass();
		$processData->setInputFileName($input['inputFile']);
		$processData->setInputFileFormat(TTRequestFileFormatEnum::INTERNAL);
c73bd535   Benjamin Renard   Fix working for g...
31
		$processData->setOutputDir(IHMConfigClass::getDownloadTmpPath());
6a8aef7f   Benjamin Renard   Add APIs getCatal...
32
33
		$processData->setOutputFileName($input['outputFileName']);
		$outputFormat = empty($input['outputFormat']) ? 'VOTABLE' : $input['outputFormat'];
c73bd535   Benjamin Renard   Fix working for g...
34
35
		switch (strtolower($outputFormat)) {
			case 'ascii':
6a8aef7f   Benjamin Renard   Add APIs getCatal...
36
37
				$processData->setOutputFileFormat(TTRequestFileFormatEnum::ASCII);
				break;
c73bd535   Benjamin Renard   Fix working for g...
38
			case 'votable':
6a8aef7f   Benjamin Renard   Add APIs getCatal...
39
40
				$processData->setOutputFileFormat(TTRequestFileFormatEnum::VOTABLE);
				break;
c73bd535   Benjamin Renard   Fix working for g...
41
			case 'internal':
6a8aef7f   Benjamin Renard   Add APIs getCatal...
42
43
				$processData->setOutputFileFormat(TTRequestFileFormatEnum::INTERNAL);
				break;
c73bd535   Benjamin Renard   Fix working for g...
44
45
			case 'hpevent':
				$processData->setOutputFileFormat(TTRequestFileFormatEnum::SPACE);
6a8aef7f   Benjamin Renard   Add APIs getCatal...
46
47
48
				break;
			default:
				throw new Exception('Unknown output format');
738745d3   Elena.Budnik   draft for Web Ser...
49
		}
6a8aef7f   Benjamin Renard   Add APIs getCatal...
50
51
52
53
		$processData->setType($function);
		$processData->setCmd("ttConversion");

		$this->processData = $processData;
738745d3   Elena.Budnik   draft for Web Ser...
54

c73bd535   Benjamin Renard   Fix working for g...
55
56
57
58
		$this->postProcessTT = new PostProcessTTClass();
		$this->postProcessTT->setOutputDirAlias(IHMConfigClass::getDownloadTmpPath());
		$this->postProcessTT->setPostCmd("mv \"".IHMConfigClass::getDownloadTmpPath().$input['outputFileName']."\" \"".WSConfigClass::getWsResultDir().$input['outputFileName']."\"");

6a8aef7f   Benjamin Renard   Add APIs getCatal...
59
		return $this->processData;
738745d3   Elena.Budnik   draft for Web Ser...
60
61
62
63
64
65
66
	}

/*
	* @brief translate output data from AMDA_Integration module to IHM client  request
*/
	public function getOutput($data)
	{
6a8aef7f   Benjamin Renard   Add APIs getCatal...
67
68
		$result  = array('success' => $data->getSuccess());
		if ($result['success']) {
c73bd535   Benjamin Renard   Fix working for g...
69
70
71
			$cmd = $this->postProcessTT->getPostCmd();
                        system($cmd);
			$result['file'] = WSConfigClass::getWsResultDir()."/".$data->getOutputFileName();
6a8aef7f   Benjamin Renard   Add APIs getCatal...
72
		}
738745d3   Elena.Budnik   draft for Web Ser...
73
74
75
76
77
		return $result;
	}
} 

?>