Commit 2b26bbddc7b3708a9f17a840caaa01a9fe1552f2

Authored by Elena.Budnik
1 parent 5e2ea05e

getPlot partial commit

php/classes/WebServer.php
... ... @@ -93,32 +93,6 @@ class WebServer
93 93 if (!$vot->save(WSConfigClass::getWsResultDir().$outputName))
94 94 $this->throwError("systemError", "Cannot save time table to result dir");
95 95 }
96   -
97   - private function setID()
98   - {
99   - $nb_min = 10000;
100   - $nb_max = 99999;
101   -
102   - return "PP".mt_rand($nb_min,$nb_max);
103   - }
104   -
105   - private function rrmdir($dir)
106   - {
107   - if (is_dir($dir)) {
108   - $objects = scandir($dir);
109   -
110   - foreach ($objects as $object) { // Recursively delete a directory that is not empty and directorys in directory
111   - if ($object != "." && $object != "..") { // If object isn't a directory recall recursively this function
112   - if (filetype($dir."/".$object) == "dir")
113   - $this->rrmdir($dir."/".$object);
114   - else
115   - unlink($dir."/".$object);
116   - }
117   - }
118   - reset($objects);
119   - rmdir($dir);
120   - }
121   - }
122 96  
123 97 private function getDatasetInfo($id)
124 98 {
... ... @@ -174,114 +148,7 @@ class WebServer
174 148  
175 149 return WSConfigClass::getUrl().$ttListResult;
176 150 }
177   -
178   -
179   - public function getPlot($data)
180   - {
181   - $res = $this->init($data);
182   - $resMgr = $this->initUserMgr();
183   -
184   - $vars = $res['vars'];
185   - $mission = $vars["missionID"];
186   -
187   - $ID = $this->setID(); // unique JobID
188   - $resDirName = WSRESULT.$ID; // Define a temporary directory for results
189   -
190   - if (is_dir($resDirName))
191   - $this->rrmdir($resDirName);
192   -
193   - mkdir($resDirName);
194   - chmod($resDirName,0775);
195   -
196   - $dom = new DomDocument("1.0");
197   - $dom->load(plotsXml);
198   -
199   - $missionTag = $dom->getElementById($mission);
200   - $params = $missionTag->getElementsByTagName('param');
201   -
202   - $paramsList = array();
203   - foreach ($params as $param)
204   - $paramsList[] = $param->getAttribute('name');
205   -
206   - $requestObject = (Object) array(
207   - "nodeType" => "request",
208   - "file-format" => "PNG",
209   - "file-output" => "WS",
210   - "ws-result-file" => $resDirName."/request.list.png",
211   - "last-plotted-tab" => 1,
212   - "timesrc" => "Interval",
213   - "startDate" => $vars["startTime"],
214   - "stopDate" => $vars["stopTime"],
215   - "tabs" => array()
216   - );
217   -
218   - $pageObject = (Object) array(
219   - "id" => 1,
220   - "multi-plot-linked" => true,
221   - "page-margins-activated" => true,
222   - "page-margin-x" => 5,
223   - "page-margin-y" => 5,
224   - "page-orientation" => "portrait",
225   - "page-dimension" => "ISO A4",
226   - "page-layout-type" => "vertical",
227   - "page-layout-object" => (Object) array(
228   - "layout-panel-height" => 0.25,
229   - "layout-panel-spacing" => 0,
230   - "layout-expand" => false
231   - ),
232   - "panels" => array()
233   - );
234   -
235   - foreach ($paramsList as $paramToPlot)
236   - {
237   - $panelObject = (Object) array(
238   - "panel-plot-type" => "timePlot",
239   - "axes" => array(),
240   - "params" => array()
241   - );
242   -
243   - $timeAxisObject = (Object) array(
244   - "id" => "time",
245   - "axis-type" => "time",
246   - "axis-range-extend" => true
247   - );
248   - $panelObject->{"axes"}[] = $timeAxisObject;
249   -
250   - $yAxisObject = (Object) array(
251   - "id" => "y-left",
252   - "axis-type" => "y-left",
253   - "axis-range-extend" => true
254   - );
255   - $panelObject->{"axes"}[] = $yAxisObject;
256   -
257   - $paramObject = (Object) array(
258   - "id" => 1,
259   - "param-id" => $paramToPlot,
260   - "param-drawing-type" => "serie",
261   - "param-drawing-object" => (Object) array(
262   - "serie-yaxis" => "y-left",
263   - "serie-lines-activated" => true
264   - )
265   - );
266   - $panelObject->{"params"}[] = $paramObject;
267   -
268   - $pageObject->{"panels"}[] = $panelObject;
269   - }
270   -
271   - $requestObject->{"tabs"}[] = $pageObject;
272   -
273   - if (!isset($this->requestManager))
274   - $this->requestManager = new RequestManagerClass();
275   -
276   - try {
277   - $plotResult = $this->requestManager->runIHMRequest($this->userID, $this->IPclient, FunctionTypeEnumClass::PARAMS, $requestObject);
278   - } catch (Exception $e) {
279   - $this->throwError("plotError", "Exeption detected : ".$e->getMessage());
280   - }
281   -
282   - return array('success' => true, 'plotDirectoryURL' => $ID);
283   - }
284   -
  151 +
