]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/nodes/class_BaseHubNode.php
node_type rewritten to 'mode' element from request
[hub.git] / application / hub / main / nodes / class_BaseHubNode.php
index c82ca908a4d1a18686ea3f09f0b9fbf15ad57776..6ca6aacb474645cf96dfa3a1dd3c2241e858f14b 100644 (file)
@@ -78,7 +78,7 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable {
 
                // Search for the node number zero which is hard-coded the default
                $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR, 1);
-               $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_TYPE, $this->__toString());
+               $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_TYPE, $requestInstance->getRequestElement('mode'));
                $searchInstance->setLimit(1);
 
                // Get a result back
@@ -91,12 +91,15 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable {
 
                        // Get the node id from result and set it
                        $this->setNodeId($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID));
+
+                       // Output message
+                       $this->getDebugInstance()->output('Re-using found node-id: ' . $this->getNodeId() . '');
                } else {
                        // Get an RNG instance (Random Number Generator)
                        $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
 
                        // Generate a pseudo-random string
-                       $randomString = $rngInstance->randomString(255);
+                       $randomString = $rngInstance->randomString(255) . ':' . $requestInstance->getRequestElement('mode');
 
                        // Get a crypto instance
                        $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
@@ -105,7 +108,10 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable {
                        $this->setNodeId($cryptoInstance->hashString($cryptoInstance->encryptString($randomString)));
 
                        // Register the node id with our wrapper
-                       $wrapperInstance->registerNodeId($this);
+                       $wrapperInstance->registerNodeId($this, $requestInstance);
+
+                       // Output message
+                       $this->getDebugInstance()->output('Creating new node-id: ' . $this->getNodeId() . '');
                }
        }
 
@@ -113,12 +119,13 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable {
         * Adds registration elements to a given dataset instance
         *
         * @param       $criteriaInstance       An instance of a storeable criteria
+        * @param       $requestInstance        An instance of a Requestable class
         * @return      void
         */
-       public function addElementsToDataSet (StoreableCriteria $criteriaInstance) {
+       public function addElementsToDataSet (StoreableCriteria $criteriaInstance, Requestable $requestInstance) {
                // Add node number and type
                $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR, 1);
-               $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_TYPE, $this->__toString());
+               $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_TYPE, $requestInstance->getRequestElement('mode'));
 
                // Add the node id
                $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID, $this->getNodeId());