saving a template to the DB.

This commit is contained in:
Naomi 2013-07-29 17:35:07 -04:00
parent a2d4af5449
commit 06e21029d0
13 changed files with 67 additions and 105 deletions

View file

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for representing a row from the 'cc_playout_history_template_tag' 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 CcPlayoutHistoryTemplateTag extends BaseCcPlayoutHistoryTemplateTag {
} // CcPlayoutHistoryTemplateTag

View file

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_playout_history_template_tag' 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 CcPlayoutHistoryTemplateTagPeer extends BaseCcPlayoutHistoryTemplateTagPeer {
} // CcPlayoutHistoryTemplateTagPeer

View file

@ -1,18 +0,0 @@
<?php
/**
* Skeleton subclass for performing query and update operations on the 'cc_playout_history_template_tag' 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 CcPlayoutHistoryTemplateTagQuery extends BaseCcPlayoutHistoryTemplateTagQuery {
} // CcPlayoutHistoryTemplateTagQuery

View file

@ -43,7 +43,7 @@ class CcPlayoutHistoryTemplateFieldTableMap extends TableMap {
$this->addColumn('NAME', 'DbName', 'VARCHAR', true, 128, null);
$this->addColumn('TYPE', 'DbType', 'VARCHAR', true, 128, null);
$this->addColumn('IS_FILE_MD', 'DbIsFileMD', 'BOOLEAN', true, null, false);
$this->addColumn('POSITION', 'DbTagPosition', 'INTEGER', true, null, null);
$this->addColumn('POSITION', 'DbPosition', 'INTEGER', true, null, null);
// validators
} // initialize()

View file

@ -39,7 +39,7 @@ class CcPlayoutHistoryTemplateTableMap extends TableMap {
$this->setPrimaryKeyMethodInfo('cc_playout_history_template_id_seq');
// columns
$this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null);
$this->addColumn('TEMPLATE_NAME', 'DbTemplateName', 'VARCHAR', true, 128, null);
$this->addColumn('TEMPLATE_NAME', 'DbName', 'VARCHAR', true, 128, null);
// validators
} // initialize()

View file

@ -70,7 +70,7 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persi
*
* @return string
*/
public function getDbTemplateName()
public function getDbName()
{
return $this->template_name;
}
@ -101,7 +101,7 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persi
* @param string $v new value
* @return CcPlayoutHistoryTemplate The current object (for fluent API support)
*/
public function setDbTemplateName($v)
public function setDbName($v)
{
if ($v !== null) {
$v = (string) $v;
@ -113,7 +113,7 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persi
}
return $this;
} // setDbTemplateName()
} // setDbName()
/**
* Indicates whether the columns in this object are only set to default values.
@ -478,7 +478,7 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persi
return $this->getDbId();
break;
case 1:
return $this->getDbTemplateName();
return $this->getDbName();
break;
default:
return null;
@ -504,7 +504,7 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persi
$keys = CcPlayoutHistoryTemplatePeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getDbId(),
$keys[1] => $this->getDbTemplateName(),
$keys[1] => $this->getDbName(),
);
return $result;
}
@ -540,7 +540,7 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persi
$this->setDbId($value);
break;
case 1:
$this->setDbTemplateName($value);
$this->setDbName($value);
break;
} // switch()
}
@ -567,7 +567,7 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persi
$keys = CcPlayoutHistoryTemplatePeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setDbTemplateName($arr[$keys[1]]);
if (array_key_exists($keys[1], $arr)) $this->setDbName($arr[$keys[1]]);
}
/**
@ -642,7 +642,7 @@ abstract class BaseCcPlayoutHistoryTemplate extends BaseObject implements Persi
*/
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setDbTemplateName($this->template_name);
$copyObj->setDbName($this->template_name);
if ($deepCopy) {
// important: temporarily setNew(false) because this affects the behavior of

View file

@ -156,7 +156,7 @@ abstract class BaseCcPlayoutHistoryTemplateField extends BaseObject implements
*
* @return int
*/
public function getDbTagPosition()
public function getDbPosition()
{
return $this->position;
}
@ -271,7 +271,7 @@ abstract class BaseCcPlayoutHistoryTemplateField extends BaseObject implements
* @param int $v new value
* @return CcPlayoutHistoryTemplateField The current object (for fluent API support)
*/
public function setDbTagPosition($v)
public function setDbPosition($v)
{
if ($v !== null) {
$v = (int) $v;
@ -283,7 +283,7 @@ abstract class BaseCcPlayoutHistoryTemplateField extends BaseObject implements
}
return $this;
} // setDbTagPosition()
} // setDbPosition()
/**
* Indicates whether the columns in this object are only set to default values.
@ -678,7 +678,7 @@ abstract class BaseCcPlayoutHistoryTemplateField extends BaseObject implements
return $this->getDbIsFileMD();
break;
case 5:
return $this->getDbTagPosition();
return $this->getDbPosition();
break;
default:
return null;
@ -709,7 +709,7 @@ abstract class BaseCcPlayoutHistoryTemplateField extends BaseObject implements
$keys[2] => $this->getDbName(),
$keys[3] => $this->getDbType(),
$keys[4] => $this->getDbIsFileMD(),
$keys[5] => $this->getDbTagPosition(),
$keys[5] => $this->getDbPosition(),
);
if ($includeForeignObjects) {
if (null !== $this->aCcPlayoutHistoryTemplate) {
@ -762,7 +762,7 @@ abstract class BaseCcPlayoutHistoryTemplateField extends BaseObject implements
$this->setDbIsFileMD($value);
break;
case 5:
$this->setDbTagPosition($value);
$this->setDbPosition($value);
break;
} // switch()
}
@ -793,7 +793,7 @@ abstract class BaseCcPlayoutHistoryTemplateField extends BaseObject implements
if (array_key_exists($keys[2], $arr)) $this->setDbName($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setDbType($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setDbIsFileMD($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setDbTagPosition($arr[$keys[5]]);
if (array_key_exists($keys[5], $arr)) $this->setDbPosition($arr[$keys[5]]);
}
/**
@ -876,7 +876,7 @@ abstract class BaseCcPlayoutHistoryTemplateField extends BaseObject implements
$copyObj->setDbName($this->name);
$copyObj->setDbType($this->type);
$copyObj->setDbIsFileMD($this->is_file_md);
$copyObj->setDbTagPosition($this->position);
$copyObj->setDbPosition($this->position);
$copyObj->setNew(true);
$copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value

View file

@ -65,8 +65,8 @@ abstract class BaseCcPlayoutHistoryTemplateFieldPeer {
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbTemplateId', 'DbName', 'DbType', 'DbIsFileMD', 'DbTagPosition', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbTemplateId', 'dbName', 'dbType', 'dbIsFileMD', 'dbTagPosition', ),
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbTemplateId', 'DbName', 'DbType', 'DbIsFileMD', 'DbPosition', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbTemplateId', 'dbName', 'dbType', 'dbIsFileMD', 'dbPosition', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::TEMPLATE_ID, self::NAME, self::TYPE, self::IS_FILE_MD, self::POSITION, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TEMPLATE_ID', 'NAME', 'TYPE', 'IS_FILE_MD', 'POSITION', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'template_id', 'name', 'type', 'is_file_md', 'position', ),
@ -80,8 +80,8 @@ abstract class BaseCcPlayoutHistoryTemplateFieldPeer {
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbTemplateId' => 1, 'DbName' => 2, 'DbType' => 3, 'DbIsFileMD' => 4, 'DbTagPosition' => 5, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbTemplateId' => 1, 'dbName' => 2, 'dbType' => 3, 'dbIsFileMD' => 4, 'dbTagPosition' => 5, ),
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbTemplateId' => 1, 'DbName' => 2, 'DbType' => 3, 'DbIsFileMD' => 4, 'DbPosition' => 5, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbTemplateId' => 1, 'dbName' => 2, 'dbType' => 3, 'dbIsFileMD' => 4, 'dbPosition' => 5, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::TEMPLATE_ID => 1, self::NAME => 2, self::TYPE => 3, self::IS_FILE_MD => 4, self::POSITION => 5, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TEMPLATE_ID' => 1, 'NAME' => 2, 'TYPE' => 3, 'IS_FILE_MD' => 4, 'POSITION' => 5, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'template_id' => 1, 'name' => 2, 'type' => 3, 'is_file_md' => 4, 'position' => 5, ),

View file

@ -11,14 +11,14 @@
* @method CcPlayoutHistoryTemplateFieldQuery orderByDbName($order = Criteria::ASC) Order by the name column
* @method CcPlayoutHistoryTemplateFieldQuery orderByDbType($order = Criteria::ASC) Order by the type column
* @method CcPlayoutHistoryTemplateFieldQuery orderByDbIsFileMD($order = Criteria::ASC) Order by the is_file_md column
* @method CcPlayoutHistoryTemplateFieldQuery orderByDbTagPosition($order = Criteria::ASC) Order by the position column
* @method CcPlayoutHistoryTemplateFieldQuery orderByDbPosition($order = Criteria::ASC) Order by the position column
*
* @method CcPlayoutHistoryTemplateFieldQuery groupByDbId() Group by the id column
* @method CcPlayoutHistoryTemplateFieldQuery groupByDbTemplateId() Group by the template_id column
* @method CcPlayoutHistoryTemplateFieldQuery groupByDbName() Group by the name column
* @method CcPlayoutHistoryTemplateFieldQuery groupByDbType() Group by the type column
* @method CcPlayoutHistoryTemplateFieldQuery groupByDbIsFileMD() Group by the is_file_md column
* @method CcPlayoutHistoryTemplateFieldQuery groupByDbTagPosition() Group by the position column
* @method CcPlayoutHistoryTemplateFieldQuery groupByDbPosition() Group by the position column
*
* @method CcPlayoutHistoryTemplateFieldQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method CcPlayoutHistoryTemplateFieldQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
@ -36,14 +36,14 @@
* @method CcPlayoutHistoryTemplateField findOneByDbName(string $name) Return the first CcPlayoutHistoryTemplateField filtered by the name column
* @method CcPlayoutHistoryTemplateField findOneByDbType(string $type) Return the first CcPlayoutHistoryTemplateField filtered by the type column
* @method CcPlayoutHistoryTemplateField findOneByDbIsFileMD(boolean $is_file_md) Return the first CcPlayoutHistoryTemplateField filtered by the is_file_md column
* @method CcPlayoutHistoryTemplateField findOneByDbTagPosition(int $position) Return the first CcPlayoutHistoryTemplateField filtered by the position column
* @method CcPlayoutHistoryTemplateField findOneByDbPosition(int $position) Return the first CcPlayoutHistoryTemplateField filtered by the position column
*
* @method array findByDbId(int $id) Return CcPlayoutHistoryTemplateField objects filtered by the id column
* @method array findByDbTemplateId(int $template_id) Return CcPlayoutHistoryTemplateField objects filtered by the template_id column
* @method array findByDbName(string $name) Return CcPlayoutHistoryTemplateField objects filtered by the name column
* @method array findByDbType(string $type) Return CcPlayoutHistoryTemplateField objects filtered by the type column
* @method array findByDbIsFileMD(boolean $is_file_md) Return CcPlayoutHistoryTemplateField objects filtered by the is_file_md column
* @method array findByDbTagPosition(int $position) Return CcPlayoutHistoryTemplateField objects filtered by the position column
* @method array findByDbPosition(int $position) Return CcPlayoutHistoryTemplateField objects filtered by the position column
*
* @package propel.generator.airtime.om
*/
@ -265,22 +265,22 @@ abstract class BaseCcPlayoutHistoryTemplateFieldQuery extends ModelCriteria
/**
* Filter the query on the position column
*
* @param int|array $dbTagPosition The value to use as filter.
* @param int|array $dbPosition The value to use as filter.
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcPlayoutHistoryTemplateFieldQuery The current query, for fluid interface
*/
public function filterByDbTagPosition($dbTagPosition = null, $comparison = null)
public function filterByDbPosition($dbPosition = null, $comparison = null)
{
if (is_array($dbTagPosition)) {
if (is_array($dbPosition)) {
$useMinMax = false;
if (isset($dbTagPosition['min'])) {
$this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::POSITION, $dbTagPosition['min'], Criteria::GREATER_EQUAL);
if (isset($dbPosition['min'])) {
$this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::POSITION, $dbPosition['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($dbTagPosition['max'])) {
$this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::POSITION, $dbTagPosition['max'], Criteria::LESS_EQUAL);
if (isset($dbPosition['max'])) {
$this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::POSITION, $dbPosition['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
@ -290,7 +290,7 @@ abstract class BaseCcPlayoutHistoryTemplateFieldQuery extends ModelCriteria
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::POSITION, $dbTagPosition, $comparison);
return $this->addUsingAlias(CcPlayoutHistoryTemplateFieldPeer::POSITION, $dbPosition, $comparison);
}
/**

View file

@ -53,8 +53,8 @@ abstract class BaseCcPlayoutHistoryTemplatePeer {
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbTemplateName', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbTemplateName', ),
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', ),
BasePeer::TYPE_COLNAME => array (self::ID, self::TEMPLATE_NAME, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TEMPLATE_NAME', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'template_name', ),
@ -68,8 +68,8 @@ abstract class BaseCcPlayoutHistoryTemplatePeer {
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbTemplateName' => 1, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbTemplateName' => 1, ),
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, ),
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::TEMPLATE_NAME => 1, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TEMPLATE_NAME' => 1, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'template_name' => 1, ),

View file

@ -7,10 +7,10 @@
*
*
* @method CcPlayoutHistoryTemplateQuery orderByDbId($order = Criteria::ASC) Order by the id column
* @method CcPlayoutHistoryTemplateQuery orderByDbTemplateName($order = Criteria::ASC) Order by the template_name column
* @method CcPlayoutHistoryTemplateQuery orderByDbName($order = Criteria::ASC) Order by the template_name column
*
* @method CcPlayoutHistoryTemplateQuery groupByDbId() Group by the id column
* @method CcPlayoutHistoryTemplateQuery groupByDbTemplateName() Group by the template_name column
* @method CcPlayoutHistoryTemplateQuery groupByDbName() Group by the template_name column
*
* @method CcPlayoutHistoryTemplateQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method CcPlayoutHistoryTemplateQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
@ -24,10 +24,10 @@
* @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
*
* @method CcPlayoutHistoryTemplate findOneByDbId(int $id) Return the first CcPlayoutHistoryTemplate filtered by the id column
* @method CcPlayoutHistoryTemplate findOneByDbTemplateName(string $template_name) Return the first CcPlayoutHistoryTemplate filtered by the template_name column
* @method CcPlayoutHistoryTemplate findOneByDbName(string $template_name) Return the first CcPlayoutHistoryTemplate filtered by the template_name column
*
* @method array findByDbId(int $id) Return CcPlayoutHistoryTemplate objects filtered by the id column
* @method array findByDbTemplateName(string $template_name) Return CcPlayoutHistoryTemplate objects filtered by the template_name column
* @method array findByDbName(string $template_name) Return CcPlayoutHistoryTemplate objects filtered by the template_name column
*
* @package propel.generator.airtime.om
*/
@ -157,23 +157,23 @@ abstract class BaseCcPlayoutHistoryTemplateQuery extends ModelCriteria
/**
* Filter the query on the template_name column
*
* @param string $dbTemplateName The value to use as filter.
* @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 CcPlayoutHistoryTemplateQuery The current query, for fluid interface
*/
public function filterByDbTemplateName($dbTemplateName = null, $comparison = null)
public function filterByDbName($dbName = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($dbTemplateName)) {
if (is_array($dbName)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $dbTemplateName)) {
$dbTemplateName = str_replace('*', '%', $dbTemplateName);
} elseif (preg_match('/[\%\*]/', $dbName)) {
$dbName = str_replace('*', '%', $dbName);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CcPlayoutHistoryTemplatePeer::TEMPLATE_NAME, $dbTemplateName, $comparison);
return $this->addUsingAlias(CcPlayoutHistoryTemplatePeer::TEMPLATE_NAME, $dbName, $comparison);
}
/**

View file

@ -472,13 +472,29 @@ class Application_Service_HistoryService
return $template;
}
public function createItemTemplate($fields) {
public function createItemTemplate($config) {
$this->con->beginTransaction();
try {
$template = new CcPlayoutHistoryTemplate();
$template->setDbName($config["name"]);
$fields = $config["fields"];
foreach ($fields as $index=>$field) {
$templateField = new CcPlayoutHistoryTemplateField();
$templateField->setDbName($field["name"]);
$templateField->setDbType($field["type"]);
$templateField->setDbIsFileMD($field["filemd"]);
$templateField->setDbPosition($index);
$template->addCcPlayoutHistoryTemplateField($templateField);
}
$template->save($this->con);
$this->con->commit();
}

View file

@ -499,7 +499,7 @@
</table>
<table name="cc_playout_history_template" phpName="CcPlayoutHistoryTemplate">
<column name="id" phpName="DbId" primaryKey="true" type="INTEGER" autoIncrement="true" required="true" />
<column name="template_name" phpName="DbTemplateName" type="VARCHAR" size="128" required="true" />
<column name="template_name" phpName="DbName" type="VARCHAR" size="128" required="true" />
</table>
<table name="cc_playout_history_template_field" phpName="CcPlayoutHistoryTemplateField">
<column name="id" phpName="DbId" primaryKey="true" type="INTEGER" autoIncrement="true" required="true" />
@ -507,7 +507,7 @@
<column name="name" phpName="DbName" type="VARCHAR" size="128" required="true" />
<column name="type" phpName="DbType" type="VARCHAR" size="128" required="true" />
<column name="is_file_md" phpName="DbIsFileMD" type="BOOLEAN" required="true" defaultValue="false"/>
<column name="position" phpName="DbTagPosition" type="INTEGER" required="true" />
<column name="position" phpName="DbPosition" type="INTEGER" required="true" />
<foreign-key foreignTable="cc_playout_history_template" name="cc_playout_history_template_template_fkey" onDelete="CASCADE">
<reference local="template_id" foreign="id"/>
</foreign-key>