Blame view

php/old_amda/moreData.php 2.56 KB
16035364   Benjamin Renard   First commit
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
<?php
 /**
 *  $Id: moreData.php 2913 2015-05-19 10:30:52Z elena $
*/
   require_once ("../../../../php/config.php"); 
   
 
   $dom = new DomDocument("1.0"); 
   $dom->load(getenv('USER_DATA_PATH').'base.xml');    
   $vi = $dom->getElementById($argv[1]);
 
   $requestStart = (int)$argv[2];
   $requestStop  = (int)$argv[3];
 
   $argumentsByParam = array();
 
   if ($vi->getAttribute("moreData")) {

    $masks = $vi->getElementsByTagName('mask');
    $mask = $masks->item(0)->nodeValue;

    $isSimu = strncmp($mask, "impex___", 8) === 0 || strncmp($mask, "spase___", 8) === 0;
    $isClWeb = strncmp($mask, "CLWEB_", 6) === 0;
 
    if ($isSimu) $myParamMgr = new SimuParamMgr();
    else if ($isClWeb) $myParamMgr = new WsrParamMgr();
    else exit();
 
    $paramBuilder = new ParamBuilder();

    $paramDom = new DomDocument("1.0");
    $paramDom->load(getenv('USER_WS_PATH').'WsParams.xml');
    $xpdSimu = new domxpath($paramDom); 
      
    $paramsSimu = $xpdSimu->query("//*[@mask='".$mask."']");  
    $simuID = $paramsSimu->item(0)->getAttribute('xml:id'); 

    $files = $vi->getElementsByTagName('file'); 
    $param = $vi->getElementsByTagName('param')->item(0)->nodeValue; 
    $args = $vi->getElementsByTagName('arguments'); 

    if ($args->item(0)){
        if ($args->item(0)->hasChildNodes()){
            $arguments = array(); 
            foreach ($args->item(0)->childNodes as $child){
                if ($child instanceof DOMElement){
                $arguments[$child->nodeName] = $child->nodeValue;
                }
            }
            $argumentsByParam[$param] = $arguments;
        }
    }
    $myBaseManager = new BaseManager();
    $intervalsToGet = $myBaseManager->intervalsToGet($requestStart, $requestStop, $mask);
    $start = $intervalsToGet['start'];
    $stop = $intervalsToGet['stop'];
    // Data to get
     if (count($start) > 0) {
        for ($i = 0; $i < count($start); $i++) {

            $startD = gmdate("Y-m-d\TH:i:s\Z",$start[$i]); 
            $stopD = gmdate("Y-m-d\TH:i:s\Z",$stop[$i]);
            if ($isClWeb)  {
                    $data['paramID'] = $param;
                    $data['startDate'] = $startD;
                    $data['stopDate'] = $stopD;
                    $myParamMgr->setParams($data);
                    $wsrFileNames = $myParamMgr->getData();
            }
            else {
                    $myParamMgr->setParams($param, $startD, $stopD, $argumentsByParam);
                    $simuFileNames = $myParamMgr->getSimuData();
            }         
        } 
        $paramBuilder->makeWsdParam($simuID);
    }
 }
 exit();
?>