Blame view

src/Request/ParamsRequestImpl/Nodes/Requests/RequestTimesNodeClass.php 5.64 KB
22521f1c   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
<?php

define ("REQUESTTIMEINTERVAL_NAME", "interval");
define ("REQUESTTIMEINTERVAL_START", "startTime");
define ("REQUESTTIMEINTERVAL_DURATION", "timeInterval");

/**
 * @class RequestTimesIntervalNodeClass
 * @brief Definition of a request time interval node for AMDA_Kernel
 * @details
*/
class RequestTimesIntervalNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(REQUESTTIMEINTERVAL_NAME);
	}

	public function setInterval($start, $duration)
	{
		$startNode = $this->getChildInstanceByName(REQUESTTIMEINTERVAL_START, true);
		$startNode->setValue($start);
		$durationNode = $this->getChildInstanceByName(REQUESTTIMEINTERVAL_DURATION, true);
		$durationNode->setValue($duration);
	}

	public function getStart()
	{
		$startNode = $this->getChildInstanceByName(REQUESTTIMEINTERVAL_START);
		if ($startNode == NULL)
			return "";
		return $startNode->getValue();
	}

	public function getDuration()
	{
		$durationNode = $this->getChildInstanceByName(REQUESTTIMEINTERVAL_DURATION);
		if ($durationNode == NULL)
			return "";
		return $durationNode->getValue();
	}
966bd5f8   Benjamin Renard   Add request to ge...
42
43
44
45
46
47
48
49
	
	public function loadFromNode($xmlNode)
	{
		$startXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTTIMEINTERVAL_START);
		$durationXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTTIMEINTERVAL_DURATION);
		if (isset($startXmlNode) && isset($durationXmlNode))
			$this->setInterval($this->getXmlNodeValue($startXmlNode), $this->getXmlNodeValue($durationXmlNode));
	}
22521f1c   Benjamin Renard   First commit
50
51
52
53
}

define ("REQUESTTIMETABLE_NAME", "timetable");
define ("REQUESTTIMETABLE_ID", "id");
00a22067   Benjamin Renard   TT navigation
54
define ("REQUESTTIMETABLE_TTNAME", "name");
c0e7e5be   Benjamin Renard   Add integration f...
55
define ("REQUESTTIMETABLE_INDEX", "index");
22521f1c   Benjamin Renard   First commit
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77

/**
 * @class RequestTimesTimeTableNodeClass
 * @brief Definition of a request time table node for AMDA_Kernel
 * @details
*/
class RequestTimesTimeTableNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(REQUESTTIMETABLE_NAME);
	}

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

	public function getId()
	{
		return $this->getAttribute(REQUESTTIMETABLE_ID);
	}
c0e7e5be   Benjamin Renard   Add integration f...
78
	
00a22067   Benjamin Renard   TT navigation
79
80
81
82
83
84
85
86
87
88
	public function setTTName($name)
	{
		$this->setAttribute(REQUESTTIMETABLE_TTNAME, $name);
	}
	
	public function getTTName()
	{
		return $this->getAttribute(REQUESTTIMETABLE_TTNAME);
	}
	
c0e7e5be   Benjamin Renard   Add integration f...
89
90
91
92
93
94
95
96
97
	public function setIndex($index)
	{
		$this->setAttribute(REQUESTTIMETABLE_INDEX, $index);
	}
	
	public function getIndex()
	{
		return $this->getAttribute(REQUESTTIMETABLE_INDEX);
	}
966bd5f8   Benjamin Renard   Add request to ge...
98
99
100
101
102
103
104
	
	public function loadFromNode($xmlNode)
	{
		$this->setId($this->getXmlNodeAttribute($xmlNode, REQUESTTIMETABLE_ID));
		$this->setTTName($this->getXmlNodeAttribute($xmlNode, REQUESTTIMETABLE_TTNAME));
		$this->setIndex($this->getXmlNodeAttribute($xmlNode, REQUESTTIMETABLE_INDEX));
	}
c0e7e5be   Benjamin Renard   Add integration f...
105
106
107
108
}

define ("REQUESTCATALOG_NAME", "catalog");
define ("REQUESTCATALOG_ID", "id");
00a22067   Benjamin Renard   TT navigation
109
define ("REQUESTCATALOG_TTNAME", "name");
c0e7e5be   Benjamin Renard   Add integration f...
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
define ("REQUESTCATALOG_INDEX", "index");

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

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

	public function getId()
	{
		return $this->getAttribute(REQUESTCATALOG_ID);
	}
