diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php
index 7f0bc7d7d..94acbc5db 100644
--- a/airtime_mvc/application/Bootstrap.php
+++ b/airtime_mvc/application/Bootstrap.php
@@ -27,7 +27,9 @@ require_once "ProvisioningHelper.php";
require_once "GoogleAnalytics.php";
require_once "Timezone.php";
require_once "Auth.php";
+require_once "interface/OAuth2.php";
require_once "TaskManager.php";
+require_once __DIR__.'/services/CeleryService.php';
require_once __DIR__.'/services/SoundcloudService.php';
require_once __DIR__.'/forms/helpers/ValidationTypes.php';
require_once __DIR__.'/forms/helpers/CustomDecorators.php';
diff --git a/airtime_mvc/application/common/TaskManager.php b/airtime_mvc/application/common/TaskManager.php
index a52bfa063..21b2b073f 100644
--- a/airtime_mvc/application/common/TaskManager.php
+++ b/airtime_mvc/application/common/TaskManager.php
@@ -9,8 +9,8 @@ final class TaskManager {
* @var array tasks to be run
*/
protected $_taskList = [
- AirtimeTask::SOUNDCLOUD,
- AirtimeTask::UPGRADE
+ AirtimeTask::UPGRADE, // Always run the upgrade first
+ AirtimeTask::CELERY
];
/**
@@ -18,6 +18,17 @@ final class TaskManager {
*/
protected static $_instance;
+ /**
+ * @var int TASK_INTERVAL_SECONDS how often, in seconds, to run the TaskManager tasks,
+ * if they need to be run
+ */
+ const TASK_INTERVAL_SECONDS = 60;
+
+ /**
+ * @var $con PDO Propel connection object
+ */
+ private $_con;
+
/**
* Private constructor so class is uninstantiable
*/
@@ -40,14 +51,63 @@ final class TaskManager {
* Run all tasks that need to be run
*/
public function runTasks() {
+ // If there is data in auth storage, this could be a user request
+ // so we should lock the TaskManager to avoid blocking
+ if ($this->_isUserSessionRequest()) return;
+ $this->_con = Propel::getConnection(CcPrefPeer::DATABASE_NAME);
+ $this->_con->beginTransaction();
+ try {
+ $lock = $this->_getLock();
+ if ($lock && microtime(true) < $lock['valstr'] + self::TASK_INTERVAL_SECONDS) return;
+ $this->_updateLock($lock);
+ $this->_con->commit();
+ } catch (Exception $e) {
+ // We get here if there are simultaneous requests trying to fetch the lock row
+ $this->_con->rollBack();
+ Logging::info($e->getMessage());
+ return;
+ }
foreach ($this->_taskList as $task) {
$task = TaskFactory::getTask($task);
- assert(is_subclass_of($task, 'AirtimeTask')); // Sanity check
- /** @var $task AirtimeTask */
if ($task && $task->shouldBeRun()) $task->run();
}
}
+ /**
+ * Check if the current session is a user request
+ *
+ * @return bool
+ */
+ private function _isUserSessionRequest() {
+ $auth = Zend_Auth::getInstance();
+ $data = $auth->getStorage()->read();
+ return !empty($data);
+ }
+
+ /**
+ * Get the task_manager_lock from cc_pref with a row-level lock for atomicity
+ *
+ * @return array|bool an array containing the row values, or false on failure
+ */
+ private function _getLock() {
+ $sql = "SELECT * FROM cc_pref WHERE keystr='task_manager_lock' LIMIT 1 FOR UPDATE NOWAIT";
+ $st = $this->_con->prepare($sql);
+ $st->execute();
+ return $st->fetch();
+ }
+
+ /**
+ * Update and commit the new lock value, or insert it if it doesn't exist
+ *
+ * @param $lock array cc_pref lock row values
+ */
+ private function _updateLock($lock) {
+ $sql = empty($lock) ? "INSERT INTO cc_pref (keystr, valstr) VALUES ('task_manager_lock', :value)"
+ : "UPDATE cc_pref SET valstr=:value WHERE keystr='task_manager_lock'";
+ $st = $this->_con->prepare($sql);
+ $st->execute(array(":value" => microtime(true)));
+ }
+
}
/**
@@ -60,8 +120,8 @@ interface AirtimeTask {
* Task types - values don't really matter as long as they're unique
*/
- const SOUNDCLOUD = "soundcloud";
const UPGRADE = "upgrade";
+ const CELERY = "celery";
/**
* Check whether the task should be run
@@ -94,10 +154,10 @@ class TaskFactory {
*/
public static function getTask($task) {
switch($task) {
- case AirtimeTask::SOUNDCLOUD:
- return new SoundcloudUploadTask();
case AirtimeTask::UPGRADE:
return new UpgradeTask();
+ case AirtimeTask::CELERY:
+ return new CeleryTask();
}
return null;
}
@@ -128,33 +188,24 @@ class UpgradeTask implements AirtimeTask {
}
/**
- * Class SoundcloudUploadTask
+ * Class CeleryTask
*/
-class SoundcloudUploadTask implements AirtimeTask {
+class CeleryTask implements AirtimeTask {
/**
- * @var SoundcloudService
- */
- protected $_service;
-
- public function __construct() {
- $this->_service = new SoundcloudService();
- }
-
- /**
- * Check the ThirdPartyTrackReferences table to see if there are any pending SoundCloud tasks
+ * Check the ThirdPartyTrackReferences table to see if there are any pending tasks
*
* @return bool true if there are pending tasks in ThirdPartyTrackReferences
*/
public function shouldBeRun() {
- return !$this->_service->isBrokerTaskQueueEmpty();
+ return !CeleryService::isBrokerTaskQueueEmpty();
}
/**
* Poll the task queue for any completed Celery tasks
*/
public function run() {
- $this->_service->pollBrokerTaskQueue();
+ CeleryService::pollBrokerTaskQueue();
}
}
\ No newline at end of file
diff --git a/airtime_mvc/application/common/interface/OAuth2.php b/airtime_mvc/application/common/interface/OAuth2.php
new file mode 100644
index 000000000..28283c8e8
--- /dev/null
+++ b/airtime_mvc/application/common/interface/OAuth2.php
@@ -0,0 +1,31 @@
+ 'airtime/om/BaseCcWebstreamMetadataQuery.php',
'BaseCcWebstreamPeer' => 'airtime/om/BaseCcWebstreamPeer.php',
'BaseCcWebstreamQuery' => 'airtime/om/BaseCcWebstreamQuery.php',
+ 'BaseCeleryTasks' => 'airtime/om/BaseCeleryTasks.php',
+ 'BaseCeleryTasksPeer' => 'airtime/om/BaseCeleryTasksPeer.php',
+ 'BaseCeleryTasksQuery' => 'airtime/om/BaseCeleryTasksQuery.php',
'BaseCloudFile' => 'airtime/om/BaseCloudFile.php',
'BaseCloudFilePeer' => 'airtime/om/BaseCloudFilePeer.php',
'BaseCloudFileQuery' => 'airtime/om/BaseCloudFileQuery.php',
@@ -238,6 +241,10 @@ return array (
'CcWebstreamPeer' => 'airtime/CcWebstreamPeer.php',
'CcWebstreamQuery' => 'airtime/CcWebstreamQuery.php',
'CcWebstreamTableMap' => 'airtime/map/CcWebstreamTableMap.php',
+ 'CeleryTasks' => 'airtime/CeleryTasks.php',
+ 'CeleryTasksPeer' => 'airtime/CeleryTasksPeer.php',
+ 'CeleryTasksQuery' => 'airtime/CeleryTasksQuery.php',
+ 'CeleryTasksTableMap' => 'airtime/map/CeleryTasksTableMap.php',
'CloudFile' => 'airtime/CloudFile.php',
'CloudFilePeer' => 'airtime/CloudFilePeer.php',
'CloudFileQuery' => 'airtime/CloudFileQuery.php',
diff --git a/airtime_mvc/application/configs/constants.php b/airtime_mvc/application/configs/constants.php
index 2b8337e8c..33247cbcc 100644
--- a/airtime_mvc/application/configs/constants.php
+++ b/airtime_mvc/application/configs/constants.php
@@ -81,24 +81,6 @@ define('UI_PLAYLISTCONTROLLER_OBJ_SESSNAME', 'PLAYLISTCONTROLLER_OBJ');
/*define('UI_PLAYLIST_SESSNAME', 'PLAYLIST');
define('UI_BLOCK_SESSNAME', 'BLOCK');*/
-
-// Soundcloud contants
-/**
- * @var string status string for pending Celery tasks
- */
-define('CELERY_PENDING_STATUS', 'PENDING');
-
-/**
- * @var string status string for successful Celery tasks
- */
-define('CELERY_SUCCESS_STATUS', 'SUCCESS');
-
-/**
- * @var string status string for failed Celery tasks
- */
-define('CELERY_FAILED_STATUS', 'FAILED');
-
-
//WHMCS integration
define("WHMCS_API_URL", "https://account.sourcefabric.com/includes/api.php");
define("SUBDOMAIN_WHMCS_CUSTOM_FIELD_NAME", "Choose your domain");
@@ -113,3 +95,11 @@ define('PROVISIONING_STATUS_ACTIVE' , 'Active');
//TuneIn integration
define("TUNEIN_API_URL", "http://air.radiotime.com/Playing.ashx");
+// Celery
+define('CELERY_PENDING_STATUS', 'PENDING');
+define('CELERY_SUCCESS_STATUS', 'SUCCESS');
+define('CELERY_FAILED_STATUS', 'FAILED');
+
+// Celery Services
+define('SOUNDCLOUD_SERVICE_NAME', 'soundcloud');
+
diff --git a/airtime_mvc/application/controllers/upgrade_sql/airtime_2.5.13/upgrade.sql b/airtime_mvc/application/controllers/upgrade_sql/airtime_2.5.13/upgrade.sql
index 15a6432d7..fbf7235bf 100644
--- a/airtime_mvc/application/controllers/upgrade_sql/airtime_2.5.13/upgrade.sql
+++ b/airtime_mvc/application/controllers/upgrade_sql/airtime_2.5.13/upgrade.sql
@@ -1,19 +1,41 @@
+-----------------------------------------------------------------------
+-- third_party_track_references
+-----------------------------------------------------------------------
+
CREATE TABLE IF NOT EXISTS "third_party_track_references"
(
"id" serial NOT NULL,
"service" VARCHAR(256) NOT NULL,
"foreign_id" VARCHAR(256),
- "broker_task_id" VARCHAR(256),
- "broker_task_name" VARCHAR(256),
- "broker_task_dispatch_time" TIMESTAMP,
"file_id" INTEGER NOT NULL,
- "status" VARCHAR(256) NOT NULL,
+ "upload_time" TIMESTAMP,
+ "status" VARCHAR(256),
PRIMARY KEY ("id"),
- CONSTRAINT "broker_task_id_unique" UNIQUE ("broker_task_id"),
CONSTRAINT "foreign_id_unique" UNIQUE ("foreign_id")
);
+-----------------------------------------------------------------------
+-- celery_tasks
+-----------------------------------------------------------------------
+
+CREATE TABLE IF NOT EXISTS "celery_tasks"
+(
+ "id" VARCHAR(256) NOT NULL,
+ "track_reference" INTEGER NOT NULL,
+ "name" VARCHAR(256),
+ "dispatch_time" TIMESTAMP,
+ "status" VARCHAR(256) NOT NULL,
+ PRIMARY KEY ("id"),
+ CONSTRAINT "id_unique" UNIQUE ("id")
+);
+
+
ALTER TABLE "third_party_track_references" ADD CONSTRAINT "track_reference_fkey"
FOREIGN KEY ("file_id")
REFERENCES "cc_files" ("id")
ON DELETE CASCADE;
+
+ALTER TABLE "celery_tasks" ADD CONSTRAINT "celery_service_fkey"
+ FOREIGN KEY ("track_reference")
+ REFERENCES "third_party_track_references" ("id")
+ ON DELETE CASCADE;
diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php
index 0ac3c199a..5bb478e7b 100644
--- a/airtime_mvc/application/models/Preference.php
+++ b/airtime_mvc/application/models/Preference.php
@@ -1461,4 +1461,14 @@ class Application_Model_Preference
self::setValue("soundcloud_request_token", $value);
}
+ // TaskManager Lock Timestamp
+
+ public static function getTaskManagerLock() {
+ return self::getValue("task_manager_lock");
+ }
+
+ public static function setTaskManagerLock($value) {
+ self::setValue("task_manager_lock", $value);
+ }
+
}
diff --git a/airtime_mvc/application/models/RabbitMq.php b/airtime_mvc/application/models/RabbitMq.php
index 6f64c1643..87a89336d 100644
--- a/airtime_mvc/application/models/RabbitMq.php
+++ b/airtime_mvc/application/models/RabbitMq.php
@@ -6,19 +6,6 @@ class Application_Model_RabbitMq
{
public static $doPush = false;
- /**
- * @var int milliseconds (for compatibility with celery) until we consider a message to have timed out
- */
- public static $_CELERY_MESSAGE_TIMEOUT = 600000; // 10 minutes
-
- /**
- * We have to use celeryresults (the default results exchange) because php-celery doesn't support
- * named results exchanges.
- *
- * @var string exchange for celery task results
- */
- public static $_CELERY_RESULTS_EXCHANGE = 'celeryresults';
-
/**
* Sets a flag to push the schedule at the end of the request.
*/
@@ -56,73 +43,6 @@ class Application_Model_RabbitMq
$conn->close();
}
- /**
- * Connect to the Celery daemon via amqp
- *
- * @param $config array the airtime configuration array
- * @param $exchange string the amqp exchange name
- * @param $queue string the amqp queue name
- *
- * @return Celery the Celery connection object
- *
- * @throws Exception when a connection error occurs
- */
- private static function _setupCeleryExchange($config, $exchange, $queue) {
- return new Celery($config["rabbitmq"]["host"],
- $config["rabbitmq"]["user"],
- $config["rabbitmq"]["password"],
- $config["rabbitmq"]["vhost"],
- $exchange, // Exchange name
- $queue, // Binding/queue
- $config["rabbitmq"]["port"],
- false, // Connector
- true, // Persistent messages
- self::$_CELERY_MESSAGE_TIMEOUT); // Result expiration
- }
-
- /**
- * Send an amqp message to Celery the airtime-celery daemon to perform a task
- *
- * @param $task string the Celery task name
- * @param $exchange string the amqp exchange name
- * @param $data array an associative array containing arguments for the Celery task
- *
- * @return string the task identifier for the started Celery task so we can fetch the
- * results asynchronously later
- *
- * @throws CeleryException when no message is found
- */
- public static function sendCeleryMessage($task, $exchange, $data) {
- $config = parse_ini_file(self::_getRmqConfigPath(), true);
- $queue = $routingKey = $exchange;
- $c = self::_setupCeleryExchange($config, $exchange, $queue); // Use the exchange name for the queue
- $result = $c->PostTask($task, $data, true, $routingKey); // and routing key
- return $result->getId();
- }
-
- /**
- * Given a task name and identifier, check the Celery results queue for any
- * corresponding messages
- *
- * @param $task string the Celery task name
- * @param $id string the Celery task identifier
- *
- * @return object the message object
- *
- * @throws CeleryException when no message is found
- */
- public static function getAsyncResultMessage($task, $id) {
- $config = parse_ini_file(self::_getRmqConfigPath(), true);
- $queue = self::$_CELERY_RESULTS_EXCHANGE . "." . $task;
- $c = self::_setupCeleryExchange($config, self::$_CELERY_RESULTS_EXCHANGE, $queue);
- $message = $c->getAsyncResultMessage($task, $id);
-
- if ($message == FALSE) {
- throw new CeleryException("Failed to get message for task $task with ID $id");
- }
- return $message;
- }
-
public static function SendMessageToPypo($event_type, $md)
{
$md["event_type"] = $event_type;
@@ -160,7 +80,7 @@ class Application_Model_RabbitMq
self::sendMessage($exchange, 'direct', true, $data);
}
- private static function _getRmqConfigPath() {
+ public static function getRmqConfigPath() {
//Hack for Airtime Pro. The RabbitMQ settings for communicating with airtime_analyzer are global
//and shared between all instances on Airtime Pro.
$CC_CONFIG = Config::getConfig();
@@ -180,7 +100,7 @@ class Application_Model_RabbitMq
public static function SendMessageToAnalyzer($tmpFilePath, $importedStorageDirectory, $originalFilename,
$callbackUrl, $apiKey, $storageBackend, $filePrefix)
{
- $config = parse_ini_file(self::_getRmqConfigPath(), true);
+ $config = parse_ini_file(self::getRmqConfigPath(), true);
$conn = new AMQPConnection($config["rabbitmq"]["host"],
$config["rabbitmq"]["port"],
$config["rabbitmq"]["user"],
diff --git a/airtime_mvc/application/models/airtime/CeleryTasks.php b/airtime_mvc/application/models/airtime/CeleryTasks.php
new file mode 100644
index 000000000..f91e22a5d
--- /dev/null
+++ b/airtime_mvc/application/models/airtime/CeleryTasks.php
@@ -0,0 +1,18 @@
+addRelation('CcBlockcontents', 'CcBlockcontents', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null, 'CcBlockcontentss');
$this->addRelation('CcSchedule', 'CcSchedule', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null, 'CcSchedules');
$this->addRelation('CcPlayoutHistory', 'CcPlayoutHistory', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null, 'CcPlayoutHistorys');
+ $this->addRelation('ThirdPartyTrackReferences', 'ThirdPartyTrackReferences', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null, 'ThirdPartyTrackReferencess');
} // buildRelations()
} // CcFilesTableMap
diff --git a/airtime_mvc/application/models/airtime/map/CcPlayoutHistoryTemplateTableMap.php b/airtime_mvc/application/models/airtime/map/CcPlayoutHistoryTemplateTableMap.php
index 23c00c076..78be57d28 100644
--- a/airtime_mvc/application/models/airtime/map/CcPlayoutHistoryTemplateTableMap.php
+++ b/airtime_mvc/application/models/airtime/map/CcPlayoutHistoryTemplateTableMap.php
@@ -51,7 +51,6 @@ class CcPlayoutHistoryTemplateTableMap extends TableMap
public function buildRelations()
{
$this->addRelation('CcPlayoutHistoryTemplateField', 'CcPlayoutHistoryTemplateField', RelationMap::ONE_TO_MANY, array('id' => 'template_id', ), 'CASCADE', null, 'CcPlayoutHistoryTemplateFields');
- $this->addRelation('ThirdPartyTrackReferences', 'ThirdPartyTrackReferences', RelationMap::ONE_TO_MANY, array('id' => 'file_id', ), 'CASCADE', null, 'ThirdPartyTrackReferencess');
} // buildRelations()
} // CcPlayoutHistoryTemplateTableMap
diff --git a/airtime_mvc/application/models/airtime/map/CeleryTasksTableMap.php b/airtime_mvc/application/models/airtime/map/CeleryTasksTableMap.php
new file mode 100644
index 000000000..f2ed15cb6
--- /dev/null
+++ b/airtime_mvc/application/models/airtime/map/CeleryTasksTableMap.php
@@ -0,0 +1,57 @@
+setName('celery_tasks');
+ $this->setPhpName('CeleryTasks');
+ $this->setClassname('CeleryTasks');
+ $this->setPackage('airtime');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addPrimaryKey('id', 'DbId', 'VARCHAR', true, 256, null);
+ $this->addForeignKey('track_reference', 'DbTrackReference', 'INTEGER', 'third_party_track_references', 'id', true, null, null);
+ $this->addColumn('name', 'DbName', 'VARCHAR', false, 256, null);
+ $this->addColumn('dispatch_time', 'DbDispatchTime', 'TIMESTAMP', false, null, null);
+ $this->addColumn('status', 'DbStatus', 'VARCHAR', true, 256, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('ThirdPartyTrackReferences', 'ThirdPartyTrackReferences', RelationMap::MANY_TO_ONE, array('track_reference' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+} // CeleryTasksTableMap
diff --git a/airtime_mvc/application/models/airtime/map/ThirdPartyTrackReferencesTableMap.php b/airtime_mvc/application/models/airtime/map/ThirdPartyTrackReferencesTableMap.php
index 07f49e86a..98b907c19 100644
--- a/airtime_mvc/application/models/airtime/map/ThirdPartyTrackReferencesTableMap.php
+++ b/airtime_mvc/application/models/airtime/map/ThirdPartyTrackReferencesTableMap.php
@@ -42,11 +42,9 @@ class ThirdPartyTrackReferencesTableMap extends TableMap
$this->addPrimaryKey('id', 'DbId', 'INTEGER', true, null, null);
$this->addColumn('service', 'DbService', 'VARCHAR', true, 256, null);
$this->addColumn('foreign_id', 'DbForeignId', 'VARCHAR', false, 256, null);
- $this->addColumn('broker_task_id', 'DbBrokerTaskId', 'VARCHAR', false, 256, null);
- $this->addColumn('broker_task_name', 'DbBrokerTaskName', 'VARCHAR', false, 256, null);
- $this->addColumn('broker_task_dispatch_time', 'DbBrokerTaskDispatchTime', 'TIMESTAMP', false, null, null);
- $this->addForeignKey('file_id', 'DbFileId', 'INTEGER', 'cc_playout_history_template', 'id', true, null, null);
- $this->addColumn('status', 'DbStatus', 'VARCHAR', true, 256, null);
+ $this->addForeignKey('file_id', 'DbFileId', 'INTEGER', 'cc_files', 'id', true, null, null);
+ $this->addColumn('upload_time', 'DbUploadTime', 'TIMESTAMP', false, null, null);
+ $this->addColumn('status', 'DbStatus', 'VARCHAR', false, 256, null);
// validators
} // initialize()
@@ -55,7 +53,8 @@ class ThirdPartyTrackReferencesTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('CcPlayoutHistoryTemplate', 'CcPlayoutHistoryTemplate', RelationMap::MANY_TO_ONE, array('file_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('CcFiles', 'CcFiles', RelationMap::MANY_TO_ONE, array('file_id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('CeleryTasks', 'CeleryTasks', RelationMap::ONE_TO_MANY, array('id' => 'track_reference', ), 'CASCADE', null, 'CeleryTaskss');
} // buildRelations()
} // ThirdPartyTrackReferencesTableMap
diff --git a/airtime_mvc/application/models/airtime/om/BaseCcFiles.php b/airtime_mvc/application/models/airtime/om/BaseCcFiles.php
index ef2d942dc..faa0964c0 100644
--- a/airtime_mvc/application/models/airtime/om/BaseCcFiles.php
+++ b/airtime_mvc/application/models/airtime/om/BaseCcFiles.php
@@ -521,6 +521,12 @@ abstract class BaseCcFiles extends BaseObject implements Persistent
protected $collCcPlayoutHistorys;
protected $collCcPlayoutHistorysPartial;
+ /**
+ * @var PropelObjectCollection|ThirdPartyTrackReferences[] Collection to store aggregation of ThirdPartyTrackReferences objects.
+ */
+ protected $collThirdPartyTrackReferencess;
+ protected $collThirdPartyTrackReferencessPartial;
+
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
@@ -577,6 +583,12 @@ abstract class BaseCcFiles extends BaseObject implements Persistent
*/
protected $ccPlayoutHistorysScheduledForDeletion = null;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $thirdPartyTrackReferencessScheduledForDeletion = null;
+
/**
* Applies default values to this object.
* This method should be called from the object's constructor (or
@@ -3298,6 +3310,8 @@ abstract class BaseCcFiles extends BaseObject implements Persistent
$this->collCcPlayoutHistorys = null;
+ $this->collThirdPartyTrackReferencess = null;
+
} // if (deep)
}
@@ -3550,6 +3564,23 @@ abstract class BaseCcFiles extends BaseObject implements Persistent
}
}
+ if ($this->thirdPartyTrackReferencessScheduledForDeletion !== null) {
+ if (!$this->thirdPartyTrackReferencessScheduledForDeletion->isEmpty()) {
+ ThirdPartyTrackReferencesQuery::create()
+ ->filterByPrimaryKeys($this->thirdPartyTrackReferencessScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->thirdPartyTrackReferencessScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collThirdPartyTrackReferencess !== null) {
+ foreach ($this->collThirdPartyTrackReferencess as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -4187,6 +4218,14 @@ abstract class BaseCcFiles extends BaseObject implements Persistent
}
}
+ if ($this->collThirdPartyTrackReferencess !== null) {
+ foreach ($this->collThirdPartyTrackReferencess as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -4569,6 +4608,9 @@ abstract class BaseCcFiles extends BaseObject implements Persistent
if (null !== $this->collCcPlayoutHistorys) {
$result['CcPlayoutHistorys'] = $this->collCcPlayoutHistorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
+ if (null !== $this->collThirdPartyTrackReferencess) {
+ $result['ThirdPartyTrackReferencess'] = $this->collThirdPartyTrackReferencess->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
}
return $result;
@@ -5170,6 +5212,12 @@ abstract class BaseCcFiles extends BaseObject implements Persistent
}
}
+ foreach ($this->getThirdPartyTrackReferencess() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addThirdPartyTrackReferences($relObj->copy($deepCopy));
+ }
+ }
+
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -5405,6 +5453,9 @@ abstract class BaseCcFiles extends BaseObject implements Persistent
if ('CcPlayoutHistory' == $relationName) {
$this->initCcPlayoutHistorys();
}
+ if ('ThirdPartyTrackReferences' == $relationName) {
+ $this->initThirdPartyTrackReferencess();
+ }
}
/**
@@ -6957,6 +7008,231 @@ abstract class BaseCcFiles extends BaseObject implements Persistent
return $this->getCcPlayoutHistorys($query, $con);
}
+ /**
+ * Clears out the collThirdPartyTrackReferencess collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return CcFiles The current object (for fluent API support)
+ * @see addThirdPartyTrackReferencess()
+ */
+ public function clearThirdPartyTrackReferencess()
+ {
+ $this->collThirdPartyTrackReferencess = null; // important to set this to null since that means it is uninitialized
+ $this->collThirdPartyTrackReferencessPartial = null;
+
+ return $this;
+ }
+
+ /**
+ * reset is the collThirdPartyTrackReferencess collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialThirdPartyTrackReferencess($v = true)
+ {
+ $this->collThirdPartyTrackReferencessPartial = $v;
+ }
+
+ /**
+ * Initializes the collThirdPartyTrackReferencess collection.
+ *
+ * By default this just sets the collThirdPartyTrackReferencess collection to an empty array (like clearcollThirdPartyTrackReferencess());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initThirdPartyTrackReferencess($overrideExisting = true)
+ {
+ if (null !== $this->collThirdPartyTrackReferencess && !$overrideExisting) {
+ return;
+ }
+ $this->collThirdPartyTrackReferencess = new PropelObjectCollection();
+ $this->collThirdPartyTrackReferencess->setModel('ThirdPartyTrackReferences');
+ }
+
+ /**
+ * Gets an array of ThirdPartyTrackReferences objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this CcFiles is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @return PropelObjectCollection|ThirdPartyTrackReferences[] List of ThirdPartyTrackReferences objects
+ * @throws PropelException
+ */
+ public function getThirdPartyTrackReferencess($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collThirdPartyTrackReferencessPartial && !$this->isNew();
+ if (null === $this->collThirdPartyTrackReferencess || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collThirdPartyTrackReferencess) {
+ // return empty collection
+ $this->initThirdPartyTrackReferencess();
+ } else {
+ $collThirdPartyTrackReferencess = ThirdPartyTrackReferencesQuery::create(null, $criteria)
+ ->filterByCcFiles($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collThirdPartyTrackReferencessPartial && count($collThirdPartyTrackReferencess)) {
+ $this->initThirdPartyTrackReferencess(false);
+
+ foreach ($collThirdPartyTrackReferencess as $obj) {
+ if (false == $this->collThirdPartyTrackReferencess->contains($obj)) {
+ $this->collThirdPartyTrackReferencess->append($obj);
+ }
+ }
+
+ $this->collThirdPartyTrackReferencessPartial = true;
+ }
+
+ $collThirdPartyTrackReferencess->getInternalIterator()->rewind();
+
+ return $collThirdPartyTrackReferencess;
+ }
+
+ if ($partial && $this->collThirdPartyTrackReferencess) {
+ foreach ($this->collThirdPartyTrackReferencess as $obj) {
+ if ($obj->isNew()) {
+ $collThirdPartyTrackReferencess[] = $obj;
+ }
+ }
+ }
+
+ $this->collThirdPartyTrackReferencess = $collThirdPartyTrackReferencess;
+ $this->collThirdPartyTrackReferencessPartial = false;
+ }
+ }
+
+ return $this->collThirdPartyTrackReferencess;
+ }
+
+ /**
+ * Sets a collection of ThirdPartyTrackReferences objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param PropelCollection $thirdPartyTrackReferencess A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ * @return CcFiles The current object (for fluent API support)
+ */
+ public function setThirdPartyTrackReferencess(PropelCollection $thirdPartyTrackReferencess, PropelPDO $con = null)
+ {
+ $thirdPartyTrackReferencessToDelete = $this->getThirdPartyTrackReferencess(new Criteria(), $con)->diff($thirdPartyTrackReferencess);
+
+
+ $this->thirdPartyTrackReferencessScheduledForDeletion = $thirdPartyTrackReferencessToDelete;
+
+ foreach ($thirdPartyTrackReferencessToDelete as $thirdPartyTrackReferencesRemoved) {
+ $thirdPartyTrackReferencesRemoved->setCcFiles(null);
+ }
+
+ $this->collThirdPartyTrackReferencess = null;
+ foreach ($thirdPartyTrackReferencess as $thirdPartyTrackReferences) {
+ $this->addThirdPartyTrackReferences($thirdPartyTrackReferences);
+ }
+
+ $this->collThirdPartyTrackReferencess = $thirdPartyTrackReferencess;
+ $this->collThirdPartyTrackReferencessPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related ThirdPartyTrackReferences objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related ThirdPartyTrackReferences objects.
+ * @throws PropelException
+ */
+ public function countThirdPartyTrackReferencess(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collThirdPartyTrackReferencessPartial && !$this->isNew();
+ if (null === $this->collThirdPartyTrackReferencess || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collThirdPartyTrackReferencess) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getThirdPartyTrackReferencess());
+ }
+ $query = ThirdPartyTrackReferencesQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCcFiles($this)
+ ->count($con);
+ }
+
+ return count($this->collThirdPartyTrackReferencess);
+ }
+
+ /**
+ * Method called to associate a ThirdPartyTrackReferences object to this object
+ * through the ThirdPartyTrackReferences foreign key attribute.
+ *
+ * @param ThirdPartyTrackReferences $l ThirdPartyTrackReferences
+ * @return CcFiles The current object (for fluent API support)
+ */
+ public function addThirdPartyTrackReferences(ThirdPartyTrackReferences $l)
+ {
+ if ($this->collThirdPartyTrackReferencess === null) {
+ $this->initThirdPartyTrackReferencess();
+ $this->collThirdPartyTrackReferencessPartial = true;
+ }
+
+ if (!in_array($l, $this->collThirdPartyTrackReferencess->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddThirdPartyTrackReferences($l);
+
+ if ($this->thirdPartyTrackReferencessScheduledForDeletion and $this->thirdPartyTrackReferencessScheduledForDeletion->contains($l)) {
+ $this->thirdPartyTrackReferencessScheduledForDeletion->remove($this->thirdPartyTrackReferencessScheduledForDeletion->search($l));
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ThirdPartyTrackReferences $thirdPartyTrackReferences The thirdPartyTrackReferences object to add.
+ */
+ protected function doAddThirdPartyTrackReferences($thirdPartyTrackReferences)
+ {
+ $this->collThirdPartyTrackReferencess[]= $thirdPartyTrackReferences;
+ $thirdPartyTrackReferences->setCcFiles($this);
+ }
+
+ /**
+ * @param ThirdPartyTrackReferences $thirdPartyTrackReferences The thirdPartyTrackReferences object to remove.
+ * @return CcFiles The current object (for fluent API support)
+ */
+ public function removeThirdPartyTrackReferences($thirdPartyTrackReferences)
+ {
+ if ($this->getThirdPartyTrackReferencess()->contains($thirdPartyTrackReferences)) {
+ $this->collThirdPartyTrackReferencess->remove($this->collThirdPartyTrackReferencess->search($thirdPartyTrackReferences));
+ if (null === $this->thirdPartyTrackReferencessScheduledForDeletion) {
+ $this->thirdPartyTrackReferencessScheduledForDeletion = clone $this->collThirdPartyTrackReferencess;
+ $this->thirdPartyTrackReferencessScheduledForDeletion->clear();
+ }
+ $this->thirdPartyTrackReferencessScheduledForDeletion[]= clone $thirdPartyTrackReferences;
+ $thirdPartyTrackReferences->setCcFiles(null);
+ }
+
+ return $this;
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -7086,6 +7362,11 @@ abstract class BaseCcFiles extends BaseObject implements Persistent
$o->clearAllReferences($deep);
}
}
+ if ($this->collThirdPartyTrackReferencess) {
+ foreach ($this->collThirdPartyTrackReferencess as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
if ($this->aFkOwner instanceof Persistent) {
$this->aFkOwner->clearAllReferences($deep);
}
@@ -7123,6 +7404,10 @@ abstract class BaseCcFiles extends BaseObject implements Persistent
$this->collCcPlayoutHistorys->clearIterator();
}
$this->collCcPlayoutHistorys = null;
+ if ($this->collThirdPartyTrackReferencess instanceof PropelCollection) {
+ $this->collThirdPartyTrackReferencess->clearIterator();
+ }
+ $this->collThirdPartyTrackReferencess = null;
$this->aFkOwner = null;
$this->aCcSubjsRelatedByDbEditedby = null;
$this->aCcMusicDirs = null;
diff --git a/airtime_mvc/application/models/airtime/om/BaseCcFilesPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcFilesPeer.php
index c6928a0d2..cbe44f498 100644
--- a/airtime_mvc/application/models/airtime/om/BaseCcFilesPeer.php
+++ b/airtime_mvc/application/models/airtime/om/BaseCcFilesPeer.php
@@ -723,6 +723,9 @@ abstract class BaseCcFilesPeer
// Invalidate objects in CcPlayoutHistoryPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
CcPlayoutHistoryPeer::clearInstancePool();
+ // Invalidate objects in ThirdPartyTrackReferencesPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ ThirdPartyTrackReferencesPeer::clearInstancePool();
}
/**
diff --git a/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php
index 01357b305..1ed4e004f 100644
--- a/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php
+++ b/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php
@@ -190,6 +190,10 @@
* @method CcFilesQuery rightJoinCcPlayoutHistory($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CcPlayoutHistory relation
* @method CcFilesQuery innerJoinCcPlayoutHistory($relationAlias = null) Adds a INNER JOIN clause to the query using the CcPlayoutHistory relation
*
+ * @method CcFilesQuery leftJoinThirdPartyTrackReferences($relationAlias = null) Adds a LEFT JOIN clause to the query using the ThirdPartyTrackReferences relation
+ * @method CcFilesQuery rightJoinThirdPartyTrackReferences($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ThirdPartyTrackReferences relation
+ * @method CcFilesQuery innerJoinThirdPartyTrackReferences($relationAlias = null) Adds a INNER JOIN clause to the query using the ThirdPartyTrackReferences relation
+ *
* @method CcFiles findOne(PropelPDO $con = null) Return the first CcFiles matching the query
* @method CcFiles findOneOrCreate(PropelPDO $con = null) Return the first CcFiles matching the query, or a new CcFiles object populated from the query conditions when no match is found
*
@@ -3509,6 +3513,80 @@ abstract class BaseCcFilesQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'CcPlayoutHistory', 'CcPlayoutHistoryQuery');
}
+ /**
+ * Filter the query by a related ThirdPartyTrackReferences object
+ *
+ * @param ThirdPartyTrackReferences|PropelObjectCollection $thirdPartyTrackReferences the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CcFilesQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByThirdPartyTrackReferences($thirdPartyTrackReferences, $comparison = null)
+ {
+ if ($thirdPartyTrackReferences instanceof ThirdPartyTrackReferences) {
+ return $this
+ ->addUsingAlias(CcFilesPeer::ID, $thirdPartyTrackReferences->getDbFileId(), $comparison);
+ } elseif ($thirdPartyTrackReferences instanceof PropelObjectCollection) {
+ return $this
+ ->useThirdPartyTrackReferencesQuery()
+ ->filterByPrimaryKeys($thirdPartyTrackReferences->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByThirdPartyTrackReferences() only accepts arguments of type ThirdPartyTrackReferences or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ThirdPartyTrackReferences relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CcFilesQuery The current query, for fluid interface
+ */
+ public function joinThirdPartyTrackReferences($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ThirdPartyTrackReferences');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ThirdPartyTrackReferences');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ThirdPartyTrackReferences relation ThirdPartyTrackReferences object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ThirdPartyTrackReferencesQuery A secondary query class using the current class as primary query
+ */
+ public function useThirdPartyTrackReferencesQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinThirdPartyTrackReferences($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ThirdPartyTrackReferences', 'ThirdPartyTrackReferencesQuery');
+ }
+
/**
* Exclude object from result
*
diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplate.php b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplate.php
index a78619c7c..6a2b9230f 100644
--- a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplate.php
+++ b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplate.php
@@ -53,12 +53,6 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persis
protected $collCcPlayoutHistoryTemplateFields;
protected $collCcPlayoutHistoryTemplateFieldsPartial;
- /**
- * @var PropelObjectCollection|ThirdPartyTrackReferences[] Collection to store aggregation of ThirdPartyTrackReferences objects.
- */
- protected $collThirdPartyTrackReferencess;
- protected $collThirdPartyTrackReferencessPartial;
-
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
@@ -85,12 +79,6 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persis
*/
protected $ccPlayoutHistoryTemplateFieldsScheduledForDeletion = null;
- /**
- * An array of objects scheduled for deletion.
- * @var PropelObjectCollection
- */
- protected $thirdPartyTrackReferencessScheduledForDeletion = null;
-
/**
* Get the [id] column value.
*
@@ -295,8 +283,6 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persis
$this->collCcPlayoutHistoryTemplateFields = null;
- $this->collThirdPartyTrackReferencess = null;
-
} // if (deep)
}
@@ -438,23 +424,6 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persis
}
}
- if ($this->thirdPartyTrackReferencessScheduledForDeletion !== null) {
- if (!$this->thirdPartyTrackReferencessScheduledForDeletion->isEmpty()) {
- ThirdPartyTrackReferencesQuery::create()
- ->filterByPrimaryKeys($this->thirdPartyTrackReferencessScheduledForDeletion->getPrimaryKeys(false))
- ->delete($con);
- $this->thirdPartyTrackReferencessScheduledForDeletion = null;
- }
- }
-
- if ($this->collThirdPartyTrackReferencess !== null) {
- foreach ($this->collThirdPartyTrackReferencess as $referrerFK) {
- if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
- $affectedRows += $referrerFK->save($con);
- }
- }
- }
-
$this->alreadyInSave = false;
}
@@ -620,14 +589,6 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persis
}
}
- if ($this->collThirdPartyTrackReferencess !== null) {
- foreach ($this->collThirdPartyTrackReferencess as $referrerFK) {
- if (!$referrerFK->validate($columns)) {
- $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
- }
- }
- }
-
$this->alreadyInValidation = false;
}
@@ -714,9 +675,6 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persis
if (null !== $this->collCcPlayoutHistoryTemplateFields) {
$result['CcPlayoutHistoryTemplateFields'] = $this->collCcPlayoutHistoryTemplateFields->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
- if (null !== $this->collThirdPartyTrackReferencess) {
- $result['ThirdPartyTrackReferencess'] = $this->collThirdPartyTrackReferencess->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
- }
}
return $result;
@@ -880,12 +838,6 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persis
}
}
- foreach ($this->getThirdPartyTrackReferencess() as $relObj) {
- if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
- $copyObj->addThirdPartyTrackReferences($relObj->copy($deepCopy));
- }
- }
-
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -950,9 +902,6 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persis
if ('CcPlayoutHistoryTemplateField' == $relationName) {
$this->initCcPlayoutHistoryTemplateFields();
}
- if ('ThirdPartyTrackReferences' == $relationName) {
- $this->initThirdPartyTrackReferencess();
- }
}
/**
@@ -1180,231 +1129,6 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persis
return $this;
}
- /**
- * Clears out the collThirdPartyTrackReferencess collection
- *
- * This does not modify the database; however, it will remove any associated objects, causing
- * them to be refetched by subsequent calls to accessor method.
- *
- * @return CcPlayoutHistoryTemplate The current object (for fluent API support)
- * @see addThirdPartyTrackReferencess()
- */
- public function clearThirdPartyTrackReferencess()
- {
- $this->collThirdPartyTrackReferencess = null; // important to set this to null since that means it is uninitialized
- $this->collThirdPartyTrackReferencessPartial = null;
-
- return $this;
- }
-
- /**
- * reset is the collThirdPartyTrackReferencess collection loaded partially
- *
- * @return void
- */
- public function resetPartialThirdPartyTrackReferencess($v = true)
- {
- $this->collThirdPartyTrackReferencessPartial = $v;
- }
-
- /**
- * Initializes the collThirdPartyTrackReferencess collection.
- *
- * By default this just sets the collThirdPartyTrackReferencess collection to an empty array (like clearcollThirdPartyTrackReferencess());
- * however, you may wish to override this method in your stub class to provide setting appropriate
- * to your application -- for example, setting the initial array to the values stored in database.
- *
- * @param boolean $overrideExisting If set to true, the method call initializes
- * the collection even if it is not empty
- *
- * @return void
- */
- public function initThirdPartyTrackReferencess($overrideExisting = true)
- {
- if (null !== $this->collThirdPartyTrackReferencess && !$overrideExisting) {
- return;
- }
- $this->collThirdPartyTrackReferencess = new PropelObjectCollection();
- $this->collThirdPartyTrackReferencess->setModel('ThirdPartyTrackReferences');
- }
-
- /**
- * Gets an array of ThirdPartyTrackReferences objects which contain a foreign key that references this object.
- *
- * If the $criteria is not null, it is used to always fetch the results from the database.
- * Otherwise the results are fetched from the database the first time, then cached.
- * Next time the same method is called without $criteria, the cached collection is returned.
- * If this CcPlayoutHistoryTemplate is new, it will return
- * an empty collection or the current collection; the criteria is ignored on a new object.
- *
- * @param Criteria $criteria optional Criteria object to narrow the query
- * @param PropelPDO $con optional connection object
- * @return PropelObjectCollection|ThirdPartyTrackReferences[] List of ThirdPartyTrackReferences objects
- * @throws PropelException
- */
- public function getThirdPartyTrackReferencess($criteria = null, PropelPDO $con = null)
- {
- $partial = $this->collThirdPartyTrackReferencessPartial && !$this->isNew();
- if (null === $this->collThirdPartyTrackReferencess || null !== $criteria || $partial) {
- if ($this->isNew() && null === $this->collThirdPartyTrackReferencess) {
- // return empty collection
- $this->initThirdPartyTrackReferencess();
- } else {
- $collThirdPartyTrackReferencess = ThirdPartyTrackReferencesQuery::create(null, $criteria)
- ->filterByCcPlayoutHistoryTemplate($this)
- ->find($con);
- if (null !== $criteria) {
- if (false !== $this->collThirdPartyTrackReferencessPartial && count($collThirdPartyTrackReferencess)) {
- $this->initThirdPartyTrackReferencess(false);
-
- foreach ($collThirdPartyTrackReferencess as $obj) {
- if (false == $this->collThirdPartyTrackReferencess->contains($obj)) {
- $this->collThirdPartyTrackReferencess->append($obj);
- }
- }
-
- $this->collThirdPartyTrackReferencessPartial = true;
- }
-
- $collThirdPartyTrackReferencess->getInternalIterator()->rewind();
-
- return $collThirdPartyTrackReferencess;
- }
-
- if ($partial && $this->collThirdPartyTrackReferencess) {
- foreach ($this->collThirdPartyTrackReferencess as $obj) {
- if ($obj->isNew()) {
- $collThirdPartyTrackReferencess[] = $obj;
- }
- }
- }
-
- $this->collThirdPartyTrackReferencess = $collThirdPartyTrackReferencess;
- $this->collThirdPartyTrackReferencessPartial = false;
- }
- }
-
- return $this->collThirdPartyTrackReferencess;
- }
-
- /**
- * Sets a collection of ThirdPartyTrackReferences objects related by a one-to-many relationship
- * to the current object.
- * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
- * and new objects from the given Propel collection.
- *
- * @param PropelCollection $thirdPartyTrackReferencess A Propel collection.
- * @param PropelPDO $con Optional connection object
- * @return CcPlayoutHistoryTemplate The current object (for fluent API support)
- */
- public function setThirdPartyTrackReferencess(PropelCollection $thirdPartyTrackReferencess, PropelPDO $con = null)
- {
- $thirdPartyTrackReferencessToDelete = $this->getThirdPartyTrackReferencess(new Criteria(), $con)->diff($thirdPartyTrackReferencess);
-
-
- $this->thirdPartyTrackReferencessScheduledForDeletion = $thirdPartyTrackReferencessToDelete;
-
- foreach ($thirdPartyTrackReferencessToDelete as $thirdPartyTrackReferencesRemoved) {
- $thirdPartyTrackReferencesRemoved->setCcPlayoutHistoryTemplate(null);
- }
-
- $this->collThirdPartyTrackReferencess = null;
- foreach ($thirdPartyTrackReferencess as $thirdPartyTrackReferences) {
- $this->addThirdPartyTrackReferences($thirdPartyTrackReferences);
- }
-
- $this->collThirdPartyTrackReferencess = $thirdPartyTrackReferencess;
- $this->collThirdPartyTrackReferencessPartial = false;
-
- return $this;
- }
-
- /**
- * Returns the number of related ThirdPartyTrackReferences objects.
- *
- * @param Criteria $criteria
- * @param boolean $distinct
- * @param PropelPDO $con
- * @return int Count of related ThirdPartyTrackReferences objects.
- * @throws PropelException
- */
- public function countThirdPartyTrackReferencess(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
- {
- $partial = $this->collThirdPartyTrackReferencessPartial && !$this->isNew();
- if (null === $this->collThirdPartyTrackReferencess || null !== $criteria || $partial) {
- if ($this->isNew() && null === $this->collThirdPartyTrackReferencess) {
- return 0;
- }
-
- if ($partial && !$criteria) {
- return count($this->getThirdPartyTrackReferencess());
- }
- $query = ThirdPartyTrackReferencesQuery::create(null, $criteria);
- if ($distinct) {
- $query->distinct();
- }
-
- return $query
- ->filterByCcPlayoutHistoryTemplate($this)
- ->count($con);
- }
-
- return count($this->collThirdPartyTrackReferencess);
- }
-
- /**
- * Method called to associate a ThirdPartyTrackReferences object to this object
- * through the ThirdPartyTrackReferences foreign key attribute.
- *
- * @param ThirdPartyTrackReferences $l ThirdPartyTrackReferences
- * @return CcPlayoutHistoryTemplate The current object (for fluent API support)
- */
- public function addThirdPartyTrackReferences(ThirdPartyTrackReferences $l)
- {
- if ($this->collThirdPartyTrackReferencess === null) {
- $this->initThirdPartyTrackReferencess();
- $this->collThirdPartyTrackReferencessPartial = true;
- }
-
- if (!in_array($l, $this->collThirdPartyTrackReferencess->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
- $this->doAddThirdPartyTrackReferences($l);
-
- if ($this->thirdPartyTrackReferencessScheduledForDeletion and $this->thirdPartyTrackReferencessScheduledForDeletion->contains($l)) {
- $this->thirdPartyTrackReferencessScheduledForDeletion->remove($this->thirdPartyTrackReferencessScheduledForDeletion->search($l));
- }
- }
-
- return $this;
- }
-
- /**
- * @param ThirdPartyTrackReferences $thirdPartyTrackReferences The thirdPartyTrackReferences object to add.
- */
- protected function doAddThirdPartyTrackReferences($thirdPartyTrackReferences)
- {
- $this->collThirdPartyTrackReferencess[]= $thirdPartyTrackReferences;
- $thirdPartyTrackReferences->setCcPlayoutHistoryTemplate($this);
- }
-
- /**
- * @param ThirdPartyTrackReferences $thirdPartyTrackReferences The thirdPartyTrackReferences object to remove.
- * @return CcPlayoutHistoryTemplate The current object (for fluent API support)
- */
- public function removeThirdPartyTrackReferences($thirdPartyTrackReferences)
- {
- if ($this->getThirdPartyTrackReferencess()->contains($thirdPartyTrackReferences)) {
- $this->collThirdPartyTrackReferencess->remove($this->collThirdPartyTrackReferencess->search($thirdPartyTrackReferences));
- if (null === $this->thirdPartyTrackReferencessScheduledForDeletion) {
- $this->thirdPartyTrackReferencessScheduledForDeletion = clone $this->collThirdPartyTrackReferencess;
- $this->thirdPartyTrackReferencessScheduledForDeletion->clear();
- }
- $this->thirdPartyTrackReferencessScheduledForDeletion[]= clone $thirdPartyTrackReferences;
- $thirdPartyTrackReferences->setCcPlayoutHistoryTemplate(null);
- }
-
- return $this;
- }
-
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1440,11 +1164,6 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persis
$o->clearAllReferences($deep);
}
}
- if ($this->collThirdPartyTrackReferencess) {
- foreach ($this->collThirdPartyTrackReferencess as $o) {
- $o->clearAllReferences($deep);
- }
- }
$this->alreadyInClearAllReferencesDeep = false;
} // if ($deep)
@@ -1453,10 +1172,6 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persis
$this->collCcPlayoutHistoryTemplateFields->clearIterator();
}
$this->collCcPlayoutHistoryTemplateFields = null;
- if ($this->collThirdPartyTrackReferencess instanceof PropelCollection) {
- $this->collThirdPartyTrackReferencess->clearIterator();
- }
- $this->collThirdPartyTrackReferencess = null;
}
/**
diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplatePeer.php b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplatePeer.php
index f30c447fe..89c7cdc9d 100644
--- a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplatePeer.php
+++ b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplatePeer.php
@@ -368,9 +368,6 @@ abstract class BaseCcPlayoutHistoryTemplatePeer
// Invalidate objects in CcPlayoutHistoryTemplateFieldPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
CcPlayoutHistoryTemplateFieldPeer::clearInstancePool();
- // Invalidate objects in ThirdPartyTrackReferencesPeer instance pool,
- // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- ThirdPartyTrackReferencesPeer::clearInstancePool();
}
/**
diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplateQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplateQuery.php
index 34ed52def..262b0ee2c 100644
--- a/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplateQuery.php
+++ b/airtime_mvc/application/models/airtime/om/BaseCcPlayoutHistoryTemplateQuery.php
@@ -22,10 +22,6 @@
* @method CcPlayoutHistoryTemplateQuery rightJoinCcPlayoutHistoryTemplateField($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CcPlayoutHistoryTemplateField relation
* @method CcPlayoutHistoryTemplateQuery innerJoinCcPlayoutHistoryTemplateField($relationAlias = null) Adds a INNER JOIN clause to the query using the CcPlayoutHistoryTemplateField relation
*
- * @method CcPlayoutHistoryTemplateQuery leftJoinThirdPartyTrackReferences($relationAlias = null) Adds a LEFT JOIN clause to the query using the ThirdPartyTrackReferences relation
- * @method CcPlayoutHistoryTemplateQuery rightJoinThirdPartyTrackReferences($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ThirdPartyTrackReferences relation
- * @method CcPlayoutHistoryTemplateQuery innerJoinThirdPartyTrackReferences($relationAlias = null) Adds a INNER JOIN clause to the query using the ThirdPartyTrackReferences relation
- *
* @method CcPlayoutHistoryTemplate findOne(PropelPDO $con = null) Return the first CcPlayoutHistoryTemplate matching the query
* @method CcPlayoutHistoryTemplate findOneOrCreate(PropelPDO $con = null) Return the first CcPlayoutHistoryTemplate matching the query, or a new CcPlayoutHistoryTemplate object populated from the query conditions when no match is found
*
@@ -405,80 +401,6 @@ abstract class BaseCcPlayoutHistoryTemplateQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'CcPlayoutHistoryTemplateField', 'CcPlayoutHistoryTemplateFieldQuery');
}
- /**
- * Filter the query by a related ThirdPartyTrackReferences object
- *
- * @param ThirdPartyTrackReferences|PropelObjectCollection $thirdPartyTrackReferences the related object to use as filter
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return CcPlayoutHistoryTemplateQuery The current query, for fluid interface
- * @throws PropelException - if the provided filter is invalid.
- */
- public function filterByThirdPartyTrackReferences($thirdPartyTrackReferences, $comparison = null)
- {
- if ($thirdPartyTrackReferences instanceof ThirdPartyTrackReferences) {
- return $this
- ->addUsingAlias(CcPlayoutHistoryTemplatePeer::ID, $thirdPartyTrackReferences->getDbFileId(), $comparison);
- } elseif ($thirdPartyTrackReferences instanceof PropelObjectCollection) {
- return $this
- ->useThirdPartyTrackReferencesQuery()
- ->filterByPrimaryKeys($thirdPartyTrackReferences->getPrimaryKeys())
- ->endUse();
- } else {
- throw new PropelException('filterByThirdPartyTrackReferences() only accepts arguments of type ThirdPartyTrackReferences or PropelCollection');
- }
- }
-
- /**
- * Adds a JOIN clause to the query using the ThirdPartyTrackReferences relation
- *
- * @param string $relationAlias optional alias for the relation
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return CcPlayoutHistoryTemplateQuery The current query, for fluid interface
- */
- public function joinThirdPartyTrackReferences($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- $tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('ThirdPartyTrackReferences');
-
- // create a ModelJoin object for this join
- $join = new ModelJoin();
- $join->setJoinType($joinType);
- $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
- if ($previousJoin = $this->getPreviousJoin()) {
- $join->setPreviousJoin($previousJoin);
- }
-
- // add the ModelJoin to the current object
- if ($relationAlias) {
- $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
- $this->addJoinObject($join, $relationAlias);
- } else {
- $this->addJoinObject($join, 'ThirdPartyTrackReferences');
- }
-
- return $this;
- }
-
- /**
- * Use the ThirdPartyTrackReferences relation ThirdPartyTrackReferences object
- *
- * @see useQuery()
- *
- * @param string $relationAlias optional alias for the relation,
- * to be used as main alias in the secondary query
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
- *
- * @return ThirdPartyTrackReferencesQuery A secondary query class using the current class as primary query
- */
- public function useThirdPartyTrackReferencesQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
- {
- return $this
- ->joinThirdPartyTrackReferences($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'ThirdPartyTrackReferences', 'ThirdPartyTrackReferencesQuery');
- }
-
/**
* Exclude object from result
*
diff --git a/airtime_mvc/application/models/airtime/om/BaseCeleryTasks.php b/airtime_mvc/application/models/airtime/om/BaseCeleryTasks.php
new file mode 100644
index 000000000..c95a5f649
--- /dev/null
+++ b/airtime_mvc/application/models/airtime/om/BaseCeleryTasks.php
@@ -0,0 +1,1119 @@
+id;
+ }
+
+ /**
+ * Get the [track_reference] column value.
+ *
+ * @return int
+ */
+ public function getDbTrackReference()
+ {
+
+ return $this->track_reference;
+ }
+
+ /**
+ * Get the [name] column value.
+ *
+ * @return string
+ */
+ public function getDbName()
+ {
+
+ return $this->name;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [dispatch_time] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is null, then the raw DateTime object will be returned.
+ * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getDbDispatchTime($format = 'Y-m-d H:i:s')
+ {
+ if ($this->dispatch_time === null) {
+ return null;
+ }
+
+
+ try {
+ $dt = new DateTime($this->dispatch_time);
+ } catch (Exception $x) {
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->dispatch_time, true), $x);
+ }
+
+ if ($format === null) {
+ // Because propel.useDateTimeClass is true, we return a DateTime object.
+ return $dt;
+ }
+
+ if (strpos($format, '%') !== false) {
+ return strftime($format, $dt->format('U'));
+ }
+
+ return $dt->format($format);
+
+ }
+
+ /**
+ * Get the [status] column value.
+ *
+ * @return string
+ */
+ public function getDbStatus()
+ {
+
+ return $this->status;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param string $v new value
+ * @return CeleryTasks The current object (for fluent API support)
+ */
+ public function setDbId($v)
+ {
+ if ($v !== null && is_numeric($v)) {
+ $v = (string) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CeleryTasksPeer::ID;
+ }
+
+
+ return $this;
+ } // setDbId()
+
+ /**
+ * Set the value of [track_reference] column.
+ *
+ * @param int $v new value
+ * @return CeleryTasks The current object (for fluent API support)
+ */
+ public function setDbTrackReference($v)
+ {
+ if ($v !== null && is_numeric($v)) {
+ $v = (int) $v;
+ }
+
+ if ($this->track_reference !== $v) {
+ $this->track_reference = $v;
+ $this->modifiedColumns[] = CeleryTasksPeer::TRACK_REFERENCE;
+ }
+
+ if ($this->aThirdPartyTrackReferences !== null && $this->aThirdPartyTrackReferences->getDbId() !== $v) {
+ $this->aThirdPartyTrackReferences = null;
+ }
+
+
+ return $this;
+ } // setDbTrackReference()
+
+ /**
+ * Set the value of [name] column.
+ *
+ * @param string $v new value
+ * @return CeleryTasks The current object (for fluent API support)
+ */
+ public function setDbName($v)
+ {
+ if ($v !== null && is_numeric($v)) {
+ $v = (string) $v;
+ }
+
+ if ($this->name !== $v) {
+ $this->name = $v;
+ $this->modifiedColumns[] = CeleryTasksPeer::NAME;
+ }
+
+
+ return $this;
+ } // setDbName()
+
+ /**
+ * Sets the value of [dispatch_time] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return CeleryTasks The current object (for fluent API support)
+ */
+ public function setDbDispatchTime($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->dispatch_time !== null || $dt !== null) {
+ $currentDateAsString = ($this->dispatch_time !== null && $tmpDt = new DateTime($this->dispatch_time)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->dispatch_time = $newDateAsString;
+ $this->modifiedColumns[] = CeleryTasksPeer::DISPATCH_TIME;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setDbDispatchTime()
+
+ /**
+ * Set the value of [status] column.
+ *
+ * @param string $v new value
+ * @return CeleryTasks The current object (for fluent API support)
+ */
+ public function setDbStatus($v)
+ {
+ if ($v !== null && is_numeric($v)) {
+ $v = (string) $v;
+ }
+
+ if ($this->status !== $v) {
+ $this->status = $v;
+ $this->modifiedColumns[] = CeleryTasksPeer::STATUS;
+ }
+
+
+ return $this;
+ } // setDbStatus()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return true
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-based "start column") is specified so that objects can be hydrated
+ * with a subset of the columns in the resultset rows. This is needed, for example,
+ * for results of JOIN queries where the resultset row includes columns from two or
+ * more tables.
+ *
+ * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
+ * @param int $startcol 0-based offset column which indicates which resultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false)
+ {
+ try {
+
+ $this->id = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null;
+ $this->track_reference = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
+ $this->name = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
+ $this->dispatch_time = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
+ $this->status = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+ $this->postHydrate($row, $startcol, $rehydrate);
+
+ return $startcol + 5; // 5 = CeleryTasksPeer::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating CeleryTasks object", $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+
+ if ($this->aThirdPartyTrackReferences !== null && $this->track_reference !== $this->aThirdPartyTrackReferences->getDbId()) {
+ $this->aThirdPartyTrackReferences = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param PropelPDO $con (optional) The PropelPDO connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $stmt = CeleryTasksPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
+ $row = $stmt->fetch(PDO::FETCH_NUM);
+ $stmt->closeCursor();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aThirdPartyTrackReferences = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param PropelPDO $con
+ * @return void
+ * @throws PropelException
+ * @throws Exception
+ * @see BaseObject::setDeleted()
+ * @see BaseObject::isDeleted()
+ */
+ public function delete(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = CeleryTasksQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @throws Exception
+ * @see doSave()
+ */
+ public function save(PropelPDO $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CeleryTasksPeer::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param PropelPDO $con
+ * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(PropelPDO $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ // We call the save method on the following object(s) if they
+ // were passed to this object by their corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aThirdPartyTrackReferences !== null) {
+ if ($this->aThirdPartyTrackReferences->isModified() || $this->aThirdPartyTrackReferences->isNew()) {
+ $affectedRows += $this->aThirdPartyTrackReferences->save($con);
+ }
+ $this->setThirdPartyTrackReferences($this->aThirdPartyTrackReferences);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(PropelPDO $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CeleryTasksPeer::ID)) {
+ $modifiedColumns[':p' . $index++] = '"id"';
+ }
+ if ($this->isColumnModified(CeleryTasksPeer::TRACK_REFERENCE)) {
+ $modifiedColumns[':p' . $index++] = '"track_reference"';
+ }
+ if ($this->isColumnModified(CeleryTasksPeer::NAME)) {
+ $modifiedColumns[':p' . $index++] = '"name"';
+ }
+ if ($this->isColumnModified(CeleryTasksPeer::DISPATCH_TIME)) {
+ $modifiedColumns[':p' . $index++] = '"dispatch_time"';
+ }
+ if ($this->isColumnModified(CeleryTasksPeer::STATUS)) {
+ $modifiedColumns[':p' . $index++] = '"status"';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO "celery_tasks" (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case '"id"':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_STR);
+ break;
+ case '"track_reference"':
+ $stmt->bindValue($identifier, $this->track_reference, PDO::PARAM_INT);
+ break;
+ case '"name"':
+ $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR);
+ break;
+ case '"dispatch_time"':
+ $stmt->bindValue($identifier, $this->dispatch_time, PDO::PARAM_STR);
+ break;
+ case '"status"':
+ $stmt->bindValue($identifier, $this->status, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param PropelPDO $con
+ *
+ * @see doSave()
+ */
+ protected function doUpdate(PropelPDO $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+ BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
+ }
+
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected $validationFailures = array();
+
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+ /**
+ * Validates the objects modified field values and all objects related to this table.
+ *
+ * If $columns is either a column name or an array of column names
+ * only those columns are validated.
+ *
+ * @param mixed $columns Column name or an array of column names.
+ * @return boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+
+ return true;
+ }
+
+ $this->validationFailures = $res;
+
+ return false;
+ }
+
+ /**
+ * This function performs the validation work for complex object models.
+ *
+ * In addition to checking the current object, all related objects will
+ * also be validated. If all pass then true is returned; otherwise
+ * an aggregated array of ValidationFailed objects will be returned.
+ *
+ * @param array $columns Array of column names to validate.
+ * @return mixed true if all validations pass; array of ValidationFailed objects otherwise.
+ */
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ // We call the validate method on the following object(s) if they
+ // were passed to this object by their corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aThirdPartyTrackReferences !== null) {
+ if (!$this->aThirdPartyTrackReferences->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aThirdPartyTrackReferences->getValidationFailures());
+ }
+ }
+
+
+ if (($retval = CeleryTasksPeer::doValidate($this, $columns)) !== true) {
+ $failureMap = array_merge($failureMap, $retval);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string $name name
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CeleryTasksPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * Retrieves a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @return mixed Value of field at $pos
+ */
+ public function getByPosition($pos)
+ {
+ switch ($pos) {
+ case 0:
+ return $this->getDbId();
+ break;
+ case 1:
+ return $this->getDbTrackReference();
+ break;
+ case 2:
+ return $this->getDbName();
+ break;
+ case 3:
+ return $this->getDbDispatchTime();
+ break;
+ case 4:
+ return $this->getDbStatus();
+ break;
+ default:
+ return null;
+ break;
+ } // switch()
+ }
+
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CeleryTasks'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CeleryTasks'][$this->getPrimaryKey()] = true;
+ $keys = CeleryTasksPeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getDbId(),
+ $keys[1] => $this->getDbTrackReference(),
+ $keys[2] => $this->getDbName(),
+ $keys[3] => $this->getDbDispatchTime(),
+ $keys[4] => $this->getDbStatus(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach ($virtualColumns as $key => $virtualColumn) {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aThirdPartyTrackReferences) {
+ $result['ThirdPartyTrackReferences'] = $this->aThirdPartyTrackReferences->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name peer name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * Defaults to BasePeer::TYPE_PHPNAME
+ * @return void
+ */
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = CeleryTasksPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+
+ $this->setByPosition($pos, $value);
+ }
+
+ /**
+ * Sets a field from the object by Position as specified in the xml schema.
+ * Zero-based.
+ *
+ * @param int $pos position in xml schema
+ * @param mixed $value field value
+ * @return void
+ */
+ public function setByPosition($pos, $value)
+ {
+ switch ($pos) {
+ case 0:
+ $this->setDbId($value);
+ break;
+ case 1:
+ $this->setDbTrackReference($value);
+ break;
+ case 2:
+ $this->setDbName($value);
+ break;
+ case 3:
+ $this->setDbDispatchTime($value);
+ break;
+ case 4:
+ $this->setDbStatus($value);
+ break;
+ } // switch()
+ }
+
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. $_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
+ * The default key type is the column's BasePeer::TYPE_PHPNAME
+ *
+ * @param array $arr An array to populate the object from.
+ * @param string $keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = CeleryTasksPeer::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setDbTrackReference($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setDbName($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDbDispatchTime($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDbStatus($arr[$keys[4]]);
+ }
+
+ /**
+ * Build a Criteria object containing the values of all modified columns in this object.
+ *
+ * @return Criteria The Criteria object containing all modified values.
+ */
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(CeleryTasksPeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(CeleryTasksPeer::ID)) $criteria->add(CeleryTasksPeer::ID, $this->id);
+ if ($this->isColumnModified(CeleryTasksPeer::TRACK_REFERENCE)) $criteria->add(CeleryTasksPeer::TRACK_REFERENCE, $this->track_reference);
+ if ($this->isColumnModified(CeleryTasksPeer::NAME)) $criteria->add(CeleryTasksPeer::NAME, $this->name);
+ if ($this->isColumnModified(CeleryTasksPeer::DISPATCH_TIME)) $criteria->add(CeleryTasksPeer::DISPATCH_TIME, $this->dispatch_time);
+ if ($this->isColumnModified(CeleryTasksPeer::STATUS)) $criteria->add(CeleryTasksPeer::STATUS, $this->status);
+
+ return $criteria;
+ }
+
+ /**
+ * Builds a Criteria object containing the primary key for this object.
+ *
+ * Unlike buildCriteria() this method includes the primary key values regardless
+ * of whether or not they have been modified.
+ *
+ * @return Criteria The Criteria object containing value(s) for primary key(s).
+ */
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(CeleryTasksPeer::DATABASE_NAME);
+ $criteria->add(CeleryTasksPeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the primary key for this object (row).
+ * @return string
+ */
+ public function getPrimaryKey()
+ {
+ return $this->getDbId();
+ }
+
+ /**
+ * Generic method to set the primary key (id column).
+ *
+ * @param string $key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey($key)
+ {
+ $this->setDbId($key);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getDbId();
+ }
+
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object $copyObj An object of CeleryTasks (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setDbTrackReference($this->getDbTrackReference());
+ $copyObj->setDbName($this->getDbName());
+ $copyObj->setDbDispatchTime($this->getDbDispatchTime());
+ $copyObj->setDbStatus($this->getDbStatus());
+
+ if ($deepCopy && !$this->startCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ $copyObj->setNew(false);
+ // store object hash to prevent cycle
+ $this->startCopy = true;
+
+ //unflag object copy
+ $this->startCopy = false;
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value
+ }
+ }
+
+ /**
+ * Makes a copy of this object that will be inserted as a new row in table when saved.
+ * It creates a new object filling in the simple attributes, but skipping any primary
+ * keys that are defined for the table.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @return CeleryTasks Clone of current object.
+ * @throws PropelException
+ */
+ public function copy($deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+
+ return $copyObj;
+ }
+
+ /**
+ * Returns a peer instance associated with this om.
+ *
+ * Since Peer classes are not to have any instance attributes, this method returns the
+ * same instance for all member of this class. The method could therefore
+ * be static, but this would prevent one from overriding the behavior.
+ *
+ * @return CeleryTasksPeer
+ */
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new CeleryTasksPeer();
+ }
+
+ return self::$peer;
+ }
+
+ /**
+ * Declares an association between this object and a ThirdPartyTrackReferences object.
+ *
+ * @param ThirdPartyTrackReferences $v
+ * @return CeleryTasks The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setThirdPartyTrackReferences(ThirdPartyTrackReferences $v = null)
+ {
+ if ($v === null) {
+ $this->setDbTrackReference(NULL);
+ } else {
+ $this->setDbTrackReference($v->getDbId());
+ }
+
+ $this->aThirdPartyTrackReferences = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ThirdPartyTrackReferences object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCeleryTasks($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ThirdPartyTrackReferences object
+ *
+ * @param PropelPDO $con Optional Connection object.
+ * @param $doQuery Executes a query to get the object if required
+ * @return ThirdPartyTrackReferences The associated ThirdPartyTrackReferences object.
+ * @throws PropelException
+ */
+ public function getThirdPartyTrackReferences(PropelPDO $con = null, $doQuery = true)
+ {
+ if ($this->aThirdPartyTrackReferences === null && ($this->track_reference !== null) && $doQuery) {
+ $this->aThirdPartyTrackReferences = ThirdPartyTrackReferencesQuery::create()->findPk($this->track_reference, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aThirdPartyTrackReferences->addCeleryTaskss($this);
+ */
+ }
+
+ return $this->aThirdPartyTrackReferences;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->track_reference = null;
+ $this->name = null;
+ $this->dispatch_time = null;
+ $this->status = null;
+ $this->alreadyInSave = false;
+ $this->alreadyInValidation = false;
+ $this->alreadyInClearAllReferencesDeep = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep && !$this->alreadyInClearAllReferencesDeep) {
+ $this->alreadyInClearAllReferencesDeep = true;
+ if ($this->aThirdPartyTrackReferences instanceof Persistent) {
+ $this->aThirdPartyTrackReferences->clearAllReferences($deep);
+ }
+
+ $this->alreadyInClearAllReferencesDeep = false;
+ } // if ($deep)
+
+ $this->aThirdPartyTrackReferences = null;
+ }
+
+ /**
+ * return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CeleryTasksPeer::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * return true is the object is in saving state
+ *
+ * @return boolean
+ */
+ public function isAlreadyInSave()
+ {
+ return $this->alreadyInSave;
+ }
+
+}
diff --git a/airtime_mvc/application/models/airtime/om/BaseCeleryTasksPeer.php b/airtime_mvc/application/models/airtime/om/BaseCeleryTasksPeer.php
new file mode 100644
index 000000000..2a651fd0e
--- /dev/null
+++ b/airtime_mvc/application/models/airtime/om/BaseCeleryTasksPeer.php
@@ -0,0 +1,1010 @@
+ array ('DbId', 'DbTrackReference', 'DbName', 'DbDispatchTime', 'DbStatus', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbTrackReference', 'dbName', 'dbDispatchTime', 'dbStatus', ),
+ BasePeer::TYPE_COLNAME => array (CeleryTasksPeer::ID, CeleryTasksPeer::TRACK_REFERENCE, CeleryTasksPeer::NAME, CeleryTasksPeer::DISPATCH_TIME, CeleryTasksPeer::STATUS, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TRACK_REFERENCE', 'NAME', 'DISPATCH_TIME', 'STATUS', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'track_reference', 'name', 'dispatch_time', 'status', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. CeleryTasksPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbTrackReference' => 1, 'DbName' => 2, 'DbDispatchTime' => 3, 'DbStatus' => 4, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbTrackReference' => 1, 'dbName' => 2, 'dbDispatchTime' => 3, 'dbStatus' => 4, ),
+ BasePeer::TYPE_COLNAME => array (CeleryTasksPeer::ID => 0, CeleryTasksPeer::TRACK_REFERENCE => 1, CeleryTasksPeer::NAME => 2, CeleryTasksPeer::DISPATCH_TIME => 3, CeleryTasksPeer::STATUS => 4, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TRACK_REFERENCE' => 1, 'NAME' => 2, 'DISPATCH_TIME' => 3, 'STATUS' => 4, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'track_reference' => 1, 'name' => 2, 'dispatch_time' => 3, 'status' => 4, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string $name field name
+ * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @param string $toType One of the class type constants
+ * @return string translated name of the field.
+ * @throws PropelException - if the specified name could not be found in the fieldname mappings.
+ */
+ public static function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = CeleryTasksPeer::getFieldNames($toType);
+ $key = isset(CeleryTasksPeer::$fieldKeys[$fromType][$name]) ? CeleryTasksPeer::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CeleryTasksPeer::$fieldKeys[$fromType], true));
+ }
+
+ return $toNames[$key];
+ }
+
+ /**
+ * Returns an array of field names.
+ *
+ * @param string $type The type of fieldnames to return:
+ * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
+ * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
+ * @return array A list of field names
+ * @throws PropelException - if the type is not valid.
+ */
+ public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, CeleryTasksPeer::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
+ }
+
+ return CeleryTasksPeer::$fieldNames[$type];
+ }
+
+ /**
+ * Convenience method which changes table.column to alias.column.
+ *
+ * Using this method you can maintain SQL abstraction while using column aliases.
+ *
+ * $c->addAlias("alias1", TablePeer::TABLE_NAME);
+ * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
+ *
+ * @param string $alias The alias for the current table.
+ * @param string $column The column name for current table. (i.e. CeleryTasksPeer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias($alias, $column)
+ {
+ return str_replace(CeleryTasksPeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad="true" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param Criteria $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CeleryTasksPeer::ID);
+ $criteria->addSelectColumn(CeleryTasksPeer::TRACK_REFERENCE);
+ $criteria->addSelectColumn(CeleryTasksPeer::NAME);
+ $criteria->addSelectColumn(CeleryTasksPeer::DISPATCH_TIME);
+ $criteria->addSelectColumn(CeleryTasksPeer::STATUS);
+ } else {
+ $criteria->addSelectColumn($alias . '.id');
+ $criteria->addSelectColumn($alias . '.track_reference');
+ $criteria->addSelectColumn($alias . '.name');
+ $criteria->addSelectColumn($alias . '.dispatch_time');
+ $criteria->addSelectColumn($alias . '.status');
+ }
+ }
+
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
+ {
+ // we may modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(CeleryTasksPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ CeleryTasksPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+ $criteria->setDbName(CeleryTasksPeer::DATABASE_NAME); // Set the correct dbName
+
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ // BasePeer returns a PDOStatement
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+ /**
+ * Selects one object from the DB.
+ *
+ * @param Criteria $criteria object used to create the SELECT statement.
+ * @param PropelPDO $con
+ * @return CeleryTasks
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = CeleryTasksPeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+
+ return null;
+ }
+ /**
+ * Selects several row from the DB.
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria $criteria, PropelPDO $con = null)
+ {
+ return CeleryTasksPeer::populateObjects(CeleryTasksPeer::doSelectStmt($criteria, $con));
+ }
+ /**
+ * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
+ *
+ * Use this method directly if you want to work with an executed statement directly (for example
+ * to perform your own object hydration).
+ *
+ * @param Criteria $criteria The Criteria object used to build the SELECT statement.
+ * @param PropelPDO $con The connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return PDOStatement The executed PDOStatement object.
+ * @see BasePeer::doSelect()
+ */
+ public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ $criteria = clone $criteria;
+ CeleryTasksPeer::addSelectColumns($criteria);
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(CeleryTasksPeer::DATABASE_NAME);
+
+ // BasePeer returns a PDOStatement
+ return BasePeer::doSelect($criteria, $con);
+ }
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doSelect*()
+ * methods in your stub classes -- you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by doSelect*()
+ * and retrieveByPK*() calls.
+ *
+ * @param CeleryTasks $obj A CeleryTasks object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if ($key === null) {
+ $key = (string) $obj->getDbId();
+ } // if key === null
+ CeleryTasksPeer::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A CeleryTasks object or a primary key value.
+ *
+ * @return void
+ * @throws PropelException - if the value is invalid.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && $value !== null) {
+ if (is_object($value) && $value instanceof CeleryTasks) {
+ $key = (string) $value->getDbId();
+ } elseif (is_scalar($value)) {
+ // assume we've been passed a primary key
+ $key = (string) $value;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or CeleryTasks object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
+ throw $e;
+ }
+
+ unset(CeleryTasksPeer::$instances[$key]);
+ }
+ } // removeInstanceFromPool()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param string $key The key (@see getPrimaryKeyHash()) for this instance.
+ * @return CeleryTasks Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
+ * @see getPrimaryKeyHash()
+ */
+ public static function getInstanceFromPool($key)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (isset(CeleryTasksPeer::$instances[$key])) {
+ return CeleryTasksPeer::$instances[$key];
+ }
+ }
+
+ return null; // just to be explicit
+ }
+
+ /**
+ * Clear the instance pool.
+ *
+ * @return void
+ */
+ public static function clearInstancePool($and_clear_all_references = false)
+ {
+ if ($and_clear_all_references) {
+ foreach (CeleryTasksPeer::$instances as $instance) {
+ $instance->clearAllReferences(true);
+ }
+ }
+ CeleryTasksPeer::$instances = array();
+ }
+
+ /**
+ * Method to invalidate the instance pool of all tables related to celery_tasks
+ * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return string A string version of PK or null if the components of primary key in result array are all null.
+ */
+ public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
+ {
+ // If the PK cannot be derived from the row, return null.
+ if ($row[$startcol] === null) {
+ return null;
+ }
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $startcol = 0)
+ {
+
+ return (string) $row[$startcol];
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(PDOStatement $stmt)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = CeleryTasksPeer::getOMClass();
+ // populate the object(s)
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key = CeleryTasksPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj = CeleryTasksPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CeleryTasksPeer::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row PropelPDO resultset row.
+ * @param int $startcol The 0-based offset for reading from the resultset row.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CeleryTasks object, last column rank)
+ */
+ public static function populateObject($row, $startcol = 0)
+ {
+ $key = CeleryTasksPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if (null !== ($obj = CeleryTasksPeer::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $startcol, true); // rehydrate
+ $col = $startcol + CeleryTasksPeer::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CeleryTasksPeer::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $startcol);
+ CeleryTasksPeer::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining the related ThirdPartyTrackReferences table
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinThirdPartyTrackReferences(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ // we're going to modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(CeleryTasksPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ CeleryTasksPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(CeleryTasksPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(CeleryTasksPeer::TRACK_REFERENCE, ThirdPartyTrackReferencesPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+
+ /**
+ * Selects a collection of CeleryTasks objects pre-filled with their ThirdPartyTrackReferences objects.
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of CeleryTasks objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinThirdPartyTrackReferences(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(CeleryTasksPeer::DATABASE_NAME);
+ }
+
+ CeleryTasksPeer::addSelectColumns($criteria);
+ $startcol = CeleryTasksPeer::NUM_HYDRATE_COLUMNS;
+ ThirdPartyTrackReferencesPeer::addSelectColumns($criteria);
+
+ $criteria->addJoin(CeleryTasksPeer::TRACK_REFERENCE, ThirdPartyTrackReferencesPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = CeleryTasksPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = CeleryTasksPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+
+ $cls = CeleryTasksPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ CeleryTasksPeer::addInstanceToPool($obj1, $key1);
+ } // if $obj1 already loaded
+
+ $key2 = ThirdPartyTrackReferencesPeer::getPrimaryKeyHashFromRow($row, $startcol);
+ if ($key2 !== null) {
+ $obj2 = ThirdPartyTrackReferencesPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ThirdPartyTrackReferencesPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol);
+ ThirdPartyTrackReferencesPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 already loaded
+
+ // Add the $obj1 (CeleryTasks) to $obj2 (ThirdPartyTrackReferences)
+ $obj2->addCeleryTasks($obj1);
+
+ } // if joined row was not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ // we're going to modify criteria, so copy it first
+ $criteria = clone $criteria;
+
+ // We need to set the primary table name, since in the case that there are no WHERE columns
+ // it will be impossible for the BasePeer::createSelectSql() method to determine which
+ // tables go into the FROM clause.
+ $criteria->setPrimaryTableName(CeleryTasksPeer::TABLE_NAME);
+
+ if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->setDistinct();
+ }
+
+ if (!$criteria->hasSelectClause()) {
+ CeleryTasksPeer::addSelectColumns($criteria);
+ }
+
+ $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
+
+ // Set the correct dbName
+ $criteria->setDbName(CeleryTasksPeer::DATABASE_NAME);
+
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria->addJoin(CeleryTasksPeer::TRACK_REFERENCE, ThirdPartyTrackReferencesPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doCount($criteria, $con);
+
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $count = (int) $row[0];
+ } else {
+ $count = 0; // no rows returned; we infer that means 0 matches.
+ }
+ $stmt->closeCursor();
+
+ return $count;
+ }
+
+ /**
+ * Selects a collection of CeleryTasks objects pre-filled with all related objects.
+ *
+ * @param Criteria $criteria
+ * @param PropelPDO $con
+ * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
+ * @return array Array of CeleryTasks objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ {
+ $criteria = clone $criteria;
+
+ // Set the correct dbName if it has not been overridden
+ if ($criteria->getDbName() == Propel::getDefaultDB()) {
+ $criteria->setDbName(CeleryTasksPeer::DATABASE_NAME);
+ }
+
+ CeleryTasksPeer::addSelectColumns($criteria);
+ $startcol2 = CeleryTasksPeer::NUM_HYDRATE_COLUMNS;
+
+ ThirdPartyTrackReferencesPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + ThirdPartyTrackReferencesPeer::NUM_HYDRATE_COLUMNS;
+
+ $criteria->addJoin(CeleryTasksPeer::TRACK_REFERENCE, ThirdPartyTrackReferencesPeer::ID, $join_behavior);
+
+ $stmt = BasePeer::doSelect($criteria, $con);
+ $results = array();
+
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $key1 = CeleryTasksPeer::getPrimaryKeyHashFromRow($row, 0);
+ if (null !== ($obj1 = CeleryTasksPeer::getInstanceFromPool($key1))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj1->hydrate($row, 0, true); // rehydrate
+ } else {
+ $cls = CeleryTasksPeer::getOMClass();
+
+ $obj1 = new $cls();
+ $obj1->hydrate($row);
+ CeleryTasksPeer::addInstanceToPool($obj1, $key1);
+ } // if obj1 already loaded
+
+ // Add objects for joined ThirdPartyTrackReferences rows
+
+ $key2 = ThirdPartyTrackReferencesPeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ if ($key2 !== null) {
+ $obj2 = ThirdPartyTrackReferencesPeer::getInstanceFromPool($key2);
+ if (!$obj2) {
+
+ $cls = ThirdPartyTrackReferencesPeer::getOMClass();
+
+ $obj2 = new $cls();
+ $obj2->hydrate($row, $startcol2);
+ ThirdPartyTrackReferencesPeer::addInstanceToPool($obj2, $key2);
+ } // if obj2 loaded
+
+ // Add the $obj1 (CeleryTasks) to the collection in $obj2 (ThirdPartyTrackReferences)
+ $obj2->addCeleryTasks($obj1);
+ } // if joined row not null
+
+ $results[] = $obj1;
+ }
+ $stmt->closeCursor();
+
+ return $results;
+ }
+
+ /**
+ * Returns the TableMap related to this peer.
+ * This method is not needed for general use but a specific application could have a need.
+ * @return TableMap
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(CeleryTasksPeer::DATABASE_NAME)->getTable(CeleryTasksPeer::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this peer class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getDatabaseMap(BaseCeleryTasksPeer::DATABASE_NAME);
+ if (!$dbMap->hasTable(BaseCeleryTasksPeer::TABLE_NAME)) {
+ $dbMap->addTableObject(new \CeleryTasksTableMap());
+ }
+ }
+
+ /**
+ * The class that the Peer will make instances of.
+ *
+ *
+ * @return string ClassName
+ */
+ public static function getOMClass($row = 0, $colnum = 0)
+ {
+ return CeleryTasksPeer::OM_CLASS;
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CeleryTasks or Criteria object.
+ *
+ * @param mixed $values Criteria or CeleryTasks object containing data that is used to create the INSERT statement.
+ * @param PropelPDO $con the PropelPDO connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+ } else {
+ $criteria = $values->buildCriteria(); // build Criteria from CeleryTasks object
+ }
+
+
+ // Set the correct dbName
+ $criteria->setDbName(CeleryTasksPeer::DATABASE_NAME);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+ /**
+ * Performs an UPDATE on the database, given a CeleryTasks or Criteria object.
+ *
+ * @param mixed $values Criteria or CeleryTasks object containing data that is used to create the UPDATE statement.
+ * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ $selectCriteria = new Criteria(CeleryTasksPeer::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; // rename for clarity
+
+ $comparison = $criteria->getComparison(CeleryTasksPeer::ID);
+ $value = $criteria->remove(CeleryTasksPeer::ID);
+ if ($value) {
+ $selectCriteria->add(CeleryTasksPeer::ID, $value, $comparison);
+ } else {
+ $selectCriteria->setPrimaryTableName(CeleryTasksPeer::TABLE_NAME);
+ }
+
+ } else { // $values is CeleryTasks object
+ $criteria = $values->buildCriteria(); // gets full criteria
+ $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
+
+ // set the correct dbName
+ $criteria->setDbName(CeleryTasksPeer::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+ /**
+ * Deletes all rows from the celery_tasks table.
+ *
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException
+ */
+ public static function doDeleteAll(PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+ $affectedRows += BasePeer::doDeleteAll(CeleryTasksPeer::TABLE_NAME, $con, CeleryTasksPeer::DATABASE_NAME);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CeleryTasksPeer::clearInstancePool();
+ CeleryTasksPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CeleryTasks or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CeleryTasks object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param PropelPDO $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete($values, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
+ }
+
+ if ($values instanceof Criteria) {
+ // invalidate the cache for all objects of this type, since we have no
+ // way of knowing (without running a query) what objects should be invalidated
+ // from the cache based on this Criteria.
+ CeleryTasksPeer::clearInstancePool();
+ // rename for clarity
+ $criteria = clone $values;
+ } elseif ($values instanceof CeleryTasks) { // it's a model object
+ // invalidate the cache for this single object
+ CeleryTasksPeer::removeInstanceFromPool($values);
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CeleryTasksPeer::DATABASE_NAME);
+ $criteria->add(CeleryTasksPeer::ID, (array) $values, Criteria::IN);
+ // invalidate the cache for this object(s)
+ foreach ((array) $values as $singleval) {
+ CeleryTasksPeer::removeInstanceFromPool($singleval);
+ }
+ }
+
+ // Set the correct dbName
+ $criteria->setDbName(CeleryTasksPeer::DATABASE_NAME);
+
+ $affectedRows = 0; // initialize var to track total num of affected rows
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ $con->beginTransaction();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ CeleryTasksPeer::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Validates all modified columns of given CeleryTasks object.
+ * If parameter $columns is either a single column name or an array of column names
+ * than only those columns are validated.
+ *
+ * NOTICE: This does not apply to primary or foreign keys for now.
+ *
+ * @param CeleryTasks $obj The object to validate.
+ * @param mixed $cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate($obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(CeleryTasksPeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(CeleryTasksPeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach ($cols as $colName) {
+ if ($tableMap->hasColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ return BasePeer::doValidate(CeleryTasksPeer::DATABASE_NAME, CeleryTasksPeer::TABLE_NAME, $columns);
+ }
+
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param string $pk the primary key.
+ * @param PropelPDO $con the connection to use
+ * @return CeleryTasks
+ */
+ public static function retrieveByPK($pk, PropelPDO $con = null)
+ {
+
+ if (null !== ($obj = CeleryTasksPeer::getInstanceFromPool((string) $pk))) {
+ return $obj;
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $criteria = new Criteria(CeleryTasksPeer::DATABASE_NAME);
+ $criteria->add(CeleryTasksPeer::ID, $pk);
+
+ $v = CeleryTasksPeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array $pks List of primary keys
+ * @param PropelPDO $con the connection to use
+ * @return CeleryTasks[]
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function retrieveByPKs($pks, PropelPDO $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria(CeleryTasksPeer::DATABASE_NAME);
+ $criteria->add(CeleryTasksPeer::ID, $pks, Criteria::IN);
+ $objs = CeleryTasksPeer::doSelect($criteria, $con);
+ }
+
+ return $objs;
+ }
+
+} // BaseCeleryTasksPeer
+
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+BaseCeleryTasksPeer::buildTableMap();
+
diff --git a/airtime_mvc/application/models/airtime/om/BaseCeleryTasksQuery.php b/airtime_mvc/application/models/airtime/om/BaseCeleryTasksQuery.php
new file mode 100644
index 000000000..20e683d70
--- /dev/null
+++ b/airtime_mvc/application/models/airtime/om/BaseCeleryTasksQuery.php
@@ -0,0 +1,504 @@
+mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return CeleryTasks|CeleryTasks[]|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CeleryTasksPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getConnection(CeleryTasksPeer::DATABASE_NAME, Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Alias of findPk to use instance pooling
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return CeleryTasks A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ public function findOneByDbId($key, $con = null)
+ {
+ return $this->findPk($key, $con);
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return CeleryTasks A model object, or null if the key is not found
+ * @throws PropelException
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT "id", "track_reference", "name", "dispatch_time", "status" FROM "celery_tasks" WHERE "id" = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_STR);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ $obj = new CeleryTasks();
+ $obj->hydrate($row);
+ CeleryTasksPeer::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con A connection object
+ *
+ * @return CeleryTasks|CeleryTasks[]|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con an optional connection object
+ *
+ * @return PropelObjectCollection|CeleryTasks[]|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $stmt = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($stmt);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return CeleryTasksQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CeleryTasksPeer::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return CeleryTasksQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CeleryTasksPeer::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterByDbId('fooValue'); // WHERE id = 'fooValue'
+ * $query->filterByDbId('%fooValue%'); // WHERE id LIKE '%fooValue%'
+ *
+ *
+ * @param string $dbId The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CeleryTasksQuery The current query, for fluid interface
+ */
+ public function filterByDbId($dbId = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($dbId)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $dbId)) {
+ $dbId = str_replace('*', '%', $dbId);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CeleryTasksPeer::ID, $dbId, $comparison);
+ }
+
+ /**
+ * Filter the query on the track_reference column
+ *
+ * Example usage:
+ *
+ * $query->filterByDbTrackReference(1234); // WHERE track_reference = 1234
+ * $query->filterByDbTrackReference(array(12, 34)); // WHERE track_reference IN (12, 34)
+ * $query->filterByDbTrackReference(array('min' => 12)); // WHERE track_reference >= 12
+ * $query->filterByDbTrackReference(array('max' => 12)); // WHERE track_reference <= 12
+ *
+ *
+ * @see filterByThirdPartyTrackReferences()
+ *
+ * @param mixed $dbTrackReference The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CeleryTasksQuery The current query, for fluid interface
+ */
+ public function filterByDbTrackReference($dbTrackReference = null, $comparison = null)
+ {
+ if (is_array($dbTrackReference)) {
+ $useMinMax = false;
+ if (isset($dbTrackReference['min'])) {
+ $this->addUsingAlias(CeleryTasksPeer::TRACK_REFERENCE, $dbTrackReference['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($dbTrackReference['max'])) {
+ $this->addUsingAlias(CeleryTasksPeer::TRACK_REFERENCE, $dbTrackReference['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CeleryTasksPeer::TRACK_REFERENCE, $dbTrackReference, $comparison);
+ }
+
+ /**
+ * Filter the query on the name column
+ *
+ * Example usage:
+ *
+ * $query->filterByDbName('fooValue'); // WHERE name = 'fooValue'
+ * $query->filterByDbName('%fooValue%'); // WHERE name LIKE '%fooValue%'
+ *
+ *
+ * @param string $dbName The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CeleryTasksQuery The current query, for fluid interface
+ */
+ public function filterByDbName($dbName = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($dbName)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $dbName)) {
+ $dbName = str_replace('*', '%', $dbName);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CeleryTasksPeer::NAME, $dbName, $comparison);
+ }
+
+ /**
+ * Filter the query on the dispatch_time column
+ *
+ * Example usage:
+ *
+ * $query->filterByDbDispatchTime('2011-03-14'); // WHERE dispatch_time = '2011-03-14'
+ * $query->filterByDbDispatchTime('now'); // WHERE dispatch_time = '2011-03-14'
+ * $query->filterByDbDispatchTime(array('max' => 'yesterday')); // WHERE dispatch_time < '2011-03-13'
+ *
+ *
+ * @param mixed $dbDispatchTime The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CeleryTasksQuery The current query, for fluid interface
+ */
+ public function filterByDbDispatchTime($dbDispatchTime = null, $comparison = null)
+ {
+ if (is_array($dbDispatchTime)) {
+ $useMinMax = false;
+ if (isset($dbDispatchTime['min'])) {
+ $this->addUsingAlias(CeleryTasksPeer::DISPATCH_TIME, $dbDispatchTime['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($dbDispatchTime['max'])) {
+ $this->addUsingAlias(CeleryTasksPeer::DISPATCH_TIME, $dbDispatchTime['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CeleryTasksPeer::DISPATCH_TIME, $dbDispatchTime, $comparison);
+ }
+
+ /**
+ * Filter the query on the status column
+ *
+ * Example usage:
+ *
+ * $query->filterByDbStatus('fooValue'); // WHERE status = 'fooValue'
+ * $query->filterByDbStatus('%fooValue%'); // WHERE status LIKE '%fooValue%'
+ *
+ *
+ * @param string $dbStatus The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CeleryTasksQuery The current query, for fluid interface
+ */
+ public function filterByDbStatus($dbStatus = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($dbStatus)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $dbStatus)) {
+ $dbStatus = str_replace('*', '%', $dbStatus);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CeleryTasksPeer::STATUS, $dbStatus, $comparison);
+ }
+
+ /**
+ * Filter the query by a related ThirdPartyTrackReferences object
+ *
+ * @param ThirdPartyTrackReferences|PropelObjectCollection $thirdPartyTrackReferences The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CeleryTasksQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByThirdPartyTrackReferences($thirdPartyTrackReferences, $comparison = null)
+ {
+ if ($thirdPartyTrackReferences instanceof ThirdPartyTrackReferences) {
+ return $this
+ ->addUsingAlias(CeleryTasksPeer::TRACK_REFERENCE, $thirdPartyTrackReferences->getDbId(), $comparison);
+ } elseif ($thirdPartyTrackReferences instanceof PropelObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CeleryTasksPeer::TRACK_REFERENCE, $thirdPartyTrackReferences->toKeyValue('PrimaryKey', 'DbId'), $comparison);
+ } else {
+ throw new PropelException('filterByThirdPartyTrackReferences() only accepts arguments of type ThirdPartyTrackReferences or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ThirdPartyTrackReferences relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CeleryTasksQuery The current query, for fluid interface
+ */
+ public function joinThirdPartyTrackReferences($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ThirdPartyTrackReferences');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ThirdPartyTrackReferences');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ThirdPartyTrackReferences relation ThirdPartyTrackReferences object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ThirdPartyTrackReferencesQuery A secondary query class using the current class as primary query
+ */
+ public function useThirdPartyTrackReferencesQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinThirdPartyTrackReferences($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ThirdPartyTrackReferences', 'ThirdPartyTrackReferencesQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param CeleryTasks $celeryTasks Object to remove from the list of results
+ *
+ * @return CeleryTasksQuery The current query, for fluid interface
+ */
+ public function prune($celeryTasks = null)
+ {
+ if ($celeryTasks) {
+ $this->addUsingAlias(CeleryTasksPeer::ID, $celeryTasks->getDbId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+}
diff --git a/airtime_mvc/application/models/airtime/om/BaseThirdPartyTrackReferences.php b/airtime_mvc/application/models/airtime/om/BaseThirdPartyTrackReferences.php
index b880cd0d4..a7860e1eb 100644
--- a/airtime_mvc/application/models/airtime/om/BaseThirdPartyTrackReferences.php
+++ b/airtime_mvc/application/models/airtime/om/BaseThirdPartyTrackReferences.php
@@ -47,30 +47,18 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
*/
protected $foreign_id;
- /**
- * The value for the broker_task_id field.
- * @var string
- */
- protected $broker_task_id;
-
- /**
- * The value for the broker_task_name field.
- * @var string
- */
- protected $broker_task_name;
-
- /**
- * The value for the broker_task_dispatch_time field.
- * @var string
- */
- protected $broker_task_dispatch_time;
-
/**
* The value for the file_id field.
* @var int
*/
protected $file_id;
+ /**
+ * The value for the upload_time field.
+ * @var string
+ */
+ protected $upload_time;
+
/**
* The value for the status field.
* @var string
@@ -78,9 +66,15 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
protected $status;
/**
- * @var CcPlayoutHistoryTemplate
+ * @var CcFiles
*/
- protected $aCcPlayoutHistoryTemplate;
+ protected $aCcFiles;
+
+ /**
+ * @var PropelObjectCollection|CeleryTasks[] Collection to store aggregation of CeleryTasks objects.
+ */
+ protected $collCeleryTaskss;
+ protected $collCeleryTaskssPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
@@ -102,6 +96,12 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
*/
protected $alreadyInClearAllReferencesDeep = false;
+ /**
+ * An array of objects scheduled for deletion.
+ * @var PropelObjectCollection
+ */
+ protected $celeryTaskssScheduledForDeletion = null;
+
/**
* Get the [id] column value.
*
@@ -136,29 +136,18 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
}
/**
- * Get the [broker_task_id] column value.
+ * Get the [file_id] column value.
*
- * @return string
+ * @return int
*/
- public function getDbBrokerTaskId()
+ public function getDbFileId()
{
- return $this->broker_task_id;
+ return $this->file_id;
}
/**
- * Get the [broker_task_name] column value.
- *
- * @return string
- */
- public function getDbBrokerTaskName()
- {
-
- return $this->broker_task_name;
- }
-
- /**
- * Get the [optionally formatted] temporal [broker_task_dispatch_time] column value.
+ * Get the [optionally formatted] temporal [upload_time] column value.
*
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
@@ -166,17 +155,17 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
* @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null
* @throws PropelException - if unable to parse/validate the date/time value.
*/
- public function getDbBrokerTaskDispatchTime($format = 'Y-m-d H:i:s')
+ public function getDbUploadTime($format = 'Y-m-d H:i:s')
{
- if ($this->broker_task_dispatch_time === null) {
+ if ($this->upload_time === null) {
return null;
}
try {
- $dt = new DateTime($this->broker_task_dispatch_time);
+ $dt = new DateTime($this->upload_time);
} catch (Exception $x) {
- throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->broker_task_dispatch_time, true), $x);
+ throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->upload_time, true), $x);
}
if ($format === null) {
@@ -192,17 +181,6 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
}
- /**
- * Get the [file_id] column value.
- *
- * @return int
- */
- public function getDbFileId()
- {
-
- return $this->file_id;
- }
-
/**
* Get the [status] column value.
*
@@ -277,71 +255,6 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
return $this;
} // setDbForeignId()
- /**
- * Set the value of [broker_task_id] column.
- *
- * @param string $v new value
- * @return ThirdPartyTrackReferences The current object (for fluent API support)
- */
- public function setDbBrokerTaskId($v)
- {
- if ($v !== null && is_numeric($v)) {
- $v = (string) $v;
- }
-
- if ($this->broker_task_id !== $v) {
- $this->broker_task_id = $v;
- $this->modifiedColumns[] = ThirdPartyTrackReferencesPeer::BROKER_TASK_ID;
- }
-
-
- return $this;
- } // setDbBrokerTaskId()
-
- /**
- * Set the value of [broker_task_name] column.
- *
- * @param string $v new value
- * @return ThirdPartyTrackReferences The current object (for fluent API support)
- */
- public function setDbBrokerTaskName($v)
- {
- if ($v !== null && is_numeric($v)) {
- $v = (string) $v;
- }
-
- if ($this->broker_task_name !== $v) {
- $this->broker_task_name = $v;
- $this->modifiedColumns[] = ThirdPartyTrackReferencesPeer::BROKER_TASK_NAME;
- }
-
-
- return $this;
- } // setDbBrokerTaskName()
-
- /**
- * Sets the value of [broker_task_dispatch_time] column to a normalized version of the date/time value specified.
- *
- * @param mixed $v string, integer (timestamp), or DateTime value.
- * Empty strings are treated as null.
- * @return ThirdPartyTrackReferences The current object (for fluent API support)
- */
- public function setDbBrokerTaskDispatchTime($v)
- {
- $dt = PropelDateTime::newInstance($v, null, 'DateTime');
- if ($this->broker_task_dispatch_time !== null || $dt !== null) {
- $currentDateAsString = ($this->broker_task_dispatch_time !== null && $tmpDt = new DateTime($this->broker_task_dispatch_time)) ? $tmpDt->format('Y-m-d H:i:s') : null;
- $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
- if ($currentDateAsString !== $newDateAsString) {
- $this->broker_task_dispatch_time = $newDateAsString;
- $this->modifiedColumns[] = ThirdPartyTrackReferencesPeer::BROKER_TASK_DISPATCH_TIME;
- }
- } // if either are not null
-
-
- return $this;
- } // setDbBrokerTaskDispatchTime()
-
/**
* Set the value of [file_id] column.
*
@@ -359,14 +272,37 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
$this->modifiedColumns[] = ThirdPartyTrackReferencesPeer::FILE_ID;
}
- if ($this->aCcPlayoutHistoryTemplate !== null && $this->aCcPlayoutHistoryTemplate->getDbId() !== $v) {
- $this->aCcPlayoutHistoryTemplate = null;
+ if ($this->aCcFiles !== null && $this->aCcFiles->getDbId() !== $v) {
+ $this->aCcFiles = null;
}
return $this;
} // setDbFileId()
+ /**
+ * Sets the value of [upload_time] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or DateTime value.
+ * Empty strings are treated as null.
+ * @return ThirdPartyTrackReferences The current object (for fluent API support)
+ */
+ public function setDbUploadTime($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, 'DateTime');
+ if ($this->upload_time !== null || $dt !== null) {
+ $currentDateAsString = ($this->upload_time !== null && $tmpDt = new DateTime($this->upload_time)) ? $tmpDt->format('Y-m-d H:i:s') : null;
+ $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
+ if ($currentDateAsString !== $newDateAsString) {
+ $this->upload_time = $newDateAsString;
+ $this->modifiedColumns[] = ThirdPartyTrackReferencesPeer::UPLOAD_TIME;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setDbUploadTime()
+
/**
* Set the value of [status] column.
*
@@ -423,11 +359,9 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
$this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
$this->service = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
$this->foreign_id = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
- $this->broker_task_id = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
- $this->broker_task_name = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
- $this->broker_task_dispatch_time = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
- $this->file_id = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
- $this->status = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
+ $this->file_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
+ $this->upload_time = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
+ $this->status = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
$this->resetModified();
$this->setNew(false);
@@ -437,7 +371,7 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
}
$this->postHydrate($row, $startcol, $rehydrate);
- return $startcol + 8; // 8 = ThirdPartyTrackReferencesPeer::NUM_HYDRATE_COLUMNS.
+ return $startcol + 6; // 6 = ThirdPartyTrackReferencesPeer::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating ThirdPartyTrackReferences object", $e);
@@ -460,8 +394,8 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
public function ensureConsistency()
{
- if ($this->aCcPlayoutHistoryTemplate !== null && $this->file_id !== $this->aCcPlayoutHistoryTemplate->getDbId()) {
- $this->aCcPlayoutHistoryTemplate = null;
+ if ($this->aCcFiles !== null && $this->file_id !== $this->aCcFiles->getDbId()) {
+ $this->aCcFiles = null;
}
} // ensureConsistency
@@ -502,7 +436,9 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
if ($deep) { // also de-associate any related objects?
- $this->aCcPlayoutHistoryTemplate = null;
+ $this->aCcFiles = null;
+ $this->collCeleryTaskss = null;
+
} // if (deep)
}
@@ -621,11 +557,11 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
// method. This object relates to these object(s) by a
// foreign key reference.
- if ($this->aCcPlayoutHistoryTemplate !== null) {
- if ($this->aCcPlayoutHistoryTemplate->isModified() || $this->aCcPlayoutHistoryTemplate->isNew()) {
- $affectedRows += $this->aCcPlayoutHistoryTemplate->save($con);
+ if ($this->aCcFiles !== null) {
+ if ($this->aCcFiles->isModified() || $this->aCcFiles->isNew()) {
+ $affectedRows += $this->aCcFiles->save($con);
}
- $this->setCcPlayoutHistoryTemplate($this->aCcPlayoutHistoryTemplate);
+ $this->setCcFiles($this->aCcFiles);
}
if ($this->isNew() || $this->isModified()) {
@@ -639,6 +575,23 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
$this->resetModified();
}
+ if ($this->celeryTaskssScheduledForDeletion !== null) {
+ if (!$this->celeryTaskssScheduledForDeletion->isEmpty()) {
+ CeleryTasksQuery::create()
+ ->filterByPrimaryKeys($this->celeryTaskssScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->celeryTaskssScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCeleryTaskss !== null) {
+ foreach ($this->collCeleryTaskss as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -684,18 +637,12 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::FOREIGN_ID)) {
$modifiedColumns[':p' . $index++] = '"foreign_id"';
}
- if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::BROKER_TASK_ID)) {
- $modifiedColumns[':p' . $index++] = '"broker_task_id"';
- }
- if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::BROKER_TASK_NAME)) {
- $modifiedColumns[':p' . $index++] = '"broker_task_name"';
- }
- if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::BROKER_TASK_DISPATCH_TIME)) {
- $modifiedColumns[':p' . $index++] = '"broker_task_dispatch_time"';
- }
if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::FILE_ID)) {
$modifiedColumns[':p' . $index++] = '"file_id"';
}
+ if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::UPLOAD_TIME)) {
+ $modifiedColumns[':p' . $index++] = '"upload_time"';
+ }
if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::STATUS)) {
$modifiedColumns[':p' . $index++] = '"status"';
}
@@ -719,18 +666,12 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
case '"foreign_id"':
$stmt->bindValue($identifier, $this->foreign_id, PDO::PARAM_STR);
break;
- case '"broker_task_id"':
- $stmt->bindValue($identifier, $this->broker_task_id, PDO::PARAM_STR);
- break;
- case '"broker_task_name"':
- $stmt->bindValue($identifier, $this->broker_task_name, PDO::PARAM_STR);
- break;
- case '"broker_task_dispatch_time"':
- $stmt->bindValue($identifier, $this->broker_task_dispatch_time, PDO::PARAM_STR);
- break;
case '"file_id"':
$stmt->bindValue($identifier, $this->file_id, PDO::PARAM_INT);
break;
+ case '"upload_time"':
+ $stmt->bindValue($identifier, $this->upload_time, PDO::PARAM_STR);
+ break;
case '"status"':
$stmt->bindValue($identifier, $this->status, PDO::PARAM_STR);
break;
@@ -826,9 +767,9 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
// method. This object relates to these object(s) by a
// foreign key reference.
- if ($this->aCcPlayoutHistoryTemplate !== null) {
- if (!$this->aCcPlayoutHistoryTemplate->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->aCcPlayoutHistoryTemplate->getValidationFailures());
+ if ($this->aCcFiles !== null) {
+ if (!$this->aCcFiles->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aCcFiles->getValidationFailures());
}
}
@@ -838,6 +779,14 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
}
+ if ($this->collCeleryTaskss !== null) {
+ foreach ($this->collCeleryTaskss as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -883,18 +832,12 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
return $this->getDbForeignId();
break;
case 3:
- return $this->getDbBrokerTaskId();
- break;
- case 4:
- return $this->getDbBrokerTaskName();
- break;
- case 5:
- return $this->getDbBrokerTaskDispatchTime();
- break;
- case 6:
return $this->getDbFileId();
break;
- case 7:
+ case 4:
+ return $this->getDbUploadTime();
+ break;
+ case 5:
return $this->getDbStatus();
break;
default:
@@ -929,11 +872,9 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
$keys[0] => $this->getDbId(),
$keys[1] => $this->getDbService(),
$keys[2] => $this->getDbForeignId(),
- $keys[3] => $this->getDbBrokerTaskId(),
- $keys[4] => $this->getDbBrokerTaskName(),
- $keys[5] => $this->getDbBrokerTaskDispatchTime(),
- $keys[6] => $this->getDbFileId(),
- $keys[7] => $this->getDbStatus(),
+ $keys[3] => $this->getDbFileId(),
+ $keys[4] => $this->getDbUploadTime(),
+ $keys[5] => $this->getDbStatus(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
@@ -941,8 +882,11 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
}
if ($includeForeignObjects) {
- if (null !== $this->aCcPlayoutHistoryTemplate) {
- $result['CcPlayoutHistoryTemplate'] = $this->aCcPlayoutHistoryTemplate->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ if (null !== $this->aCcFiles) {
+ $result['CcFiles'] = $this->aCcFiles->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->collCeleryTaskss) {
+ $result['CeleryTaskss'] = $this->collCeleryTaskss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
@@ -988,18 +932,12 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
$this->setDbForeignId($value);
break;
case 3:
- $this->setDbBrokerTaskId($value);
- break;
- case 4:
- $this->setDbBrokerTaskName($value);
- break;
- case 5:
- $this->setDbBrokerTaskDispatchTime($value);
- break;
- case 6:
$this->setDbFileId($value);
break;
- case 7:
+ case 4:
+ $this->setDbUploadTime($value);
+ break;
+ case 5:
$this->setDbStatus($value);
break;
} // switch()
@@ -1029,11 +967,9 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setDbService($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setDbForeignId($arr[$keys[2]]);
- if (array_key_exists($keys[3], $arr)) $this->setDbBrokerTaskId($arr[$keys[3]]);
- if (array_key_exists($keys[4], $arr)) $this->setDbBrokerTaskName($arr[$keys[4]]);
- if (array_key_exists($keys[5], $arr)) $this->setDbBrokerTaskDispatchTime($arr[$keys[5]]);
- if (array_key_exists($keys[6], $arr)) $this->setDbFileId($arr[$keys[6]]);
- if (array_key_exists($keys[7], $arr)) $this->setDbStatus($arr[$keys[7]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDbFileId($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDbUploadTime($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setDbStatus($arr[$keys[5]]);
}
/**
@@ -1048,10 +984,8 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::ID)) $criteria->add(ThirdPartyTrackReferencesPeer::ID, $this->id);
if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::SERVICE)) $criteria->add(ThirdPartyTrackReferencesPeer::SERVICE, $this->service);
if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::FOREIGN_ID)) $criteria->add(ThirdPartyTrackReferencesPeer::FOREIGN_ID, $this->foreign_id);
- if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::BROKER_TASK_ID)) $criteria->add(ThirdPartyTrackReferencesPeer::BROKER_TASK_ID, $this->broker_task_id);
- if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::BROKER_TASK_NAME)) $criteria->add(ThirdPartyTrackReferencesPeer::BROKER_TASK_NAME, $this->broker_task_name);
- if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::BROKER_TASK_DISPATCH_TIME)) $criteria->add(ThirdPartyTrackReferencesPeer::BROKER_TASK_DISPATCH_TIME, $this->broker_task_dispatch_time);
if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::FILE_ID)) $criteria->add(ThirdPartyTrackReferencesPeer::FILE_ID, $this->file_id);
+ if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::UPLOAD_TIME)) $criteria->add(ThirdPartyTrackReferencesPeer::UPLOAD_TIME, $this->upload_time);
if ($this->isColumnModified(ThirdPartyTrackReferencesPeer::STATUS)) $criteria->add(ThirdPartyTrackReferencesPeer::STATUS, $this->status);
return $criteria;
@@ -1118,10 +1052,8 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
{
$copyObj->setDbService($this->getDbService());
$copyObj->setDbForeignId($this->getDbForeignId());
- $copyObj->setDbBrokerTaskId($this->getDbBrokerTaskId());
- $copyObj->setDbBrokerTaskName($this->getDbBrokerTaskName());
- $copyObj->setDbBrokerTaskDispatchTime($this->getDbBrokerTaskDispatchTime());
$copyObj->setDbFileId($this->getDbFileId());
+ $copyObj->setDbUploadTime($this->getDbUploadTime());
$copyObj->setDbStatus($this->getDbStatus());
if ($deepCopy && !$this->startCopy) {
@@ -1131,6 +1063,12 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
// store object hash to prevent cycle
$this->startCopy = true;
+ foreach ($this->getCeleryTaskss() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCeleryTasks($relObj->copy($deepCopy));
+ }
+ }
+
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
@@ -1182,13 +1120,13 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
}
/**
- * Declares an association between this object and a CcPlayoutHistoryTemplate object.
+ * Declares an association between this object and a CcFiles object.
*
- * @param CcPlayoutHistoryTemplate $v
+ * @param CcFiles $v
* @return ThirdPartyTrackReferences The current object (for fluent API support)
* @throws PropelException
*/
- public function setCcPlayoutHistoryTemplate(CcPlayoutHistoryTemplate $v = null)
+ public function setCcFiles(CcFiles $v = null)
{
if ($v === null) {
$this->setDbFileId(NULL);
@@ -1196,10 +1134,10 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
$this->setDbFileId($v->getDbId());
}
- $this->aCcPlayoutHistoryTemplate = $v;
+ $this->aCcFiles = $v;
// Add binding for other direction of this n:n relationship.
- // If this object has already been added to the CcPlayoutHistoryTemplate object, it will not be re-added.
+ // If this object has already been added to the CcFiles object, it will not be re-added.
if ($v !== null) {
$v->addThirdPartyTrackReferences($this);
}
@@ -1210,27 +1148,268 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
/**
- * Get the associated CcPlayoutHistoryTemplate object
+ * Get the associated CcFiles object
*
* @param PropelPDO $con Optional Connection object.
* @param $doQuery Executes a query to get the object if required
- * @return CcPlayoutHistoryTemplate The associated CcPlayoutHistoryTemplate object.
+ * @return CcFiles The associated CcFiles object.
* @throws PropelException
*/
- public function getCcPlayoutHistoryTemplate(PropelPDO $con = null, $doQuery = true)
+ public function getCcFiles(PropelPDO $con = null, $doQuery = true)
{
- if ($this->aCcPlayoutHistoryTemplate === null && ($this->file_id !== null) && $doQuery) {
- $this->aCcPlayoutHistoryTemplate = CcPlayoutHistoryTemplateQuery::create()->findPk($this->file_id, $con);
+ if ($this->aCcFiles === null && ($this->file_id !== null) && $doQuery) {
+ $this->aCcFiles = CcFilesQuery::create()->findPk($this->file_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
- $this->aCcPlayoutHistoryTemplate->addThirdPartyTrackReferencess($this);
+ $this->aCcFiles->addThirdPartyTrackReferencess($this);
*/
}
- return $this->aCcPlayoutHistoryTemplate;
+ return $this->aCcFiles;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('CeleryTasks' == $relationName) {
+ $this->initCeleryTaskss();
+ }
+ }
+
+ /**
+ * Clears out the collCeleryTaskss collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return ThirdPartyTrackReferences The current object (for fluent API support)
+ * @see addCeleryTaskss()
+ */
+ public function clearCeleryTaskss()
+ {
+ $this->collCeleryTaskss = null; // important to set this to null since that means it is uninitialized
+ $this->collCeleryTaskssPartial = null;
+
+ return $this;
+ }
+
+ /**
+ * reset is the collCeleryTaskss collection loaded partially
+ *
+ * @return void
+ */
+ public function resetPartialCeleryTaskss($v = true)
+ {
+ $this->collCeleryTaskssPartial = $v;
+ }
+
+ /**
+ * Initializes the collCeleryTaskss collection.
+ *
+ * By default this just sets the collCeleryTaskss collection to an empty array (like clearcollCeleryTaskss());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initCeleryTaskss($overrideExisting = true)
+ {
+ if (null !== $this->collCeleryTaskss && !$overrideExisting) {
+ return;
+ }
+ $this->collCeleryTaskss = new PropelObjectCollection();
+ $this->collCeleryTaskss->setModel('CeleryTasks');
+ }
+
+ /**
+ * Gets an array of CeleryTasks objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ThirdPartyTrackReferences is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param PropelPDO $con optional connection object
+ * @return PropelObjectCollection|CeleryTasks[] List of CeleryTasks objects
+ * @throws PropelException
+ */
+ public function getCeleryTaskss($criteria = null, PropelPDO $con = null)
+ {
+ $partial = $this->collCeleryTaskssPartial && !$this->isNew();
+ if (null === $this->collCeleryTaskss || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCeleryTaskss) {
+ // return empty collection
+ $this->initCeleryTaskss();
+ } else {
+ $collCeleryTaskss = CeleryTasksQuery::create(null, $criteria)
+ ->filterByThirdPartyTrackReferences($this)
+ ->find($con);
+ if (null !== $criteria) {
+ if (false !== $this->collCeleryTaskssPartial && count($collCeleryTaskss)) {
+ $this->initCeleryTaskss(false);
+
+ foreach ($collCeleryTaskss as $obj) {
+ if (false == $this->collCeleryTaskss->contains($obj)) {
+ $this->collCeleryTaskss->append($obj);
+ }
+ }
+
+ $this->collCeleryTaskssPartial = true;
+ }
+
+ $collCeleryTaskss->getInternalIterator()->rewind();
+
+ return $collCeleryTaskss;
+ }
+
+ if ($partial && $this->collCeleryTaskss) {
+ foreach ($this->collCeleryTaskss as $obj) {
+ if ($obj->isNew()) {
+ $collCeleryTaskss[] = $obj;
+ }
+ }
+ }
+
+ $this->collCeleryTaskss = $collCeleryTaskss;
+ $this->collCeleryTaskssPartial = false;
+ }
+ }
+
+ return $this->collCeleryTaskss;
+ }
+
+ /**
+ * Sets a collection of CeleryTasks objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param PropelCollection $celeryTaskss A Propel collection.
+ * @param PropelPDO $con Optional connection object
+ * @return ThirdPartyTrackReferences The current object (for fluent API support)
+ */
+ public function setCeleryTaskss(PropelCollection $celeryTaskss, PropelPDO $con = null)
+ {
+ $celeryTaskssToDelete = $this->getCeleryTaskss(new Criteria(), $con)->diff($celeryTaskss);
+
+
+ $this->celeryTaskssScheduledForDeletion = $celeryTaskssToDelete;
+
+ foreach ($celeryTaskssToDelete as $celeryTasksRemoved) {
+ $celeryTasksRemoved->setThirdPartyTrackReferences(null);
+ }
+
+ $this->collCeleryTaskss = null;
+ foreach ($celeryTaskss as $celeryTasks) {
+ $this->addCeleryTasks($celeryTasks);
+ }
+
+ $this->collCeleryTaskss = $celeryTaskss;
+ $this->collCeleryTaskssPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related CeleryTasks objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related CeleryTasks objects.
+ * @throws PropelException
+ */
+ public function countCeleryTaskss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ $partial = $this->collCeleryTaskssPartial && !$this->isNew();
+ if (null === $this->collCeleryTaskss || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCeleryTaskss) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getCeleryTaskss());
+ }
+ $query = CeleryTasksQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByThirdPartyTrackReferences($this)
+ ->count($con);
+ }
+
+ return count($this->collCeleryTaskss);
+ }
+
+ /**
+ * Method called to associate a CeleryTasks object to this object
+ * through the CeleryTasks foreign key attribute.
+ *
+ * @param CeleryTasks $l CeleryTasks
+ * @return ThirdPartyTrackReferences The current object (for fluent API support)
+ */
+ public function addCeleryTasks(CeleryTasks $l)
+ {
+ if ($this->collCeleryTaskss === null) {
+ $this->initCeleryTaskss();
+ $this->collCeleryTaskssPartial = true;
+ }
+
+ if (!in_array($l, $this->collCeleryTaskss->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddCeleryTasks($l);
+
+ if ($this->celeryTaskssScheduledForDeletion and $this->celeryTaskssScheduledForDeletion->contains($l)) {
+ $this->celeryTaskssScheduledForDeletion->remove($this->celeryTaskssScheduledForDeletion->search($l));
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param CeleryTasks $celeryTasks The celeryTasks object to add.
+ */
+ protected function doAddCeleryTasks($celeryTasks)
+ {
+ $this->collCeleryTaskss[]= $celeryTasks;
+ $celeryTasks->setThirdPartyTrackReferences($this);
+ }
+
+ /**
+ * @param CeleryTasks $celeryTasks The celeryTasks object to remove.
+ * @return ThirdPartyTrackReferences The current object (for fluent API support)
+ */
+ public function removeCeleryTasks($celeryTasks)
+ {
+ if ($this->getCeleryTaskss()->contains($celeryTasks)) {
+ $this->collCeleryTaskss->remove($this->collCeleryTaskss->search($celeryTasks));
+ if (null === $this->celeryTaskssScheduledForDeletion) {
+ $this->celeryTaskssScheduledForDeletion = clone $this->collCeleryTaskss;
+ $this->celeryTaskssScheduledForDeletion->clear();
+ }
+ $this->celeryTaskssScheduledForDeletion[]= clone $celeryTasks;
+ $celeryTasks->setThirdPartyTrackReferences(null);
+ }
+
+ return $this;
}
/**
@@ -1241,10 +1420,8 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
$this->id = null;
$this->service = null;
$this->foreign_id = null;
- $this->broker_task_id = null;
- $this->broker_task_name = null;
- $this->broker_task_dispatch_time = null;
$this->file_id = null;
+ $this->upload_time = null;
$this->status = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
@@ -1268,14 +1445,23 @@ abstract class BaseThirdPartyTrackReferences extends BaseObject implements Persi
{
if ($deep && !$this->alreadyInClearAllReferencesDeep) {
$this->alreadyInClearAllReferencesDeep = true;
- if ($this->aCcPlayoutHistoryTemplate instanceof Persistent) {
- $this->aCcPlayoutHistoryTemplate->clearAllReferences($deep);
+ if ($this->collCeleryTaskss) {
+ foreach ($this->collCeleryTaskss as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->aCcFiles instanceof Persistent) {
+ $this->aCcFiles->clearAllReferences($deep);
}
$this->alreadyInClearAllReferencesDeep = false;
} // if ($deep)
- $this->aCcPlayoutHistoryTemplate = null;
+ if ($this->collCeleryTaskss instanceof PropelCollection) {
+ $this->collCeleryTaskss->clearIterator();
+ }
+ $this->collCeleryTaskss = null;
+ $this->aCcFiles = null;
}
/**
diff --git a/airtime_mvc/application/models/airtime/om/BaseThirdPartyTrackReferencesPeer.php b/airtime_mvc/application/models/airtime/om/BaseThirdPartyTrackReferencesPeer.php
index 079dd9808..38c8ddbd9 100644
--- a/airtime_mvc/application/models/airtime/om/BaseThirdPartyTrackReferencesPeer.php
+++ b/airtime_mvc/application/models/airtime/om/BaseThirdPartyTrackReferencesPeer.php
@@ -24,13 +24,13 @@ abstract class BaseThirdPartyTrackReferencesPeer
const TM_CLASS = 'ThirdPartyTrackReferencesTableMap';
/** The total number of columns. */
- const NUM_COLUMNS = 8;
+ const NUM_COLUMNS = 6;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */
- const NUM_HYDRATE_COLUMNS = 8;
+ const NUM_HYDRATE_COLUMNS = 6;
/** the column name for the id field */
const ID = 'third_party_track_references.id';
@@ -41,18 +41,12 @@ abstract class BaseThirdPartyTrackReferencesPeer
/** the column name for the foreign_id field */
const FOREIGN_ID = 'third_party_track_references.foreign_id';
- /** the column name for the broker_task_id field */
- const BROKER_TASK_ID = 'third_party_track_references.broker_task_id';
-
- /** the column name for the broker_task_name field */
- const BROKER_TASK_NAME = 'third_party_track_references.broker_task_name';
-
- /** the column name for the broker_task_dispatch_time field */
- const BROKER_TASK_DISPATCH_TIME = 'third_party_track_references.broker_task_dispatch_time';
-
/** the column name for the file_id field */
const FILE_ID = 'third_party_track_references.file_id';
+ /** the column name for the upload_time field */
+ const UPLOAD_TIME = 'third_party_track_references.upload_time';
+
/** the column name for the status field */
const STATUS = 'third_party_track_references.status';
@@ -75,12 +69,12 @@ abstract class BaseThirdPartyTrackReferencesPeer
* e.g. ThirdPartyTrackReferencesPeer::$fieldNames[ThirdPartyTrackReferencesPeer::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
- BasePeer::TYPE_PHPNAME => array ('DbId', 'DbService', 'DbForeignId', 'DbBrokerTaskId', 'DbBrokerTaskName', 'DbBrokerTaskDispatchTime', 'DbFileId', 'DbStatus', ),
- BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbService', 'dbForeignId', 'dbBrokerTaskId', 'dbBrokerTaskName', 'dbBrokerTaskDispatchTime', 'dbFileId', 'dbStatus', ),
- BasePeer::TYPE_COLNAME => array (ThirdPartyTrackReferencesPeer::ID, ThirdPartyTrackReferencesPeer::SERVICE, ThirdPartyTrackReferencesPeer::FOREIGN_ID, ThirdPartyTrackReferencesPeer::BROKER_TASK_ID, ThirdPartyTrackReferencesPeer::BROKER_TASK_NAME, ThirdPartyTrackReferencesPeer::BROKER_TASK_DISPATCH_TIME, ThirdPartyTrackReferencesPeer::FILE_ID, ThirdPartyTrackReferencesPeer::STATUS, ),
- BasePeer::TYPE_RAW_COLNAME => array ('ID', 'SERVICE', 'FOREIGN_ID', 'BROKER_TASK_ID', 'BROKER_TASK_NAME', 'BROKER_TASK_DISPATCH_TIME', 'FILE_ID', 'STATUS', ),
- BasePeer::TYPE_FIELDNAME => array ('id', 'service', 'foreign_id', 'broker_task_id', 'broker_task_name', 'broker_task_dispatch_time', 'file_id', 'status', ),
- BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ BasePeer::TYPE_PHPNAME => array ('DbId', 'DbService', 'DbForeignId', 'DbFileId', 'DbUploadTime', 'DbStatus', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbService', 'dbForeignId', 'dbFileId', 'dbUploadTime', 'dbStatus', ),
+ BasePeer::TYPE_COLNAME => array (ThirdPartyTrackReferencesPeer::ID, ThirdPartyTrackReferencesPeer::SERVICE, ThirdPartyTrackReferencesPeer::FOREIGN_ID, ThirdPartyTrackReferencesPeer::FILE_ID, ThirdPartyTrackReferencesPeer::UPLOAD_TIME, ThirdPartyTrackReferencesPeer::STATUS, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'SERVICE', 'FOREIGN_ID', 'FILE_ID', 'UPLOAD_TIME', 'STATUS', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'service', 'foreign_id', 'file_id', 'upload_time', 'status', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
);
/**
@@ -90,12 +84,12 @@ abstract class BaseThirdPartyTrackReferencesPeer
* e.g. ThirdPartyTrackReferencesPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
- BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbService' => 1, 'DbForeignId' => 2, 'DbBrokerTaskId' => 3, 'DbBrokerTaskName' => 4, 'DbBrokerTaskDispatchTime' => 5, 'DbFileId' => 6, 'DbStatus' => 7, ),
- BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbService' => 1, 'dbForeignId' => 2, 'dbBrokerTaskId' => 3, 'dbBrokerTaskName' => 4, 'dbBrokerTaskDispatchTime' => 5, 'dbFileId' => 6, 'dbStatus' => 7, ),
- BasePeer::TYPE_COLNAME => array (ThirdPartyTrackReferencesPeer::ID => 0, ThirdPartyTrackReferencesPeer::SERVICE => 1, ThirdPartyTrackReferencesPeer::FOREIGN_ID => 2, ThirdPartyTrackReferencesPeer::BROKER_TASK_ID => 3, ThirdPartyTrackReferencesPeer::BROKER_TASK_NAME => 4, ThirdPartyTrackReferencesPeer::BROKER_TASK_DISPATCH_TIME => 5, ThirdPartyTrackReferencesPeer::FILE_ID => 6, ThirdPartyTrackReferencesPeer::STATUS => 7, ),
- BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'SERVICE' => 1, 'FOREIGN_ID' => 2, 'BROKER_TASK_ID' => 3, 'BROKER_TASK_NAME' => 4, 'BROKER_TASK_DISPATCH_TIME' => 5, 'FILE_ID' => 6, 'STATUS' => 7, ),
- BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'service' => 1, 'foreign_id' => 2, 'broker_task_id' => 3, 'broker_task_name' => 4, 'broker_task_dispatch_time' => 5, 'file_id' => 6, 'status' => 7, ),
- BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
+ BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbService' => 1, 'DbForeignId' => 2, 'DbFileId' => 3, 'DbUploadTime' => 4, 'DbStatus' => 5, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbService' => 1, 'dbForeignId' => 2, 'dbFileId' => 3, 'dbUploadTime' => 4, 'dbStatus' => 5, ),
+ BasePeer::TYPE_COLNAME => array (ThirdPartyTrackReferencesPeer::ID => 0, ThirdPartyTrackReferencesPeer::SERVICE => 1, ThirdPartyTrackReferencesPeer::FOREIGN_ID => 2, ThirdPartyTrackReferencesPeer::FILE_ID => 3, ThirdPartyTrackReferencesPeer::UPLOAD_TIME => 4, ThirdPartyTrackReferencesPeer::STATUS => 5, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'SERVICE' => 1, 'FOREIGN_ID' => 2, 'FILE_ID' => 3, 'UPLOAD_TIME' => 4, 'STATUS' => 5, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'service' => 1, 'foreign_id' => 2, 'file_id' => 3, 'upload_time' => 4, 'status' => 5, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
);
/**
@@ -172,19 +166,15 @@ abstract class BaseThirdPartyTrackReferencesPeer
$criteria->addSelectColumn(ThirdPartyTrackReferencesPeer::ID);
$criteria->addSelectColumn(ThirdPartyTrackReferencesPeer::SERVICE);
$criteria->addSelectColumn(ThirdPartyTrackReferencesPeer::FOREIGN_ID);
- $criteria->addSelectColumn(ThirdPartyTrackReferencesPeer::BROKER_TASK_ID);
- $criteria->addSelectColumn(ThirdPartyTrackReferencesPeer::BROKER_TASK_NAME);
- $criteria->addSelectColumn(ThirdPartyTrackReferencesPeer::BROKER_TASK_DISPATCH_TIME);
$criteria->addSelectColumn(ThirdPartyTrackReferencesPeer::FILE_ID);
+ $criteria->addSelectColumn(ThirdPartyTrackReferencesPeer::UPLOAD_TIME);
$criteria->addSelectColumn(ThirdPartyTrackReferencesPeer::STATUS);
} else {
$criteria->addSelectColumn($alias . '.id');
$criteria->addSelectColumn($alias . '.service');
$criteria->addSelectColumn($alias . '.foreign_id');
- $criteria->addSelectColumn($alias . '.broker_task_id');
- $criteria->addSelectColumn($alias . '.broker_task_name');
- $criteria->addSelectColumn($alias . '.broker_task_dispatch_time');
$criteria->addSelectColumn($alias . '.file_id');
+ $criteria->addSelectColumn($alias . '.upload_time');
$criteria->addSelectColumn($alias . '.status');
}
}
@@ -390,6 +380,9 @@ abstract class BaseThirdPartyTrackReferencesPeer
*/
public static function clearRelatedInstancePool()
{
+ // Invalidate objects in CeleryTasksPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ CeleryTasksPeer::clearInstancePool();
}
/**
@@ -488,7 +481,7 @@ abstract class BaseThirdPartyTrackReferencesPeer
/**
- * Returns the number of rows matching criteria, joining the related CcPlayoutHistoryTemplate table
+ * Returns the number of rows matching criteria, joining the related CcFiles table
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
@@ -496,7 +489,7 @@ abstract class BaseThirdPartyTrackReferencesPeer
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
* @return int Number of matching rows.
*/
- public static function doCountJoinCcPlayoutHistoryTemplate(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ public static function doCountJoinCcFiles(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
// we're going to modify criteria, so copy it first
$criteria = clone $criteria;
@@ -523,7 +516,7 @@ abstract class BaseThirdPartyTrackReferencesPeer
$con = Propel::getConnection(ThirdPartyTrackReferencesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
- $criteria->addJoin(ThirdPartyTrackReferencesPeer::FILE_ID, CcPlayoutHistoryTemplatePeer::ID, $join_behavior);
+ $criteria->addJoin(ThirdPartyTrackReferencesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@@ -539,7 +532,7 @@ abstract class BaseThirdPartyTrackReferencesPeer
/**
- * Selects a collection of ThirdPartyTrackReferences objects pre-filled with their CcPlayoutHistoryTemplate objects.
+ * Selects a collection of ThirdPartyTrackReferences objects pre-filled with their CcFiles objects.
* @param Criteria $criteria
* @param PropelPDO $con
* @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
@@ -547,7 +540,7 @@ abstract class BaseThirdPartyTrackReferencesPeer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
- public static function doSelectJoinCcPlayoutHistoryTemplate(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
+ public static function doSelectJoinCcFiles(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
$criteria = clone $criteria;
@@ -558,9 +551,9 @@ abstract class BaseThirdPartyTrackReferencesPeer
ThirdPartyTrackReferencesPeer::addSelectColumns($criteria);
$startcol = ThirdPartyTrackReferencesPeer::NUM_HYDRATE_COLUMNS;
- CcPlayoutHistoryTemplatePeer::addSelectColumns($criteria);
+ CcFilesPeer::addSelectColumns($criteria);
- $criteria->addJoin(ThirdPartyTrackReferencesPeer::FILE_ID, CcPlayoutHistoryTemplatePeer::ID, $join_behavior);
+ $criteria->addJoin(ThirdPartyTrackReferencesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
@@ -580,19 +573,19 @@ abstract class BaseThirdPartyTrackReferencesPeer
ThirdPartyTrackReferencesPeer::addInstanceToPool($obj1, $key1);
} // if $obj1 already loaded
- $key2 = CcPlayoutHistoryTemplatePeer::getPrimaryKeyHashFromRow($row, $startcol);
+ $key2 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol);
if ($key2 !== null) {
- $obj2 = CcPlayoutHistoryTemplatePeer::getInstanceFromPool($key2);
+ $obj2 = CcFilesPeer::getInstanceFromPool($key2);
if (!$obj2) {
- $cls = CcPlayoutHistoryTemplatePeer::getOMClass();
+ $cls = CcFilesPeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol);
- CcPlayoutHistoryTemplatePeer::addInstanceToPool($obj2, $key2);
+ CcFilesPeer::addInstanceToPool($obj2, $key2);
} // if obj2 already loaded
- // Add the $obj1 (ThirdPartyTrackReferences) to $obj2 (CcPlayoutHistoryTemplate)
+ // Add the $obj1 (ThirdPartyTrackReferences) to $obj2 (CcFiles)
$obj2->addThirdPartyTrackReferences($obj1);
} // if joined row was not null
@@ -641,7 +634,7 @@ abstract class BaseThirdPartyTrackReferencesPeer
$con = Propel::getConnection(ThirdPartyTrackReferencesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
- $criteria->addJoin(ThirdPartyTrackReferencesPeer::FILE_ID, CcPlayoutHistoryTemplatePeer::ID, $join_behavior);
+ $criteria->addJoin(ThirdPartyTrackReferencesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior);
$stmt = BasePeer::doCount($criteria, $con);
@@ -677,10 +670,10 @@ abstract class BaseThirdPartyTrackReferencesPeer
ThirdPartyTrackReferencesPeer::addSelectColumns($criteria);
$startcol2 = ThirdPartyTrackReferencesPeer::NUM_HYDRATE_COLUMNS;
- CcPlayoutHistoryTemplatePeer::addSelectColumns($criteria);
- $startcol3 = $startcol2 + CcPlayoutHistoryTemplatePeer::NUM_HYDRATE_COLUMNS;
+ CcFilesPeer::addSelectColumns($criteria);
+ $startcol3 = $startcol2 + CcFilesPeer::NUM_HYDRATE_COLUMNS;
- $criteria->addJoin(ThirdPartyTrackReferencesPeer::FILE_ID, CcPlayoutHistoryTemplatePeer::ID, $join_behavior);
+ $criteria->addJoin(ThirdPartyTrackReferencesPeer::FILE_ID, CcFilesPeer::ID, $join_behavior);
$stmt = BasePeer::doSelect($criteria, $con);
$results = array();
@@ -699,21 +692,21 @@ abstract class BaseThirdPartyTrackReferencesPeer
ThirdPartyTrackReferencesPeer::addInstanceToPool($obj1, $key1);
} // if obj1 already loaded
- // Add objects for joined CcPlayoutHistoryTemplate rows
+ // Add objects for joined CcFiles rows
- $key2 = CcPlayoutHistoryTemplatePeer::getPrimaryKeyHashFromRow($row, $startcol2);
+ $key2 = CcFilesPeer::getPrimaryKeyHashFromRow($row, $startcol2);
if ($key2 !== null) {
- $obj2 = CcPlayoutHistoryTemplatePeer::getInstanceFromPool($key2);
+ $obj2 = CcFilesPeer::getInstanceFromPool($key2);
if (!$obj2) {
- $cls = CcPlayoutHistoryTemplatePeer::getOMClass();
+ $cls = CcFilesPeer::getOMClass();
$obj2 = new $cls();
$obj2->hydrate($row, $startcol2);
- CcPlayoutHistoryTemplatePeer::addInstanceToPool($obj2, $key2);
+ CcFilesPeer::addInstanceToPool($obj2, $key2);
} // if obj2 loaded
- // Add the $obj1 (ThirdPartyTrackReferences) to the collection in $obj2 (CcPlayoutHistoryTemplate)
+ // Add the $obj1 (ThirdPartyTrackReferences) to the collection in $obj2 (CcFiles)
$obj2->addThirdPartyTrackReferences($obj1);
} // if joined row not null
diff --git a/airtime_mvc/application/models/airtime/om/BaseThirdPartyTrackReferencesQuery.php b/airtime_mvc/application/models/airtime/om/BaseThirdPartyTrackReferencesQuery.php
index 8602b947b..86f0a174d 100644
--- a/airtime_mvc/application/models/airtime/om/BaseThirdPartyTrackReferencesQuery.php
+++ b/airtime_mvc/application/models/airtime/om/BaseThirdPartyTrackReferencesQuery.php
@@ -9,47 +9,43 @@
* @method ThirdPartyTrackReferencesQuery orderByDbId($order = Criteria::ASC) Order by the id column
* @method ThirdPartyTrackReferencesQuery orderByDbService($order = Criteria::ASC) Order by the service column
* @method ThirdPartyTrackReferencesQuery orderByDbForeignId($order = Criteria::ASC) Order by the foreign_id column
- * @method ThirdPartyTrackReferencesQuery orderByDbBrokerTaskId($order = Criteria::ASC) Order by the broker_task_id column
- * @method ThirdPartyTrackReferencesQuery orderByDbBrokerTaskName($order = Criteria::ASC) Order by the broker_task_name column
- * @method ThirdPartyTrackReferencesQuery orderByDbBrokerTaskDispatchTime($order = Criteria::ASC) Order by the broker_task_dispatch_time column
* @method ThirdPartyTrackReferencesQuery orderByDbFileId($order = Criteria::ASC) Order by the file_id column
+ * @method ThirdPartyTrackReferencesQuery orderByDbUploadTime($order = Criteria::ASC) Order by the upload_time column
* @method ThirdPartyTrackReferencesQuery orderByDbStatus($order = Criteria::ASC) Order by the status column
*
* @method ThirdPartyTrackReferencesQuery groupByDbId() Group by the id column
* @method ThirdPartyTrackReferencesQuery groupByDbService() Group by the service column
* @method ThirdPartyTrackReferencesQuery groupByDbForeignId() Group by the foreign_id column
- * @method ThirdPartyTrackReferencesQuery groupByDbBrokerTaskId() Group by the broker_task_id column
- * @method ThirdPartyTrackReferencesQuery groupByDbBrokerTaskName() Group by the broker_task_name column
- * @method ThirdPartyTrackReferencesQuery groupByDbBrokerTaskDispatchTime() Group by the broker_task_dispatch_time column
* @method ThirdPartyTrackReferencesQuery groupByDbFileId() Group by the file_id column
+ * @method ThirdPartyTrackReferencesQuery groupByDbUploadTime() Group by the upload_time column
* @method ThirdPartyTrackReferencesQuery groupByDbStatus() Group by the status column
*
* @method ThirdPartyTrackReferencesQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ThirdPartyTrackReferencesQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ThirdPartyTrackReferencesQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
- * @method ThirdPartyTrackReferencesQuery leftJoinCcPlayoutHistoryTemplate($relationAlias = null) Adds a LEFT JOIN clause to the query using the CcPlayoutHistoryTemplate relation
- * @method ThirdPartyTrackReferencesQuery rightJoinCcPlayoutHistoryTemplate($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CcPlayoutHistoryTemplate relation
- * @method ThirdPartyTrackReferencesQuery innerJoinCcPlayoutHistoryTemplate($relationAlias = null) Adds a INNER JOIN clause to the query using the CcPlayoutHistoryTemplate relation
+ * @method ThirdPartyTrackReferencesQuery leftJoinCcFiles($relationAlias = null) Adds a LEFT JOIN clause to the query using the CcFiles relation
+ * @method ThirdPartyTrackReferencesQuery rightJoinCcFiles($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CcFiles relation
+ * @method ThirdPartyTrackReferencesQuery innerJoinCcFiles($relationAlias = null) Adds a INNER JOIN clause to the query using the CcFiles relation
+ *
+ * @method ThirdPartyTrackReferencesQuery leftJoinCeleryTasks($relationAlias = null) Adds a LEFT JOIN clause to the query using the CeleryTasks relation
+ * @method ThirdPartyTrackReferencesQuery rightJoinCeleryTasks($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CeleryTasks relation
+ * @method ThirdPartyTrackReferencesQuery innerJoinCeleryTasks($relationAlias = null) Adds a INNER JOIN clause to the query using the CeleryTasks relation
*
* @method ThirdPartyTrackReferences findOne(PropelPDO $con = null) Return the first ThirdPartyTrackReferences matching the query
* @method ThirdPartyTrackReferences findOneOrCreate(PropelPDO $con = null) Return the first ThirdPartyTrackReferences matching the query, or a new ThirdPartyTrackReferences object populated from the query conditions when no match is found
*
* @method ThirdPartyTrackReferences findOneByDbService(string $service) Return the first ThirdPartyTrackReferences filtered by the service column
* @method ThirdPartyTrackReferences findOneByDbForeignId(string $foreign_id) Return the first ThirdPartyTrackReferences filtered by the foreign_id column
- * @method ThirdPartyTrackReferences findOneByDbBrokerTaskId(string $broker_task_id) Return the first ThirdPartyTrackReferences filtered by the broker_task_id column
- * @method ThirdPartyTrackReferences findOneByDbBrokerTaskName(string $broker_task_name) Return the first ThirdPartyTrackReferences filtered by the broker_task_name column
- * @method ThirdPartyTrackReferences findOneByDbBrokerTaskDispatchTime(string $broker_task_dispatch_time) Return the first ThirdPartyTrackReferences filtered by the broker_task_dispatch_time column
* @method ThirdPartyTrackReferences findOneByDbFileId(int $file_id) Return the first ThirdPartyTrackReferences filtered by the file_id column
+ * @method ThirdPartyTrackReferences findOneByDbUploadTime(string $upload_time) Return the first ThirdPartyTrackReferences filtered by the upload_time column
* @method ThirdPartyTrackReferences findOneByDbStatus(string $status) Return the first ThirdPartyTrackReferences filtered by the status column
*
* @method array findByDbId(int $id) Return ThirdPartyTrackReferences objects filtered by the id column
* @method array findByDbService(string $service) Return ThirdPartyTrackReferences objects filtered by the service column
* @method array findByDbForeignId(string $foreign_id) Return ThirdPartyTrackReferences objects filtered by the foreign_id column
- * @method array findByDbBrokerTaskId(string $broker_task_id) Return ThirdPartyTrackReferences objects filtered by the broker_task_id column
- * @method array findByDbBrokerTaskName(string $broker_task_name) Return ThirdPartyTrackReferences objects filtered by the broker_task_name column
- * @method array findByDbBrokerTaskDispatchTime(string $broker_task_dispatch_time) Return ThirdPartyTrackReferences objects filtered by the broker_task_dispatch_time column
* @method array findByDbFileId(int $file_id) Return ThirdPartyTrackReferences objects filtered by the file_id column
+ * @method array findByDbUploadTime(string $upload_time) Return ThirdPartyTrackReferences objects filtered by the upload_time column
* @method array findByDbStatus(string $status) Return ThirdPartyTrackReferences objects filtered by the status column
*
* @package propel.generator.airtime.om
@@ -158,7 +154,7 @@ abstract class BaseThirdPartyTrackReferencesQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
- $sql = 'SELECT "id", "service", "foreign_id", "broker_task_id", "broker_task_name", "broker_task_dispatch_time", "file_id", "status" FROM "third_party_track_references" WHERE "id" = :p0';
+ $sql = 'SELECT "id", "service", "foreign_id", "file_id", "upload_time", "status" FROM "third_party_track_references" WHERE "id" = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -347,107 +343,6 @@ abstract class BaseThirdPartyTrackReferencesQuery extends ModelCriteria
return $this->addUsingAlias(ThirdPartyTrackReferencesPeer::FOREIGN_ID, $dbForeignId, $comparison);
}
- /**
- * Filter the query on the broker_task_id column
- *
- * Example usage:
- *
- * $query->filterByDbBrokerTaskId('fooValue'); // WHERE broker_task_id = 'fooValue'
- * $query->filterByDbBrokerTaskId('%fooValue%'); // WHERE broker_task_id LIKE '%fooValue%'
- *
- *
- * @param string $dbBrokerTaskId The value to use as filter.
- * Accepts wildcards (* and % trigger a LIKE)
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return ThirdPartyTrackReferencesQuery The current query, for fluid interface
- */
- public function filterByDbBrokerTaskId($dbBrokerTaskId = null, $comparison = null)
- {
- if (null === $comparison) {
- if (is_array($dbBrokerTaskId)) {
- $comparison = Criteria::IN;
- } elseif (preg_match('/[\%\*]/', $dbBrokerTaskId)) {
- $dbBrokerTaskId = str_replace('*', '%', $dbBrokerTaskId);
- $comparison = Criteria::LIKE;
- }
- }
-
- return $this->addUsingAlias(ThirdPartyTrackReferencesPeer::BROKER_TASK_ID, $dbBrokerTaskId, $comparison);
- }
-
- /**
- * Filter the query on the broker_task_name column
- *
- * Example usage:
- *
- * $query->filterByDbBrokerTaskName('fooValue'); // WHERE broker_task_name = 'fooValue'
- * $query->filterByDbBrokerTaskName('%fooValue%'); // WHERE broker_task_name LIKE '%fooValue%'
- *
- *
- * @param string $dbBrokerTaskName The value to use as filter.
- * Accepts wildcards (* and % trigger a LIKE)
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return ThirdPartyTrackReferencesQuery The current query, for fluid interface
- */
- public function filterByDbBrokerTaskName($dbBrokerTaskName = null, $comparison = null)
- {
- if (null === $comparison) {
- if (is_array($dbBrokerTaskName)) {
- $comparison = Criteria::IN;
- } elseif (preg_match('/[\%\*]/', $dbBrokerTaskName)) {
- $dbBrokerTaskName = str_replace('*', '%', $dbBrokerTaskName);
- $comparison = Criteria::LIKE;
- }
- }
-
- return $this->addUsingAlias(ThirdPartyTrackReferencesPeer::BROKER_TASK_NAME, $dbBrokerTaskName, $comparison);
- }
-
- /**
- * Filter the query on the broker_task_dispatch_time column
- *
- * Example usage:
- *
- * $query->filterByDbBrokerTaskDispatchTime('2011-03-14'); // WHERE broker_task_dispatch_time = '2011-03-14'
- * $query->filterByDbBrokerTaskDispatchTime('now'); // WHERE broker_task_dispatch_time = '2011-03-14'
- * $query->filterByDbBrokerTaskDispatchTime(array('max' => 'yesterday')); // WHERE broker_task_dispatch_time < '2011-03-13'
- *
- *
- * @param mixed $dbBrokerTaskDispatchTime The value to use as filter.
- * Values can be integers (unix timestamps), DateTime objects, or strings.
- * Empty strings are treated as NULL.
- * Use scalar values for equality.
- * Use array values for in_array() equivalent.
- * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
- * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
- *
- * @return ThirdPartyTrackReferencesQuery The current query, for fluid interface
- */
- public function filterByDbBrokerTaskDispatchTime($dbBrokerTaskDispatchTime = null, $comparison = null)
- {
- if (is_array($dbBrokerTaskDispatchTime)) {
- $useMinMax = false;
- if (isset($dbBrokerTaskDispatchTime['min'])) {
- $this->addUsingAlias(ThirdPartyTrackReferencesPeer::BROKER_TASK_DISPATCH_TIME, $dbBrokerTaskDispatchTime['min'], Criteria::GREATER_EQUAL);
- $useMinMax = true;
- }
- if (isset($dbBrokerTaskDispatchTime['max'])) {
- $this->addUsingAlias(ThirdPartyTrackReferencesPeer::BROKER_TASK_DISPATCH_TIME, $dbBrokerTaskDispatchTime['max'], Criteria::LESS_EQUAL);
- $useMinMax = true;
- }
- if ($useMinMax) {
- return $this;
- }
- if (null === $comparison) {
- $comparison = Criteria::IN;
- }
- }
-
- return $this->addUsingAlias(ThirdPartyTrackReferencesPeer::BROKER_TASK_DISPATCH_TIME, $dbBrokerTaskDispatchTime, $comparison);
- }
-
/**
* Filter the query on the file_id column
*
@@ -459,7 +354,7 @@ abstract class BaseThirdPartyTrackReferencesQuery extends ModelCriteria
* $query->filterByDbFileId(array('max' => 12)); // WHERE file_id <= 12
*
*
- * @see filterByCcPlayoutHistoryTemplate()
+ * @see filterByCcFiles()
*
* @param mixed $dbFileId The value to use as filter.
* Use scalar values for equality.
@@ -492,6 +387,49 @@ abstract class BaseThirdPartyTrackReferencesQuery extends ModelCriteria
return $this->addUsingAlias(ThirdPartyTrackReferencesPeer::FILE_ID, $dbFileId, $comparison);
}
+ /**
+ * Filter the query on the upload_time column
+ *
+ * Example usage:
+ *
+ * $query->filterByDbUploadTime('2011-03-14'); // WHERE upload_time = '2011-03-14'
+ * $query->filterByDbUploadTime('now'); // WHERE upload_time = '2011-03-14'
+ * $query->filterByDbUploadTime(array('max' => 'yesterday')); // WHERE upload_time < '2011-03-13'
+ *
+ *
+ * @param mixed $dbUploadTime The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ThirdPartyTrackReferencesQuery The current query, for fluid interface
+ */
+ public function filterByDbUploadTime($dbUploadTime = null, $comparison = null)
+ {
+ if (is_array($dbUploadTime)) {
+ $useMinMax = false;
+ if (isset($dbUploadTime['min'])) {
+ $this->addUsingAlias(ThirdPartyTrackReferencesPeer::UPLOAD_TIME, $dbUploadTime['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($dbUploadTime['max'])) {
+ $this->addUsingAlias(ThirdPartyTrackReferencesPeer::UPLOAD_TIME, $dbUploadTime['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ThirdPartyTrackReferencesPeer::UPLOAD_TIME, $dbUploadTime, $comparison);
+ }
+
/**
* Filter the query on the status column
*
@@ -522,43 +460,43 @@ abstract class BaseThirdPartyTrackReferencesQuery extends ModelCriteria
}
/**
- * Filter the query by a related CcPlayoutHistoryTemplate object
+ * Filter the query by a related CcFiles object
*
- * @param CcPlayoutHistoryTemplate|PropelObjectCollection $ccPlayoutHistoryTemplate The related object(s) to use as filter
+ * @param CcFiles|PropelObjectCollection $ccFiles The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ThirdPartyTrackReferencesQuery The current query, for fluid interface
* @throws PropelException - if the provided filter is invalid.
*/
- public function filterByCcPlayoutHistoryTemplate($ccPlayoutHistoryTemplate, $comparison = null)
+ public function filterByCcFiles($ccFiles, $comparison = null)
{
- if ($ccPlayoutHistoryTemplate instanceof CcPlayoutHistoryTemplate) {
+ if ($ccFiles instanceof CcFiles) {
return $this
- ->addUsingAlias(ThirdPartyTrackReferencesPeer::FILE_ID, $ccPlayoutHistoryTemplate->getDbId(), $comparison);
- } elseif ($ccPlayoutHistoryTemplate instanceof PropelObjectCollection) {
+ ->addUsingAlias(ThirdPartyTrackReferencesPeer::FILE_ID, $ccFiles->getDbId(), $comparison);
+ } elseif ($ccFiles instanceof PropelObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
- ->addUsingAlias(ThirdPartyTrackReferencesPeer::FILE_ID, $ccPlayoutHistoryTemplate->toKeyValue('PrimaryKey', 'DbId'), $comparison);
+ ->addUsingAlias(ThirdPartyTrackReferencesPeer::FILE_ID, $ccFiles->toKeyValue('PrimaryKey', 'DbId'), $comparison);
} else {
- throw new PropelException('filterByCcPlayoutHistoryTemplate() only accepts arguments of type CcPlayoutHistoryTemplate or PropelCollection');
+ throw new PropelException('filterByCcFiles() only accepts arguments of type CcFiles or PropelCollection');
}
}
/**
- * Adds a JOIN clause to the query using the CcPlayoutHistoryTemplate relation
+ * Adds a JOIN clause to the query using the CcFiles relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ThirdPartyTrackReferencesQuery The current query, for fluid interface
*/
- public function joinCcPlayoutHistoryTemplate($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function joinCcFiles($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
- $relationMap = $tableMap->getRelation('CcPlayoutHistoryTemplate');
+ $relationMap = $tableMap->getRelation('CcFiles');
// create a ModelJoin object for this join
$join = new ModelJoin();
@@ -573,14 +511,14 @@ abstract class BaseThirdPartyTrackReferencesQuery extends ModelCriteria
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
- $this->addJoinObject($join, 'CcPlayoutHistoryTemplate');
+ $this->addJoinObject($join, 'CcFiles');
}
return $this;
}
/**
- * Use the CcPlayoutHistoryTemplate relation CcPlayoutHistoryTemplate object
+ * Use the CcFiles relation CcFiles object
*
* @see useQuery()
*
@@ -588,13 +526,87 @@ abstract class BaseThirdPartyTrackReferencesQuery extends ModelCriteria
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
- * @return CcPlayoutHistoryTemplateQuery A secondary query class using the current class as primary query
+ * @return CcFilesQuery A secondary query class using the current class as primary query
*/
- public function useCcPlayoutHistoryTemplateQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ public function useCcFilesQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
- ->joinCcPlayoutHistoryTemplate($relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : 'CcPlayoutHistoryTemplate', 'CcPlayoutHistoryTemplateQuery');
+ ->joinCcFiles($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CcFiles', 'CcFilesQuery');
+ }
+
+ /**
+ * Filter the query by a related CeleryTasks object
+ *
+ * @param CeleryTasks|PropelObjectCollection $celeryTasks the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ThirdPartyTrackReferencesQuery The current query, for fluid interface
+ * @throws PropelException - if the provided filter is invalid.
+ */
+ public function filterByCeleryTasks($celeryTasks, $comparison = null)
+ {
+ if ($celeryTasks instanceof CeleryTasks) {
+ return $this
+ ->addUsingAlias(ThirdPartyTrackReferencesPeer::ID, $celeryTasks->getDbTrackReference(), $comparison);
+ } elseif ($celeryTasks instanceof PropelObjectCollection) {
+ return $this
+ ->useCeleryTasksQuery()
+ ->filterByPrimaryKeys($celeryTasks->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCeleryTasks() only accepts arguments of type CeleryTasks or PropelCollection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CeleryTasks relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ThirdPartyTrackReferencesQuery The current query, for fluid interface
+ */
+ public function joinCeleryTasks($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CeleryTasks');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'CeleryTasks');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CeleryTasks relation CeleryTasks object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CeleryTasksQuery A secondary query class using the current class as primary query
+ */
+ public function useCeleryTasksQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCeleryTasks($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CeleryTasks', 'CeleryTasksQuery');
}
/**
diff --git a/airtime_mvc/application/services/CeleryService.php b/airtime_mvc/application/services/CeleryService.php
new file mode 100644
index 000000000..f47ccd715
--- /dev/null
+++ b/airtime_mvc/application/services/CeleryService.php
@@ -0,0 +1,206 @@
+PostTask($task, $data, true, $routingKey); // and routing key
+ return $result->getId();
+ }
+
+ /**
+ * Given a task name and identifier, check the Celery results queue for any
+ * corresponding messages
+ *
+ * @param $task CeleryTasks the Celery task object
+ *
+ * @return object the message object
+ *
+ * @throws CeleryTimeoutException when no message is found and more than
+ * $_CELERY_MESSAGE_TIMEOUT milliseconds have passed
+ */
+ private static function getAsyncResultMessage($task) {
+ $config = parse_ini_file(Application_Model_RabbitMq::getRmqConfigPath(), true);
+ $queue = self::$_CELERY_RESULTS_EXCHANGE . "." . $task;
+ $c = self::_setupCeleryExchange($config, self::$_CELERY_RESULTS_EXCHANGE, $queue);
+ $message = $c->getAsyncResultMessage($task->getDbName(), $task->getDbId());
+
+ // If the message isn't ready yet (Celery hasn't finished the task),
+ // only throw an exception if the message has timed out.
+ if ($message == FALSE && self::_checkMessageTimeout($task)) {
+ throw new CeleryTimeoutException("Celery task " . $task->getDbName()
+ . " with ID " . $task->getDbId() . " timed out");
+ }
+ return $message;
+ }
+
+ /**
+ * Check to see if there are any pending tasks for this service
+ *
+ * @param string $taskName the name of the task to poll for
+ * @param string $serviceName the name of the service to poll for
+ *
+ * @return bool true if there are any pending tasks, otherwise false
+ */
+ public static function isBrokerTaskQueueEmpty($taskName="", $serviceName = "") {
+ $pendingTasks = self::_getPendingTasks($taskName, $serviceName);
+ return empty($pendingTasks);
+ }
+
+ /**
+ * Poll the message queue for this service to see if any tasks with the given name have completed
+ *
+ * If we find any completed tasks, adjust the ThirdPartyTrackReferences table accordingly
+ *
+ * If no task name is passed, we poll all tasks for this service
+ *
+ * @param string $taskName the name of the task to poll for
+ * @param string $serviceName the name of the service to poll for
+ */
+ public static function pollBrokerTaskQueue($taskName = "", $serviceName = "") {
+ $pendingTasks = self::_getPendingTasks($taskName, $serviceName);
+ foreach ($pendingTasks as $task) {
+ try {
+ $message = self::_getTaskMessage($task);
+ self::_processTaskMessage($task, $message);
+ } catch (CeleryTimeoutException $e) {
+ // If the task times out, mark it as failed. We don't want to remove the
+ // track reference here in case it was a deletion that failed, for example.
+ // TODO: Move this somewhere more appropriate
+ $task->setDbStatus(CELERY_FAILED_STATUS);
+ $task->save();
+ Logging::info($e->getMessage());
+ } catch (Exception $e) {
+ // Because $message->result can be either an object or a string, sometimes
+ // we get a json_decode error and end up here
+ Logging::info($e->getMessage());
+ }
+ }
+ }
+
+ /**
+ * Return a collection of all pending CeleryTasks for this service or task
+ *
+ * @param string $taskName the name of the task to find
+ * @param string $serviceName the name of the service to find
+ *
+ * @return PropelCollection any pending CeleryTasks results for this service
+ * or task if taskName is provided
+ */
+ protected static function _getPendingTasks($taskName, $serviceName) {
+ $query = CeleryTasksQuery::create()
+ ->filterByDbStatus(CELERY_PENDING_STATUS)
+ ->filterByDbId('', Criteria::NOT_EQUAL);
+ if (!empty($taskName)) {
+ $query->filterByDbName($taskName);
+ }
+ if (!empty($serviceName)) {
+ $query->useThirdPartyTrackReferencesQuery()
+ ->filterByDbService($serviceName)->endUse();
+ }
+ return $query->joinThirdPartyTrackReferences()
+ ->with('ThirdPartyTrackReferences')->find();
+ }
+
+ /**
+ * Get a Celery task message from the results queue
+ *
+ * @param $task CeleryTasks the Celery task object
+ *
+ * @return object the task message object
+ *
+ * @throws CeleryException when the result message for this task no longer exists
+ */
+ protected static function _getTaskMessage($task) {
+ $message = self::getAsyncResultMessage($task);
+ return json_decode($message['body']);
+ }
+
+ /**
+ * Process a message from the results queue
+ *
+ * @param $task CeleryTasks Celery task object
+ * @param $message mixed async message object from php-celery
+ */
+ protected static function _processTaskMessage($task, $message) {
+ $ref = $task->getThirdPartyTrackReferences(); // ThirdPartyTrackReferences join
+ $service = CeleryServiceFactory::getService($ref->getDbService());
+ if ($message->status == CELERY_SUCCESS_STATUS
+ && $task->getDbName() == $service->getCeleryDeleteTaskName()) {
+ $service->removeTrackReference($ref->getDbFileId());
+ } else {
+ $service->updateTrackReference($ref->getDbId(), json_decode($message->result), $message->status);
+ }
+ }
+
+ /**
+ * Check if a task message has been unreachable for more our timeout time
+ *
+ * @param $task CeleryTasks the Celery task object
+ *
+ * @return bool true if the dispatch time is empty or it's been more than our timeout time
+ * since the message was dispatched, otherwise false
+ */
+ protected static function _checkMessageTimeout($task) {
+ $utc = new DateTimeZone("UTC");
+ $dispatchTime = new DateTime($task->getDbDispatchTime(), $utc);
+ $now = new DateTime("now", $utc);
+ $timeoutSeconds = self::$_CELERY_MESSAGE_TIMEOUT / 1000; // Convert from milliseconds
+ $timeoutInterval = new DateInterval("PT" . $timeoutSeconds . "S");
+ return (empty($dispatchTime) || $dispatchTime->add($timeoutInterval) <= $now);
+ }
+
+}
\ No newline at end of file
diff --git a/airtime_mvc/application/services/CeleryServiceFactory.php b/airtime_mvc/application/services/CeleryServiceFactory.php
new file mode 100644
index 000000000..defb6ce81
--- /dev/null
+++ b/airtime_mvc/application/services/CeleryServiceFactory.php
@@ -0,0 +1,20 @@
+filterByDbService(static::$_SERVICE_NAME)
- ->findOneByDbFileId($fileId);
+ ->findOneByDbId($trackId);
if (is_null($ref)) {
$ref = new ThirdPartyTrackReferences();
- } // If this was a delete task, just remove the record and return
- else if ($ref->getDbBrokerTaskName() == static::$_CELERY_DELETE_TASK_NAME) {
- $ref->delete();
- return;
}
$ref->setDbService(static::$_SERVICE_NAME);
// Only set the SoundCloud fields if the task was successful
@@ -110,15 +105,8 @@ class SoundcloudService extends ThirdPartyService {
// TODO: fetch any additional SoundCloud parameters we want to store
$ref->setDbForeignId($track->id); // SoundCloud identifier
}
- $ref->setDbFileId($fileId);
- $ref->setDbStatus($status);
- // Null the broker task fields because we no longer need them
- // We use NULL over an empty string/object here because we have
- // a unique constraint on the task ID and it's easier to filter
- // and query against NULLs
- $ref->setDbBrokerTaskId(NULL);
- $ref->setDbBrokerTaskName(NULL);
- $ref->setDbBrokerTaskDispatchTime(NULL);
+ // TODO: set SoundCloud upload status?
+ // $ref->setDbStatus($status);
$ref->save();
}
diff --git a/airtime_mvc/application/services/ThirdPartyCeleryService.php b/airtime_mvc/application/services/ThirdPartyCeleryService.php
new file mode 100644
index 000000000..5588c2cf7
--- /dev/null
+++ b/airtime_mvc/application/services/ThirdPartyCeleryService.php
@@ -0,0 +1,135 @@
+ $this->_getUploadData($file),
+ 'token' => $this->_accessToken,
+ 'file_path' => $file->getFilePaths()[0]
+ );
+ try {
+ $brokerTaskId = CeleryService::sendCeleryMessage(static::$_CELERY_UPLOAD_TASK_NAME,
+ static::$_CELERY_EXCHANGE_NAME,
+ $data);
+ $this->_createTaskReference($fileId, $brokerTaskId, static::$_CELERY_UPLOAD_TASK_NAME);
+ } catch (Exception $e) {
+ Logging::info("Invalid request: " . $e->getMessage());
+ }
+ }
+
+ /**
+ * Delete the file with the given identifier from a third-party service
+ *
+ * @param int $fileId the local CcFiles identifier
+ *
+ * @throws ServiceNotFoundException when a $fileId with no corresponding
+ * service identifier is given
+ */
+ public function delete($fileId) {
+ $serviceId = $this->getServiceId($fileId);
+ if ($serviceId == 0) {
+ throw new ServiceNotFoundException("No service found for file with ID $fileId");
+ }
+ $data = array(
+ 'token' => $this->_accessToken,
+ 'track_id' => $serviceId
+ );
+ try {
+ $brokerTaskId = CeleryService::sendCeleryMessage(static::$_CELERY_DELETE_TASK_NAME,
+ static::$_CELERY_EXCHANGE_NAME,
+ $data);
+ $this->_createTaskReference($fileId, $brokerTaskId, static::$_CELERY_DELETE_TASK_NAME);
+ } catch (Exception $e) {
+ Logging::info("Invalid request: " . $e->getMessage());
+ }
+ }
+
+ /**
+ * Create a CeleryTasks object for a pending task
+ * TODO: should we have a database layer class to handle Propel operations?
+ *
+ * @param $fileId int CcFiles identifier
+ * @param $brokerTaskId int broker task identifier to so we can asynchronously
+ * receive completed task messages
+ * @param $taskName string broker task name
+ *
+ * @throws Exception
+ * @throws PropelException
+ */
+ protected function _createTaskReference($fileId, $brokerTaskId, $taskName) {
+ $trackId = $this->createTrackReference($fileId);
+ // First, check if the track already has an entry in the database
+ $ref = CeleryTasksQuery::create()->findOneByDbId($brokerTaskId);
+ if (is_null($ref)) {
+ $ref = new CeleryTasks();
+ }
+ $ref->setDbId($brokerTaskId);
+ $ref->setDbName($taskName);
+ $utc = new DateTimeZone("UTC");
+ $ref->setDbDispatchTime(new DateTime("now", $utc));
+ $ref->setDbStatus(CELERY_PENDING_STATUS);
+ $ref->setDbTrackReference($trackId);
+ $ref->save();
+ }
+
+ /**
+ * Update a CeleryTasks object for a completed upload
+ * TODO: should we have a database layer class to handle Propel operations?
+ *
+ * @param $trackId int ThirdPartyTrackReferences identifier
+ * @param $track object third-party service track object
+ * @param $status string Celery task status
+ *
+ * @throws Exception
+ * @throws PropelException
+ */
+ public function updateTrackReference($trackId, $track, $status) {
+ $ref = CeleryTasksQuery::create()
+ ->findOneByDbTrackReference($trackId);
+ $ref->setDbStatus($status);
+ $ref->save();
+ }
+
+ /**
+ * Build a parameter array for the file being uploaded to a third party service
+ *
+ * @param $file Application_Model_StoredFile the file being uploaded
+ *
+ * @return array the track array to send to the third party service
+ */
+ abstract protected function _getUploadData($file);
+
+ /**
+ * Field accessor for $_CELERY_DELETE_TASK_NAME
+ *
+ * @return string the Celery task name for deleting tracks from this service
+ */
+ public function getCeleryDeleteTaskName() {
+ return self::$_CELERY_DELETE_TASK_NAME;
+ }
+
+}
\ No newline at end of file
diff --git a/airtime_mvc/application/services/ThirdPartyService.php b/airtime_mvc/application/services/ThirdPartyService.php
index 058f3db97..365002ee7 100644
--- a/airtime_mvc/application/services/ThirdPartyService.php
+++ b/airtime_mvc/application/services/ThirdPartyService.php
@@ -7,12 +7,11 @@ class ServiceNotFoundException extends Exception {}
/**
* Class ThirdPartyService generic superclass for third-party services
- * TODO: decouple the media/track-specific functions into ThirdPartyMediaService class?
*/
abstract class ThirdPartyService {
/**
- * @var string service access token for accessing remote API
+ * @var string service access token for accessing third-party API
*/
protected $_accessToken;
@@ -27,86 +26,18 @@ abstract class ThirdPartyService {
protected static $_THIRD_PARTY_TRACK_URI;
/**
- * @var string broker exchange name for third party tasks
- */
- protected static $_CELERY_EXCHANGE_NAME;
-
- /**
- * @var string celery task name for third party uploads
- */
- protected static $_CELERY_UPLOAD_TASK_NAME;
-
- /**
- * @var string celery task name for third party deletion
- */
- protected static $_CELERY_DELETE_TASK_NAME;
-
- /**
- * Upload the file with the given identifier to a third-party service
- *
- * @param int $fileId the local CcFiles identifier
- */
- public function upload($fileId) {
- $file = Application_Model_StoredFile::RecallById($fileId);
- $data = array(
- 'data' => $this->_getUploadData($file),
- 'token' => $this->_accessToken,
- 'file_path' => $file->getFilePaths()[0]
- );
- try {
- $brokerTaskId = Application_Model_RabbitMq::sendCeleryMessage(static::$_CELERY_UPLOAD_TASK_NAME,
- static::$_CELERY_EXCHANGE_NAME,
- $data);
- $this->_createTaskReference($fileId, $brokerTaskId, static::$_CELERY_UPLOAD_TASK_NAME);
- } catch (Exception $e) {
- Logging::info("Invalid request: " . $e->getMessage());
- // We should only get here if we have an access token, so attempt to refresh
- $this->accessTokenRefresh();
- }
- }
-
- /**
- * Delete the file with the given identifier from a third-party service
- *
- * @param int $fileId the local CcFiles identifier
- *
- * @throws ServiceNotFoundException when a $fileId with no corresponding
- * service identifier is given
- */
- public function delete($fileId) {
- $serviceId = $this->getServiceId($fileId);
- if ($serviceId == 0) {
- throw new ServiceNotFoundException("No service found for file with ID $fileId");
- }
- $data = array(
- 'token' => $this->_accessToken,
- 'track_id' => $serviceId
- );
- try {
- $brokerTaskId = Application_Model_RabbitMq::sendCeleryMessage(static::$_CELERY_DELETE_TASK_NAME,
- static::$_CELERY_EXCHANGE_NAME,
- $data);
- $this->_createTaskReference($fileId, $brokerTaskId, static::$_CELERY_DELETE_TASK_NAME);
- } catch (Exception $e) {
- Logging::info("Invalid request: " . $e->getMessage());
- // We should only get here if we have an access token, so attempt to refresh
- $this->accessTokenRefresh();
- }
- }
-
- /**
- * Create a ThirdPartyTrackReferences object for a pending task
+ * Create a ThirdPartyTrackReferences object for a track that's been uploaded
+ * to an external service
* TODO: should we have a database layer class to handle Propel operations?
*
- * @param $fileId int local CcFiles identifier
- * @param $brokerTaskId int broker task identifier to so we can asynchronously
- * receive completed task messages
- * @param $taskName string broker task name
+ * @param $fileId int local CcFiles identifier
+ *
+ * @return string the new ThirdPartyTrackReferences identifier
*
* @throws Exception
* @throws PropelException
*/
- protected function _createTaskReference($fileId, $brokerTaskId, $taskName) {
+ public function createTrackReference($fileId) {
// First, check if the track already has an entry in the database
$ref = ThirdPartyTrackReferencesQuery::create()
->filterByDbService(static::$_SERVICE_NAME)
@@ -115,13 +46,11 @@ abstract class ThirdPartyService {
$ref = new ThirdPartyTrackReferences();
}
$ref->setDbService(static::$_SERVICE_NAME);
- $ref->setDbBrokerTaskId($brokerTaskId);
- $ref->setDbBrokerTaskName($taskName);
- $utc = new DateTimeZone("UTC");
- $ref->setDbBrokerTaskDispatchTime(new DateTime("now", $utc));
+ // TODO: implement service-specific statuses?
+ // $ref->setDbStatus(CELERY_PENDING_STATUS);
$ref->setDbFileId($fileId);
- $ref->setDbStatus(CELERY_PENDING_STATUS);
$ref->save();
+ return $ref->getDbId();
}
/**
@@ -129,7 +58,7 @@ abstract class ThirdPartyService {
* This is necessary if the track was removed from the service
* or the foreign id in our database is incorrect
*
- * @param $fileId int local CcFiles identifier
+ * @param $fileId int cc_files identifier
*
* @throws Exception
* @throws PropelException
@@ -147,169 +76,55 @@ abstract class ThirdPartyService {
*
* @param int $fileId the local CcFiles identifier
*
- * @return int the service foreign identifier
+ * @return string the service foreign identifier
*/
public function getServiceId($fileId) {
$ref = ThirdPartyTrackReferencesQuery::create()
->filterByDbService(static::$_SERVICE_NAME)
->findOneByDbFileId($fileId); // There shouldn't be duplicates!
- return empty($ref) ? 0 : $ref->getDbForeignId();
+ return empty($ref) ? '' : $ref->getDbForeignId();
}
/**
* Given a CcFiles identifier for a file that's been uploaded to a third-party service,
* return a link to the remote file
*
- * @param int $fileId the local CcFiles identifier
+ * @param int $fileId CcFiles identifier
*
* @return string the link to the remote file
*/
public function getLinkToFile($fileId) {
$serviceId = $this->getServiceId($fileId);
- return $serviceId > 0 ? static::$_THIRD_PARTY_TRACK_URI . $serviceId : '';
+ return empty($serviceId) ? '' : static::$_THIRD_PARTY_TRACK_URI . $serviceId;
}
/**
- * Check to see if there are any pending tasks for this service
+ * Upload the file with the given identifier to a third-party service
*
- * @param string $taskName
- *
- * @return bool true if there are any pending tasks, otherwise false
+ * @param int $fileId CcFiles identifier
*/
- public function isBrokerTaskQueueEmpty($taskName="") {
- $query = ThirdPartyTrackReferencesQuery::create()
- ->filterByDbService(static::$_SERVICE_NAME);
- if (!empty($taskName)) {
- $query->filterByDbBrokerTaskName($taskName);
- }
- $result = $query->findOneByDbStatus(CELERY_PENDING_STATUS);
- return empty($result);
- }
+ abstract function upload($fileId);
/**
- * Poll the message queue for this service to see if any tasks with the given name have completed
- * If we find any completed tasks, adjust the ThirdPartyTrackReferences table accordingly
- * If no task name is passed, we poll all tasks for this service
+ * Delete the file with the given identifier from a third-party service
*
- * @param string $taskName the name of the task to poll for
+ * @param int $fileId the local CcFiles identifier
+ *
+ * @throws ServiceNotFoundException when a $fileId with no corresponding
+ * service identifier is given
*/
- public function pollBrokerTaskQueue($taskName="") {
- $pendingTasks = static::_getPendingTasks($taskName);
- foreach ($pendingTasks as $task) {
- try {
- $message = static::_getTaskMessage($task);
- static::_addOrUpdateTrackReference($task->getDbFileId(), json_decode($message->result), $message->status);
- } catch (CeleryException $e) {
- // Fail silently unless the message has timed out; often we end up here when
- // the Celery task takes a while to execute
- if (static::_checkMessageTimeout($task)) {
- Logging::info($e->getMessage());
- $task->setDbStatus(CELERY_FAILED_STATUS);
- $task->save();
- }
- } catch (Exception $e) {
- // Sometimes we might catch a json_decode error and end up here
- Logging::info($e->getMessage());
- }
- }
- }
-
- /**
- * Return a collection of all pending ThirdPartyTrackReferences to tasks for this service or task
- *
- * @param string $taskName the name of the task to look for
- *
- * @return PropelCollection any pending ThirdPartyTrackReferences results for this service
- * or task if taskName is provided
- */
- protected function _getPendingTasks($taskName) {
- $query = ThirdPartyTrackReferencesQuery::create()
- ->filterByDbService(static::$_SERVICE_NAME)
- ->filterByDbStatus(CELERY_PENDING_STATUS)
- ->filterByDbBrokerTaskId('', Criteria::NOT_EQUAL);
- if (!empty($taskName)) {
- $query->filterByDbBrokerTaskName($taskName);
- }
- return $query->find();
- }
-
- /**
- * Get a Celery task message from the results queue
- *
- * @param $task ThirdPartyTrackReferences the track reference object
- *
- * @return object the task message object
- *
- * @throws CeleryException when the result message for this task no longer exists
- */
- protected static function _getTaskMessage($task) {
- $message = Application_Model_RabbitMq::getAsyncResultMessage($task->getDbBrokerTaskName(),
- $task->getDbBrokerTaskId());
- return json_decode($message['body']);
- }
-
- /**
- * Check if a task message has been unreachable for more our timeout time
- *
- * @param $task ThirdPartyTrackReferences the track reference object
- *
- * @return bool true if the dispatch time is empty or it's been more than our timeout time
- * since the message was dispatched, otherwise false
- */
- protected static function _checkMessageTimeout($task) {
- $utc = new DateTimeZone("UTC");
- $dispatchTime = new DateTime($task->getDbBrokerTaskDispatchTime(), $utc);
- $now = new DateTime("now", $utc);
- $timeoutSeconds = Application_Model_RabbitMq::$_CELERY_MESSAGE_TIMEOUT / 1000; // Convert from milliseconds
- $timeoutInterval = new DateInterval("PT" . $timeoutSeconds . "S");
- return (empty($dispatchTime) || $dispatchTime->add($timeoutInterval) <= $now);
- }
-
- /**
- * Build a parameter array for the file being uploaded to a third party service
- *
- * @param $file Application_Model_StoredFile the file being uploaded
- *
- * @return array the track array to send to the third party service
- */
- abstract protected function _getUploadData($file);
+ abstract function delete($fileId);
/**
* Update a ThirdPartyTrackReferences object for a completed task
*
- * @param $fileId int local CcFiles identifier
- * @param $track object third-party service track object
- * @param $status string Celery task status
+ * @param $trackId int ThirdPartyTrackReferences identifier
+ * @param $track object third-party service track object
+ * @param $status string Celery task status
*
* @throws Exception
* @throws PropelException
*/
- abstract protected function _addOrUpdateTrackReference($fileId, $track, $status);
-
- /**
- * Check whether an OAuth access token exists for the third-party client
- *
- * @return bool true if an access token exists, otherwise false
- */
- abstract function hasAccessToken();
-
- /**
- * Get the OAuth authorization URL
- *
- * @return string the authorization URL
- */
- abstract function getAuthorizeUrl();
-
- /**
- * Request a new OAuth access token from a third-party service and store it in CcPref
- *
- * @param $code string exchange authorization code for access token
- */
- abstract function requestNewAccessToken($code);
-
- /**
- * Regenerate the third-party client's OAuth access token
- */
- abstract function accessTokenRefresh();
+ abstract function updateTrackReference($trackId, $track, $status);
}
\ No newline at end of file
diff --git a/airtime_mvc/build/schema.xml b/airtime_mvc/build/schema.xml
index 53a479dc9..a4ce8193b 100644
--- a/airtime_mvc/build/schema.xml
+++ b/airtime_mvc/build/schema.xml
@@ -536,19 +536,28 @@
-
-
-
-
-
-
-
+
+
-
+
+
+
diff --git a/airtime_mvc/build/sql/schema.sql b/airtime_mvc/build/sql/schema.sql
index 74a39e597..9868de899 100644
--- a/airtime_mvc/build/sql/schema.sql
+++ b/airtime_mvc/build/sql/schema.sql
@@ -681,14 +681,28 @@ CREATE TABLE "third_party_track_references"
"id" serial NOT NULL,
"service" VARCHAR(256) NOT NULL,
"foreign_id" VARCHAR(256),
- "broker_task_id" VARCHAR(256),
- "broker_task_name" VARCHAR(256),
- "broker_task_dispatch_time" TIMESTAMP,
"file_id" INTEGER NOT NULL,
+ "upload_time" TIMESTAMP,
+ "status" VARCHAR(256),
+ PRIMARY KEY ("id"),
+ CONSTRAINT "foreign_id_unique" UNIQUE ("foreign_id")
+);
+
+-----------------------------------------------------------------------
+-- celery_tasks
+-----------------------------------------------------------------------
+
+DROP TABLE IF EXISTS "celery_tasks" CASCADE;
+
+CREATE TABLE "celery_tasks"
+(
+ "id" VARCHAR(256) NOT NULL,
+ "track_reference" INTEGER NOT NULL,
+ "name" VARCHAR(256),
+ "dispatch_time" TIMESTAMP,
"status" VARCHAR(256) NOT NULL,
PRIMARY KEY ("id"),
- CONSTRAINT "broker_task_id_unique" UNIQUE ("broker_task_id"),
- CONSTRAINT "foreign_id_unique" UNIQUE ("foreign_id")
+ CONSTRAINT "id_unique" UNIQUE ("id")
);
ALTER TABLE "cc_files" ADD CONSTRAINT "cc_files_owner_fkey"
@@ -855,5 +869,10 @@ ALTER TABLE "cc_playout_history_template_field" ADD CONSTRAINT "cc_playout_histo
ALTER TABLE "third_party_track_references" ADD CONSTRAINT "track_reference_fkey"
FOREIGN KEY ("file_id")
- REFERENCES "cc_playout_history_template" ("id")
+ REFERENCES "cc_files" ("id")
+ ON DELETE CASCADE;
+
+ALTER TABLE "celery_tasks" ADD CONSTRAINT "celery_service_fkey"
+ FOREIGN KEY ("track_reference")
+ REFERENCES "third_party_track_references" ("id")
ON DELETE CASCADE;