Commit 01c17a023467cf3c4b8c5acd202d9df760f092a2
1 parent
1c3d1a0c
Exists in
master
and in
64 other branches
Add detailled info when creating jobs
Showing
1 changed file
with
94 additions
and
44 deletions
Show diff stats
src/InputOutput/IHMImpl/Tools/IHMJobsManagerClass.php
... | ... | @@ -258,95 +258,145 @@ class IHMJobsManagerClass { |
258 | 258 | /* |
259 | 259 | * @brief Add a new job |
260 | 260 | */ |
261 | - public function addJob($obj, $id, $folder, | |
262 | - $running, $start, $result, $exitcode) | |
261 | + public function addJob($obj, $id, $folder, $running, $start, $result, $exitcode) | |
263 | 262 | { |
263 | + $obj = get_object_vars($obj); // Allow access to elements where the key is in dash-separated form. | |
264 | 264 | $res = $this->init(); |
265 | 265 | if (!$res['success']) |
266 | 266 | return $res; |
267 | 267 | |
268 | - $newJob = $this->jobXml->createElement('job'); | |
269 | - | |
270 | - $newJob->setAttribute('xml:id', $id); | |
271 | - $newJob->setAttribute('jobType', $obj->nodeType); | |
268 | +// $f = fopen('/AMDA/AMDA_Integration/debug/serialise.json', 'w') or die("Unable to open file!"); | |
269 | +// fwrite($f, json_encode($obj, JSON_PRETTY_PRINT)); | |
270 | +// fclose($f); | |
272 | 271 | |
273 | - switch ($obj->nodeType) | |
274 | - { | |
275 | - case 'condition' : | |
272 | + $infos = []; | |
273 | + switch ($obj['nodeType']) { | |
274 | + // Data mining | |
275 | + case 'condition': | |
276 | 276 | $name = 'datamining_'.time(); |
277 | - $info = $obj->expression; | |
277 | + $infos['Name'] = $obj['name']; | |
278 | + $infos['Condition'] = $obj['expression']; | |
279 | + $infos['Start date'] = $obj['startDate']; | |
280 | + $infos['Stop date'] = $obj['stopDate']; | |
281 | + $infos['Duration'] = $obj['durationDay'] . 'd ' . $obj['durationHour'] . 'h ' . $obj['durationMin'] . 'm ' . $obj['durationSec'] . 's'; | |
278 | 282 | break; |
279 | - case 'statistics' : | |
283 | + | |
284 | + case 'statistics': | |
280 | 285 | $name = 'statistics_'.time(); |
281 | - $info = isset($obj->expression) ? $obj->expression : ""; | |
286 | + $infos['Name'] = $obj['name']; | |
287 | + $infos['Start date'] = $obj['startDate']; | |
288 | + $infos['Stop date'] = $obj['stopDate']; | |
289 | + $infos['Duration'] = $obj['durationDay'] . 'd ' . $obj['durationHour'] . 'h ' . $obj['durationMin'] . 'm ' . $obj['durationSec'] . 's'; | |
290 | + if(array_key_exists('expression', $obj)) { | |
291 | + $infos['Expression'] = $obj['expression']; | |
292 | + } | |
293 | + $params = []; | |
294 | + foreach ($obj['parameter'] as $param) { | |
295 | + $params[] = $param->function . '(' . $param->paramid . ')'; | |
296 | + } | |
297 | + if(count($params) == 1) { | |
298 | + $infos['Parameter'] = $params[0]; | |
299 | + } else { | |
300 | + $infos['Parameters'] = '<ul><li>' . join('</li><li>', $params) . '</li></ul>'; | |
301 | + } | |
282 | 302 | break; |
283 | - case 'download' : | |
284 | - if ($obj->downloadSrc == '2') //fits image | |
285 | - $name = "download_fits_".time(); | |
286 | - else | |
287 | - $name = "download_data_".time(); | |
288 | - $info = ''; | |
289 | - foreach ($obj->list as $param) | |
290 | - { | |
291 | - if ($obj->downloadSrc == '2') //fits image | |
292 | - $info = $info.' '.$param->url; | |
293 | - else | |
294 | - $info = $info.' '.$param->name; //data | |
303 | + | |
304 | + case 'download': | |
305 | + $name = $obj['downloadSrc'] == '2' ? "download_fits_".time() : "download_data_".time(); | |
306 | + $params = []; | |
307 | + foreach ($obj['list'] as $param) { | |
308 | + $params[] = $param->paramid; | |
309 | + } | |
310 | + if(count($params) == 1) { | |
311 | + $infos['Parameter'] = $params[0]; | |
312 | + } else { | |
313 | + $infos['Parameters'] = join(', ', $params); | |
295 | 314 | } |
315 | + $infos['Start date'] = $obj['startDate']; | |
316 | + $infos['Stop date'] = $obj['stopDate']; | |
317 | + $infos['Duration'] = $obj['durationDay'] . 'd ' . $obj['durationHour'] . 'h ' . $obj['durationMin'] . 'm ' . $obj['durationSec'] . 's'; | |
296 | 318 | break; |
297 | - case 'request' : | |
319 | + | |
320 | + // Plot | |
321 | + case 'request': | |
298 | 322 | $name = "request_".time(); |
299 | - $info = ''; | |
300 | - for ($i=0; $i < count($obj->children); $i++) { | |
301 | - for ($j=0; $j < count($obj->children[$i]->children); $j++) { | |
302 | - $info = $info.' '.$obj->children[$i]->children[$j]->name; | |
323 | + | |
324 | + $infos['Output'] = strtolower($obj['file-format']) . ' (' . strtolower($obj['file-output']) . ')'; | |
325 | + foreach ($obj['tabs'] as $tab) { | |
326 | + if($tab->id == $obj['last-plotted-tab']) { | |
327 | + $infos['Start date'] = $tab->startDate; | |
328 | + $infos['Stop date'] = $tab->stopDate; | |
329 | + $infos['Duration'] = $tab->durationDay . 'd ' . $tab->durationHour . 'h ' . $tab->durationMin . 'm ' . $tab->durationSec . 's'; | |
330 | + | |
331 | + $strPanels = []; | |
332 | + foreach ($tab->panels as $panel) { | |
333 | + $axes = []; | |
334 | + foreach ($panel->axes as $axe) { | |
335 | + $axes[] = $axe->id; | |
336 | + } | |
337 | + $params = []; | |
338 | + foreach ($panel->params as $param) { | |
339 | + $params[] = $param->paramid; | |
340 | + } | |
341 | + $strPanels[] = join(', ', $params) . ' (' . join(', ', $axes) . ')'; | |
342 | + } | |
343 | + | |
344 | + if(count($strPanels) == 1) { | |
345 | + $infos['Parameters'] = $strPanels[0]; | |
346 | + } else { | |
347 | + $infos['Panels'] = '<ul><li>' . join('</li><li>', $strPanels) . '</li></ul>'; | |
348 | + } | |
349 | + | |
350 | + continue; | |
303 | 351 | } |
304 | 352 | } |
305 | 353 | break; |
354 | + | |
306 | 355 | default: |
307 | 356 | $name = "unknown_".time(); |
308 | - $info = ''; | |
309 | 357 | } |
358 | + $infos['Started at'] = gmdate("Y-m-d\TH:i:s\Z", $start); | |
310 | 359 | |
311 | - $newJob->setAttribute('name', $name); | |
312 | - $newJob->setAttribute('info', $info); | |
360 | + $strInfo = ''; | |
361 | + foreach ($infos as $key => $info) { | |
362 | + $strInfo .= '<b>' . $key . '</b>: ' . $info . '<br/>'; | |
363 | + } | |
313 | 364 | |
365 | + $newJob = $this->jobXml->createElement('job'); | |
366 | + $newJob->setAttribute('xml:id', $id); | |
367 | + $newJob->setAttribute('jobType', $obj['nodeType']); | |
368 | + $newJob->setAttribute('name', $name); | |
369 | + $newJob->setAttribute('info', $strInfo); | |
314 | 370 | $newJob->setAttribute('folder', $folder); |
315 | - | |
316 | 371 | $newJob->setAttribute('result', $result); |
317 | - | |
318 | 372 | $newJob->setAttribute('start', date('d-m-Y H:i:s', $start)); |
319 | - | |
320 | - $newJob->setAttribute('result', $result); | |
321 | - | |
322 | 373 | //to know if know if it's an immediate job or not |
323 | 374 | $newJob->setAttribute('immediate', !$running); |
324 | 375 | |
325 | - $sendToSamp = isset($obj->sendToSamp) ? $obj->sendToSamp : FALSE; | |
376 | + $sendToSamp = isset($obj['sendToSamp']) ? $obj['sendToSamp'] : FALSE; | |
326 | 377 | if ($sendToSamp) { |
327 | 378 | $newJob->setAttribute('sendToSamp', "true"); |
328 | 379 | } |
329 | 380 | |
381 | + $key = $obj['nodeType']; | |
330 | 382 | if ($running) |
331 | 383 | { |
332 | - $rootJobNode = $this->jobXml->getElementById($this->bkgRootNode[$obj->nodeType]); | |
384 | + $rootJobNode = $this->jobXml->getElementById($this->bkgRootNode[$key]); | |
333 | 385 | if (!$rootJobNode) |
334 | 386 | { |
335 | - $key = $obj->nodeType; | |
336 | 387 | $rootJobNode = $this->jobXml->createElement("$key"); |
337 | - $rootJobNode->setAttribute('xml:id', $this->bkgRootNode[$obj->nodeType]); | |
388 | + $rootJobNode->setAttribute('xml:id', $this->bkgRootNode[$key]); | |
338 | 389 | $jobsInProgress = $this->jobXml->getElementsByTagName('jobsInProgress')->item(0); |
339 | 390 | $jobsInProgress->appendChild($rootJobNode); |
340 | 391 | } |
341 | 392 | } |
342 | 393 | else |
343 | 394 | { |
344 | - $rootJobNode = $this->jobXml->getElementById($this->resRootNode[$obj->nodeType]); | |
395 | + $rootJobNode = $this->jobXml->getElementById($this->resRootNode[$key]); | |
345 | 396 | if (!$rootJobNode) |
346 | 397 | { |
347 | - $key = $obj->nodeType; | |
348 | 398 | $rootJobNode = $this->jobXml->createElement("$key"); |
349 | - $rootJobNode->setAttribute('xml:id', $this->resRootNode[$obj->nodeType]); | |
399 | + $rootJobNode->setAttribute('xml:id', $this->resRootNode[$key]); | |
350 | 400 | $jobsFinished = $this->jobXml->getElementsByTagName('jobsFinished')->item(0); |
351 | 401 | $jobsFinished->appendChild($rootJobNode); |
352 | 402 | } |
... | ... |