From: Roland Häder Date: Mon, 3 Aug 2009 21:32:10 +0000 (+0000) Subject: First attempt to store session id in database X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=101074ad123680dcafef4dfdd3c8a7af01868177;p=hub.git First attempt to store session id in database --- diff --git a/application/hub/main/database/wrapper/class_NodeInformationDatabaseWrapper.php b/application/hub/main/database/wrapper/class_NodeInformationDatabaseWrapper.php index a9d279de7..e8550f281 100644 --- a/application/hub/main/database/wrapper/class_NodeInformationDatabaseWrapper.php +++ b/application/hub/main/database/wrapper/class_NodeInformationDatabaseWrapper.php @@ -26,9 +26,10 @@ class NodeInformationDatabaseWrapper extends BaseDatabaseWrapper { const DB_TABLE_NODE_INFORMATION = 'node_data'; // Constants for database column names - const DB_COLUMN_NODE_NR = 'node_nr'; - const DB_COLUMN_NODE_ID = 'node_id'; - const DB_COLUMN_NODE_TYPE = 'node_type'; + const DB_COLUMN_NODE_NR = 'node_nr'; + const DB_COLUMN_NODE_ID = 'node_id'; + const DB_COLUMN_SESSION_ID = 'session_id'; + const DB_COLUMN_NODE_TYPE = 'node_type'; /** * Protected constructor @@ -86,6 +87,28 @@ class NodeInformationDatabaseWrapper extends BaseDatabaseWrapper { // "Insert" this request instance completely into the database $this->getDatabaseInstance()->queryInsertDataSet($dataSetInstance); } + + /** + * 'Registers' a new session id along with data provided in the node instance. + * This may sound confusing but avoids double code very nicely... + * + * @param $nodeInstance A node instance + * @param $requestInstance An instance of a Requestable class + * @return void + */ + public function registerSessionId (BaseHubNode $nodeInstance, Requestable $requestInstance) { + // Get a dataset instance + $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_INFORMATION)); + + // Set the primary key + $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID); + + // Add registration elements to the dataset + $nodeInstance->addElementsToDataSet($dataSetInstance, $requestInstance); + + // "Insert" this request instance completely into the database + $this->getDatabaseInstance()->queryInsertDataSet($dataSetInstance); + } } // [EOF] diff --git a/application/hub/main/nodes/class_BaseHubNode.php b/application/hub/main/nodes/class_BaseHubNode.php index 13bdbf75b..ecf088899 100644 --- a/application/hub/main/nodes/class_BaseHubNode.php +++ b/application/hub/main/nodes/class_BaseHubNode.php @@ -264,7 +264,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable { $wrapperInstance = ObjectFactory::createObjectByConfiguredName('node_info_db_wrapper_class'); // Register the node id with our wrapper - $wrapperInstance->registerNodeId($this, $this->getRequestInstance()); + $wrapperInstance->registerSessionId($this, $this->getRequestInstance()); // Output message $this->debugOutput('BOOTSTRAP: Created new session-id: ' . $this->getSessionId() . '');