Blame view

src/Request/ParamsRequestImpl/Nodes/Requests/RequestNodeClass.php 4.54 KB
22521f1c   Benjamin Renard   First commit
1
2
<?php

966bd5f8   Benjamin Renard   Add request to ge...
3
4
5
require_once "RequestTimesNodeClass.php";
require_once "RequestOutputsNodeClass.php";

22521f1c   Benjamin Renard   First commit
6
7
8
define ("REQUESTPARAM_NAME", "param");
define ("REQUESTPARAM_ID", "id");

b3343120   Benjamin Renard   Check parameters ...
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
define ("REQUESTPARAMTIMERESTRICTION_NAME", "param");
define ("REQUESTPARAMTIMERESTRICTION_ID", "id");
define ("REQUESTPARAMTIMERESTRICTION_RESTRICTION", "restriction");

class RequestParamTimeRestrictionClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(REQUESTPARAMTIMERESTRICTION_NAME);
	}

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

	public function getId()
	{
		return $this->getAttribute(REQUESTPARAM_ID);
	}

	public function setTimeRestriction($restriction)
	{
		$this->setAttribute(REQUESTPARAMTIMERESTRICTION_RESTRICTION, $restriction);
	}

	public function getTimeRestriction()
	{
		return $this->getAttribute(REQUESTPARAMTIMERESTRICTION_RESTRICTION);
	}
}

define ("REQUESTPARAMSTIMERESTRICTIONS_NAME", "paramsTimeRestrictions");

class RequestParamsTimeRestrictionsClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(REQUESTPARAMSTIMERESTRICTIONS_NAME);
	}

	public function addParamTimeRestriction($id, $restriction)
	{
		foreach ($this->getChildrenByName(REQUESTPARAMTIMERESTRICTION_NAME) as $paramNode) {
			if ($paramNode->getId() == $id) {
				$oldTimeRestriction = intval($paramNode->getTimeRestriction());
				if ($oldTimeRestriction < $restriction) {
					// Old restriction is more restrictive => keep it
					return $paramNode;
				}
				$paramNode->setTimeRestriction($restriction);
				return $paramNode;
			}
		}

		$paramNode = new RequestParamTimeRestrictionClass();
		$paramNode->setId($id);
		$paramNode->setTimeRestriction($restriction);
		$this->addChild($paramNode);

		return $paramNode;
	}
}

22521f1c   Benjamin Renard   First commit
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
 * @class RequestParamNodeClass
 * @brief Definition of a request param node for AMDA_Kernel
 * @details
*/
class RequestParamNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(REQUESTPARAM_NAME);
	}

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

	public function getId()
	{
		return $this->getAttribute(REQUESTPARAM_ID);
	}
966bd5f8   Benjamin Renard   Add request to ge...
94
95
96
97
98
	
	public function loadFromNode($xmlNode)
	{
		$this->setId($this->getXmlNodeAttribute($xmlNode, REQUESTPARAM_ID));
	}
22521f1c   Benjamin Renard   First commit
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
}

define ("REQUESTPARAMS_NAME", "params");

/**
 * @class RequestParamsNodeClass
 * @brief Definition of a request params node for AMDA_Kernel
 * @details
*/
class RequestParamsNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(REQUESTPARAMS_NAME);
	}

966bd5f8   Benjamin Renard   Add request to ge...
115
	public function addParam($id = "")
22521f1c   Benjamin Renard   First commit
116
	{
4ede4320   Benjamin Renard   Integration for s...
117
118
		foreach ($this->getChildrenByName(REQUESTPARAM_NAME) as $paramNode)
			if ($paramNode->getId() == $id)
966bd5f8   Benjamin Renard   Add request to ge...
119
				return $paramNode;
22521f1c   Benjamin Renard   First commit
120
121
122
		$param = new RequestParamNodeClass();
		$param->setId($id);
		$this->addChild($param);
966bd5f8   Benjamin Renard   Add request to ge...
123
124
		
		return $param;
22521f1c   Benjamin Renard   First commit
125
126
127
128
129
130
	}

	public function getParamList()
	{
		return $this->getChildrenByName(REQUESTPARAM_NAME);
	}
966bd5f8   Benjamin Renard   Add request to ge...
131
132
133
134
135
136
137
	
	public function loadFromNode($xmlNode)
	{
		foreach ($this->getXmlNodeChildrenByTagName($xmlNode, REQUESTPARAM_NAME) as $requestParamXmlNode) {
			$this->addParam()->loadFromNode($requestParamXmlNode);
		}
	}
22521f1c   Benjamin Renard   First commit
138
139
140
141
142
143
144
145
146
147
148
}

define ("REQUEST_NAME", "request");

/**
 * @class RequestNodeClass
 * @brief Definition of a request node for AMDA_Kernel
 * @details
*/
class RequestNodeClass extends NodeClass
{
22521f1c   Benjamin Renard   First commit
149
150
151
152
153
154
	public function __construct()
	{
		parent::__construct(REQUEST_NAME);

		$this->addChild(new RequestParamsNodeClass());
		$this->addChild(new RequestTimesNodeClass());
b3343120   Benjamin Renard   Check parameters ...
155
		$this->addChild(new RequestParamsTimeRestrictionsClass());
22521f1c   Benjamin Renard   First commit
156
157
158
159
160
161
162
163
164
165
166
167
168
		$this->addChild(new RequestOutputsNodeClass());
	}

	public function getParamsNode()
	{
		return $this->getFirstChildByName(REQUESTPARAMS_NAME);
	}

	public function getTimesNode()
	{
		return $this->getFirstChildByName(REQUESTTIMES_NAME);
	}

b3343120   Benjamin Renard   Check parameters ...
169
170
171
172
173
	public function getParamsTimeRestrictions()
	{
		return $this->getFirstChildByName(REQUESTPARAMSTIMERESTRICTIONS_NAME);
	}

22521f1c   Benjamin Renard   First commit
174
175
176
177
	public function getOutputsNode()
	{
		return $this->getFirstChildByName(REQUESTOUTPUTS_NAME);
	}
00a22067   Benjamin Renard   TT navigation
178
	
966bd5f8   Benjamin Renard   Add request to ge...
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
	public function loadFromNode($xmlNode)
	{
		$paramsXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTPARAMS_NAME);
		if (isset($paramsXmlNode))
			$this->getParamsNode()->loadFromNode($paramsXmlNode);
		
		$timesXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTTIMES_NAME);
		if (isset($timesXmlNode))
			$this->getTimesNode()->loadFromNode($timesXmlNode);
		
		$outputsXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTS_NAME);
		if (isset($outputsXmlNode))
			$this->getOutputsNode()->loadFromNode($outputsXmlNode);
		
	}
22521f1c   Benjamin Renard   First commit
194
195
}

7d84634e   Benjamin Renard   Fix plot request ...
196
?>