SAAS-868 - Refactor third party + celery workflow, implement locking on TaskManager

This commit is contained in:
Duncan Sommerville 2015-06-16 15:10:08 -04:00
parent 3902c8c746
commit 8d2e476ff1
34 changed files with 4302 additions and 1143 deletions

View file

@ -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';

View file

@ -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();
}
}

View file

@ -0,0 +1,31 @@
<?php
interface OAuth2 {
/**
* Check whether an OAuth access token exists
*
* @return bool true if an access token exists, otherwise false
*/
public function hasAccessToken();
/**
* Get the OAuth authorization URL
*
* @return string the authorization URL
*/
public function getAuthorizeUrl();
/**
* Request a new OAuth access token and store it in CcPref
*
* @param $code string exchange authorization code for access token
*/
public function requestNewAccessToken($code);
/**
* Regenerate the OAuth access token
*/
public function accessTokenRefresh();
}

View file

@ -100,6 +100,9 @@ return array (
'BaseCcWebstreamMetadataQuery' => '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',

View file

@ -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');

View file

@ -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;

View file

@ -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);
}
}

View file

@ -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"],

View file

@ -0,0 +1,18 @@
<?php
/**
* Skeleton subclass for representing a row from the 'celery_tasks' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CeleryTasks extends BaseCeleryTasks
{
}

View file

@ -0,0 +1,18 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'celery_tasks' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CeleryTasksPeer extends BaseCeleryTasksPeer
{
}

View file

@ -0,0 +1,18 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'celery_tasks' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.airtime
*/
class CeleryTasksQuery extends BaseCeleryTasksQuery
{
}

View file

@ -127,6 +127,7 @@ class CcFilesTableMap extends TableMap
$this->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

View file

@ -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

View file

