Commit 1c3d1a0c43d9fb4ca6ab2de88790cd393c933a02

Authored by Nathanaël Jourdane
2 parents c6b591d9 91c2a59a

Merge branch 'master' of https://gitlab.irap.omp.eu/CDPP/AMDA_Integration

src/ClientTypeEnumClass.php 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +<?php
  2 +/**
  3 + * @class ClientTypeEnumClass
  4 + * @brief Abstract class used as an enumerate for AMDA_Integration client.
  5 + * @details
  6 + */
  7 +abstract class ClientTypeEnumClass
  8 +{
  9 + const IHM = "ihm";
  10 + const TEST = "test";
  11 + const WEBSERVICE = "webservice";
  12 +}
  13 +?>
... ...
src/FunctionTypeEnumClass.php 0 → 100644
... ... @@ -0,0 +1,23 @@
  1 +<?php
  2 +/**
  3 + * @class FunctionTypeEnumClass
  4 + * @brief Abstract class used as an enumerate for function type.
  5 + * @details
  6 +*/
  7 +abstract class FunctionTypeEnumClass
  8 +{
  9 + const PARAMS = "params";
  10 + const PARAMSGEN = "params_gen";
  11 + const ACTION = "action";
  12 + const PROCESSDELETE = "process_delete";
  13 + const PROCESSRUNNINGINFO = "process_running_info";
  14 + const PROCESSGETINFO = "process_get_info";
  15 + const PROCESSCLEAN = "process_clean";
  16 + const PROCESSGETREQUEST = "process_get_request";
  17 + const TTMERGE = "tt_merge";
  18 + const TTUNION = "tt_union";
  19 + const TTCONVERT = "tt_convert";
  20 + const PARAMINFO = "param_info";
  21 +}
  22 +?>
  23 +
... ...
src/InputOutput/IHMImpl/Params/DownloadImpl/IHMInputOutputParamsDownloadClass.php
... ... @@ -26,7 +26,7 @@ class IHMInputOutputParamsDownloadClass extends IHMInputOutputParamsAbstractClas
26 26 //Send to SAMP
27 27 $this->sendToSamp = isset($input->sendToSamp) ? $input->sendToSamp : FALSE;
28 28 if ($this->sendToSamp) {
29   - $input->disablebatch = FALSE;
  29 + $input->disablebatch = TRUE;
30 30 $input->timeformat = 'YYYY-MM-DDThh:mm:ss';
31 31 $input->fileformat = 'vot';
32 32 $input->compression = '';
... ...
src/Request/Config/KernelConfigClass.php
... ... @@ -48,6 +48,8 @@ class KernelConfigClass
48 48  
49 49 private static $userHost = "";
50 50 private static $userName = "";
  51 +
  52 + private static $timeToBatchMode = 10; // secs : interval after which batch mode is launched
51 53  
52 54 private static $kernelAbout = "Created by CDPP/AMDA(c)";
53 55 private static $kernelAcknow = "CDPP/AMDA Team";
... ... @@ -156,10 +158,15 @@ class KernelConfigClass
156 158 "LD_LIBRARY_PATH" => self::$gccDir."lib64:".self::$gccDir."lib:".getenv("LD_LIBRARY_PATH")
157 159 );
158 160 }
159   -
  161 +
  162 + public static function setTimeToBatchMode($timeToBatchMode)
  163 + {
  164 + self::$timeToBatchMode = $timeToBatchMode;
  165 + }
  166 +
160 167 public static function getTimeToBatchMode()
161 168 {
162   - return 10;
  169 + return self::$timeToBatchMode;
163 170 }
164 171  
165 172 public static function write($working_dir, $compilation_path, $localbase_path)
... ...
src/Request/ParamInfoRequestClass.php
... ... @@ -50,11 +50,11 @@ class ParamInfoRequestClass extends RequestAbstractClass
50 50 $dom->formatOutput = true;
51 51  
52 52 $res = $dom->load($this->requestData->getFilePath());
53   -
  53 +
