Blame view

src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputStatisticNodeClass.php 5.68 KB
952dd7c7   elena   catalog integration
1
2
3
4
5
6
7
8
9
10
11
<?php

define ("REQUESTOUTPUTSTATISTIC_NAME", "statistic");
define ("REQUESTOUTPUTSTATISTIC_TIMEFORMAT", "timeFormat");
define ("REQUESTOUTPUTSTATISTIC_FILEFORMAT", "fileFormat");
define ("REQUESTOUTPUTSTATISTIC_STRUCTURE", "outputStructure");
define ("REQUESTOUTPUTSTATISTIC_FILENAME", "fileName");

define ("REQUESTOUTPUTSTATISTICPARAM_NAME",  "param");
define ("REQUESTOUTPUTSTATISTICFUNCTION_NAME",  "function");
define ("REQUESTOUTPUTSTATISTICPARAM_ID", "id");
ecdabbec   elena   index for statistics
12
define ("REQUESTOUTPUTSTATISTICPARAM_INDEX", "index");
952dd7c7   elena   catalog integration
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
define ("REQUESTOUTPUTSTATISTICFUNCTION_ID",  "name");

abstract class RequestOutputStatisticTimeFormatEnum
{
	const UNKNOWN = "";
	const ISO   = "ISO";
}

abstract class RequestOutputStatisticFileFormatEnum
{
	const UNKNOWN = "";
	const ASCII   = "ASCII";
	const XML     = "XML";
	const VOT     = "VOT";
}

abstract class RequestOutputStatisticStructureEnum
{
	const UNKNOWN                             = "";
	const ONE_FILE                            = "one-file";
	const ONE_FILE_PER_INTERVAL               = "one-file-per-interval";
}

class RequestOutputStatisticFunctionNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(REQUESTOUTPUTSTATISTICFUNCTION_NAME);		
	}

	public function setFunctionName($name)
	{
		$this->setAttribute(REQUESTOUTPUTSTATISTICFUNCTION_ID, $name);
	}
966bd5f8   Benjamin Renard   Add request to ge...
47
48
49
50
51
	
	public function loadFromNode($xmlNode)
	{
		$this->setFunctionName($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTSTATISTICFUNCTION_ID));
	}
952dd7c7   elena   catalog integration
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
}

class RequestOutputStatisticParamNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(REQUESTOUTPUTSTATISTICPARAM_NAME);
	}

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

	public function getId()
	{
		return $this->getAttribute(REQUESTOUTPUTSTATISTICPARAM_ID);
	}
		
966bd5f8   Benjamin Renard   Add request to ge...
71
	public function addFunction($name = "")
952dd7c7   elena   catalog integration
72
73
74
	{		
		$node = new RequestOutputStatisticFunctionNodeClass();	 
		$this->addChild($node);		 
966bd5f8   Benjamin Renard   Add request to ge...
75
76
	 	$node->setFunctionName($name);
	 	return $node; 
952dd7c7   elena   catalog integration
77
	}
ecdabbec   elena   index for statistics
78
79
80
81
	
	public function indexExist($index)
	{
		if ($this->getAttribute(REQUESTOUTPUTSTATISTICPARAM_INDEX) == $index) 
966bd5f8   Benjamin Renard   Add request to ge...
82
			return true;
ecdabbec   elena   index for statistics
83
84
85
86
87
88
89
		return false;
	}

	public function setIndex($index)
	{
		if ($this->indexExist($index))
			return;
ecdabbec   elena   index for statistics
90
91
92
		$this->setAttribute(REQUESTOUTPUTSTATISTICPARAM_INDEX, $index);
		
	}
966bd5f8   Benjamin Renard   Add request to ge...
93
94
95
96
97
98
99
100
101
102
103
104
	
	public function loadFromNode($xmlNode)
	{
		$this->setId($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTSTATISTICPARAM_ID));
		
		foreach ($this->getXmlNodeChildrenByTagName($xmlNode, REQUESTOUTPUTSTATISTICFUNCTION_NAME) as $functionXmlNode) {
			$this->addFunction()->loadFromNode($functionXmlNode);
		}
		
		$this->setIndex($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTSTATISTICPARAM_INDEX));
	}
	