@ -0,0 +1,57 @@
<?php
/**
* This class defines the structure of the 'celery_tasks' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package propel.generator.airtime.map
*/
class CeleryTasksTableMap extends TableMap
{
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'airtime.map.CeleryTasksTableMap';
/**
* Initialize the table attributes, columns and validators
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->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

View file

@ -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

View file

@ -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;

View file

@ -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();
}
/**

View file

@ -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
*

View file

@ -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;
}
/**

View file

@ -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();
}
/**

View file

@ -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
*

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,504 @@
<?php
/**
* Base class that represents a query for the 'celery_tasks' table.
*
*
*
* @method CeleryTasksQuery orderByDbId($order = Criteria::ASC) Order by the id column
* @method CeleryTasksQuery orderByDbTrackReference($order = Criteria::ASC) Order by the track_reference column
* @method CeleryTasksQuery orderByDbName($order = Criteria::ASC) Order by the name column
* @method CeleryTasksQuery orderByDbDispatchTime($order = Criteria::ASC) Order by the dispatch_time column
* @method CeleryTasksQuery orderByDbStatus($order = Criteria::ASC) Order by the status column
*
* @method CeleryTasksQuery groupByDbId() Group by the id column
* @method CeleryTasksQuery groupByDbTrackReference() Group by the track_reference column
* @method CeleryTasksQuery groupByDbName() Group by the name column
* @method CeleryTasksQuery groupByDbDispatchTime() Group by the dispatch_time column
* @method CeleryTasksQuery groupByDbStatus() Group by the status column
*
* @method CeleryTasksQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method CeleryTasksQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method CeleryTasksQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method CeleryTasksQuery leftJoinThirdPartyTrackReferences($relationAlias = null) Adds a LEFT JOIN clause to the query using the ThirdPartyTrackReferences relation
* @method CeleryTasksQuery rightJoinThirdPartyTrackReferences($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ThirdPartyTrackReferences relation
* @method CeleryTasksQuery innerJoinThirdPartyTrackReferences($relationAlias = null) Adds a INNER JOIN clause to the query using the ThirdPartyTrackReferences relation
*
* @method CeleryTasks findOne(PropelPDO $con = null) Return the first CeleryTasks matching the query
* @method CeleryTasks findOneOrCreate(PropelPDO $con = null) Return the first CeleryTasks matching the query, or a new CeleryTasks object populated from the query conditions when no match is found
*
* @method CeleryTasks findOneByDbTrackReference(int $track_reference) Return the first CeleryTasks filtered by the track_reference column
* @method CeleryTasks findOneByDbName(string $name) Return the first CeleryTasks filtered by the name column
* @method CeleryTasks findOneByDbDispatchTime(string $dispatch_time) Return the first CeleryTasks filtered by the dispatch_time column
* @method CeleryTasks findOneByDbStatus(string $status) Return the first CeleryTasks filtered by the status column
*
* @method array findByDbId(string $id) Return CeleryTasks objects filtered by the id column
* @method array findByDbTrackReference(int $track_reference) Return CeleryTasks objects filtered by the track_reference column
* @method array findByDbName(string $name) Return CeleryTasks objects filtered by the name column
* @method array findByDbDispatchTime(string $dispatch_time) Return CeleryTasks objects filtered by the dispatch_time column
* @method array findByDbStatus(string $status) Return CeleryTasks objects filtered by the status column
*
* @package propel.generator.airtime.om
*/
abstract class BaseCeleryTasksQuery extends ModelCriteria
{
/**
* Initializes internal state of BaseCeleryTasksQuery object.
*
* @param string $dbName The dabase name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = null, $modelName = null, $modelAlias = null)
{
if (null === $dbName) {
$dbName = 'airtime';
}
if (null === $modelName) {
$modelName = 'CeleryTasks';
}
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new CeleryTasksQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param CeleryTasksQuery|Criteria $criteria Optional Criteria to build the query from
*
* @return CeleryTasksQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof CeleryTasksQuery) {
return $criteria;
}
$query = new CeleryTasksQuery(null, null, $modelAlias);
if ($criteria instanceof Criteria) {
$query->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.
*
* <code>
* $obj = $c->findPk(12, $con);
* </code>
*
* @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
* <code>
* $objs = $c->findPks(array(12, 56, 832), $con);
* </code>
* @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:
* <code>
* $query->filterByDbId('fooValue'); // WHERE id = 'fooValue'
* $query->filterByDbId('%fooValue%'); // WHERE id LIKE '%fooValue%'
* </code>
*
* @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:
* <code>
* $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
* </code>
*
* @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:
* <code>
* $query->filterByDbName('fooValue'); // WHERE name = 'fooValue'
* $query->filterByDbName('%fooValue%'); // WHERE name LIKE '%fooValue%'
* </code>
*
* @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:
* <code>
* $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'
* </code>
*
* @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:
* <code>
* $query->filterByDbStatus('fooValue'); // WHERE status = 'fooValue'
* $query->filterByDbStatus('%fooValue%'); // WHERE status LIKE '%fooValue%'
* </code>
*
* @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;
}
}

View file

@ -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;
}
/**

View file

@ -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

View file

@ -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:
* <code>
* $query->filterByDbBrokerTaskId('fooValue'); // WHERE broker_task_id = 'fooValue'
* $query->filterByDbBrokerTaskId('%fooValue%'); // WHERE broker_task_id LIKE '%fooValue%'
* </code>
*
* @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:
* <code>
* $query->filterByDbBrokerTaskName('fooValue'); // WHERE broker_task_name = 'fooValue'
* $query->filterByDbBrokerTaskName('%fooValue%'); // WHERE broker_task_name LIKE '%fooValue%'
* </code>
*
* @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:
* <code>
* $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'
* </code>
*
* @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
* </code>
*
* @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:
* <code>
* $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'
* </code>
*
* @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');
}
/**

View file

@ -0,0 +1,206 @@
<?php
require_once "CeleryServiceFactory.php";
class CeleryService {
/**
* @var int milliseconds (for compatibility with celery) until we consider a message to have timed out
*/
private 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
*/
private static $_CELERY_RESULTS_EXCHANGE = 'celeryresults';
/**
* 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,
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(Application_Model_RabbitMq::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 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);
}
}

View file

@ -0,0 +1,20 @@
<?php
class CeleryServiceFactory {
/**
*
*
* @param $serviceName string the name of the service to create
*
* @return ThirdPartyCeleryService|null
*/
public static function getService($serviceName) {
switch($serviceName) {
case SOUNDCLOUD_SERVICE_NAME:
return new SoundcloudService();
}
return null;
}
}

View file

@ -1,8 +1,8 @@
<?php
require_once "ThirdPartyService.php";
require_once "ThirdPartyCeleryService.php";
class SoundcloudService extends ThirdPartyService {
class SoundcloudService extends ThirdPartyCeleryService implements OAuth2 {
/**
* @var string service access token for accessing remote API
@ -17,7 +17,7 @@ class SoundcloudService extends ThirdPartyService {
/**
* @var string service name to store in ThirdPartyTrackReferences database
*/
protected static $_SERVICE_NAME = 'SoundCloud';
protected static $_SERVICE_NAME = SOUNDCLOUD_SERVICE_NAME; // SoundCloud service name constant from constants.php
/**
* @var string exchange name for SoundCloud tasks
@ -84,25 +84,20 @@ class SoundcloudService extends ThirdPartyService {
/**
* Update a ThirdPartyTrackReferences object for a completed upload
* TODO: should we have a database layer class to handle Propel operations?
* TODO: break this function up, it's a bit of a beast
*
* @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
*/
protected function _addOrUpdateTrackReference($fileId, $track, $status) {
public function updateTrackReference($trackId, $track, $status) {
parent::updateTrackReference($trackId, $track, $status);
$ref = ThirdPartyTrackReferencesQuery::create()
->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();
}

View file

@ -0,0 +1,135 @@
<?php
require_once "ThirdPartyService.php";
abstract class ThirdPartyCeleryService extends ThirdPartyService {
/**
* @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 = 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;
}
}

View file

@ -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);
}

View file

@ -536,19 +536,28 @@
<column name="service" phpName="DbService" type="VARCHAR" size="256" required="true" />
<!-- Make foreign ID a VARCHAR field in case a service uses hashes or other non-integer identifiers -->
<column name="foreign_id" phpName="DbForeignId" type="VARCHAR" size="256" />
<column name="broker_task_id" phpName="DbBrokerTaskId" type="VARCHAR" size="256" />
<column name="broker_task_name" phpName="DbBrokerTaskName" type="VARCHAR" size="256" />
<column name="broker_task_dispatch_time" phpName="DbBrokerTaskDispatchTime" type="TIMESTAMP" />
<column name="file_id" phpName="DbFileId" type="INTEGER" required="true" />
<column name="status" phpName="DbStatus" type="VARCHAR" size="256" required="true" />
<unique name="broker_task_id_unique">
<unique-column name="broker_task_id"/>
</unique>
<column name="upload_time" phpName="DbUploadTime" type="TIMESTAMP" />
<column name="status" phpName="DbStatus" type="VARCHAR" size="256" />
<unique name="foreign_id_unique">
<unique-column name="foreign_id"/>
</unique>
<foreign-key foreignTable="cc_playout_history_template" name="track_reference_fkey" onDelete="CASCADE">
<foreign-key foreignTable="cc_files" name="track_reference_fkey" onDelete="CASCADE">
<reference local="file_id" foreign="id"/>
</foreign-key>
</table>
<table name="celery_tasks" phpName="CeleryTasks">
<column name="id" phpName="DbId" primaryKey="true" type="VARCHAR" size="256" required="true" />
<column name="track_reference" phpName="DbTrackReference" type="INTEGER" required="true" />
<column name="name" phpName="DbName" type="VARCHAR" size="256" />
<column name="dispatch_time" phpName="DbDispatchTime" type="TIMESTAMP" />
<column name="status" phpName="DbStatus" type="VARCHAR" size="256" required="true" />
<unique name="id_unique">
<unique-column name="id"/>
</unique>
<foreign-key foreignTable="third_party_track_references" name="celery_service_fkey" onDelete="CASCADE">
<reference local="track_reference" foreign="id"/>
</foreign-key>
</table>
</database>

View file

@ -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;