removed cc_show_schedule table.

This commit is contained in:
naomiaro 2011-02-06 22:07:17 -05:00
parent fae1401568
commit 0152514ef3
8 changed files with 19 additions and 320 deletions

View File

@ -57,13 +57,6 @@ return array (
'BaseCcShowHostsPeer' => 'airtime/om/BaseCcShowHostsPeer.php',
'BaseCcShowHosts' => 'airtime/om/BaseCcShowHosts.php',
'BaseCcShowHostsQuery' => 'airtime/om/BaseCcShowHostsQuery.php',
'CcShowScheduleTableMap' => 'airtime/map/CcShowScheduleTableMap.php',
'CcShowSchedulePeer' => 'airtime/CcShowSchedulePeer.php',
'CcShowSchedule' => 'airtime/CcShowSchedule.php',
'CcShowScheduleQuery' => 'airtime/CcShowScheduleQuery.php',
'BaseCcShowSchedulePeer' => 'airtime/om/BaseCcShowSchedulePeer.php',
'BaseCcShowSchedule' => 'airtime/om/BaseCcShowSchedule.php',
'BaseCcShowScheduleQuery' => 'airtime/om/BaseCcShowScheduleQuery.php',
'CcPlaylistTableMap' => 'airtime/map/CcPlaylistTableMap.php',
'CcPlaylistPeer' => 'airtime/CcPlaylistPeer.php',
'CcPlaylist' => 'airtime/CcPlaylist.php',

View File

@ -466,22 +466,10 @@ class ShowInstance {
$this->setShowEnd($new_ends);
}
private function getNextPos() {
global $CC_DBC;
$sql = "SELECT MAX(position)+1 from cc_show_schedule WHERE instance_id = '{$this->_instanceId}'";
$res = $CC_DBC->GetOne($sql);
if(is_null($res))
return 0;
return $res;
}
private function getLastGroupId() {
global $CC_DBC;
$sql = "SELECT MAX(group_id) from cc_show_schedule WHERE instance_id = '{$this->_instanceId}'";
$sql = "SELECT group_id FROM cc_schedule WHERE instance_id = '{$this->_instanceId}' ORDER BY ends DESC LIMIT 1";
$res = $CC_DBC->GetOne($sql);
return $res;
@ -491,8 +479,7 @@ class ShowInstance {
$sched = new ScheduleGroup();
$lastGroupId = $this->getLastGroupId();
$pos = $this->getNextPos();
if(is_null($lastGroupId)) {
$groupId = $sched->add($this->_instanceId, $this->getShowStart(), null, $plId);
@ -500,12 +487,6 @@ class ShowInstance {
else {
$groupId = $sched->addPlaylistAfter($this->_instanceId, $lastGroupId, $plId);
}
$groupsched = new CcShowSchedule();
$groupsched->setDbInstanceId($this->_instanceId);
$groupsched->setDbGroupId($groupId);
$groupsched->setDbPosition($pos);
$groupsched->save();
}
public function scheduleShow($plIds) {
@ -518,60 +499,33 @@ class ShowInstance {
public function removeGroupFromShow($group_id){
global $CC_DBC;
$group = CcShowScheduleQuery::create()
->filterByDbInstanceId($this->_instanceId)
$sql = "SELECT MAX(ends) as end_timestamp, (MAX(ends) - MIN(starts)) as length
FROM cc_schedule
WHERE group_id = '{$group_id}'";
$groupBoundry = $CC_DBC->GetRow($sql);
$group = CcScheduleQuery::create()
->filterByDbGroupId($group_id)
->findOne();
->delete();
$position = $group->getDbPosition();
$sql = "UPDATE cc_schedule
SET starts = (starts - INTERVAL '{$groupBoundry["length"]}'), ends = (ends - INTERVAL '{$groupBoundry["length"]}')
WHERE starts >= '{$groupBoundry["end_timestamp"]}' AND instance_id = {$this->_instanceId}";
$sql = "SELECT group_id FROM cc_show_schedule
WHERE instance_id = '{$this->_instanceId}' AND position > '{$position}'";
$followingGroups = $CC_DBC->GetAll($sql);
$sql = "SELECT SUM(clip_length) FROM cc_schedule WHERE group_id='{$group_id}'";
$group_length = $CC_DBC->GetOne($sql);
$sql = "DELETE FROM cc_schedule WHERE group_id = '{$group_id}'";
$CC_DBC->query($sql);
if(!is_null($followingGroups)) {
$sql_opt = array();
foreach ($followingGroups as $row) {
$sql_opt[] = "group_id = {$row["group_id"]}";
}
$sql_group_ids = join(" OR ", $sql_opt);
$sql = "UPDATE cc_schedule
SET starts = (starts - INTERVAL '{$group_length}'), ends = (ends - INTERVAL '{$group_length}')
WHERE " . $sql_group_ids;
$CC_DBC->query($sql);
}
$group->delete();
}
public function clearShow() {
$groups = CcShowScheduleQuery::create()
->filterByDbInstanceId($this->_instanceId)
->find();
foreach($groups as $group) {
$groupId = $group->getDbGroupId();
CcScheduleQuery::create()
->filterByDbGroupId($groupId)
->delete();
$group->delete();
}
CcScheduleQuery::create()
->filterByDbInstanceId($this->_instanceId)
->delete();
}
public function deleteShow() {
$this->clearShow();
$showInstance = CcShowInstancesQuery::create()
CcShowInstancesQuery::create()
->findPK($this->_instanceId)
->delete();
}
@ -627,11 +581,10 @@ class ShowInstance {
global $CC_DBC;
$sql = "SELECT *
FROM (cc_show_schedule AS ss LEFT JOIN cc_schedule AS s USING(group_id)
LEFT JOIN cc_files AS f ON f.id = s.file_id
FROM (cc_schedule AS s LEFT JOIN cc_files AS f ON f.id = s.file_id
LEFT JOIN cc_playlist AS p ON p.id = s.playlist_id )
WHERE ss.instance_id = '{$this->_instanceId}' ORDER BY starts";
WHERE s.instance_id = '{$this->_instanceId}' ORDER BY starts";
return $CC_DBC->GetAll($sql);
}

View File

@ -51,7 +51,6 @@ class CcShowInstancesTableMap extends TableMap {
public function buildRelations()
{
$this->addRelation('CcShow', 'CcShow', RelationMap::MANY_TO_ONE, array('show_id' => 'id', ), 'CASCADE', null);
$this->addRelation('CcShowSchedule', 'CcShowSchedule', RelationMap::ONE_TO_MANY, array('id' => 'instance_id', ), 'CASCADE', null);
$this->addRelation('CcSchedule', 'CcSchedule', RelationMap::ONE_TO_MANY, array('id' => 'instance_id', ), 'CASCADE', null);
} // buildRelations()

View File

@ -53,11 +53,6 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
*/
protected $aCcShow;
/**
* @var array CcShowSchedule[] Collection to store aggregation of CcShowSchedule objects.
*/
protected $collCcShowSchedules;
/**
* @var array CcSchedule[] Collection to store aggregation of CcSchedule objects.
*/
@ -415,8 +410,6 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
if ($deep) { // also de-associate any related objects?
$this->aCcShow = null;
$this->collCcShowSchedules = null;
$this->collCcSchedules = null;
} // if (deep)
@ -564,14 +557,6 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
}
if ($this->collCcShowSchedules !== null) {
foreach ($this->collCcShowSchedules as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
if ($this->collCcSchedules !== null) {
foreach ($this->collCcSchedules as $referrerFK) {
if (!$referrerFK->isDeleted()) {
@ -663,14 +648,6 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
}
if ($this->collCcShowSchedules !== null) {
foreach ($this->collCcShowSchedules as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
if ($this->collCcSchedules !== null) {
foreach ($this->collCcSchedules as $referrerFK) {
if (!$referrerFK->validate($columns)) {
@ -913,12 +890,6 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
// the getter/setter methods for fkey referrer objects.
$copyObj->setNew(false);
foreach ($this->getCcShowSchedules() as $relObj) {
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
$copyObj->addCcShowSchedule($relObj->copy($deepCopy));
}
}
foreach ($this->getCcSchedules() as $relObj) {
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
$copyObj->addCcSchedule($relObj->copy($deepCopy));
@ -1019,115 +990,6 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
return $this->aCcShow;
}
/**
* Clears out the collCcShowSchedules 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 void
* @see addCcShowSchedules()
*/
public function clearCcShowSchedules()
{
$this->collCcShowSchedules = null; // important to set this to NULL since that means it is uninitialized
}
/**
* Initializes the collCcShowSchedules collection.
*
* By default this just sets the collCcShowSchedules collection to an empty array (like clearcollCcShowSchedules());
* 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.
*
* @return void
*/
public function initCcShowSchedules()
{
$this->collCcShowSchedules = new PropelObjectCollection();
$this->collCcShowSchedules->setModel('CcShowSchedule');
}
/**
* Gets an array of CcShowSchedule 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 CcShowInstances 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 PropelCollection|array CcShowSchedule[] List of CcShowSchedule objects
* @throws PropelException
*/
public function getCcShowSchedules($criteria = null, PropelPDO $con = null)
{
if(null === $this->collCcShowSchedules || null !== $criteria) {
if ($this->isNew() && null === $this->collCcShowSchedules) {
// return empty collection
$this->initCcShowSchedules();
} else {
$collCcShowSchedules = CcShowScheduleQuery::create(null, $criteria)
->filterByCcShowInstances($this)
->find($con);
if (null !== $criteria) {
return $collCcShowSchedules;
}
$this->collCcShowSchedules = $collCcShowSchedules;
}
}
return $this->collCcShowSchedules;
}
/**
* Returns the number of related CcShowSchedule objects.
*
* @param Criteria $criteria
* @param boolean $distinct
* @param PropelPDO $con
* @return int Count of related CcShowSchedule objects.
* @throws PropelException
*/
public function countCcShowSchedules(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
{
if(null === $this->collCcShowSchedules || null !== $criteria) {
if ($this->isNew() && null === $this->collCcShowSchedules) {
return 0;
} else {
$query = CcShowScheduleQuery::create(null, $criteria);
if($distinct) {
$query->distinct();
}
return $query
->filterByCcShowInstances($this)
->count($con);
}
} else {
return count($this->collCcShowSchedules);
}
}
/**
* Method called to associate a CcShowSchedule object to this object
* through the CcShowSchedule foreign key attribute.
*
* @param CcShowSchedule $l CcShowSchedule
* @return void
* @throws PropelException
*/
public function addCcShowSchedule(CcShowSchedule $l)
{
if ($this->collCcShowSchedules === null) {
$this->initCcShowSchedules();
}
if (!$this->collCcShowSchedules->contains($l)) { // only add it if the **same** object is not already associated
$this->collCcShowSchedules[]= $l;
$l->setCcShowInstances($this);
}
}
/**
* Clears out the collCcSchedules collection
*
@ -1266,11 +1128,6 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
public function clearAllReferences($deep = false)
{
if ($deep) {
if ($this->collCcShowSchedules) {
foreach ((array) $this->collCcShowSchedules as $o) {
$o->clearAllReferences($deep);
}
}
if ($this->collCcSchedules) {
foreach ((array) $this->collCcSchedules as $o) {
$o->clearAllReferences($deep);
@ -1278,7 +1135,6 @@ abstract class BaseCcShowInstances extends BaseObject implements Persistent
}
} // if ($deep)
$this->collCcShowSchedules = null;
$this->collCcSchedules = null;
$this->aCcShow = null;
}

View File

@ -353,9 +353,6 @@ abstract class BaseCcShowInstancesPeer {
*/
public static function clearRelatedInstancePool()
{
// Invalidate objects in CcShowSchedulePeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
CcShowSchedulePeer::clearInstancePool();
// Invalidate objects in CcSchedulePeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
CcSchedulePeer::clearInstancePool();

View File

@ -24,10 +24,6 @@
* @method CcShowInstancesQuery rightJoinCcShow($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcShow relation
* @method CcShowInstancesQuery innerJoinCcShow($relationAlias = '') Adds a INNER JOIN clause to the query using the CcShow relation
*
* @method CcShowInstancesQuery leftJoinCcShowSchedule($relationAlias = '') Adds a LEFT JOIN clause to the query using the CcShowSchedule relation
* @method CcShowInstancesQuery rightJoinCcShowSchedule($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcShowSchedule relation
* @method CcShowInstancesQuery innerJoinCcShowSchedule($relationAlias = '') Adds a INNER JOIN clause to the query using the CcShowSchedule relation
*
* @method CcShowInstancesQuery leftJoinCcSchedule($relationAlias = '') Adds a LEFT JOIN clause to the query using the CcSchedule relation
* @method CcShowInstancesQuery rightJoinCcSchedule($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcSchedule relation
* @method CcShowInstancesQuery innerJoinCcSchedule($relationAlias = '') Adds a INNER JOIN clause to the query using the CcSchedule relation
@ -327,70 +323,6 @@ abstract class BaseCcShowInstancesQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'CcShow', 'CcShowQuery');
}
/**
* Filter the query by a related CcShowSchedule object
*
* @param CcShowSchedule $ccShowSchedule the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcShowInstancesQuery The current query, for fluid interface
*/
public function filterByCcShowSchedule($ccShowSchedule, $comparison = null)
{
return $this
->addUsingAlias(CcShowInstancesPeer::ID, $ccShowSchedule->getDbInstanceId(), $comparison);
}
/**
* Adds a JOIN clause to the query using the CcShowSchedule relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return CcShowInstancesQuery The current query, for fluid interface
*/
public function joinCcShowSchedule($relationAlias = '', $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('CcShowSchedule');
// 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, 'CcShowSchedule');
}
return $this;
}
/**
* Use the CcShowSchedule relation CcShowSchedule 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 CcShowScheduleQuery A secondary query class using the current class as primary query
*/
public function useCcShowScheduleQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN)
{
return $this
->joinCcShowSchedule($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'CcShowSchedule', 'CcShowScheduleQuery');
}
/**
* Filter the query by a related CcSchedule object
*

View File

@ -162,15 +162,6 @@
<reference local="subjs_id" foreign="id"/>
</foreign-key>
</table>
<table name="cc_show_schedule" phpName="CcShowSchedule">
<column name="id" phpName="DbId" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
<column name="instance_id" phpName="DbInstanceId" type="INTEGER" required="true"/>
<column name="position" phpName="DbPosition" type="INTEGER" required="false"/>
<column name="group_id" phpName="DbGroupId" type="INTEGER" required="true"/>
<foreign-key foreignTable="cc_show_instances" name="cc_show_inst_fkey" onDelete="CASCADE">
<reference local="instance_id" foreign="id"/>
</foreign-key>
</table>
<table name="cc_playlist" phpName="CcPlaylist">
<column name="id" phpName="DbId" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
<column name="name" phpName="DbName" type="VARCHAR" size="255" required="true" defaultValue=""/>

View File

@ -235,26 +235,6 @@ CREATE TABLE "cc_show_hosts"
COMMENT ON TABLE "cc_show_hosts" IS '';
SET search_path TO public;
-----------------------------------------------------------------------------
-- cc_show_schedule
-----------------------------------------------------------------------------
DROP TABLE "cc_show_schedule" CASCADE;
CREATE TABLE "cc_show_schedule"
(
"id" serial NOT NULL,
"instance_id" INTEGER NOT NULL,
"position" INTEGER,
"group_id" INTEGER NOT NULL,
PRIMARY KEY ("id")
);
COMMENT ON TABLE "cc_show_schedule" IS '';
SET search_path TO public;
-----------------------------------------------------------------------------
-- cc_playlist
@ -492,8 +472,6 @@ ALTER TABLE "cc_show_hosts" ADD CONSTRAINT "cc_perm_show_fkey" FOREIGN KEY ("sho
ALTER TABLE "cc_show_hosts" ADD CONSTRAINT "cc_perm_host_fkey" FOREIGN KEY ("subjs_id") REFERENCES "cc_subjs" ("id") ON DELETE CASCADE;
ALTER TABLE "cc_show_schedule" ADD CONSTRAINT "cc_show_inst_fkey" FOREIGN KEY ("instance_id") REFERENCES "cc_show_instances" ("id") ON DELETE CASCADE;
ALTER TABLE "cc_playlist" ADD CONSTRAINT "cc_playlist_editedby_fkey" FOREIGN KEY ("editedby") REFERENCES "cc_subjs" ("id");
ALTER TABLE "cc_playlistcontents" ADD CONSTRAINT "cc_playlistcontents_file_id_fkey" FOREIGN KEY ("file_id") REFERENCES "cc_files" ("id") ON DELETE CASCADE;