Merge branch 'CC-3174' into devel
This commit is contained in:
commit
a0fb607d30
16 changed files with 210 additions and 235 deletions
|
@ -110,6 +110,8 @@ class CcShowInstances extends BaseCcShowInstances {
|
|||
|
||||
//post save hook to update the cc_schedule status column for the tracks in the show.
|
||||
public function updateScheduleStatus(PropelPDO $con) {
|
||||
|
||||
$this->updateDbTimeFilled($con);
|
||||
|
||||
//scheduled track is in the show
|
||||
CcScheduleQuery::create()
|
||||
|
@ -134,6 +136,32 @@ class CcShowInstances extends BaseCcShowInstances {
|
|||
->update(array('DbPlayoutStatus' => 0), $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the value of the aggregate column time_filled
|
||||
*
|
||||
* @param PropelPDO $con A connection object
|
||||
*
|
||||
* @return mixed The scalar result from the aggregate query
|
||||
*/
|
||||
public function computeDbTimeFilled(PropelPDO $con)
|
||||
{
|
||||
$stmt = $con->prepare('SELECT SUM(clip_length) FROM "cc_schedule" WHERE cc_schedule.INSTANCE_ID = :p1');
|
||||
$stmt->bindValue(':p1', $this->getDbId());
|
||||
$stmt->execute();
|
||||
return $stmt->fetchColumn();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the aggregate column time_filled
|
||||
*
|
||||
* @param PropelPDO $con A connection object
|
||||
*/
|
||||
public function updateDbTimeFilled(PropelPDO $con)
|
||||
{
|
||||
$this->setDbTimeFilled($this->computeDbTimeFilled($con));
|
||||
$this->save($con);
|
||||
}
|
||||
|
||||
public function preInsert(PropelPDO $con = null) {
|
||||
$now = new DateTime("now", new DateTimeZone("UTC"));
|
||||
$this->setDbCreated($now);
|
||||
|
|
|
@ -62,17 +62,4 @@ class CcScheduleTableMap extends TableMap {
|
|||
$this->addRelation('CcFiles', 'CcFiles', RelationMap::MANY_TO_ONE, array('file_id' => 'id', ), 'CASCADE', null);
|
||||
} // buildRelations()
|
||||
|
||||
/**
|
||||
*
|
||||
* Gets the list of behaviors registered for this table
|
||||
*
|
||||
* @return array Associative array (name => parameters) of behaviors
|
||||
*/
|
||||
public function getBehaviors()
|
||||
{
|
||||
return array(
|
||||
'aggregate_column_relation' => array('foreign_table' => 'cc_show_instances', 'update_method' => 'updateDbTimeFilled', ),
|
||||
);
|
||||
} // getBehaviors()
|
||||
|
||||
} // CcScheduleTableMap
|
||||
|
|
|
@ -65,17 +65,4 @@ class CcShowInstancesTableMap extends TableMap {
|
|||
$this->addRelation('CcSchedule', 'CcSchedule', RelationMap::ONE_TO_MANY, array('id' => 'instance_id', ), 'CASCADE', null);
|
||||
} // buildRelations()
|
||||
|
||||
/**
|
||||
*
|
||||
* Gets the list of behaviors registered for this table
|
||||
*
|
||||
* @return array Associative array (name => parameters) of behaviors
|
||||
*/
|
||||
public function getBehaviors()
|
||||
{
|
||||
return array(
|
||||
'aggregate_column' => array('name' => 'time_filled', 'expression' => 'SUM(clip_length)', 'foreign_table' => 'cc_schedule', ),
|
||||
);
|
||||
} // getBehaviors()
|
||||
|
||||
} // CcShowInstancesTableMap
|
||||
|
|
|
@ -127,9 +127,6 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
|
|||
*/
|
||||
protected $alreadyInValidation = false;
|
||||
|
||||
// aggregate_column_relation behavior
|
||||
protected $oldCcShowInstances;
|
||||
|
||||
/**
|
||||
* Applies default values to this object.
|
||||
* This method should be called from the object's constructor (or
|
||||
|
@ -966,8 +963,6 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
|
|||
$this->postUpdate($con);
|
||||
}
|
||||
$this->postSave($con);
|
||||
// aggregate_column_relation behavior
|
||||
$this->updateRelatedCcShowInstances($con);
|
||||
CcSchedulePeer::addInstanceToPool($this);
|
||||
} else {
|
||||
$affectedRows = 0;
|
||||
|
@ -1491,10 +1486,6 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
|
|||
*/
|
||||
public function setCcShowInstances(CcShowInstances $v = null)
|
||||
{
|
||||
// aggregate_column_relation behavior
|
||||
if (null !== $this->aCcShowInstances && $v !== $this->aCcShowInstances) {
|
||||
$this->oldCcShowInstances = $this->aCcShowInstances;
|
||||
}
|
||||
if ($v === null) {
|
||||
$this->setDbInstanceId(NULL);
|
||||
} else {
|
||||
|
@ -1628,24 +1619,6 @@ abstract class BaseCcSchedule extends BaseObject implements Persistent
|
|||
$this->aCcFiles = null;
|
||||
}
|
||||
|
||||
// aggregate_column_relation behavior
|
||||
|
||||
/**
|
||||
* Update the aggregate column in the related CcShowInstances object
|
||||
*
|
||||
* @param PropelPDO $con A connection object
|
||||
*/
|
||||
protected function updateRelatedCcShowInstances(PropelPDO $con)
|
||||
{
|
||||
if ($ccShowInstances = $this->getCcShowInstances()) {
|
||||
$ccShowInstances->updateDbTimeFilled($con);
|
||||
}
|
||||
if ($this->oldCcShowInstances) {
|
||||
$this->oldCcShowInstances->updateDbTimeFilled($con);
|
||||
$this->oldCcShowInstances = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Catches calls to virtual methods
|
||||
*/
|
||||
|
|
|
@ -642,90 +642,4 @@ abstract class BaseCcScheduleQuery extends ModelCriteria
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Code to execute before every DELETE statement
|
||||
*
|
||||
* @param PropelPDO $con The connection object used by the query
|
||||
*/
|
||||
protected function basePreDelete(PropelPDO $con)
|
||||
{
|
||||
// aggregate_column_relation behavior
|
||||
$this->findRelatedCcShowInstancess($con);
|
||||
|
||||
return $this->preDelete($con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Code to execute after every DELETE statement
|
||||
*
|
||||
* @param int $affectedRows the number of deleted rows
|
||||
* @param PropelPDO $con The connection object used by the query
|
||||
*/
|
||||
protected function basePostDelete($affectedRows, PropelPDO $con)
|
||||
{
|
||||
// aggregate_column_relation behavior
|
||||
$this->updateRelatedCcShowInstancess($con);
|
||||
|
||||
return $this->postDelete($affectedRows, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Code to execute before every UPDATE statement
|
||||
*
|
||||
* @param array $values The associatiove array of columns and values for the update
|
||||
* @param PropelPDO $con The connection object used by the query
|
||||
* @param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), ortherwise it is a series of save() calls on all the found objects
|
||||
*/
|
||||
protected function basePreUpdate(&$values, PropelPDO $con, $forceIndividualSaves = false)
|
||||
{
|
||||
// aggregate_column_relation behavior
|
||||
$this->findRelatedCcShowInstancess($con);
|
||||
|
||||
return $this->preUpdate($values, $con, $forceIndividualSaves);
|
||||
}
|
||||
|
||||
/**
|
||||
* Code to execute after every UPDATE statement
|
||||
*
|
||||
* @param int $affectedRows the number of udated rows
|
||||
* @param PropelPDO $con The connection object used by the query
|
||||
*/
|
||||
protected function basePostUpdate($affectedRows, PropelPDO $con)
|
||||
{
|
||||
// aggregate_column_relation behavior
|
||||
$this->updateRelatedCcShowInstancess($con);
|
||||
|
||||
return $this->postUpdate($affectedRows, $con);
|
||||
}
|
||||
|
||||
// aggregate_column_relation behavior
|
||||
|
||||
/**
|
||||
* Finds the related CcShowInstances objects and keep them for later
|
||||
*
|
||||
* @param PropelPDO $con A connection object
|
||||
*/
|
||||
protected function findRelatedCcShowInstancess($con)
|
||||
{
|
||||
$criteria = clone $this;
|
||||
if ($this->useAliasInSQL) {
|
||||
$alias = $this->getModelAlias();
|
||||
$criteria->removeAlias($alias);
|
||||
} else {
|
||||
$alias = '';
|
||||
}
|
||||
$this->ccShowInstancess = CcShowInstancesQuery::create()
|
||||
->joinCcSchedule($alias)
|
||||
->mergeWith($criteria)
|
||||
->find($con);
|
||||
}
|
||||
|
||||
protected function updateRelatedCcShowInstancess($con)
|
||||
{
|
||||
foreach ($this->ccShowInstancess as $ccShowInstances) {
|
||||
$ccShowInstances->updateDbTimeFilled($con);
|
||||
}
|
||||
$this->ccShowInstancess = array();
|
||||
}
|
||||
|
||||
} // BaseCcScheduleQuery
|
||||
|
|
|
@ -2049,34 +2049,6 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
|
|||
$this->aCcFiles = null;
|
||||
}
|
||||
|
||||
// aggregate_column behavior
|
||||
|
||||
/**
|
||||
* Computes the value of the aggregate column time_filled
|
||||
*
|
||||
* @param PropelPDO $con A connection object
|
||||
*
|
||||
* @return mixed The scalar result from the aggregate query
|
||||
*/
|
||||
public function computeDbTimeFilled(PropelPDO $con)
|
||||
{
|
||||
$stmt = $con->prepare('SELECT SUM(clip_length) FROM "cc_schedule" WHERE cc_schedule.INSTANCE_ID = :p1');
|
||||
$stmt->bindValue(':p1', $this->getDbId());
|
||||
$stmt->execute();
|
||||
return $stmt->fetchColumn();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the aggregate column time_filled
|
||||
*
|
||||
* @param PropelPDO $con A connection object
|
||||
*/
|
||||
public function updateDbTimeFilled(PropelPDO $con)
|
||||
{
|
||||
$this->setDbTimeFilled($this->computeDbTimeFilled($con));
|
||||
$this->save($con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Catches calls to virtual methods
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue