]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/criteria/class_DataSetCriteria.php
Just a space removed
[shipsimu.git] / inc / classes / main / criteria / class_DataSetCriteria.php
index d16f0395c5caeb4a9631003dd06667c3e64d0ff3..2e76c2f94d518ac66873823e0ac8ad525feda36c 100644 (file)
@@ -7,7 +7,7 @@
  * @version            0.0.0
  * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
  * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
+ * @link               http://www.ship-simu.org
  *
  * 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
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class DataSetCriteria extends BaseFrameworkSystem implements StoreableCriteria {
+       /**
+        * Table name
+        */
+       private $tableName = "";
+
+       /**
+        * Table columns (criteria) to store
+        */
+       private $tableColumns = array();
+
+       /**
+        * Unique key
+        */
+       private $uniqueKey = "";
+
        /**
         * Protected constructor
         *
@@ -36,7 +51,7 @@ class DataSetCriteria extends BaseFrameworkSystem implements StoreableCriteria {
                $this->setObjectDescription("Storeable data set for databases");
 
                // Create unique ID number
-               $this->createUniqueID();
+               $this->generateUniqueId();
 
                // Clean up a little
                $this->removeNumberFormaters();
@@ -57,14 +72,83 @@ class DataSetCriteria extends BaseFrameworkSystem implements StoreableCriteria {
        }
 
        /**
-        * Add extra criteria
+        * Add criteria
         *
         * @param       $criteriaKey    Criteria key
         * @param       $criteriaValue  Criteria value
         * @return      void
         */
        public function addCriteria ($criteriaKey, $criteriaValue) {
-               die("STUB!");
+               $this->tableColumns[(string) $criteriaKey] = $criteriaValue;
+       }
+
+       /**
+        * Add configured criteria
+        *
+        * @param       $criteriaKey    Criteria key
+        * @param       $configEntry    Configuration entry
+        * @return      void
+        */
+       public function addConfiguredCriteria ($criteriaKey, $configEntry) {
+               // Add configuration entry as criteria
+               $value = $this->getConfigInstance()->readConfig($configEntry);
+               $this->addCriteria($criteriaKey, $value);
+       }
+
+       /**
+        * Setter for table name
+        *
+        * @param       $tableName      Name of the table to set
+        * @return      void
+        */
+       public final function setTableName ($tableName) {
+               $this->tableName = (string) $tableName;
+       }
+
+       /**
+        * Getter for table name
+        *
+        * @return      $tableName      Name of the table to set
+        */
+       public final function getTableName () {
+               return $this->tableName;
+       }
+
+       /**
+        * Setter for unique key
+        *
+        * @param       $uniqueKey      Column to use as unique key
+        * @return      void
+        */
+       public final function setUniqueKey ($uniqueKey) {
+               $this->uniqueKey = (string) $uniqueKey;
+       }
+
+       /**
+        * Getter for unique key
+        *
+        * @return      $uniqueKey      Column to use as unique key
+        */
+       public final function getUniqueKey () {
+               return $this->uniqueKey;
+       }
+
+       /**
+        * Getter for unique key value
+        *
+        * @return      $uniqueValue    Value of the unique key
+        */
+       public final function getUniqueValue () {
+               return $this->tableColumns[$this->getUniqueKey()];
+       }
+
+       /**
+        * Getter for criteria array
+        *
+        * @return      $tableColumns
+        */
+       public final function getCriteriaArray () {
+               return $this->tableColumns;
        }
 }