3 * A set of data storeable in databases
5 * @see DatabaseFrontendInterface - An interface for database frontends (front-end to the application)
6 * @author Roland Haeder <webmaster@ship-simu.org>
8 * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software
9 * @license GNU GPL 3.0 or any newer version
10 * @link http://www.ship-simu.org
12 * This program is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 class DataSetCriteria extends BaseFrameworkSystem implements StoreableCriteria {
29 private $tableName = "";
32 * Table columns (criteria) to store
34 private $tableColumns = array();
39 private $uniqueKey = "";
42 * Protected constructor
46 protected function __construct() {
47 // Call parent constructor
48 parent::__construct(__CLASS__);
50 // Set part description
51 $this->setObjectDescription("Storeable data set for databases");
53 // Create unique ID number
54 $this->generateUniqueId();
57 $this->removeNumberFormaters();
58 $this->removeSystemArray();
62 * Creates an instance of this criteria
64 * @return $criteriaInstance An instance of this criteria
66 public final static function createDataSetCriteria () {
68 $criteriaInstance = new DataSetCriteria();
70 // Return the instance
71 return $criteriaInstance;
77 * @param $criteriaKey Criteria key
78 * @param $criteriaValue Criteria value
81 public function addCriteria ($criteriaKey, $criteriaValue) {
82 $this->tableColumns[(string) $criteriaKey] = $criteriaValue;
86 * Add configured criteria
88 * @param $criteriaKey Criteria key
89 * @param $configEntry Configuration entry
92 public function addConfiguredCriteria ($criteriaKey, $configEntry) {
93 // Add configuration entry as criteria
94 $value = $this->getConfigInstance()->readConfig($configEntry);
95 $this->addCriteria($criteriaKey, $value);
99 * Setter for table name
101 * @param $tableName Name of the table to set
104 public final function setTableName ($tableName) {
105 $this->tableName = (string) $tableName;
109 * Getter for table name
111 * @return $tableName Name of the table to set
113 public final function getTableName () {
114 return $this->tableName;
118 * Setter for unique key
120 * @param $uniqueKey Column to use as unique key
123 public final function setUniqueKey ($uniqueKey) {
124 $this->uniqueKey = (string) $uniqueKey;
128 * Getter for unique key
130 * @return $uniqueKey Column to use as unique key
132 public final function getUniqueKey () {
133 return $this->uniqueKey;
137 * Getter for unique key value
139 * @return $uniqueValue Value of the unique key
141 public final function getUniqueValue () {
142 return $this->tableColumns[$this->getUniqueKey()];
146 * Getter for criteria array
148 * @return $tableColumns
150 public final function getCriteriaArray () {
151 return $this->tableColumns;