diff --git a/airtime_mvc/application/configs/classmap-airtime-conf.php b/airtime_mvc/application/configs/classmap-airtime-conf.php
index 692e0c3e4..7f7fcfc47 100644
--- a/airtime_mvc/application/configs/classmap-airtime-conf.php
+++ b/airtime_mvc/application/configs/classmap-airtime-conf.php
@@ -78,6 +78,13 @@ return array (
'BaseCcPlaylistcontentsPeer' => 'airtime/om/BaseCcPlaylistcontentsPeer.php',
'BaseCcPlaylistcontents' => 'airtime/om/BaseCcPlaylistcontents.php',
'BaseCcPlaylistcontentsQuery' => 'airtime/om/BaseCcPlaylistcontentsQuery.php',
+ 'CcPlaylistcriteriaTableMap' => 'airtime/map/CcPlaylistcriteriaTableMap.php',
+ 'CcPlaylistcriteriaPeer' => 'airtime/CcPlaylistcriteriaPeer.php',
+ 'CcPlaylistcriteria' => 'airtime/CcPlaylistcriteria.php',
+ 'CcPlaylistcriteriaQuery' => 'airtime/CcPlaylistcriteriaQuery.php',
+ 'BaseCcPlaylistcriteriaPeer' => 'airtime/om/BaseCcPlaylistcriteriaPeer.php',
+ 'BaseCcPlaylistcriteria' => 'airtime/om/BaseCcPlaylistcriteria.php',
+ 'BaseCcPlaylistcriteriaQuery' => 'airtime/om/BaseCcPlaylistcriteriaQuery.php',
'CcPrefTableMap' => 'airtime/map/CcPrefTableMap.php',
'CcPrefPeer' => 'airtime/CcPrefPeer.php',
'CcPref' => 'airtime/CcPref.php',
diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php
index 74e745eb0..b270f688b 100644
--- a/airtime_mvc/application/controllers/PlaylistController.php
+++ b/airtime_mvc/application/controllers/PlaylistController.php
@@ -24,6 +24,7 @@ class PlaylistController extends Zend_Controller_Action
->addActionContext('get-playlist', 'json')
->addActionContext('smart-playlist-criteria-save', 'json')
->addActionContext('smart-playlist-generate', 'json')
+ ->addActionContext('smart-playlist-get', 'json')
->initContext();
$this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME);
@@ -445,15 +446,24 @@ class PlaylistController extends Zend_Controller_Action
{
$request = $this->getRequest();
$params = $request->getPost();
- Application_Model_Playlist::saveSmartPlaylistCriteria($param['data']);
-
+ $result = Application_Model_Playlist::saveSmartPlaylistCriteria($params['data'], $params['pl_id']);
+ die(json_encode($result));
}
public function smartPlaylistGenerateAction()
{
$request = $this->getRequest();
$params = $request->getPost();
- $result = Application_Model_Playlist::generateSmartPlaylist($params['data']);
+ Logging::log($params);
+ $result = Application_Model_Playlist::generateSmartPlaylist($params['data'], $params['pl_id']);
+ die(json_encode($result));
+ }
+
+ public function smartPlaylistGetAction()
+ {
+ $request = $this->getRequest();
+ $playlistId = $request->getParam('playlistId');
+ $result = Application_Model_Playlist::getSmartPlaylistCriteria($playlistId);
die(json_encode($result));
}
}
diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php
index 46e83c068..cb78a406a 100644
--- a/airtime_mvc/application/models/Playlist.php
+++ b/airtime_mvc/application/models/Playlist.php
@@ -854,15 +854,17 @@ class Application_Model_Playlist {
* Saves smart playlist criteria
* @param array $p_criteria
*/
- public static function saveSmartPlaylistCriteria($p_criteria)
+ public static function saveSmartPlaylistCriteria($p_criteria, $p_playlistId)
{
$data = self::organizeSmartPlyalistCriteria($p_criteria);
// things we need to check
// 1. limit value shouldn't be empty and has upperbound of 24 hrs
// 2. sp_criteria or sp_criteria_modifier shouldn't be 0
+ // 3. validate formate according to DB column type
$multiplier = 1;
$result = 0;
$errors = array();
+ $error = array();
if ($data['etc']['sp_limit_options'] == 'hours') {
$multiplier = 60;
}
@@ -875,9 +877,13 @@ class Application_Model_Playlist {
$error[] = "Litmit cannot be more than 24 hrs";
}
}
- $errors[] = array("element"=>"sp_limit_value", "msg"=>$error);
+ if (count($error) > 0){
+ $errors[] = array("element"=>"sp_limit_value", "msg"=>$error);
+ }
+ Logging::log($errors);
}
+ Logging::log($errors);
// format validation
foreach ($data['criteria'] as $key=>$d){
$error = array();
@@ -902,13 +908,45 @@ class Application_Model_Playlist {
if ($d['sp_criteria_value'] == "") {
$error[] = "Value cannot be empty";
}
-
- $errors[] = array("element"=>"sp_criteria_".$key, "msg"=>$error);
+ if(count($error) > 0){
+ $errors[] = array("element"=>"sp_criteria_".$key, "msg"=>$error);
+ }
}
$result = count($errors) > 0 ? 1 :0;
+ if ($result == 0) {
+ self::storeCriteriaIntoDb($data, $p_playlistId);
+ }
return array("result"=>$result, "errors"=>$errors);
}
+ public static function storeCriteriaIntoDb($p_criteriaData, $p_playlistId){
+ // delete criteria under $p_playlistId
+ Logging::log($p_criteriaData);
+ $deleteCrit = new Criteria();
+ $deleteCrit->add(CcPlaylistcriteriaPeer::PLAYLIST_ID, $p_playlistId);
+ CcPlaylistcriteriaPeer::doDelete($deleteCrit);
+
+ foreach( $p_criteriaData['criteria'] as $d){
+ $crit = new Criteria();
+ $crit->add(CcPlaylistcriteriaPeer::CRITERIA, $d['sp_criteria']);
+ $crit->add(CcPlaylistcriteriaPeer::MODIFIER, $d['sp_criteria_modifier']);
+ $crit->add(CcPlaylistcriteriaPeer::VALUE, $d['sp_criteria_value']);
+ if (isset($d['sp_criteria_extra'])) {
+ $crit->add(CcPlaylistcriteriaPeer::EXTRA, $d['sp_criteria_extra']);
+ }
+ $crit->add(CcPlaylistcriteriaPeer::PLAYLIST_ID, $p_playlistId);
+ CcPlaylistcriteriaPeer::doInsert($crit);
+ }
+
+ // insert limit info
+ $crit = new Criteria();
+ $crit->add(CcPlaylistcriteriaPeer::CRITERIA, "limit");
+ $crit->add(CcPlaylistcriteriaPeer::MODIFIER, $p_criteriaData['etc']['sp_limit_options']);
+ $crit->add(CcPlaylistcriteriaPeer::VALUE, $p_criteriaData['etc']['sp_limit_value']);
+ $crit->add(CcPlaylistcriteriaPeer::PLAYLIST_ID, $p_playlistId);
+ CcPlaylistcriteriaPeer::doInsert($crit);
+ }
+
/**
* Get smart playlist criteria
* @param array $p_playlistId
@@ -923,15 +961,16 @@ class Application_Model_Playlist {
* tracks.
* @param array $p_criteria
*/
- public static function generateSmartPlaylist($p_criteria)
+ public static function generateSmartPlaylist($p_criteria, $p_playlistId)
{
- $result = self::saveSmartPlaylistCriteria($p_criteria);
+ $result = self::saveSmartPlaylistCriteria($p_criteria, $p_playlistId);
+ Logging::log($result);
if ($result['result'] != 0) {
return $result;
}else{
- Logging::log($p_criteria);
$data = self::organizeSmartPlyalistCriteria($p_criteria);
$list = self::getListofFilesMeetCriteria($data['criteria']);
+ return array("result"=>0);
}
}
diff --git a/airtime_mvc/application/models/airtime/map/CcPlaylistTableMap.php b/airtime_mvc/application/models/airtime/map/CcPlaylistTableMap.php
index 3162280d0..a582d11cf 100644
--- a/airtime_mvc/application/models/airtime/map/CcPlaylistTableMap.php
+++ b/airtime_mvc/application/models/airtime/map/CcPlaylistTableMap.php
@@ -45,6 +45,7 @@ class CcPlaylistTableMap extends TableMap {
$this->addForeignKey('CREATOR_ID', 'DbCreatorId', 'INTEGER', 'cc_subjs', 'ID', false, null, null);
$this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', false, 512, null);
$this->addColumn('LENGTH', 'DbLength', 'VARCHAR', false, null, '00:00:00');
+ $this->addColumn('TYPE', 'DbType', 'VARCHAR', false, 7, 'static');
// validators
} // initialize()
@@ -55,6 +56,7 @@ class CcPlaylistTableMap extends TableMap {
{
$this->addRelation('CcSubjs', 'CcSubjs', RelationMap::MANY_TO_ONE, array('creator_id' => 'id', ), null, null);
$this->addRelation('CcPlaylistcontents', 'CcPlaylistcontents', RelationMap::ONE_TO_MANY, array('id' => 'playlist_id', ), 'CASCADE', null);
+ $this->addRelation('CcPlaylistcriteria', 'CcPlaylistcriteria', RelationMap::ONE_TO_MANY, array('id' => 'playlist_id', ), 'CASCADE', null);
} // buildRelations()
/**
diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlaylist.php b/airtime_mvc/application/models/airtime/om/BaseCcPlaylist.php
index db4e4d222..5e8e9f23a 100644
--- a/airtime_mvc/application/models/airtime/om/BaseCcPlaylist.php
+++ b/airtime_mvc/application/models/airtime/om/BaseCcPlaylist.php
@@ -68,6 +68,13 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
*/
protected $length;
+ /**
+ * The value for the type field.
+ * Note: this column has a database default value of: 'static'
+ * @var string
+ */
+ protected $type;
+
/**
* @var CcSubjs
*/
@@ -78,6 +85,11 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
*/
protected $collCcPlaylistcontentss;
+ /**
+ * @var array CcPlaylistcriteria[] Collection to store aggregation of CcPlaylistcriteria objects.
+ */
+ protected $collCcPlaylistcriterias;
+
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
@@ -102,6 +114,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
{
$this->name = '';
$this->length = '00:00:00';
+ $this->type = 'static';
}
/**
@@ -230,6 +243,16 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
return $this->length;
}
+ /**
+ * Get the [type] column value.
+ *
+ * @return string
+ */
+ public function getDbType()
+ {
+ return $this->type;
+ }
+
/**
* Set the value of [id] column.
*
@@ -432,6 +455,26 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
return $this;
} // setDbLength()
+ /**
+ * Set the value of [type] column.
+ *
+ * @param string $v new value
+ * @return CcPlaylist The current object (for fluent API support)
+ */
+ public function setDbType($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->type !== $v || $this->isNew()) {
+ $this->type = $v;
+ $this->modifiedColumns[] = CcPlaylistPeer::TYPE;
+ }
+
+ return $this;
+ } // setDbType()
+
/**
* Indicates whether the columns in this object are only set to default values.
*
@@ -450,6 +493,10 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
return false;
}
+ if ($this->type !== 'static') {
+ return false;
+ }
+
// otherwise, everything was equal, so return TRUE
return true;
} // hasOnlyDefaultValues()
@@ -479,6 +526,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$this->creator_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
$this->description = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
$this->length = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
+ $this->type = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
$this->resetModified();
$this->setNew(false);
@@ -487,7 +535,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$this->ensureConsistency();
}
- return $startcol + 7; // 7 = CcPlaylistPeer::NUM_COLUMNS - CcPlaylistPeer::NUM_LAZY_LOAD_COLUMNS).
+ return $startcol + 8; // 8 = CcPlaylistPeer::NUM_COLUMNS - CcPlaylistPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating CcPlaylist object", $e);
@@ -555,6 +603,8 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$this->aCcSubjs = null;
$this->collCcPlaylistcontentss = null;
+ $this->collCcPlaylistcriterias = null;
+
} // if (deep)
}
@@ -708,6 +758,14 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
}
}
+ if ($this->collCcPlaylistcriterias !== null) {
+ foreach ($this->collCcPlaylistcriterias as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
@@ -799,6 +857,14 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
}
}
+ if ($this->collCcPlaylistcriterias !== null) {
+ foreach ($this->collCcPlaylistcriterias as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -853,6 +919,9 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
case 6:
return $this->getDbLength();
break;
+ case 7:
+ return $this->getDbType();
+ break;
default:
return null;
break;
@@ -884,6 +953,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$keys[4] => $this->getDbCreatorId(),
$keys[5] => $this->getDbDescription(),
$keys[6] => $this->getDbLength(),
+ $keys[7] => $this->getDbType(),
);
if ($includeForeignObjects) {
if (null !== $this->aCcSubjs) {
@@ -941,6 +1011,9 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
case 6:
$this->setDbLength($value);
break;
+ case 7:
+ $this->setDbType($value);
+ break;
} // switch()
}
@@ -972,6 +1045,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
if (array_key_exists($keys[4], $arr)) $this->setDbCreatorId($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setDbDescription($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setDbLength($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setDbType($arr[$keys[7]]);
}
/**
@@ -990,6 +1064,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
if ($this->isColumnModified(CcPlaylistPeer::CREATOR_ID)) $criteria->add(CcPlaylistPeer::CREATOR_ID, $this->creator_id);
if ($this->isColumnModified(CcPlaylistPeer::DESCRIPTION)) $criteria->add(CcPlaylistPeer::DESCRIPTION, $this->description);
if ($this->isColumnModified(CcPlaylistPeer::LENGTH)) $criteria->add(CcPlaylistPeer::LENGTH, $this->length);
+ if ($this->isColumnModified(CcPlaylistPeer::TYPE)) $criteria->add(CcPlaylistPeer::TYPE, $this->type);
return $criteria;
}
@@ -1057,6 +1132,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$copyObj->setDbCreatorId($this->creator_id);
$copyObj->setDbDescription($this->description);
$copyObj->setDbLength($this->length);
+ $copyObj->setDbType($this->type);
if ($deepCopy) {
// important: temporarily setNew(false) because this affects the behavior of
@@ -1069,6 +1145,12 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
}
}
+ foreach ($this->getCcPlaylistcriterias() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCcPlaylistcriteria($relObj->copy($deepCopy));
+ }
+ }
+
} // if ($deepCopy)
@@ -1297,6 +1379,115 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
return $this->getCcPlaylistcontentss($query, $con);
}
+ /**
+ * Clears out the collCcPlaylistcriterias 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 addCcPlaylistcriterias()
+ */
+ public function clearCcPlaylistcriterias()
+ {
+ $this->collCcPlaylistcriterias = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Initializes the collCcPlaylistcriterias collection.
+ *
+ * By default this just sets the collCcPlaylistcriterias collection to an empty array (like clearcollCcPlaylistcriterias());
+ * 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 initCcPlaylistcriterias()
+ {
+ $this->collCcPlaylistcriterias = new PropelObjectCollection();
+ $this->collCcPlaylistcriterias->setModel('CcPlaylistcriteria');
+ }
+
+ /**
+ * Gets an array of CcPlaylistcriteria 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 CcPlaylist 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 CcPlaylistcriteria[] List of CcPlaylistcriteria objects
+ * @throws PropelException
+ */
+ public function getCcPlaylistcriterias($criteria = null, PropelPDO $con = null)
+ {
+ if(null === $this->collCcPlaylistcriterias || null !== $criteria) {
+ if ($this->isNew() && null === $this->collCcPlaylistcriterias) {
+ // return empty collection
+ $this->initCcPlaylistcriterias();
+ } else {
+ $collCcPlaylistcriterias = CcPlaylistcriteriaQuery::create(null, $criteria)
+ ->filterByCcPlaylist($this)
+ ->find($con);
+ if (null !== $criteria) {
+ return $collCcPlaylistcriterias;
+ }
+ $this->collCcPlaylistcriterias = $collCcPlaylistcriterias;
+ }
+ }
+ return $this->collCcPlaylistcriterias;
+ }
+
+ /**
+ * Returns the number of related CcPlaylistcriteria objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param PropelPDO $con
+ * @return int Count of related CcPlaylistcriteria objects.
+ * @throws PropelException
+ */
+ public function countCcPlaylistcriterias(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
+ {
+ if(null === $this->collCcPlaylistcriterias || null !== $criteria) {
+ if ($this->isNew() && null === $this->collCcPlaylistcriterias) {
+ return 0;
+ } else {
+ $query = CcPlaylistcriteriaQuery::create(null, $criteria);
+ if($distinct) {
+ $query->distinct();
+ }
+ return $query
+ ->filterByCcPlaylist($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collCcPlaylistcriterias);
+ }
+ }
+
+ /**
+ * Method called to associate a CcPlaylistcriteria object to this object
+ * through the CcPlaylistcriteria foreign key attribute.
+ *
+ * @param CcPlaylistcriteria $l CcPlaylistcriteria
+ * @return void
+ * @throws PropelException
+ */
+ public function addCcPlaylistcriteria(CcPlaylistcriteria $l)
+ {
+ if ($this->collCcPlaylistcriterias === null) {
+ $this->initCcPlaylistcriterias();
+ }
+ if (!$this->collCcPlaylistcriterias->contains($l)) { // only add it if the **same** object is not already associated
+ $this->collCcPlaylistcriterias[]= $l;
+ $l->setCcPlaylist($this);
+ }
+ }
+
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -1309,6 +1500,7 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$this->creator_id = null;
$this->description = null;
$this->length = null;
+ $this->type = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
$this->clearAllReferences();
@@ -1335,9 +1527,15 @@ abstract class BaseCcPlaylist extends BaseObject implements Persistent
$o->clearAllReferences($deep);
}
}
+ if ($this->collCcPlaylistcriterias) {
+ foreach ((array) $this->collCcPlaylistcriterias as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
} // if ($deep)
$this->collCcPlaylistcontentss = null;
+ $this->collCcPlaylistcriterias = null;
$this->aCcSubjs = null;
}
diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistPeer.php
index da3593e02..16f69e6db 100644
--- a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistPeer.php
+++ b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistPeer.php
@@ -26,7 +26,7 @@ abstract class BaseCcPlaylistPeer {
const TM_CLASS = 'CcPlaylistTableMap';
/** The total number of columns. */
- const NUM_COLUMNS = 7;
+ const NUM_COLUMNS = 8;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
@@ -52,6 +52,9 @@ abstract class BaseCcPlaylistPeer {
/** the column name for the LENGTH field */
const LENGTH = 'cc_playlist.LENGTH';
+ /** the column name for the TYPE field */
+ const TYPE = 'cc_playlist.TYPE';
+
/**
* An identiy map to hold any loaded instances of CcPlaylist objects.
* This must be public so that other peer classes can access this when hydrating from JOIN
@@ -68,12 +71,12 @@ abstract class BaseCcPlaylistPeer {
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
- BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbMtime', 'DbUtime', 'DbCreatorId', 'DbDescription', 'DbLength', ),
- BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbMtime', 'dbUtime', 'dbCreatorId', 'dbDescription', 'dbLength', ),
- BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::MTIME, self::UTIME, self::CREATOR_ID, self::DESCRIPTION, self::LENGTH, ),
- BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'MTIME', 'UTIME', 'CREATOR_ID', 'DESCRIPTION', 'LENGTH', ),
- BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'mtime', 'utime', 'creator_id', 'description', 'length', ),
- BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbMtime', 'DbUtime', 'DbCreatorId', 'DbDescription', 'DbLength', 'DbType', ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbMtime', 'dbUtime', 'dbCreatorId', 'dbDescription', 'dbLength', 'dbType', ),
+ BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::MTIME, self::UTIME, self::CREATOR_ID, self::DESCRIPTION, self::LENGTH, self::TYPE, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'MTIME', 'UTIME', 'CREATOR_ID', 'DESCRIPTION', 'LENGTH', 'TYPE', ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'mtime', 'utime', 'creator_id', 'description', 'length', 'type', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
);
/**
@@ -83,12 +86,12 @@ abstract class BaseCcPlaylistPeer {
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
- BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbMtime' => 2, 'DbUtime' => 3, 'DbCreatorId' => 4, 'DbDescription' => 5, 'DbLength' => 6, ),
- BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbMtime' => 2, 'dbUtime' => 3, 'dbCreatorId' => 4, 'dbDescription' => 5, 'dbLength' => 6, ),
- BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::MTIME => 2, self::UTIME => 3, self::CREATOR_ID => 4, self::DESCRIPTION => 5, self::LENGTH => 6, ),
- BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'MTIME' => 2, 'UTIME' => 3, 'CREATOR_ID' => 4, 'DESCRIPTION' => 5, 'LENGTH' => 6, ),
- BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'mtime' => 2, 'utime' => 3, 'creator_id' => 4, 'description' => 5, 'length' => 6, ),
- BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbMtime' => 2, 'DbUtime' => 3, 'DbCreatorId' => 4, 'DbDescription' => 5, 'DbLength' => 6, 'DbType' => 7, ),
+ BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbMtime' => 2, 'dbUtime' => 3, 'dbCreatorId' => 4, 'dbDescription' => 5, 'dbLength' => 6, 'dbType' => 7, ),
+ BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::MTIME => 2, self::UTIME => 3, self::CREATOR_ID => 4, self::DESCRIPTION => 5, self::LENGTH => 6, self::TYPE => 7, ),
+ BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'MTIME' => 2, 'UTIME' => 3, 'CREATOR_ID' => 4, 'DESCRIPTION' => 5, 'LENGTH' => 6, 'TYPE' => 7, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'mtime' => 2, 'utime' => 3, 'creator_id' => 4, 'description' => 5, 'length' => 6, 'type' => 7, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
);
/**
@@ -167,6 +170,7 @@ abstract class BaseCcPlaylistPeer {
$criteria->addSelectColumn(CcPlaylistPeer::CREATOR_ID);
$criteria->addSelectColumn(CcPlaylistPeer::DESCRIPTION);
$criteria->addSelectColumn(CcPlaylistPeer::LENGTH);
+ $criteria->addSelectColumn(CcPlaylistPeer::TYPE);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.NAME');
@@ -175,6 +179,7 @@ abstract class BaseCcPlaylistPeer {
$criteria->addSelectColumn($alias . '.CREATOR_ID');
$criteria->addSelectColumn($alias . '.DESCRIPTION');
$criteria->addSelectColumn($alias . '.LENGTH');
+ $criteria->addSelectColumn($alias . '.TYPE');
}
}
@@ -371,6 +376,9 @@ abstract class BaseCcPlaylistPeer {
// Invalidate objects in CcPlaylistcontentsPeer instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
CcPlaylistcontentsPeer::clearInstancePool();
+ // Invalidate objects in CcPlaylistcriteriaPeer instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ CcPlaylistcriteriaPeer::clearInstancePool();
}
/**
diff --git a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistQuery.php
index 66b50e1c2..4031f9755 100644
--- a/airtime_mvc/application/models/airtime/om/BaseCcPlaylistQuery.php
+++ b/airtime_mvc/application/models/airtime/om/BaseCcPlaylistQuery.php
@@ -13,6 +13,7 @@
* @method CcPlaylistQuery orderByDbCreatorId($order = Criteria::ASC) Order by the creator_id column
* @method CcPlaylistQuery orderByDbDescription($order = Criteria::ASC) Order by the description column
* @method CcPlaylistQuery orderByDbLength($order = Criteria::ASC) Order by the length column
+ * @method CcPlaylistQuery orderByDbType($order = Criteria::ASC) Order by the type column
*
* @method CcPlaylistQuery groupByDbId() Group by the id column
* @method CcPlaylistQuery groupByDbName() Group by the name column
@@ -21,6 +22,7 @@
* @method CcPlaylistQuery groupByDbCreatorId() Group by the creator_id column
* @method CcPlaylistQuery groupByDbDescription() Group by the description column
* @method CcPlaylistQuery groupByDbLength() Group by the length column
+ * @method CcPlaylistQuery groupByDbType() Group by the type column
*
* @method CcPlaylistQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method CcPlaylistQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
@@ -34,6 +36,10 @@
* @method CcPlaylistQuery rightJoinCcPlaylistcontents($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcPlaylistcontents relation
* @method CcPlaylistQuery innerJoinCcPlaylistcontents($relationAlias = '') Adds a INNER JOIN clause to the query using the CcPlaylistcontents relation
*
+ * @method CcPlaylistQuery leftJoinCcPlaylistcriteria($relationAlias = '') Adds a LEFT JOIN clause to the query using the CcPlaylistcriteria relation
+ * @method CcPlaylistQuery rightJoinCcPlaylistcriteria($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcPlaylistcriteria relation
+ * @method CcPlaylistQuery innerJoinCcPlaylistcriteria($relationAlias = '') Adds a INNER JOIN clause to the query using the CcPlaylistcriteria relation
+ *
* @method CcPlaylist findOne(PropelPDO $con = null) Return the first CcPlaylist matching the query
* @method CcPlaylist findOneOrCreate(PropelPDO $con = null) Return the first CcPlaylist matching the query, or a new CcPlaylist object populated from the query conditions when no match is found
*
@@ -44,6 +50,7 @@
* @method CcPlaylist findOneByDbCreatorId(int $creator_id) Return the first CcPlaylist filtered by the creator_id column
* @method CcPlaylist findOneByDbDescription(string $description) Return the first CcPlaylist filtered by the description column
* @method CcPlaylist findOneByDbLength(string $length) Return the first CcPlaylist filtered by the length column
+ * @method CcPlaylist findOneByDbType(string $type) Return the first CcPlaylist filtered by the type column
*
* @method array findByDbId(int $id) Return CcPlaylist objects filtered by the id column
* @method array findByDbName(string $name) Return CcPlaylist objects filtered by the name column
@@ -52,6 +59,7 @@
* @method array findByDbCreatorId(int $creator_id) Return CcPlaylist objects filtered by the creator_id column
* @method array findByDbDescription(string $description) Return CcPlaylist objects filtered by the description column
* @method array findByDbLength(string $length) Return CcPlaylist objects filtered by the length column
+ * @method array findByDbType(string $type) Return CcPlaylist objects filtered by the type column
*
* @package propel.generator.airtime.om
*/
@@ -337,6 +345,28 @@ abstract class BaseCcPlaylistQuery extends ModelCriteria
return $this->addUsingAlias(CcPlaylistPeer::LENGTH, $dbLength, $comparison);
}
+ /**
+ * Filter the query on the type column
+ *
+ * @param string $dbType 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 CcPlaylistQuery The current query, for fluid interface
+ */
+ public function filterByDbType($dbType = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($dbType)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $dbType)) {
+ $dbType = str_replace('*', '%', $dbType);
+ $comparison = Criteria::LIKE;
+ }
+ }
+ return $this->addUsingAlias(CcPlaylistPeer::TYPE, $dbType, $comparison);
+ }
+
/**
* Filter the query by a related CcSubjs object
*
@@ -465,6 +495,70 @@ abstract class BaseCcPlaylistQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'CcPlaylistcontents', 'CcPlaylistcontentsQuery');
}
+ /**
+ * Filter the query by a related CcPlaylistcriteria object
+ *
+ * @param CcPlaylistcriteria $ccPlaylistcriteria the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return CcPlaylistQuery The current query, for fluid interface
+ */
+ public function filterByCcPlaylistcriteria($ccPlaylistcriteria, $comparison = null)
+ {
+ return $this
+ ->addUsingAlias(CcPlaylistPeer::ID, $ccPlaylistcriteria->getDbPlaylistId(), $comparison);
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CcPlaylistcriteria relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return CcPlaylistQuery The current query, for fluid interface
+ */
+ public function joinCcPlaylistcriteria($relationAlias = '', $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CcPlaylistcriteria');
+
+ // 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, 'CcPlaylistcriteria');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CcPlaylistcriteria relation CcPlaylistcriteria 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 CcPlaylistcriteriaQuery A secondary query class using the current class as primary query
+ */
+ public function useCcPlaylistcriteriaQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCcPlaylistcriteria($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CcPlaylistcriteria', 'CcPlaylistcriteriaQuery');
+ }
+
/**
* Exclude object from result
*
diff --git a/airtime_mvc/build/schema.xml b/airtime_mvc/build/schema.xml
index f87f827ee..883f03026 100644
--- a/airtime_mvc/build/schema.xml
+++ b/airtime_mvc/build/schema.xml
@@ -255,7 +255,8 @@
-
+
+
diff --git a/airtime_mvc/build/sql/schema.sql b/airtime_mvc/build/sql/schema.sql
index 78e58cfe8..a209e8f3b 100644
--- a/airtime_mvc/build/sql/schema.sql
+++ b/airtime_mvc/build/sql/schema.sql
@@ -301,6 +301,7 @@ CREATE TABLE "cc_playlist"
"creator_id" INTEGER,
"description" VARCHAR(512),
"length" interval default '00:00:00',
+ "type" VARCHAR(7) default 'static',
PRIMARY KEY ("id")
);
@@ -332,6 +333,28 @@ CREATE TABLE "cc_playlistcontents"
COMMENT ON TABLE "cc_playlistcontents" IS '';
+SET search_path TO public;
+-----------------------------------------------------------------------------
+-- cc_playlistcriteria
+-----------------------------------------------------------------------------
+
+DROP TABLE "cc_playlistcriteria" CASCADE;
+
+
+CREATE TABLE "cc_playlistcriteria"
+(
+ "id" serial NOT NULL,
+ "criteria" VARCHAR(16) NOT NULL,
+ "modifier" VARCHAR(16) NOT NULL,
+ "value" VARCHAR(32) NOT NULL,
+ "extra" VARCHAR(32),
+ "playlist_id" INTEGER NOT NULL,
+ PRIMARY KEY ("id")
+);
+
+COMMENT ON TABLE "cc_playlistcriteria" IS '';
+
+
SET search_path TO public;
-----------------------------------------------------------------------------
-- cc_pref
@@ -606,6 +629,8 @@ ALTER TABLE "cc_playlistcontents" ADD CONSTRAINT "cc_playlistcontents_file_id_fk
ALTER TABLE "cc_playlistcontents" ADD CONSTRAINT "cc_playlistcontents_playlist_id_fkey" FOREIGN KEY ("playlist_id") REFERENCES "cc_playlist" ("id") ON DELETE CASCADE;
+ALTER TABLE "cc_playlistcriteria" ADD CONSTRAINT "cc_playlistcontents_playlist_id_fkey" FOREIGN KEY ("playlist_id") REFERENCES "cc_playlist" ("id") ON DELETE CASCADE;
+
ALTER TABLE "cc_pref" ADD CONSTRAINT "cc_pref_subjid_fkey" FOREIGN KEY ("subjid") REFERENCES "cc_subjs" ("id") ON DELETE CASCADE;
ALTER TABLE "cc_schedule" ADD CONSTRAINT "cc_show_inst_fkey" FOREIGN KEY ("instance_id") REFERENCES "cc_show_instances" ("id") ON DELETE CASCADE;