Blame view

src/Request/ParamsRequestImpl/Nodes/Params/ParamNodeClass.php 5.48 KB
22521f1c   Benjamin Renard   First commit
1
2
<?php

966bd5f8   Benjamin Renard   Add request to ge...
3
4
5
6
7
8
9
require_once "ParamClbManualNodeClass.php";
require_once "ParamGetAmdaParamNodeClass.php";
require_once "ParamGetDDBaseNodeClass.php";
require_once "ParamGetLocalBaseNodeClass.php";
require_once dirname(__FILE__)."/../Infos/InfoParamNodeClass.php";
require_once dirname(__FILE__)."/../Requests/RequestOutputPlotPanelNodeClass.php";

22521f1c   Benjamin Renard   First commit
10
11
12
13
14
15
define ("PARAM_NAME", "param");
define ("PARAM_ID", "xml:id");
define ("PARAM_SAMPLING", "time_resolution");
define ("PARAM_GAP", "gap_threshold");
define ("PARAM_GET", "get");
define ("PARAM_PROCESS", "process");
e9165342   Benjamin Renard   Write data mining...
16
define ("PARAM_PROCESS_DESCRIPTION", "description");
a04159d9   Benjamin Renard   Define common lib...
17
define ("PARAM_PROCESS_USERPROCESS", "userProcess");
22521f1c   Benjamin Renard   First commit
18
19
20
21
22
23
define ("PARAM_OUTPUT", "output");

abstract class ParamGetTypeEnum
{
	const AMDAPARAM   = "AmdaParam";
	const DDBASE      = "DDBase";
944199fe   Benjamin Renard   Use table definit...
24
	const LOCALBASE   = "LocalBase";
22521f1c   Benjamin Renard   First commit
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
}

/**
 * @class ParamNodeClass
 * @brief Definition of a parameter for AMDA_Kernel
 * @details
 */
class ParamNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(PARAM_NAME);
	}

	public function setId($id)
	{
		$this->setAttribute(PARAM_ID, $id);
	}

	public function setSampling($sampling)
	{
		$node = $this->getChildInstanceByName(PARAM_SAMPLING,true);
		$node->setValue($sampling);
	}

	public function setGap($gap)
	{

		$node = $this->getChildInstanceByName(PARAM_GAP,true);
		$node->setValue($gap);
	}

944199fe   Benjamin Renard   Use table definit...
57
58
59
60
61
62
63
64
65
66
67
68
	public function getInfo()
	{
		$infoNode = $this->getChildInstanceByName(INFOPARAM_TAGNAME, false);
		if ($infoNode)
			return $infoNode;
		
		$infoNode = new InfoParamNodeClass();
		$this->addChild($infoNode);
		
		return $infoNode;
	}
	
966bd5f8   Benjamin Renard   Add request to ge...
69
	public function addClbManual($name = "")
944199fe   Benjamin Renard   Use table definit...
70
71
72
73
74
75
76
	{
		$clbManualNode = new ParamClbManualNodeClass();
		$clbManualNode->setClbName($name);
		$this->addChildBefore($clbManualNode, PARAM_GET);
		return $clbManualNode;
	}
	
22521f1c   Benjamin Renard   First commit
77
78
79
80
81
82
83
84
85
86
87
88
	public function addParamGet($type)
	{
		$node = $this->getChildInstanceByName(PARAM_GET, true);

		switch ($type)
		{
			case ParamGetTypeEnum::AMDAPARAM :
				$paramGet = new ParamGetAmdaParamNodeClass();
				break;
			case ParamGetTypeEnum::DDBASE :
				$paramGet = new ParamGetDDBaseNodeClass();
				break;
944199fe   Benjamin Renard   Use table definit...
89
90
91
			case ParamGetTypeEnum::LOCALBASE :
				$paramGet = new ParamGetLocalBaseNodeClass();
				break;
22521f1c   Benjamin Renard   First commit
92
93
94
95
96
97
98
99
			default :
				throw new Exception('Param get node not implemented');
		}

		$node->addChild($paramGet);

		return $paramGet;
	}
944199fe   Benjamin Renard   Use table definit...
100
101
102
103
104
105
	
	public function getParamGet()
	{
		$getNode = $this->getChildInstanceByName(PARAM_GET, false);
		if (!$getNode)
			return NULL;
f7093283   Benjamin Renard   Fix pb with PHP v...
106
107
108
109
		if (count($getNode->getChildren()) > 0) {
			$getNodes = $getNode->getChildren();
			return $getNodes[0];
		}
944199fe   Benjamin Renard   Use table definit...
110
111
		return NULL;
	}