285 152 public function getResultPlot($data)
286 153 {
287 154 $res = $this->init($data);
... ... @@ -295,17 +162,6 @@ class WebServer
295 162 else
296 163 return array('success' => false);
297 164 }
298   -
299   -/*
300   -* generate AUTH token for access to REST services
301   -*/
302   - public function getNewToken()
303   - {
304   - // generate token from timeStamp and some salt
305   - $newToken = md5(1321 * (int)( time() / WSConfigClass::$timeLimitQuery));
306   -
307   - return array('success' => true, 'token' => $newToken);
308   - }
309 165  
310 166 /*
311 167 * Get corresponding orbit parameter ID
... ... @@ -420,7 +276,7 @@ class WebServer
420 276 }
421 277  
422 278 /*
423   -* delete process after execution :
  279 +* delete process after execution :
424 280 * delete temporary files/folders ( JOBS/process_xxxx, RES/DDxxx );
425 281 * delete job node in processManager.xml
426 282 */
... ... @@ -438,6 +294,17 @@ class WebServer
438 294 }
439 295 }
440 296  
  297 +/*
  298 +* generate AUTH token for access to REST services
  299 +*/
  300 + public function getNewToken()
  301 + {
  302 + // generate token from timeStamp and some salt
  303 + $newToken = md5(1321 * (int)( time() / WSConfigClass::$timeLimitQuery));
  304 +
  305 + return array('success' => true, 'token' => $newToken);
  306 + }
  307 +
