Commit 6a8aef7f9a3c5f0bfc93628990a7a6a6a39ce98d

Authored by Benjamin Renard
1 parent 63878d61

Add APIs getCatalog & getCatalogsList

src/InputOutput/WSImpl/TimeTables/WSInputOutputTTClass.php
... ... @@ -22,55 +22,37 @@ class WSInputOutputTTClass extends IHMInputOutputTTClass
22 22 */
23 23 public function getInputData($input, $function, $requestId="")
24 24 {
25   - if (isset($this->processDatas))
26   - unset($this->processDatas);
27   -
28   - $final = "";
29   -// if (is_dir(IHMConfigClass::getDownloadTmpPath())) {
30   -// foreach (glob(IHMConfigClass::getDownloadTmpPath().'*.zip') as $filename) unlink($filename);
31   -// foreach (glob(IHMConfigClass::getDownloadTmpPath().'*.tar.gz') as $filename) unlink($filename);
32   -// }
33   -
34   - foreach($input->list as $ttId)
35   - {
36   - //create a list of data to treat
37   - $processData = new TTRequestDataClass();
38   - if (strpos($id,"sharedtimeTable_") === 0) {
39   - //Shared TimeTable
40   - $result = IHMSharedObjectsClass::getPath("timeTable", $ttId);
41   - if (!$result['success'])
42   - throw new Exception('Shared TimeTable '.$ttId.' not found');
43   - $ttName = $result['path'];
44   - }
45   - else {
46   - //User TimeTable
47   - $ttName = IHMConfigClass::getUserTTPath().$ttId.'.xml';
48   - }
49   - if (!file_exists($ttName))
50   - throw new Exception('TimeTable '.$ttId.' not found');
51   -
52   - $processData->setInputFileName($ttName);
53   - $processData->setInputFileFormat(TTRequestFileFormatEnum::INTERNAL);
54   - $processData->setOutputDir(WSConfigClass::getWSResultDir());
55   -
56   - $processData->setOutputFileFormat(TTRequestFileFormatEnum::VOTABLE);
57   - $outputName = $ttId.'.xml';
  25 + if (isset($this->processData))
  26 + unset($this->processData);
58 27  
59   - $processData->setOutputFileName($outputName);
60   -
61   - $processData->setType($function);
62   - $processData->setCmd("ttConversion");
63   -
64   - $this->processDatas[] = $processData;
  28 + $processData = new TTRequestDataClass();
  29 + $processData->setInputFileName($input['inputFile']);
  30 + $processData->setInputFileFormat(TTRequestFileFormatEnum::INTERNAL);
  31 + $processData->setOutputDir(WSConfigClass::getWsResultDir());
  32 + $processData->setOutputFileName($input['outputFileName']);
  33 + $outputFormat = empty($input['outputFormat']) ? 'VOTABLE' : $input['outputFormat'];
  34 + switch ($outputFormat) {
  35 + case 'ASCII':
  36 + $processData->setOutputFileFormat(TTRequestFileFormatEnum::ASCII);
  37 + break;
  38 + case 'VOTABLE':
  39 + $processData->setOutputFileFormat(TTRequestFileFormatEnum::VOTABLE);
  40 + break;
  41 + case 'INTERNAL':
  42 + $processData->setOutputFileFormat(TTRequestFileFormatEnum::INTERNAL);
  43 + break;
  44 + case 'HPEVENT':
  45 + $processData->setOutputFileFormat(TTRequestFileFormatEnum::SPASE);
  46 + break;
  47 + default:
  48 + throw new Exception('Unknown output format');
65 49 }
66   -
67   - $this->postProcessTT = new PostProcessTTClass();
68   - $this->postProcessTT->setOutputDirAlias($this->processDatas[0]->getOutputDir());
69   -
70   - $this->postProcessTT->setOutputFileName($outputFileName);
71   - $this->postProcessTT->setOutputDir($this->processDatas[0]->getOutputDir());
  50 + $processData->setType($function);
  51 + $processData->setCmd("ttConversion");
  52 +
  53 + $this->processData = $processData;
72 54  
73   - return $this->processDatas;
  55 + return $this->processData;
74 56 }
75 57  
76 58 /*
... ... @@ -78,10 +60,10 @@ class WSInputOutputTTClass extends IHMInputOutputTTClass
78 60 */
79 61 public function getOutput($data)
80 62 {
81   -
82   - $result = array('success'=>$data[0]->getSuccess(),
83   - 'download' => $this->postProcessTT->getOutputDirAlias().$data[0]->getOutputFileName());
84   -
  63 + $result = array('success' => $data->getSuccess());
  64 + if ($result['success']) {
  65 + $result['file'] = $data->getOutputDir()."/".$data->getOutputFileName();
  66 + }
85 67 return $result;
86 68 }
87 69 }
... ...
src/InputOutput/WSImpl/WSInputOutputClass.php
... ... @@ -56,7 +56,6 @@ class WSInputOutputClass extends IHMInputOutputClass
56 56 case FunctionTypeEnumClass::PROCESSGETREQUEST :
57 57 $this->inputOutput = new IHMInputOutputGetProcessRequestClass();
58 58 break;
59   - //TODO actually this is done by WebServer xslt transformation
60 59 case FunctionTypeEnumClass::TTCONVERT :
61 60 $this->inputOutput = new WSInputOutputTTClass();
62 61 break;
... ... @@ -69,4 +68,4 @@ class WSInputOutputClass extends IHMInputOutputClass
69 68  
70 69 }
71 70  
72   -?>
73 71 \ No newline at end of file
  72 +?>
... ...