Blame view

src/Request/ParamsRequestImpl/Nodes/Params/ParamNodeClass.php 2.45 KB
22521f1c   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php

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");
define ("PARAM_OUTPUT", "output");

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

/**
 * @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...
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
	public function getInfo()
	{
		$infoNode = $this->getChildInstanceByName(INFOPARAM_TAGNAME, false);
		if ($infoNode)
			return $infoNode;
		
		$infoNode = new InfoParamNodeClass();
		$this->addChild($infoNode);
		
		return $infoNode;
	}
	
	public function addClbManual($name)
	{
		$clbManualNode = new ParamClbManualNodeClass();
		$clbManualNode->setClbName($name);
		$this->addChildBefore($clbManualNode, PARAM_GET);
		return $clbManualNode;
	}
	
22521f1c   Benjamin Renard   First commit
68
69
70
71
72
73
74
75
76
77
78
79
	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...
80
81
82
			case ParamGetTypeEnum::LOCALBASE :
				$paramGet = new ParamGetLocalBaseNodeClass();
				break;
22521f1c   Benjamin Renard   First commit
83
84
85
86
87
88
89
90
			default :
				throw new Exception('Param get node not implemented');
		}

		$node->addChild($paramGet);

		return $paramGet;
	}
944199fe   Benjamin Renard   Use table definit...
91
92
93
94
95
96
97
98
99
100
	
	public function getParamGet()
	{
		$getNode = $this->getChildInstanceByName(PARAM_GET, false);
		if (!$getNode)
			return NULL;
		if (count($getNode->getChildren()) > 0)
			return $getNode->getChildren()[0];
		return NULL;
	}
22521f1c   Benjamin Renard   First commit
101
102
103
104
105
106
107
108
109
110
111
112
113
114

	public function setProcess($process)
	{
		$node = $this->getChildInstanceByName(PARAM_PROCESS, true);
		$node->setValue($process);
	}

	public function setOutput()
	{
		$node = $this->getChildInstanceByName(PARAM_OUTPUT, true);
	}
}

?>