952dd7c7   elena   catalog integration
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
}

/**
 * @class RequestOutputStatisticNodeClass
 * @brief Definition of a request data mining output node for AMDA_Kernel
 * @details
 */
class RequestOutputStatisticNodeClass extends NodeClass
  {
	public function __construct()
	{
		parent::__construct(REQUESTOUTPUTSTATISTIC_NAME);				
	}

	public function setTimeFormat($timeFormat)
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTSTATISTIC_TIMEFORMAT, true);
		$node->setValue($timeFormat);
	}

	public function setFileFormat($fileFormat)
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTSTATISTIC_FILEFORMAT, true);
		$node->setValue($fileFormat);
	}

	public function setStructure($structure)
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTSTATISTIC_STRUCTURE, true);
		$node->setValue($structure);						
	}

	public function setFileName($fileName)
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTSTATISTIC_FILENAME, true);
		$node->setValue($fileName);
	}
ecdabbec   elena   index for statistics
142
		
952dd7c7   elena   catalog integration
143

966bd5f8   Benjamin Renard   Add request to ge...
144
	public function addParam($id = "", $indexes = array())
952dd7c7   elena   catalog integration
145
146
147
148
149
150
151
152
153
154
155
156
157
158
	{
		$paramsNode = $this->getFirstChildByName(REQUESTPARAMS_NAME);
		
		if (!$paramsNode)
		{
			$paramsNode = new RequestParamsNodeClass();
			$this->addChild($paramsNode);
		}

		$node = new RequestOutputStatisticParamNodeClass();
		$paramsNode->addChild($node);

		$node->setId($id);
		
ecdabbec   elena   index for statistics
159
160
161
162
163
164
		if (isset($indexes))
		{
			foreach ($indexes as $index)
				$node->setIndex($index);
		}
		
952dd7c7   elena   catalog integration
165
166
167
		return $node;
	}
	
966bd5f8   Benjamin Renard   Add request to ge...
168
	public function addPostProcessing($process = "")
952dd7c7   elena   catalog integration
169
170
171
172
173
174
175
176
177
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTPOSTPROCESSING_NAME);
		if ($node == NULL)
		{
			$node = new RequestOutputPostProcessingNodeClass();
			$this->addChild($node);
		}

		$node->addPostProcessing($process);
966bd5f8   Benjamin Renard   Add request to ge...
178
179
		
		return $node;
952dd7c7   elena   catalog integration
180
181
182
183
184
185
186
187
188
189
190
	}

	public function isPostProcessing($process)
	{
		$node = $this->getChildInstanceByName(REQUESTOUTPUTPOSTPROCESSING_NAME);

		if ($node == NULL)
			return false;
			
		return $node->isPostProcessing($process);
	}
966bd5f8   Benjamin Renard   Add request to ge...
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
	
	public function loadFromNode($xmlNode)
	{
		$this->setTimeFormat($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTSTATISTIC_TIMEFORMAT));
		$this->setFileFormat($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTSTATISTIC_FILEFORMAT));
		$this->setStructure($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTSTATISTIC_STRUCTURE));
		$this->setFileName($this->getXmlNodeAttribute($xmlNode, REQUESTOUTPUTSTATISTIC_FILENAME));
		
		$paramsXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTPARAMS_NAME);
		if (isset($paramsXmlNode))
		{
			foreach ($this->getXmlNodeChildrenByTagName($paramsXmlNode, REQUESTOUTPUTSTATISTICPARAM_NAME) as $paramXmlNode) {
				$this->addParam()->loadFromNode($paramXmlNode);
			}
		}
		
		$postprocessingXmlNode = $this->getXmlNodeChildByTagName($xmlNode, REQUESTOUTPUTPOSTPROCESSING_NAME);
		if (isset($postprocessingXmlNode))
			$this->addPostProcessing()->loadFromNode($paramXmlNode);
	}
952dd7c7   elena   catalog integration
211
212
213
}

?>