WSInputOutputTTClass.php
2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?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;
}
}
?>