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; } } /** * @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); } public function loadFromNode($xmlNode) { $this->setId($this->getXmlNodeAttribute($xmlNode, REQUESTPARAM_ID)); } } 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); } public function addParam($id = "") { foreach ($this->getChildrenByName(REQUESTPARAM_NAME) as $paramNode) if ($paramNode->getId() == $id) return $paramNode; $param = new RequestParamNodeClass(); $param->setId($id); $this->addChild($param); return $param; } public function getParamList() { return $this->getChildrenByName(REQUESTPARAM_NAME); } public function loadFromNode($xmlNode) { foreach ($this->getXmlNodeChildrenByTagName($xmlNode, REQUESTPARAM_NAME) as $requestParamXmlNode) { $this->addParam()->loadFromNode($requestParamXmlNode); } } } define ("REQUEST_NAME", "request"); /** * @class RequestNodeClass * @brief Definition of a request node for AMDA_Kernel * @details */ class RequestNodeClass extends NodeClass { public function __construct() { parent::__construct(REQUEST_NAME); $this->addChild(new RequestParamsNodeClass()); $this->addChild(new RequestTimesNodeClass()); $this->addChild(new RequestParamsTimeRestrictionsClass()); $this->addChild(new RequestOutputsNodeClass()); } public function getParamsNode() { return $this->getFirstChildByName(REQUESTPARAMS_NAME); } public function getTimesNode() { return $this->getFirstChildByName(REQUESTTIMES_NAME); } public function getParamsTimeRestrictions() { return $this->getFirstChildByName(REQUESTPARAMSTIMERESTRICTIONS_NAME); } public function getOutputsNode() { return $this->getFirstChildByName(REQUESTOUTPUTS_NAME); } 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); } } ?>