* @version 0.0.0 * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.shipsimu.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 * 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 . */ class CruncherUnitDatabaseWrapper extends BaseDatabaseWrapper implements UnitDatabaseWrapper, Registerable { // Constants for database table names const DB_TABLE_CRUNCHER_UNITS = 'cruncher_units'; // Constants for database column names const DB_COLUMN_UNIT_TYPE = 'unit_type'; const DB_COLUMN_UNIT_STATUS = 'unit_status'; /** * Protected constructor * * @return void */ protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); } /** * Creates an instance of this database wrapper by a provided user class * * @return $wrapperInstance An instance of the created wrapper class */ public static final function createCruncherUnitDatabaseWrapper () { // Get a new instance $wrapperInstance = new CruncherUnitDatabaseWrapper(); // Set (primary!) table name $wrapperInstance->setTableName(self::DB_TABLE_CRUNCHER_UNITS); // Return the instance return $wrapperInstance; } /** * Checks whether a test unit has been produced * * @return $isProduced Whether a test unit has already been produced */ public function isTestUnitProduced () { // Now get a search instance $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); // Add criteria for looking up already created and available test units $searchInstance->addCriteria(self::DB_COLUMN_UNIT_TYPE , BaseUnitProducer::UNIT_TYPE_TEST_UNIT); $searchInstance->addCriteria(self::DB_COLUMN_UNIT_STATUS, BaseUnitProducer::UNIT_STATUS_AVAILABLE); $searchInstance->setConfiguredLimit('cruncher_test_unit_max_count'); // Search for our units $resultInstance = $this->doSelectByCriteria($searchInstance); // Do we have some entries? $isProduced = $resultInstance->next(); // Return it return $isProduced; } } // [EOF] ?>