441 308 /************************** WEB SERVICES **************************************/
442 309  
443 310 /*
... ... @@ -792,5 +659,95 @@ class WebServer
792 659  
793 660 $this->throwError("serverError",$res['message']);
794 661 }
  662 +
  663 +/*
  664 +* getPlot : predefined; by mission
  665 +*/
  666 + public function getPlot($data)
  667 + {
  668 + $res = $this->init($data);
  669 +
  670 + if (!$res['success']){
  671 + $this->throwError("requestError", "Cannot parse request");
  672 + }
  673 +
  674 + $this->initUserMgr();
  675 +
  676 + $vars = $res['vars'];
  677 + $mission = $vars["missionID"];
  678 +
  679 + $resDirName = WSConfigClass::getWsResultDir(); // Define a temporary directory for results
  680 +
  681 + $dom = new DomDocument("1.0");
  682 + $dom->load(plotsXml);
  683 +
  684 + $missionTag = $dom->getElementById($mission);
  685 + $params = $missionTag->getElementsByTagName('param');
  686 +
  687 + $paramsList = array();
  688 + foreach ($params as $param)
  689 + $paramsList[] = $param->getAttribute('name');
  690 +
  691 + $requestObject = (Object) array(
  692 + "nodeType" => "request",
  693 + "file-format" => "PNG",
  694 + "file-output" => "WS",
  695 + "ws-result-file" => $resDirName."/request.list.png",
  696 + "last-plotted-tab" => 1,
  697 + "timesrc" => "Interval",
  698 + "startDate" => $vars["startTime"],
  699 + "stopDate" => $vars["stopTime"],
  700 + "tabs" => array()
  701 + );
  702 +
  703 + $pageObject = (Object) array(
  704 + "panels" => array()
  705 + );
  706 +
  707 + foreach ($paramsList as $paramToPlot)
  708 + {
  709 + $panelObject = (Object) array(
  710 + "panel-plot-type" => "timePlot",
  711 + "axes" => array(),
  712 + "params" => array()
  713 + );
  714 +
  715 + $timeAxisObject = (Object) array(
  716 + );
  717 + $panelObject->{"axes"}[] = $timeAxisObject;
  718 +
  719 + $yAxisObject = (Object) array(
  720 + );
  721 + $panelObject->{"axes"}[] = $yAxisObject;
  722 +
  723 + $paramObject = (Object) array(
  724 + "id" => 1,
  725 + "paramid" => $paramToPlot,
  726 + "param-drawing-type" => "serie",
  727 + "param-drawing-object" => (Object) array(
  728 + "serie-yaxis" => "y-left",
  729 + "serie-lines-activated" => true
  730 + )
  731 + );
  732 + $panelObject->{"params"}[] = $paramObject;
  733 +
  734 + $pageObject->{"panels"}[] = $panelObject;
  735 + }
  736 +
  737 + $requestObject->{"tabs"}[] = $pageObject;
  738 +
  739 + $this->service = strtolower(__FUNCTION__);
  740 +
  741 + if (!isset($this->requestManager))
  742 + $this->requestManager = new RequestManagerClass();
  743 +
  744 + try {
  745 + $plotResult = $this->requestManager->runWSRequest($this->userID, $this->IPclient, FunctionTypeEnumClass::PARAMS, $this->service, $requestObject);
  746 + } catch (Exception $e) {
  747 + $this->throwError("plotError", "Exeption detected : ".$e->getMessage());
  748 + }
  749 +
  750 + return array('success' => true, 'plotDirectoryURL' => $ID);
  751 + }