54 54 $this->requestData->setSuccess(false);
55 55  
56 56 if (!$res) {
57   - $this->requestData->setLastErrorMessage("Cannot load file");
  57 + $this->requestData->setLastErrorMessage("Cannot load file".$this->requestData->getFilePath());
58 58 return false;
59 59 }
60 60  
... ...
src/RequestManagerClass.php 0 → 100644
... ... @@ -0,0 +1,139 @@
  1 +<?php
  2 +/**
  3 + * @class RequestManagerClass
  4 + * @brief Main class to manage a request that's come from an AMDA client
  5 + * @details
  6 + */
  7 +Class RequestManagerClass
  8 +{
  9 + public static $version = "1.6.0";
  10 +
  11 +/*
  12 + * @brief Constructor
  13 +*/
  14 + function __construct()
  15 + {
  16 +
  17 + }
  18 +
  19 +/*
  20 + * @brief Treat a request that's come from the IHM
  21 +*/
  22 + public function runIHMRequest($user, $userHost, $function, $input)
  23 + {
  24 + return $this->runGenericRequest(ClientTypeEnumClass::IHM,$user,$userHost,$function,$input);
  25 + }
  26 +
  27 +/*
  28 + * @brief Treat a request that's come from a test script
  29 +*/
  30 + public function runTestRequest($user, $function, $input)
  31 + {
  32 + $userHost = "";
  33 + return $this->runGenericRequest(ClientTypeEnumClass::TEST,$user,$userHost,$function,$input);
  34 + }
  35 +
  36 +/*
  37 + * @brief Create the request instance in relation with the function type
  38 +*/
  39 + private function createRequest($user, $userHost, $function)
  40 + {
  41 + switch ($function)
  42 + {
  43 + case FunctionTypeEnumClass::PARAMS :
  44 + case FunctionTypeEnumClass::PARAMSGEN :
  45 + case FunctionTypeEnumClass::ACTION :
  46 + return new ParamsRequestClass($user, $userHost);
  47 + case FunctionTypeEnumClass::PROCESSDELETE :
  48 + case FunctionTypeEnumClass::PROCESSRUNNINGINFO :
  49 + case FunctionTypeEnumClass::PROCESSGETINFO :
  50 + case FunctionTypeEnumClass::PROCESSCLEAN :
  51 + case FunctionTypeEnumClass::PROCESSGETREQUEST :
  52 + return new ProcessRequestClass($user, $userHost);
  53 + case FunctionTypeEnumClass::TTMERGE :
  54 + case FunctionTypeEnumClass::TTUNION :
  55 + case FunctionTypeEnumClass::TTCONVERT :
  56 + return new TTRequestClass($user, $userHost);
  57 + case FunctionTypeEnumClass::PARAMINFO :
  58 + return new ParamInfoRequestClass($user, $userHost);
  59 + default :
  60 + throw new Exception('Request '.$function.' not implemented.');
  61 + }
  62 + }
  63 +
  64 +/*
  65 + * @brief Create an instance of the InputOutput interface in relation with the client
  66 +*/
  67 + private function createInputOutput($user,$userHost = null,$client)
  68 + {
  69 + switch ($client)
  70 + {
  71 + case ClientTypeEnumClass::IHM :
  72 + return new IHMInputOutputClass($user, $userHost);
  73 + case ClientTypeEnumClass::TEST :
  74 + return new TestInputOutputClass($user);
  75 + default :
  76 + throw new Exception('Client '.$client.' not implemented.');
  77 + }
  78 + }
  79 +
  80 +/*
  81 + * @brief Sequence used to run a request
  82 +*/
  83 + private function runGenericRequest($client,$user,$userHost,$function,$input)
  84 + {
  85 + //create an instance of the InputOutput interface
  86 + $inputOutput = $this->createInputOutput($user, $userHost, $client);
  87 +
  88 + //get the input data from the request input data by using the InputOutput interface
  89 + $inputdata = $inputOutput->getInputData($input,$function);
  90 +
  91 + //create an instance of the RequestClass to run the request
  92 + $request = $this->createRequest($user, $userHost, $function);
  93 +
  94 + if (is_array($inputdata))
  95 + {
  96 + $outputdata = array();
  97 + foreach ($inputdata as $data)
  98 + //execute the request
  99 + $outputdata[] = $this->runSingleRequest($request,$data);
  100 + }
  101 + else
  102 + $outputdata = $this->runSingleRequest($request,$inputdata);
  103 +
  104 + //get the request output data from the output data by using the InputOutput interface
  105 + return $inputOutput->getOutput($outputdata);
  106 + }
  107 +
  108 +/*
  109 + * @brief Run a single request
  110 +*/
  111 + private function runSingleRequest($request,$data)
  112 + {
  113 + //link the request to the input data
  114 + $request->setData($data);
  115 +
  116 + //init the request
  117 + if (!$request->init())
  118 + {
  119 + $crtData = $request->getData();
  120 + if (isset($crtData))
  121 + throw new Exception('Request initialization error : '.$crtData->getLastErrorMessage());
  122 + else
  123 + throw new Exception('Cannot init request. Unknown error.');
  124 + }
  125 +
  126 + //run the request
  127 + if (!$request->run())
  128 + {
  129 + $crtData = $request->getData();
  130 + if ($crtData)
  131 + throw new Exception('Request execution error : '.$crtData->getLastErrorMessage());
  132 + else
  133 + throw new Exception('Cannot run request. Unknown error.');
  134 + }
  135 +
  136 + return $request->getData();
  137 + }
  138 +}
  139 +?>