00a22067   Benjamin Renard   TT navigation
133
134
135
136
137
138
139
140
141
142
	
	public function setCatalogName($name)
	{
		$this->setAttribute(REQUESTCATALOG_TTNAME, $name);
	}
	
	public function getCatalogName()
	{
		return $this->getAttribute(REQUESTCATALOG_TTNAME);
	}
c0e7e5be   Benjamin Renard   Add integration f...
143
144
145
146
147
148
149
150
151
152

	public function setIndex($index)
	{
		$this->setAttribute(REQUESTCATALOG_INDEX, $index);
	}

	public function getIndex()
	{
		return $this->getAttribute(REQUESTCATALOG_INDEX);
	}
966bd5f8   Benjamin Renard   Add request to ge...
153
154
155
156
157
158
159
	
	public function loadFromNode($xmlNode)
	{
		$this->setId($this->getXmlNodeAttribute($xmlNode, REQUESTCATALOG_ID));
		$this->setCatalogName($this->getXmlNodeAttribute($xmlNode, REQUESTCATALOG_TTNAME));
		$this->setIndex($this->getXmlNodeAttribute($xmlNode, REQUESTCATALOG_INDEX));
	}
22521f1c   Benjamin Renard   First commit
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
}

define ("REQUESTTIMES_NAME", "times");

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

966bd5f8   Benjamin Renard   Add request to ge...
176
	public function addInterval($start = "", $duration = "")
22521f1c   Benjamin Renard   First commit
177
178
179
180
	{
		$interval = new RequestTimesIntervalNodeClass();
		$interval->setInterval($start, $duration);
		$this->addChild($interval);
966bd5f8   Benjamin Renard   Add request to ge...
181
		return $interval;
22521f1c   Benjamin Renard   First commit
182
183
184
185
186
187
188
	}

	public function getIntervals()
	{
		return $this->getChildrenByName(REQUESTTIMEINTERVAL_NAME);
	}

966bd5f8   Benjamin Renard   Add request to ge...
189
	public function addTimeTable($id = "", $name = "", $index = -1)
22521f1c   Benjamin Renard   First commit
190
191
192
	{
		$timeTable = new RequestTimesTimeTableNodeClass();
		$timeTable->setId($id);
00a22067   Benjamin Renard   TT navigation
193
194
		if ($name != '')
			$timeTable->setTTName($name);
c0e7e5be   Benjamin Renard   Add integration f...
195
196
		if ($index >= 0)
			$timeTable->setIndex($index);
22521f1c   Benjamin Renard   First commit
197
		$this->addChild($timeTable);
966bd5f8   Benjamin Renard   Add request to ge...
198
		return $timeTable;
22521f1c   Benjamin Renard   First commit
199
200
	}

966bd5f8   Benjamin Renard   Add request to ge...
201
	public function addCatalog($id = "", $name = "", $index = -1)
22521f1c   Benjamin Renard   First commit
202
	{
c0e7e5be   Benjamin Renard   Add integration f...
203
204
		$catalogNode = new RequestCatalogNodeClass();
		$catalogNode->setId($id);
00a22067   Benjamin Renard   TT navigation
205
206
		if ($name != '')
			$catalogNode->setCatalogName($name);
c0e7e5be   Benjamin Renard   Add integration f...
207
208
209
		if ($index >= 0)
			$catalogNode->setIndex($index);
		$this->addChild($catalogNode);
966bd5f8   Benjamin Renard   Add request to ge...
210
		return $catalogNode;
22521f1c   Benjamin Renard   First commit
211
	}
c0e7e5be   Benjamin Renard   Add integration f...
212
	
966bd5f8   Benjamin Renard   Add request to ge...
213
214
215
216
217
218
219
220
221
222
223
224
225
226
	public function loadFromNode($xmlNode)
	{
		foreach ($this->getXmlNodeChildrenByTagName($xmlNode, REQUESTTIMEINTERVAL_NAME) as $timeintervalXmlNode) {
			$this->addInterval()->loadFromNode($timeintervalXmlNode);
		}
		
		foreach ($this->getXmlNodeChildrenByTagName($xmlNode, REQUESTTIMETABLE_NAME) as $timetableXmlNode) {
			$this->addTimeTable()->loadFromNode($timetableXmlNode);
		}
		
		foreach ($this->getXmlNodeChildrenByTagName($xmlNode, REQUESTCATALOG_NAME) as $catalogXmlNode) {
			$this->addCatalog()->loadFromNode($catalogXmlNode);
		}
	}
22521f1c   Benjamin Renard   First commit
227
228
229
}

?>