CC-2110 : Soundcloud file metadata

added show genre column, this is used instead of soundcloud default genre if set.
This commit is contained in:
naomiaro 2011-04-02 17:09:37 -04:00
parent 7be60fbf84
commit b97e79773b
12 changed files with 174 additions and 38 deletions

View File

@ -276,11 +276,12 @@ class ApiController extends Zend_Controller_Action
$file = StoredFile::uploadFile($upload_dir);
$show_instance = $this->_getParam('show_instance');
$show_name = $this->_getParam('show_name');
$start_time = $this->_getParam('start_time');
$show_inst = new ShowInstance($show_instance);
$show_inst->setRecordedFile($file->getId());
$show_name = $show_inst->getName();
$show_genre = $show_inst->getGenre();
$show_start_time = $show_inst->getShowStart();
if(Application_Model_Preference::GetDoSoundCloudUpload())
{
@ -294,7 +295,7 @@ class ApiController extends Zend_Controller_Action
try {
$soundcloud = new ATSoundcloud();
$soundcloud_id = $soundcloud->uploadTrack($file->getRealFilePath(), $file->getName(), $description, $tags, $start_time);
$soundcloud_id = $soundcloud->uploadTrack($file->getRealFilePath(), $file->getName(), $description, $tags, $show_start_time, $show_genre);
$show_inst->setSoundCloudFileId($soundcloud_id);
break;
}

View File

@ -21,7 +21,15 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
'required' => false,
'filters' => array('StringTrim'),
'validators' => array('NotEmpty')
));
));
// Add genre element
$this->addElement('text', 'add_show_genre', array(
'label' => 'Genre:',
'class' => 'input_text',
'required' => false,
'filters' => array('StringTrim')
));
// Add the description element
$this->addElement('textarea', 'add_show_description', array(

View File

@ -155,6 +155,7 @@ class Show {
$show->setDbName($data['add_show_name']);
$show->setDbDescription($data['add_show_description']);
$show->setDbUrl($data['add_show_url']);
$show->setDbGenre($data['add_show_genre']);
$show->setDbColor($data['add_show_color']);
$show->setDbBackgroundColor($data['add_show_background_color']);
$show->save();
@ -616,6 +617,12 @@ class ShowInstance {
return $show->getDbName();
}
public function getGenre()
{
$show = CcShowQuery::create()->findPK($this->getShowId());
return $show->getDbGenre();
}
public function getShowStart()
{
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId);

View File

@ -28,7 +28,7 @@ class ATSoundcloud {
return $token;
}
public function uploadTrack($filepath, $filename, $description, $tags=array(), $release=null)
public function uploadTrack($filepath, $filename, $description, $tags=array(), $release=null, $genre=null)
{
if($this->getToken())
{
@ -61,11 +61,16 @@ class ATSoundcloud {
$track_data['track[release_month]'] = $release[1];
$track_data['track[release_day]'] = $release[2];
}
$genre = Application_Model_Preference::GetSoundCloudGenre();
if ($genre != "") {
if (isset($genre) && $genre != "") {
$track_data['track[genre]'] = $genre;
}
else {
$default_genre = Application_Model_Preference::GetSoundCloudTrackType();
if ($genre != "") {
$track_data['track[genre]'] = $default_genre;
}
}
$track_type = Application_Model_Preference::GetSoundCloudTrackType();
if ($track_type != "") {

View File

@ -41,6 +41,7 @@ class CcShowTableMap extends TableMap {
$this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null);
$this->addColumn('NAME', 'DbName', 'VARCHAR', true, 255, '');
$this->addColumn('URL', 'DbUrl', 'VARCHAR', false, 255, '');
$this->addColumn('GENRE', 'DbGenre', 'VARCHAR', false, 255, '');
$this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', false, 512, null);
$this->addColumn('COLOR', 'DbColor', 'VARCHAR', false, 6, null);
$this->addColumn('BACKGROUND_COLOR', 'DbBackgroundColor', 'VARCHAR', false, 6, null);

View File

@ -44,6 +44,13 @@ abstract class BaseCcShow extends BaseObject implements Persistent
*/
protected $url;
/**
* The value for the genre field.
* Note: this column has a database default value of: ''
* @var string
*/
protected $genre;
/**
* The value for the description field.
* @var string
@ -106,6 +113,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
{
$this->name = '';
$this->url = '';
$this->genre = '';
}
/**
@ -148,6 +156,16 @@ abstract class BaseCcShow extends BaseObject implements Persistent
return $this->url;
}
/**
* Get the [genre] column value.
*
* @return string
*/
public function getDbGenre()
{
return $this->genre;
}
/**
* Get the [description] column value.
*
@ -238,6 +256,26 @@ abstract class BaseCcShow extends BaseObject implements Persistent
return $this;
} // setDbUrl()
/**
* Set the value of [genre] column.
*
* @param string $v new value
* @return CcShow The current object (for fluent API support)
*/
public function setDbGenre($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->genre !== $v || $this->isNew()) {
$this->genre = $v;
$this->modifiedColumns[] = CcShowPeer::GENRE;
}
return $this;
} // setDbGenre()
/**
* Set the value of [description] column.
*
@ -316,6 +354,10 @@ abstract class BaseCcShow extends BaseObject implements Persistent
return false;
}
if ($this->genre !== '') {
return false;
}
// otherwise, everything was equal, so return TRUE
return true;
} // hasOnlyDefaultValues()
@ -341,9 +383,10 @@ abstract class BaseCcShow extends BaseObject implements Persistent
$this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
$this->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
$this->url = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
$this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
$this->color = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
$this->background_color = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
$this->genre = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
$this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
$this->color = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
$this->background_color = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
$this->resetModified();
$this->setNew(false);
@ -352,7 +395,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
$this->ensureConsistency();
}
return $startcol + 6; // 6 = CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS).
return $startcol + 7; // 7 = CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating CcShow object", $e);
@ -733,12 +776,15 @@ abstract class BaseCcShow extends BaseObject implements Persistent
return $this->getDbUrl();
break;
case 3:
return $this->getDbDescription();
return $this->getDbGenre();
break;
case 4:
return $this->getDbColor();
return $this->getDbDescription();
break;
case 5:
return $this->getDbColor();
break;
case 6:
return $this->getDbBackgroundColor();
break;
default:
@ -767,9 +813,10 @@ abstract class BaseCcShow extends BaseObject implements Persistent
$keys[0] => $this->getDbId(),
$keys[1] => $this->getDbName(),
$keys[2] => $this->getDbUrl(),
$keys[3] => $this->getDbDescription(),
$keys[4] => $this->getDbColor(),
$keys[5] => $this->getDbBackgroundColor(),
$keys[3] => $this->getDbGenre(),
$keys[4] => $this->getDbDescription(),
$keys[5] => $this->getDbColor(),
$keys[6] => $this->getDbBackgroundColor(),
);
return $result;
}
@ -811,12 +858,15 @@ abstract class BaseCcShow extends BaseObject implements Persistent
$this->setDbUrl($value);
break;
case 3:
$this->setDbDescription($value);
$this->setDbGenre($value);
break;
case 4:
$this->setDbColor($value);
$this->setDbDescription($value);
break;
case 5:
$this->setDbColor($value);
break;
case 6:
$this->setDbBackgroundColor($value);
break;
} // switch()
@ -846,9 +896,10 @@ abstract class BaseCcShow extends BaseObject implements Persistent
if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setDbName($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setDbUrl($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setDbDescription($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setDbColor($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setDbBackgroundColor($arr[$keys[5]]);
if (array_key_exists($keys[3], $arr)) $this->setDbGenre($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setDbDescription($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setDbColor($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setDbBackgroundColor($arr[$keys[6]]);
}
/**
@ -863,6 +914,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
if ($this->isColumnModified(CcShowPeer::ID)) $criteria->add(CcShowPeer::ID, $this->id);
if ($this->isColumnModified(CcShowPeer::NAME)) $criteria->add(CcShowPeer::NAME, $this->name);
if ($this->isColumnModified(CcShowPeer::URL)) $criteria->add(CcShowPeer::URL, $this->url);
if ($this->isColumnModified(CcShowPeer::GENRE)) $criteria->add(CcShowPeer::GENRE, $this->genre);
if ($this->isColumnModified(CcShowPeer::DESCRIPTION)) $criteria->add(CcShowPeer::DESCRIPTION, $this->description);
if ($this->isColumnModified(CcShowPeer::COLOR)) $criteria->add(CcShowPeer::COLOR, $this->color);
if ($this->isColumnModified(CcShowPeer::BACKGROUND_COLOR)) $criteria->add(CcShowPeer::BACKGROUND_COLOR, $this->background_color);
@ -929,6 +981,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
{
$copyObj->setDbName($this->name);
$copyObj->setDbUrl($this->url);
$copyObj->setDbGenre($this->genre);
$copyObj->setDbDescription($this->description);
$copyObj->setDbColor($this->color);
$copyObj->setDbBackgroundColor($this->background_color);
@ -1526,6 +1579,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
$this->id = null;
$this->name = null;
$this->url = null;
$this->genre = null;
$this->description = null;
$this->color = null;
$this->background_color = null;

View File

@ -26,7 +26,7 @@ abstract class BaseCcShowPeer {
const TM_CLASS = 'CcShowTableMap';
/** The total number of columns. */
const NUM_COLUMNS = 6;
const NUM_COLUMNS = 7;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
@ -40,6 +40,9 @@ abstract class BaseCcShowPeer {
/** the column name for the URL field */
const URL = 'cc_show.URL';
/** the column name for the GENRE field */
const GENRE = 'cc_show.GENRE';
/** the column name for the DESCRIPTION field */
const DESCRIPTION = 'cc_show.DESCRIPTION';
@ -65,12 +68,12 @@ abstract class BaseCcShowPeer {
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbUrl', 'DbDescription', 'DbColor', 'DbBackgroundColor', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbUrl', 'dbDescription', 'dbColor', 'dbBackgroundColor', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::URL, self::DESCRIPTION, self::COLOR, self::BACKGROUND_COLOR, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'URL', 'DESCRIPTION', 'COLOR', 'BACKGROUND_COLOR', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'url', 'description', 'color', 'background_color', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbUrl', 'DbGenre', 'DbDescription', 'DbColor', 'DbBackgroundColor', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbUrl', 'dbGenre', 'dbDescription', 'dbColor', 'dbBackgroundColor', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::URL, self::GENRE, self::DESCRIPTION, self::COLOR, self::BACKGROUND_COLOR, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'URL', 'GENRE', 'DESCRIPTION', 'COLOR', 'BACKGROUND_COLOR', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'url', 'genre', 'description', 'color', 'background_color', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
);
/**
@ -80,12 +83,12 @@ abstract class BaseCcShowPeer {
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbUrl' => 2, 'DbDescription' => 3, 'DbColor' => 4, 'DbBackgroundColor' => 5, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbUrl' => 2, 'dbDescription' => 3, 'dbColor' => 4, 'dbBackgroundColor' => 5, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::URL => 2, self::DESCRIPTION => 3, self::COLOR => 4, self::BACKGROUND_COLOR => 5, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'URL' => 2, 'DESCRIPTION' => 3, 'COLOR' => 4, 'BACKGROUND_COLOR' => 5, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'url' => 2, 'description' => 3, 'color' => 4, 'background_color' => 5, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbUrl' => 2, 'DbGenre' => 3, 'DbDescription' => 4, 'DbColor' => 5, 'DbBackgroundColor' => 6, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbUrl' => 2, 'dbGenre' => 3, 'dbDescription' => 4, 'dbColor' => 5, 'dbBackgroundColor' => 6, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::URL => 2, self::GENRE => 3, self::DESCRIPTION => 4, self::COLOR => 5, self::BACKGROUND_COLOR => 6, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'URL' => 2, 'GENRE' => 3, 'DESCRIPTION' => 4, 'COLOR' => 5, 'BACKGROUND_COLOR' => 6, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'url' => 2, 'genre' => 3, 'description' => 4, 'color' => 5, 'background_color' => 6, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
);
/**
@ -160,6 +163,7 @@ abstract class BaseCcShowPeer {
$criteria->addSelectColumn(CcShowPeer::ID);
$criteria->addSelectColumn(CcShowPeer::NAME);
$criteria->addSelectColumn(CcShowPeer::URL);
$criteria->addSelectColumn(CcShowPeer::GENRE);
$criteria->addSelectColumn(CcShowPeer::DESCRIPTION);
$criteria->addSelectColumn(CcShowPeer::COLOR);
$criteria->addSelectColumn(CcShowPeer::BACKGROUND_COLOR);
@ -167,6 +171,7 @@ abstract class BaseCcShowPeer {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.NAME');
$criteria->addSelectColumn($alias . '.URL');
$criteria->addSelectColumn($alias . '.GENRE');
$criteria->addSelectColumn($alias . '.DESCRIPTION');
$criteria->addSelectColumn($alias . '.COLOR');
$criteria->addSelectColumn($alias . '.BACKGROUND_COLOR');

View File

@ -9,6 +9,7 @@
* @method CcShowQuery orderByDbId($order = Criteria::ASC) Order by the id column
* @method CcShowQuery orderByDbName($order = Criteria::ASC) Order by the name column
* @method CcShowQuery orderByDbUrl($order = Criteria::ASC) Order by the url column
* @method CcShowQuery orderByDbGenre($order = Criteria::ASC) Order by the genre column
* @method CcShowQuery orderByDbDescription($order = Criteria::ASC) Order by the description column
* @method CcShowQuery orderByDbColor($order = Criteria::ASC) Order by the color column
* @method CcShowQuery orderByDbBackgroundColor($order = Criteria::ASC) Order by the background_color column
@ -16,6 +17,7 @@
* @method CcShowQuery groupByDbId() Group by the id column
* @method CcShowQuery groupByDbName() Group by the name column
* @method CcShowQuery groupByDbUrl() Group by the url column
* @method CcShowQuery groupByDbGenre() Group by the genre column
* @method CcShowQuery groupByDbDescription() Group by the description column
* @method CcShowQuery groupByDbColor() Group by the color column
* @method CcShowQuery groupByDbBackgroundColor() Group by the background_color column
@ -46,6 +48,7 @@
* @method CcShow findOneByDbId(int $id) Return the first CcShow filtered by the id column
* @method CcShow findOneByDbName(string $name) Return the first CcShow filtered by the name column
* @method CcShow findOneByDbUrl(string $url) Return the first CcShow filtered by the url column
* @method CcShow findOneByDbGenre(string $genre) Return the first CcShow filtered by the genre column
* @method CcShow findOneByDbDescription(string $description) Return the first CcShow filtered by the description column
* @method CcShow findOneByDbColor(string $color) Return the first CcShow filtered by the color column
* @method CcShow findOneByDbBackgroundColor(string $background_color) Return the first CcShow filtered by the background_color column
@ -53,6 +56,7 @@
* @method array findByDbId(int $id) Return CcShow objects filtered by the id column
* @method array findByDbName(string $name) Return CcShow objects filtered by the name column
* @method array findByDbUrl(string $url) Return CcShow objects filtered by the url column
* @method array findByDbGenre(string $genre) Return CcShow objects filtered by the genre column
* @method array findByDbDescription(string $description) Return CcShow objects filtered by the description column
* @method array findByDbColor(string $color) Return CcShow objects filtered by the color column
* @method array findByDbBackgroundColor(string $background_color) Return CcShow objects filtered by the background_color column
@ -226,6 +230,28 @@ abstract class BaseCcShowQuery extends ModelCriteria
return $this->addUsingAlias(CcShowPeer::URL, $dbUrl, $comparison);
}
/**
* Filter the query on the genre column
*
* @param string $dbGenre 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 CcShowQuery The current query, for fluid interface
*/
public function filterByDbGenre($dbGenre = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($dbGenre)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $dbGenre)) {
$dbGenre = str_replace('*', '%', $dbGenre);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CcShowPeer::GENRE, $dbGenre, $comparison);
}
/**
* Filter the query on the description column
*

View File

@ -118,6 +118,7 @@
<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=""/>
<column name="url" phpName="DbUrl" type="VARCHAR" size="255" required="false" defaultValue=""/>
<column name="genre" phpName="DbGenre" type="VARCHAR" size="255" required="false" defaultValue=""/>
<column name="description" phpName="DbDescription" type="VARCHAR" size="512" required="false"/>
<column name="color" phpName="DbColor" type="VARCHAR" size="6" required="false"/>
<column name="background_color" phpName="DbBackgroundColor" type="VARCHAR" size="6" required="false"/>

View File

@ -142,6 +142,7 @@ CREATE TABLE "cc_show"
"id" serial NOT NULL,
"name" VARCHAR(255) default '' NOT NULL,
"url" VARCHAR(255) default '',
"genre" VARCHAR(255) default '',
"description" VARCHAR(512),
"color" VARCHAR(6),
"background_color" VARCHAR(6),

View File

@ -0,0 +1,28 @@
<?php
namespace DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;
class Version20110402164819 extends AbstractMigration
{
public function up(Schema $schema)
{
//start cc_show modifications
$show_table = $schema->getTable('cc_show');
$show_table->addColumn('genre', 'string', array('notnull' => 0, 'length' => 255, 'default' => ""));
//end cc_show modifications
}
public function down(Schema $schema)
{
//start cc_show modifications
$show_table = $schema->getTable('cc_show');
$show_table->dropColumn('genre');
//end cc_show modifications
}
}

View File

@ -84,8 +84,7 @@ class ShowRecorder(Thread):
# headers contains the necessary Content-Type and Content-Length
# datagen is a generator object that yields the encoded parameters
datagen, headers = multipart_encode({"file": open(filepath, "rb"), 'name': filename, 'show_instance': self.show_instance, \
'show_name': self.show_name, 'start_time': self.start_time})
datagen, headers = multipart_encode({"file": open(filepath, "rb"), 'name': filename, 'show_instance': self.show_instance})
self.api_client.upload_recorded_show(datagen, headers)