22521f1c   Benjamin Renard   First commit
112

a04159d9   Benjamin Renard   Define common lib...
113
	public function setProcess($process, $process_info, $isUserProcess = false)
22521f1c   Benjamin Renard   First commit
114
115
116
	{
		$node = $this->getChildInstanceByName(PARAM_PROCESS, true);
		$node->setValue($process);
e9165342   Benjamin Renard   Write data mining...
117
		$node->setAttribute(PARAM_PROCESS_DESCRIPTION, $process_info);
a04159d9   Benjamin Renard   Define common lib...
118
119
120
		if ($isUserProcess) {
			$node->setAttribute(PARAM_PROCESS_USERPROCESS, $isUserProcess ? "true" : "false");
		}
22521f1c   Benjamin Renard   First commit
121
122
123
124
125
	}

	public function setOutput()
	{
		$node = $this->getChildInstanceByName(PARAM_OUTPUT, true);
966bd5f8   Benjamin Renard   Add request to ge...
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
		return $node;
	}
	
	public function getOutput()
	{
		return $this->getChildInstanceByName(PARAM_OUTPUT, false);
	}
	
	public function loadFromNode($xmlNode) 
	{
		$this->setId($this->getXmlNodeAttribute($xmlNode, PARAM_ID));
		
		$samplingXmlNode = $this->getXmlNodeChildByTagName($xmlNode, PARAM_SAMPLING);
		if (isset($samplingXmlNode))
			$this->setSampling($this->getXmlNodeValue($samplingXmlNode));
		
		$gapXmlNode = $this->getXmlNodeChildByTagName($xmlNode, PARAM_GAP);
		if (isset($gapXmlNode))
			$this->setGap($this->getXmlNodeValue($gapXmlNode));
		
		$infoXmlNode = $this->getXmlNodeChildByTagName($xmlNode, INFOPARAM_TAGNAME);
		if (isset($infoXmlNode))
			$this->getInfo()->loadFromNode($infoXmlNode);

		foreach ($this->getXmlNodeChildrenByTagName($xmlNode, PARAMCLBMANUAL_TAGNAME) as $clbXmlNode) {
			$this->addClbManual()->loadFromNode($clbXmlNode);
		}
		
		$paramGetXmlNode = $this->getXmlNodeChildByTagName($xmlNode, PARAM_GET);
		if (isset($paramGetXmlNode)) {
			foreach ($this->getXmlNodeChildren($paramGetXmlNode) as $paramGetDefXmlNode) {
				switch ($this->getXmlNodeName($paramGetDefXmlNode)) {
					case PARAMGETAMDAPARAM_NAME :
						$this->addParamGet(ParamGetTypeEnum::AMDAPARAM)->loadFromNode($paramGetDefXmlNode);
						break;
					case PARAMGETDDBASE_NAME :
						$this->addParamGet(ParamGetTypeEnum::DDBASE)->loadFromNode($paramGetDefXmlNode);
						break;
					case PARAMGETLOCALBASE_VI :
						$this->addParamGet(ParamGetTypeEnum::LOCALBASE)->loadFromNode($paramGetDefXmlNode);
						break;
				}
			}
		}
		
		$processXmlNode = $this->getXmlNodeChildByTagName($xmlNode, PARAM_PROCESS);
		if (isset($processXmlNode))
e9165342   Benjamin Renard   Write data mining...
173
			$this->setProcess($this->getXmlNodeValue($processXmlNode),$this->getXmlNodeAttribute($processXmlNode,PARAM_PROCESS_DESCRIPTION));
966bd5f8   Benjamin Renard   Add request to ge...
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
		
		$outputNode = $this->setOutput();
		$outputXmlNode = $this->getXmlNodeChildByTagName($xmlNode, PARAM_OUTPUT);
		if (isset($outputXmlNode))
		{
			foreach ($this->getXmlNodeChildren($outputXmlNode) as $outputTypeXmlNode) {
				switch ($this->getXmlNodeName($outputTypeXmlNode))
				{
					case "plot" :
						$plotNode = $outputNode->getChildInstanceByName("plot", TRUE);
						$node = new RequestOutputPlotPanelNodeClass();
						$plotNode->addChild($node);
						$node->loadFromNode($outputTypeXmlNode);
						break;
				}
			}
		}
			
22521f1c   Benjamin Renard   First commit
192
193
194
195
	}
}

?>