795 752 }
796 753 ?>
... ...
public/WebServices/XML/AmdaPlots.xml
1 1 <?xml version="1.0" encoding="UTF-8"?>
2   -<des>
3   - <missions>
4   - <mission xml:id='ACE' name='ACE'>
5   - <param name='sw_vb' class="plasma" description="velocity_magnitude" instrument="SWEPAM"/>
6   - <param name='sw_t' class="plasma" description="temperature_radial" instrument="SWEPAM"/>
7   - <param name='sw_n' class="plasma" description="ion_density" instrument="SWEPAM"/>
8   - <param name='imf' class="mag" description="magnetic_field_vector" instrument="MAG"/>
9   - <param name='imf_mag' class="mag" description="magnetic_field_magnitude" instrument="MAG"/>
10   - </mission>
11   - <mission xml:id='WIND' name='WIND'>
12   - <param name='wnd_swe_vmag' class="plasma" description="velocity_magnitude" instrument="SWE"/>
13   - <param name='wnd_swe_vth' class="plasma" description="v_thermal" instrument="SWE"/>
14   - <param name='wnd_swe_n' class="plasma" description="ion_density" instrument="SWE"/>
15   - <param name='wnd_b' class="mag" description="magnetic_field_vector" instrument="MFI"/>
16   - <param name='wnd_bmag' class="mag" description="magnetic_field_magnitude" instrument="MFI"/>
17   - </mission>
18   - <mission xml:id='STEREO-A' name='STA'>
19   - <param name='vpbulk_sta' class="plasma" description="velocity_magnitude" instrument="PLASTIC"/>
20   - <param name='vth_sta' class="plasma" description="v_thermal" instrument="PLASTIC"/>
21   - <param name='np_sta' class="plasma" description="ion_density" instrument="PLASTIC"/>
22   - <param name='sta_b' class="mag" description="magnetic_field_vector" instrument="MAG" />
23   - <param name='sta_btot' class="mag" description="magnetic_field_magnitude" instrument="MAG" />
24   - </mission>
25   - <mission xml:id='STEREO-B' name='STB'>
26   - <param name='vpbulk_stb' class="plasma" description="velocity_magnitude" instrument="PLASTIC"/>
27   - <param name='vth_stb' class="plasma" description="v_thermal" instrument="PLASTIC"/>
28   - <param name='np_stb' class="plasma" description="ion_density" instrument="PLASTIC"/>
29   - <param name='stb_b' class="mag" description="magnetic_field_vector" instrument="MAG"/>
30   - <param name='stb_btot' class="mag" description="magnetic_field_magnitude" instrument="MAG"/>
31   - </mission>
32   - <mission xml:id='VEX' name='VEX'>
33   - <param name='vex_mag_4s' class="mag" description="magnetic_field_magnitude" instrument="MAG"/>
34   - <param name='vex_mag_4s_tot' class="mag" description="magnetic_field_magnitude" instrument="MAG"/>
35   - </mission>
36   - <mission xml:id='OMNI' name='OMNI'>
37   - <param name='omni_sw_v' class="plasma" description="velocity" instrument="imf/sw/indices"/>
38   - <param name='omni_sw_t' class="plasma" description="temperature" instrument="imf/sw/indices"/>
39   - <param name='omni_sw_n' class="plasma" description="density" instrument="imf/sw/indices"/>
40   - <param name='omni_imf' class="mag" description="magnetic_field_magnitude" instrument="imf/sw/indices"/>
41   - <param name='omni_imf_mag' class="mag" description="magnetic_field_magnitude" instrument="imf/sw/indices"/>
42   - </mission>
43   - <mission xml:id='GEOMAG' name='GEOMAG'>
44   - <param name='omni_kp' class="mag" description="geomagnetic_indices" instrument="imf/sw/indices"/>
45   - <param name='omni_dst' class="mag" description="geomagnetic_indices" instrument="imf/sw/indices"/>
46   - <param name='omni_ae' class="mag" description="geomagnetic_indices" instrument="imf/sw/indices"/>
47   - </mission>
48   - </missions>
49   -</des>
  2 +<missions>
  3 + <mission xml:id='ACE'>
  4 + <param name='sw_vb'/>
  5 + <param name='sw_t'/>
  6 + <param name='sw_n'/>
  7 + <param name='imf'/>
  8 + <param name='imf_mag'/>
  9 + </mission>
  10 + <mission xml:id='WIND'>
  11 + <param name='wnd_swe_vmag'/>
  12 + <param name='wnd_swe_vth'/>
  13 + <param name='wnd_swe_n'/>
  14 + <param name='wnd_b' class="mag"/>
  15 + <param name='wnd_bmag'/>
  16 + </mission>
  17 + <mission xml:id='STEREO-A'>
  18 + <param name='vpbulk_sta'/>
  19 + <param name='vth_sta'/>
  20 + <param name='np_sta'/>
  21 + <param name='sta_b'/>
  22 + <param name='sta_btot'/>
  23 + </mission>
  24 + <mission xml:id='STEREO-B'>
  25 + <param name='vpbulk_stb'/>
  26 + <param name='vth_stb'/>
  27 + <param name='np_stb'/>
  28 + <param name='stb_b'/>
  29 + <param name='stb_btot'/>
  30 + </mission>
  31 + <mission xml:id='VEX'>
  32 + <param name='vex_mag_4s'/>
  33 + <param name='vex_mag_4s_tot'/>
  34 + </mission>
  35 + <mission xml:id='OMNI'>
  36 + <param name='omni_sw_v'/>
  37 + <param name='omni_sw_t'/>
  38 + <param name='omni_sw_n'/>
  39 + <param name='omni_imf' />
  40 + <param name='omni_imf_mag'/>
  41 + </mission>
  42 + <mission xml:id='GEOMAG'>
  43 + <param name='omni_kp'/>
  44 + <param name='omni_dst'/>
  45 + <param name='omni_ae'/>
  46 + </mission>
  47 +</missions>
  48 +