0 140 \ No newline at end of file
... ...
src/amdaintegration_autoload.php 0 → 100644
... ... @@ -0,0 +1,73 @@
  1 +<?php
  2 +//autoload configuration
  3 +function amdaintegration_autoload($class_name)
  4 +{
  5 + $dirs = array(
  6 + 'InputOutput',
  7 + 'InputOutput/IHMImpl',
  8 + 'InputOutput/IHMImpl/Config',
  9 + 'InputOutput/IHMImpl/Params',
  10 + 'InputOutput/IHMImpl/Params/DataMiningImpl',
  11 + 'InputOutput/IHMImpl/Params/StatisticsImpl',
  12 + 'InputOutput/IHMImpl/Params/DownloadImpl',
  13 + 'InputOutput/IHMImpl/Params/PlotImpl',
  14 + 'InputOutput/IHMImpl/Params/GeneratorImpl',
  15 + 'InputOutput/IHMImpl/Process',
  16 + 'InputOutput/IHMImpl/ParamInfo',
  17 + 'InputOutput/IHMImpl/Tools',
  18 + 'InputOutput/IHMImpl/TimeTables',
  19 + 'InputOutput/TestImpl',
  20 + 'Request',
  21 + 'Request/Config',
  22 + 'Request/ParamsRequestImpl',
  23 + 'Request/ParamsRequestImpl/Nodes',
  24 + 'Request/ParamsRequestImpl/Nodes/Infos',
  25 + 'Request/ParamsRequestImpl/Nodes/Params',
  26 + 'Request/ParamsRequestImpl/Nodes/Requests',
  27 + 'Request/ProcessRequestImpl',
  28 + 'Request/ProcessRequestImpl/Process',
  29 + 'Request/TTRequestImpl'
  30 + );
  31 +
  32 + $ihm_dirs = array(
  33 + IHM_SRC_DIR.'php/classes',
  34 + IHM_SRC_DIR.'php/RemoteDataCenter'
  35 + );
  36 +
  37 + $find = false;
  38 +
  39 + $file = __DIR__.'/'.$class_name.'.php';
  40 +
  41 + if (file_exists($file))
  42 + {
  43 + require $file;
  44 + return;
  45 + }
  46 +
  47 + if (!$find)
  48 + foreach($dirs as $dir)
  49 + {
  50 + $file = __DIR__.'/'.$dir.'/'.$class_name.'.php';
  51 + if (file_exists($file))
  52 + {
  53 + require $file;
  54 + $find = true;
  55 + break;
  56 + }
  57 + }
  58 +
  59 + if (!$find)
  60 + foreach($ihm_dirs as $dir)
  61 + {
  62 + $file = $dir.'/'.$class_name.'.php';
  63 + if (file_exists($file))
  64 + {
  65 + require $file;
  66 + break;
  67 + }
  68 + }
  69 +}
  70 +
  71 +spl_autoload_register('amdaintegration_autoload');
  72 +
  73 +?>
... ...