]> git.mxchange.org Git - hub.git/commitdiff
Re-added answer_status generically
authorRoland Häder <roland@mxchange.org>
Wed, 30 Jan 2013 22:20:15 +0000 (22:20 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 30 Jan 2013 22:20:15 +0000 (22:20 +0000)
12 files changed:
application/hub/main/handler/answer-status/class_BaseAnserStatusHandler.php
application/hub/main/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php
application/hub/main/handler/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php
application/hub/main/nodes/class_BaseHubNode.php
application/hub/main/package/class_NetworkPackage.php
application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php
application/hub/main/template/answer/class_ [new file with mode: 0644]
application/hub/main/template/answer/class_BaseXmlAnswerTemplateEngine.php [new file with mode: 0644]
application/hub/main/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php
application/hub/main/template/class_BaseXmlTemplateEngine.php
application/hub/templates/xml/answer/announcement/announcement_answer.xml
application/hub/templates/xml/answer/requests/request_node_list_answer.xml

index 18826e561101d915531a8a634fe8b23f9c2b2a71..a4b198ae57f9d453c01d5a43cd6324e947cfc562 100644 (file)
@@ -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]);
        }
 }
index 266d8c3c535799740c7dbc8ce73bb085599dba5b..e34b51c1c77830b447144fcb873e3137cc8b6ff7 100644 (file)
@@ -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
index 180a131b64e7dacff8a7ecd5a669d99fe7da2390..e8cf9f6c374db523fa956ee86020c389273b75b7 100644 (file)
@@ -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
index 1dca6472acb233e396c83f8dd0aaddc78cacae61..f207147bfc2d76ee5403cc8df6abf30d0eef4715 100644 (file)
@@ -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);
index c646ba0a79bc7e4cddb61b2fc5578819f6cdd496..0241695bd41f887c5cb2e288525c64b10d6de9b4 100644 (file)
@@ -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
index 953d681308a3e785b6afa31715df344d3a4c1b20..5245f5a329068f3b69a168b034fbf687e7123af5 100644 (file)
@@ -22,7 +22,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-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 (file)
index 0000000..9fe91b6
--- /dev/null
@@ -0,0 +1,110 @@
+<?php
+/**
+ * An ??? answer template engine class for XML templates
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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 (file)
index 0000000..37c3ffe
--- /dev/null
@@ -0,0 +1,64 @@
+<?php
+/**
+ * An generic answer template engine class for XML templates
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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]
+?>
index cc051e047e46627d951136a3d12d6f6a49fbe949..b53290d0ef1d4ba35845a90b539212441649bb18 100644 (file)
@@ -22,7 +22,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-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,
                );
        }
 
index d46c5a1b36988c6ffaff249a5566a8ff3fdc0cd4..1a6136e3d80387cefc51f2b16916eb3b69ddf280 100644 (file)
@@ -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
         *
index 36c79018281230fc79ed5fd5da8f7fb359a2f93d..706869311eff01ad9d89a816a60ee1c4407efab7 100644 (file)
@@ -70,4 +70,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
                //-->
                <your-session-id>{?your_session_id?}</your-session-id>
        </your-data>
+       <!--
+       Status of this answer. This can be something like OKAY if all went fine or
+       any other error code.
+       //-->
+       <answer-status>{?answer_status?}</answer-status>
 </announcement-answer>
index e61ca369a1b1c69a0947ef59039e4884d433196a..e5959d56b146e6f2dece4fbf6b1be99885256fb5 100644 (file)
@@ -30,4 +30,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
        List of all nodes (will be completed later)
        //-->
        <node-list />
+       <!--
+       Status of this answer. This can be something like OKAY if all went fine or
+       any other error code.
+       //-->
+       <answer-status>{?answer_status?}</answer-status>
 </request-node-list-answer>