... ...
public/wsdl/Methods_AMDA.wsdl
... ... @@ -138,7 +138,7 @@
138 138  
139 139 <xs:simpleType name="enumSpacecraft">
140 140 <xs:restriction base="xs:string">
141   - <xs:enumeration value="Cassini_Public"/>
  141 + <xs:enumeration value="Cassini"/>
142 142 <xs:enumeration value="Galileo"/>
143 143 <xs:enumeration value="Voyager_1"/>
144 144 <xs:enumeration value="Voyager_2"/>
... ... @@ -173,7 +173,19 @@
173 173 <xs:enumeration value="ISEE-2"/>
174 174 </xs:restriction>
175 175 </xs:simpleType>
176   -
  176 +
  177 + <xs:simpleType name="enumMission">
  178 + <xs:restriction base="xs:string">
  179 + <xs:enumeration value="ACE"/>
  180 + <xs:enumeration value="STEREO-A"/>
  181 + <xs:enumeration value="STEREO-B"/>
  182 + <xs:enumeration value="WIND"/>
  183 + <xs:enumeration value="VEX"/>
  184 + <xs:enumeration value="OMNI"/>
  185 + <xs:enumeration value="GEOMAG"/>
  186 + </xs:restriction>
  187 + </xs:simpleType>
  188 +
177 189 <xs:simpleType name="WorkSpaceValue">
178 190 <xs:restriction base="xs:string">
179 191 <xs:enumeration value="TimeTables"/>
... ... @@ -910,7 +922,7 @@ of a set of typically orthogonal axes.
910 922 <xs:documentation>Stop time in ISO 8601 format</xs:documentation>
911 923 </xs:annotation>
912 924 </xs:element>
913   - <xs:element name="missionID" type="xs:string" minOccurs="1" maxOccurs="1">
  925 + <xs:element name="missionID" type="tns:enumMission" minOccurs="1" maxOccurs="1">
914 926 <xs:annotation>
915 927 <xs:documentation>Id of mission defined in
916 928 Amda LocalParams.xml</xs:documentation>
... ... @@ -983,7 +995,7 @@ of a set of typically orthogonal axes.
983 995 </xs:element>
984 996 <xs:element name="spacecraft" type="tns:enumSpacecraft" maxOccurs="1" minOccurs="1">
985 997 <xs:annotation>
986   - <xs:documentation>List of spavecrafts from AMDA</xs:documentation>
  998 + <xs:documentation>List of spacecraft from AMDA</xs:documentation>
987 999 </xs:annotation>
988 1000 </xs:element>
989 1001 <xs:element name="coordinateSystem" type="tns:enumCoordinateSystemName" minOccurs="1" maxOccurs="1">
... ... @@ -1079,6 +1091,22 @@ of a set of typically orthogonal axes.
1079 1091 required parameters</xs:documentation>
1080 1092 </xs:annotation>
1081 1093 </xs:element>
  1094 + <xs:element maxOccurs="1" minOccurs="0" name="status">
  1095 + <xs:annotation>
  1096 + <xs:documentation></xs:documentation>
  1097 + </xs:annotation>
  1098 + <xs:simpleType>
  1099 + <xs:restriction base="xs:string">
  1100 + <xs:enumeration value="in progress"/>
  1101 + <xs:enumeration value="error"/>
  1102 + </xs:restriction>
  1103 + </xs:simpleType>
  1104 + </xs:element>
  1105 + <xs:element maxOccurs="1" minOccurs="0" name="id" type="xs:string">
  1106 + <xs:annotation>
  1107 + <xs:documentation>process ID</xs:documentation>
  1108 + </xs:annotation>
  1109 + </xs:element>
1082 1110 </xs:sequence>
1083 1111 </xs:complexType>
1084 1112  
... ...