From: Roland Häder Date: Wed, 30 Jan 2013 22:20:15 +0000 (+0000) Subject: Re-added answer_status generically X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=cdaba0d63145bf6677b116f6392bededb1e516b8;p=hub.git Re-added answer_status generically --- diff --git a/application/hub/main/handler/answer-status/class_BaseAnserStatusHandler.php b/application/hub/main/handler/answer-status/class_BaseAnserStatusHandler.php index 18826e561..a4b198ae5 100644 --- a/application/hub/main/handler/answer-status/class_BaseAnserStatusHandler.php +++ b/application/hub/main/handler/answer-status/class_BaseAnserStatusHandler.php @@ -53,7 +53,7 @@ abstract class BaseAnserStatusHandler extends BaseDataHandler { */ public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) { // Add some generic data all messageData arrays provide - $dataSetInstance->addCriteria(NodeListDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $messageData[NetworkPackage::MESSAGE_DATA_ANSWER_STATUS]); + $dataSetInstance->addCriteria(NodeListDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $messageData[BaseXmlAnswerTemplateEngine::ANSWER_STATUS]); $dataSetInstance->addCriteria(NodeListDatabaseWrapper::DB_COLUMN_MESSAGE_TYPE , $messageData[NetworkPackage::MESSAGE_ARRAY_TYPE]); } } diff --git a/application/hub/main/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php b/application/hub/main/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php index 266d8c3c5..e34b51c1c 100644 --- a/application/hub/main/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php +++ b/application/hub/main/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php @@ -41,7 +41,8 @@ class NodeMessageAnnouncementAnswerHandler extends BaseMessageHandler implements XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS, XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID, XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_TCP_PORT, - XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_UDP_PORT + XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_UDP_PORT, + BaseXmlAnswerTemplateEngine::ANSWER_STATUS, ); // Init message-data->configuration translation array diff --git a/application/hub/main/handler/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php b/application/hub/main/handler/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php index 180a131b6..e8cf9f6c3 100644 --- a/application/hub/main/handler/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php +++ b/application/hub/main/handler/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php @@ -38,6 +38,7 @@ class NodeMessageRequestNodeListAnswerHandler extends BaseMessageHandler impleme $this->messageDataElements = array( XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_SESSION_ID, XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST, + BaseXmlAnswerTemplateEngine::ANSWER_STATUS, ); // Init message-data->configuration translation array diff --git a/application/hub/main/nodes/class_BaseHubNode.php b/application/hub/main/nodes/class_BaseHubNode.php index 1dca6472a..f207147bf 100644 --- a/application/hub/main/nodes/class_BaseHubNode.php +++ b/application/hub/main/nodes/class_BaseHubNode.php @@ -827,10 +827,10 @@ class BaseHubNode extends BaseHubSystem implements Updateable { */ public function handleAnswerStatusByMessageData (array $messageData, Receivable $packageInstance) { // Is it not empty? - assert(!empty($messageData[NetworkPackage::MESSAGE_DATA_ANSWER_STATUS])); + assert(!empty($messageData[BaseXmlAnswerTemplateEngine::ANSWER_STATUS])); // Construct configuration entry for handling class' name - $classConfigEntry = strtolower($messageData[NetworkPackage::MESSAGE_ARRAY_TYPE] . '_status_' . $messageData[NetworkPackage::MESSAGE_DATA_ANSWER_STATUS]) . '_handler_class'; + $classConfigEntry = strtolower($messageData[NetworkPackage::MESSAGE_ARRAY_TYPE] . '_status_' . $messageData[BaseXmlAnswerTemplateEngine::ANSWER_STATUS]) . '_handler_class'; // Try to get a class $handlerInstance = ObjectFactory::createObjectByConfiguredName($classConfigEntry); diff --git a/application/hub/main/package/class_NetworkPackage.php b/application/hub/main/package/class_NetworkPackage.php index c646ba0a7..0241695bd 100644 --- a/application/hub/main/package/class_NetworkPackage.php +++ b/application/hub/main/package/class_NetworkPackage.php @@ -119,7 +119,6 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R /** * Generic answer status field */ - const MESSAGE_DATA_ANSWER_STATUS = 'answer_status'; /** * Tags separator diff --git a/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php b/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php index 953d68130..5245f5a32 100644 --- a/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php +++ b/application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php @@ -22,7 +22,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class XmlAnnouncementAnswerTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { +class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { /** * Some XML nodes must be available for later data extraction */ @@ -58,6 +58,8 @@ class XmlAnnouncementAnswerTemplateEngine extends BaseXmlTemplateEngine implemen 'your-external-ip', 'your-internal-ip', 'your-session-id', + // Answer status (generic field) + self::ANSWER_STATUS, ); } diff --git a/application/hub/main/template/answer/class_ b/application/hub/main/template/answer/class_ new file mode 100644 index 000000000..9fe91b624 --- /dev/null +++ b/application/hub/main/template/answer/class_ @@ -0,0 +1,110 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo This template engine does not make use of setTemplateType() + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Xml???AnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createXml???TemplateEngine () { + // Get a new instance + $templateInstance = new Xml???TemplateEngine(); + + // Init template instannce + $templateInstance->initXmlTemplateEngine('PREFIX', '!!!'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return false; + } // END - if + + // Assign data with matching variable here + parent::assignVariable($this->getStackerInstance()->getNamed('!!!'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function get???CacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the ||| + * + * @return void + */ + protected function start??? () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('!!!', '|||'); + } + + /** + * Finishes the ||| + * + * @return void + */ + protected function finish??? () { + // Pop the last entry + $this->getStackerInstance()->popNamed('!!!'); + } +} + +// [EOF] +?> diff --git a/application/hub/main/template/answer/class_BaseXmlAnswerTemplateEngine.php b/application/hub/main/template/answer/class_BaseXmlAnswerTemplateEngine.php new file mode 100644 index 000000000..37c3ffe3a --- /dev/null +++ b/application/hub/main/template/answer/class_BaseXmlAnswerTemplateEngine.php @@ -0,0 +1,64 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo This template engine does not make use of setTemplateType() + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseXmlAnswerTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + /** + * Generic 'answer_status' field + */ + const ANSWER_STATUS = 'answer-status'; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Starts the answer-status + * + * @return void + */ + protected function startAnswerStatus () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed($this->getStackerName(), self::ANSWER_STATUS); + } + + /** + * Finishes the answer-status + * + * @return void + */ + protected function finishAnswerStatus () { + // Pop the last entry + $this->getStackerInstance()->popNamed($this->getStackerName()); + } +} + +// [EOF] +?> diff --git a/application/hub/main/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php b/application/hub/main/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php index cc051e047..b53290d0e 100644 --- a/application/hub/main/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php +++ b/application/hub/main/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php @@ -22,7 +22,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class XmlRequestNodeListAnswerTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { +class XmlRequestNodeListAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { // Constants for array elements const REQUEST_DATA_SESSION_ID = 'session-id'; const REQUEST_DATA_NODE_LIST = 'node-list'; @@ -40,6 +40,8 @@ class XmlRequestNodeListAnswerTemplateEngine extends BaseXmlTemplateEngine imple $this->subNodes = array( self::REQUEST_DATA_SESSION_ID, self::REQUEST_DATA_NODE_LIST, + // Answer status (generic field) + self::ANSWER_STATUS, ); } diff --git a/application/hub/main/template/class_BaseXmlTemplateEngine.php b/application/hub/main/template/class_BaseXmlTemplateEngine.php index d46c5a1b3..1a6136e3d 100644 --- a/application/hub/main/template/class_BaseXmlTemplateEngine.php +++ b/application/hub/main/template/class_BaseXmlTemplateEngine.php @@ -48,6 +48,11 @@ class BaseXmlTemplateEngine extends BaseTemplateEngine { */ private $typePrefix = 'xml'; + /** + * Name of stacker + */ + private $stackerName = ''; + /** * Content from dependency */ @@ -112,8 +117,11 @@ class BaseXmlTemplateEngine extends BaseTemplateEngine { // Init a variable stacker $stackerInstance = ObjectFactory::createObjectByConfiguredName($typePrefix . '_' . $xmlTemplateType . '_stacker_class'); + // Set name + $this->stackerName = $typePrefix . '_' . $xmlTemplateType; + // Init stacker - $stackerInstance->initStacker($typePrefix . '_' . $xmlTemplateType); + $stackerInstance->initStacker($this->stackerName); // Set it $this->setStackerInstance($stackerInstance); @@ -174,6 +182,15 @@ class BaseXmlTemplateEngine extends BaseTemplateEngine { return $this->mainNodes; } + /** + * Getter for stacker name + * + * @return $stackerName Name of stacker of this class + */ + protected final function getStackerName () { + return $this->stackerName; + } + /** * Getter for sub node array * diff --git a/application/hub/templates/xml/answer/announcement/announcement_answer.xml b/application/hub/templates/xml/answer/announcement/announcement_answer.xml index 36c790182..706869311 100644 --- a/application/hub/templates/xml/answer/announcement/announcement_answer.xml +++ b/application/hub/templates/xml/answer/announcement/announcement_answer.xml @@ -70,4 +70,9 @@ along with this program. If not, see //--> {?your_session_id?} + + {?answer_status?} diff --git a/application/hub/templates/xml/answer/requests/request_node_list_answer.xml b/application/hub/templates/xml/answer/requests/request_node_list_answer.xml index e61ca369a..e5959d56b 100644 --- a/application/hub/templates/xml/answer/requests/request_node_list_answer.xml +++ b/application/hub/templates/xml/answer/requests/request_node_list_answer.xml @@ -30,4 +30,9 @@ along with this program. If not, see List of all nodes (will be completed later) //--> + + {?answer_status?}