Author: sevein
Date: Tue Jul 19 15:32:55 2011
New Revision: 9326
Log:
s/QubitRights/QubitRight and remove unused files
Added:
trunk/lib/model/QubitRight.php
trunk/lib/model/QubitRightI18n.php
trunk/lib/model/map/RightI18nTableMap.php
trunk/lib/model/map/RightTableMap.php
trunk/lib/model/om/BaseRight.php
trunk/lib/model/om/BaseRightI18n.php
Deleted:
trunk/lib/model/QubitRights.php
trunk/lib/model/QubitRightsI18n.php
trunk/lib/model/map/RightsActorRelationTableMap.php
trunk/lib/model/map/RightsI18nTableMap.php
trunk/lib/model/map/RightsTableMap.php
trunk/lib/model/map/RightsTermRelationTableMap.php
trunk/lib/model/om/BaseRights.php
trunk/lib/model/om/BaseRightsI18n.php
Modified:
trunk/config/schema.yml
trunk/data/sql/lib.model.schema.sql
trunk/lib/model/map/ObjectTableMap.php
trunk/lib/model/map/TermTableMap.php
trunk/lib/model/om/BaseTerm.php
Modified: trunk/config/schema.yml
==============================================================================
--- trunk/config/schema.yml Tue Jul 19 15:29:14 2011 (r9325)
+++ trunk/config/schema.yml Tue Jul 19 15:32:55 2011 (r9326)
@@ -306,12 +306,13 @@
desc_sources: longvarchar
desc_revision_history: longvarchar
- rights:
+ right:
id: { type: integer, required: true, primaryKey: true, foreignTable:
object, foreignReference: id, onDelete: cascade, inheritanceKey: true }
start_date: bu_date
end_date: bu_date
+ copyright_status_id: { type: integer, foreignTable: term,
foreignReference: id }
- rights_i18n:
+ right_i18n:
copyright_note: longvarchar
setting:
Modified: trunk/data/sql/lib.model.schema.sql
==============================================================================
--- trunk/data/sql/lib.model.schema.sql Tue Jul 19 15:29:14 2011 (r9325)
+++ trunk/data/sql/lib.model.schema.sql Tue Jul 19 15:32:55 2011 (r9326)
@@ -1053,41 +1053,46 @@
)Engine=InnoDB;
#-----------------------------------------------------------------------------
-#-- rights
+#-- right
#-----------------------------------------------------------------------------
-DROP TABLE IF EXISTS `rights`;
+DROP TABLE IF EXISTS `right`;
-CREATE TABLE `rights`
+CREATE TABLE `right`
(
`id` INTEGER NOT NULL,
`start_date` DATE,
`end_date` DATE,
+ `copyright_status_id` INTEGER,
`source_culture` VARCHAR(7) NOT NULL,
PRIMARY KEY (`id`),
- CONSTRAINT `rights_FK_1`
+ CONSTRAINT `right_FK_1`
FOREIGN KEY (`id`)
REFERENCES `object` (`id`)
- ON DELETE CASCADE
+ ON DELETE CASCADE,
+ INDEX `right_FI_2` (`copyright_status_id`),
+ CONSTRAINT `right_FK_2`
+ FOREIGN KEY (`copyright_status_id`)
+ REFERENCES `term` (`id`)
)Engine=InnoDB;
#-----------------------------------------------------------------------------
-#-- rights_i18n
+#-- right_i18n
#-----------------------------------------------------------------------------
-DROP TABLE IF EXISTS `rights_i18n`;
+DROP TABLE IF EXISTS `right_i18n`;
-CREATE TABLE `rights_i18n`
+CREATE TABLE `right_i18n`
(
`copyright_note` TEXT,
`id` INTEGER NOT NULL,
`culture` VARCHAR(7) NOT NULL,
PRIMARY KEY (`id`,`culture`),
- CONSTRAINT `rights_i18n_FK_1`
+ CONSTRAINT `right_i18n_FK_1`
FOREIGN KEY (`id`)
- REFERENCES `rights` (`id`)
+ REFERENCES `right` (`id`)
ON DELETE CASCADE
)Engine=InnoDB;
Added: trunk/lib/model/QubitRight.php
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/lib/model/QubitRight.php Tue Jul 19 15:32:55 2011 (r9326)
@@ -0,0 +1,17 @@
+<?php
+
+
+/**
+ * Skeleton subclass for representing a row from the 'right' 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 lib.model
+ */
+class QubitRight extends BaseRight {
+
+} // QubitRight
Added: trunk/lib/model/QubitRightI18n.php
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/lib/model/QubitRightI18n.php Tue Jul 19 15:32:55 2011 (r9326)
@@ -0,0 +1,17 @@
+<?php
+
+
+/**
+ * Skeleton subclass for representing a row from the 'right_i18n' 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 lib.model
+ */
+class QubitRightI18n extends BaseRightI18n {
+
+} // QubitRightI18n
Modified: trunk/lib/model/map/ObjectTableMap.php
==============================================================================
--- trunk/lib/model/map/ObjectTableMap.php Tue Jul 19 15:29:14 2011
(r9325)
+++ trunk/lib/model/map/ObjectTableMap.php Tue Jul 19 15:32:55 2011
(r9326)
@@ -65,7 +65,7 @@
$this->addRelation('relationRelatedByid', 'relation',
RelationMap::ONE_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
$this->addRelation('relationRelatedBysubjectId', 'relation',
RelationMap::ONE_TO_MANY, array('id' => 'subject_id', ), null, null);
$this->addRelation('relationRelatedByobjectId', 'relation',
RelationMap::ONE_TO_MANY, array('id' => 'object_id', ), null, null);
- $this->addRelation('rights', 'rights', RelationMap::ONE_TO_ONE, array('id'
=> 'id', ), 'CASCADE', null);
+ $this->addRelation('right', 'right', RelationMap::ONE_TO_ONE, array('id'
=> 'id', ), 'CASCADE', null);
$this->addRelation('slug', 'slug', RelationMap::ONE_TO_MANY, array('id' =>
'object_id', ), 'CASCADE', null);
$this->addRelation('staticPage', 'staticPage', RelationMap::ONE_TO_ONE,
array('id' => 'id', ), 'CASCADE', null);
$this->addRelation('status', 'status', RelationMap::ONE_TO_MANY,
array('id' => 'object_id', ), 'CASCADE', null);
Added: trunk/lib/model/map/RightI18nTableMap.php
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/lib/model/map/RightI18nTableMap.php Tue Jul 19 15:32:55 2011
(r9326)
@@ -0,0 +1,53 @@
+<?php
+
+
+/**
+ * This class defines the structure of the 'right_i18n' table.
+ *
+ *
+ *
+ * This map class is used by Propel to do runtime db structure discovery.
+ * For example, the createSelectSql() method checks the type of a given column
used in an
+ * ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY
case-insensitive
+ * (i.e. if it's a text column type).
+ *
+ * @package lib.model.map
+ */
+class RightI18nTableMap extends TableMap {
+
+ /**
+ * The (dot-path) name of this class
+ */
+ const CLASS_NAME = 'lib.model.map.RightI18nTableMap';
+
+ /**
+ * Initialize the table attributes, columns and validators
+ * Relations are not initialized by this method since they are lazy
loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('right_i18n');
+ $this->setPhpName('rightI18n');
+ $this->setClassname('QubitRightI18n');
+ $this->setPackage('lib.model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addColumn('COPYRIGHT_NOTE', 'copyrightNote',
'LONGVARCHAR', false, null, null);
+ $this->addForeignPrimaryKey('ID', 'id', 'INTEGER' , 'right',
'ID', true, null, null);
+ $this->addPrimaryKey('CULTURE', 'culture', 'VARCHAR', true, 7,
null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('right', 'right', RelationMap::MANY_TO_ONE, array('id'
=> 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+} // RightI18nTableMap
Added: trunk/lib/model/map/RightTableMap.php
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/lib/model/map/RightTableMap.php Tue Jul 19 15:32:55 2011
(r9326)
@@ -0,0 +1,57 @@
+<?php
+
+
+/**
+ * This class defines the structure of the 'right' table.
+ *
+ *
+ *
+ * This map class is used by Propel to do runtime db structure discovery.
+ * For example, the createSelectSql() method checks the type of a given column
used in an
+ * ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY
case-insensitive
+ * (i.e. if it's a text column type).
+ *
+ * @package lib.model.map
+ */
+class RightTableMap extends TableMap {
+
+ /**
+ * The (dot-path) name of this class
+ */
+ const CLASS_NAME = 'lib.model.map.RightTableMap';
+
+ /**
+ * Initialize the table attributes, columns and validators
+ * Relations are not initialized by this method since they are lazy
loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('right');
+ $this->setPhpName('right');
+ $this->setClassname('QubitRight');
+ $this->setPackage('lib.model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'id', 'INTEGER' , 'object',
'ID', true, null, null);
+ $this->addColumn('START_DATE', 'startDate', 'DATE', false,
null, null);
+ $this->addColumn('END_DATE', 'endDate', 'DATE', false, null,
null);
+ $this->addForeignKey('COPYRIGHT_STATUS_ID',
'copyrightStatusId', 'INTEGER', 'term', 'ID', false, null, null);
+ $this->addColumn('SOURCE_CULTURE', 'sourceCulture', 'VARCHAR',
true, 7, null);
+ // validators
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('object', 'object', RelationMap::MANY_TO_ONE,
array('id' => 'id', ), 'CASCADE', null);
+ $this->addRelation('term', 'term', RelationMap::MANY_TO_ONE,
array('copyright_status_id' => 'id', ), null, null);
+ $this->addRelation('rightI18n', 'rightI18n', RelationMap::ONE_TO_MANY,
array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+} // RightTableMap
Modified: trunk/lib/model/map/TermTableMap.php
==============================================================================
--- trunk/lib/model/map/TermTableMap.php Tue Jul 19 15:29:14 2011
(r9325)
+++ trunk/lib/model/map/TermTableMap.php Tue Jul 19 15:32:55 2011
(r9326)
@@ -81,6 +81,7 @@
$this->addRelation('relation', 'relation', RelationMap::ONE_TO_MANY,
array('id' => 'type_id', ), null, null);
$this->addRelation('repositoryRelatedBydescStatusId', 'repository',
RelationMap::ONE_TO_MANY, array('id' => 'desc_status_id', ), 'SET NULL', null);
$this->addRelation('repositoryRelatedBydescDetailId', 'repository',
RelationMap::ONE_TO_MANY, array('id' => 'desc_detail_id', ), 'SET NULL', null);
+ $this->addRelation('right', 'right', RelationMap::ONE_TO_MANY, array('id'
=> 'copyright_status_id', ), null, null);
$this->addRelation('statusRelatedBytypeId', 'status',
RelationMap::ONE_TO_MANY, array('id' => 'type_id', ), 'CASCADE', null);
$this->addRelation('statusRelatedBystatusId', 'status',
RelationMap::ONE_TO_MANY, array('id' => 'status_id', ), 'CASCADE', null);
$this->addRelation('systemEvent', 'systemEvent', RelationMap::ONE_TO_MANY,
array('id' => 'type_id', ), null, null);
Added: trunk/lib/model/om/BaseRight.php
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/lib/model/om/BaseRight.php Tue Jul 19 15:32:55 2011 (r9326)
@@ -0,0 +1,268 @@
+<?php
+
+abstract class BaseRight extends QubitObject implements ArrayAccess
+{
+ const
+ DATABASE_NAME = 'propel',
+
+ TABLE_NAME = 'right',
+
+ ID = 'right.ID',
+ START_DATE = 'right.START_DATE',
+ END_DATE = 'right.END_DATE',
+ COPYRIGHT_STATUS_ID = 'right.COPYRIGHT_STATUS_ID',
+ SOURCE_CULTURE = 'right.SOURCE_CULTURE';
+
+ public static function addSelectColumns(Criteria $criteria)
+ {
+ parent::addSelectColumns($criteria);
+
+ $criteria->addJoin(QubitRight::ID, QubitObject::ID);
+
+ $criteria->addSelectColumn(QubitRight::ID);
+ $criteria->addSelectColumn(QubitRight::START_DATE);
+ $criteria->addSelectColumn(QubitRight::END_DATE);
+ $criteria->addSelectColumn(QubitRight::COPYRIGHT_STATUS_ID);
+ $criteria->addSelectColumn(QubitRight::SOURCE_CULTURE);
+
+ return $criteria;
+ }
+
+ public static function get(Criteria $criteria, array $options = array())
+ {
+ if (!isset($options['connection']))
+ {
+ $options['connection'] =
Propel::getConnection(QubitRight::DATABASE_NAME);
+ }
+
+ self::addSelectColumns($criteria);
+
+ return QubitQuery::createFromCriteria($criteria, 'QubitRight', $options);
+ }
+
+ public static function getAll(array $options = array())
+ {
+ return self::get(new Criteria, $options);
+ }
+
+ public static function getOne(Criteria $criteria, array $options = array())
+ {
+ $criteria->setLimit(1);
+
+ return self::get($criteria, $options)->__get(0, array('defaultValue' =>
null));
+ }
+
+ public static function getById($id, array $options = array())
+ {
+ $criteria = new Criteria;
+ $criteria->add(QubitRight::ID, $id);
+
+ if (1 == count($query = self::get($criteria, $options)))
+ {
+ return $query[0];
+ }
+ }
+
+ public function __construct()
+ {
+ parent::__construct();
+
+ $this->tables[] =
Propel::getDatabaseMap(QubitRight::DATABASE_NAME)->getTable(QubitRight::TABLE_NAME);
+ }
+
+ public function __isset($name)
+ {
+ $args = func_get_args();
+
+ $options = array();
+ if (1 < count($args))
+ {
+ $options = $args[1];
+ }
+
+ try
+ {
+ return call_user_func_array(array($this, 'QubitObject::__isset'), $args);
+ }
+ catch (sfException $e)
+ {
+ }
+
+ if ('rightI18ns' == $name)
+ {
+ return true;
+ }
+
+ try
+ {
+ if (!$value =
call_user_func_array(array($this->getCurrentrightI18n($options), '__isset'),
$args) && !empty($options['cultureFallback']))
+ {
+ return
call_user_func_array(array($this->getCurrentrightI18n(array('sourceCulture' =>
true) + $options), '__isset'), $args);
+ }
+
+ return $value;
+ }
+ catch (sfException $e)
+ {
+ }
+
+ throw new sfException("Unknown record property \"$name\" on
\"".get_class($this).'"');
+ }
+
+ public function __get($name)
+ {
+ $args = func_get_args();
+
+ $options = array();
+ if (1 < count($args))
+ {
+ $options = $args[1];
+ }
+
+ try
+ {
+ return call_user_func_array(array($this, 'QubitObject::__get'), $args);
+ }
+ catch (sfException $e)
+ {
+ }
+
+ if ('rightI18ns' == $name)
+ {
+ if (!isset($this->refFkValues['rightI18ns']))
+ {
+ if (!isset($this->id))
+ {
+ $this->refFkValues['rightI18ns'] = QubitQuery::create();
+ }
+ else
+ {
+ $this->refFkValues['rightI18ns'] =
self::getrightI18nsById($this->id, array('self' => $this) + $options);
+ }
+ }
+
+ return $this->refFkValues['rightI18ns'];
+ }
+
+ try
+ {
+ if (1 > strlen($value =
call_user_func_array(array($this->getCurrentrightI18n($options), '__get'),
$args)) && !empty($options['cultureFallback']))
+ {
+ return
call_user_func_array(array($this->getCurrentrightI18n(array('sourceCulture' =>
true) + $options), '__get'), $args);
+ }
+
+ return $value;
+ }
+ catch (sfException $e)
+ {
+ }
+
+ throw new sfException("Unknown record property \"$name\" on
\"".get_class($this).'"');
+ }
+
+ public function __set($name, $value)
+ {
+ $args = func_get_args();
+
+ $options = array();
+ if (2 < count($args))
+ {
+ $options = $args[2];
+ }
+
+ call_user_func_array(array($this, 'QubitObject::__set'), $args);
+
+ call_user_func_array(array($this->getCurrentrightI18n($options), '__set'),
$args);
+
+ return $this;
+ }
+
+ public function __unset($name)
+ {
+ $args = func_get_args();
+
+ $options = array();
+ if (1 < count($args))
+ {
+ $options = $args[1];
+ }
+
+ call_user_func_array(array($this, 'QubitObject::__unset'), $args);
+
+ call_user_func_array(array($this->getCurrentrightI18n($options),
'__unset'), $args);
+
+ return $this;
+ }
+
+ public function clear()
+ {
+ foreach ($this->rightI18ns as $rightI18n)
+ {
+ $rightI18n->clear();
+ }
+
+ return parent::clear();
+ }
+
+ public function save($connection = null)
+ {
+ parent::save($connection);
+
+ foreach ($this->rightI18ns as $rightI18n)
+ {
+ $rightI18n->id = $this->id;
+
+ $rightI18n->save($connection);
+ }
+
+ return $this;
+ }
+
+ public static function addJoincopyrightStatusCriteria(Criteria $criteria)
+ {
+ $criteria->addJoin(QubitRight::COPYRIGHT_STATUS_ID, QubitTerm::ID);
+
+ return $criteria;
+ }
+
+ public static function addrightI18nsCriteriaById(Criteria $criteria, $id)
+ {
+ $criteria->add(QubitRightI18n::ID, $id);
+
+ return $criteria;
+ }
+
+ public static function getrightI18nsById($id, array $options = array())
+ {
+ $criteria = new Criteria;
+ self::addrightI18nsCriteriaById($criteria, $id);
+
+ return QubitRightI18n::get($criteria, $options);
+ }
+
+ public function addrightI18nsCriteria(Criteria $criteria)
+ {
+ return self::addrightI18nsCriteriaById($criteria, $this->id);
+ }
+
+ public function getCurrentrightI18n(array $options = array())
+ {
+ if (!empty($options['sourceCulture']))
+ {
+ $options['culture'] = $this->sourceCulture;
+ }
+
+ if (!isset($options['culture']))
+ {
+ $options['culture'] = sfPropel::getDefaultCulture();
+ }
+
+ $rightI18ns = $this->rightI18ns->indexBy('culture');
+ if (!isset($rightI18ns[$options['culture']]))
+ {
+ $rightI18ns[$options['culture']] = new QubitRightI18n;
+ }
+
+ return $rightI18ns[$options['culture']];
+ }
+}
Added: trunk/lib/model/om/BaseRightI18n.php
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/lib/model/om/BaseRightI18n.php Tue Jul 19 15:32:55 2011
(r9326)
@@ -0,0 +1,549 @@
+<?php
+
+abstract class BaseRightI18n implements ArrayAccess
+{
+ const
+ DATABASE_NAME = 'propel',
+
+ TABLE_NAME = 'right_i18n',
+
+ COPYRIGHT_NOTE = 'right_i18n.COPYRIGHT_NOTE',
+ ID = 'right_i18n.ID',
+ CULTURE = 'right_i18n.CULTURE';
+
+ public static function addSelectColumns(Criteria $criteria)
+ {
+ $criteria->addSelectColumn(QubitRightI18n::COPYRIGHT_NOTE);
+ $criteria->addSelectColumn(QubitRightI18n::ID);
+ $criteria->addSelectColumn(QubitRightI18n::CULTURE);
+
+ return $criteria;
+ }
+
+ protected static
+ $rightI18ns = array();
+
+ protected
+ $keys = array(),
+ $row = array();
+
+ public static function getFromRow(array $row)
+ {
+ $keys = array();
+ $keys['id'] = $row[1];
+ $keys['culture'] = $row[2];
+
+ $key = serialize($keys);
+ if (!isset(self::$rightI18ns[$key]))
+ {
+ $rightI18n = new QubitRightI18n;
+
+ $rightI18n->keys = $keys;
+ $rightI18n->row = $row;
+
+ $rightI18n->new = false;
+
+ self::$rightI18ns[$key] = $rightI18n;
+ }
+
+ return self::$rightI18ns[$key];
+ }
+
+ public static function get(Criteria $criteria, array $options = array())
+ {
+ if (!isset($options['connection']))
+ {
+ $options['connection'] =
Propel::getConnection(QubitRightI18n::DATABASE_NAME);
+ }
+
+ self::addSelectColumns($criteria);
+
+ return QubitQuery::createFromCriteria($criteria, 'QubitRightI18n',
$options);
+ }
+
+ public static function getAll(array $options = array())
+ {
+ return self::get(new Criteria, $options);
+ }
+
+ public static function getOne(Criteria $criteria, array $options = array())
+ {
+ $criteria->setLimit(1);
+
+ return self::get($criteria, $options)->__get(0, array('defaultValue' =>
null));
+ }
+
+ public static function getByIdAndCulture($id, $culture, array $options =
array())
+ {
+ $criteria = new Criteria;
+ $criteria->add(QubitRightI18n::ID, $id);
+ $criteria->add(QubitRightI18n::CULTURE, $culture);
+
+ if (1 == count($query = self::get($criteria, $options)))
+ {
+ return $query[0];
+ }
+ }
+
+ public static function doDelete(Criteria $criteria, $connection = null)
+ {
+ if (!isset($connection))
+ {
+ $connection =
QubitTransactionFilter::getConnection(QubitRightI18n::DATABASE_NAME);
+ }
+
+ $affectedRows = 0;
+
+ $affectedRows += BasePeer::doDelete($criteria, $connection);
+
+ return $affectedRows;
+ }
+
+ protected
+ $tables = array();
+
+ public function __construct()
+ {
+ $this->tables[] =
Propel::getDatabaseMap(QubitRightI18n::DATABASE_NAME)->getTable(QubitRightI18n::TABLE_NAME);
+ }
+
+ protected
+ $values = array(),
+ $refFkValues = array();
+
+ protected function rowOffsetGet($name, $offset, $options)
+ {
+ if (empty($options['clean']) && array_key_exists($name, $this->values))
+ {
+ return $this->values[$name];
+ }
+
+ if (array_key_exists($name, $this->keys))
+ {
+ return $this->keys[$name];
+ }
+
+ if (!array_key_exists($offset, $this->row))
+ {
+ if ($this->new)
+ {
+ return;
+ }
+
+ if (!isset($options['connection']))
+ {
+ $options['connection'] =
Propel::getConnection(QubitRightI18n::DATABASE_NAME);
+ }
+
+ $criteria = new Criteria;
+ $criteria->add(QubitRightI18n::ID, $this->id);
+ $criteria->add(QubitRightI18n::CULTURE, $this->culture);
+
+ call_user_func(array(get_class($this), 'addSelectColumns'), $criteria);
+
+ $statement = BasePeer::doSelect($criteria, $options['connection']);
+ $this->row = $statement->fetch();
+ }
+
+ return $this->row[$offset];
+ }
+
+ public function __isset($name)
+ {
+ $args = func_get_args();
+
+ $options = array();
+ if (1 < count($args))
+ {
+ $options = $args[1];
+ }
+
+ $offset = 0;
+ foreach ($this->tables as $table)
+ {
+ foreach ($table->getColumns() as $column)
+ {
+ if ($name == $column->getPhpName())
+ {
+ return null !== $this->rowOffsetGet($name, $offset, $options);
+ }
+
+ if ("{$name}Id" == $column->getPhpName())
+ {
+ return null !== $this->rowOffsetGet("{$name}Id", $offset, $options);
+ }
+
+ $offset++;
+ }
+ }
+
+ throw new sfException("Unknown record property \"$name\" on
\"".get_class($this).'"');
+ }
+
+ public function offsetExists($offset)
+ {
+ $args = func_get_args();
+
+ return call_user_func_array(array($this, '__isset'), $args);
+ }
+
+ public function __get($name)
+ {
+ $args = func_get_args();
+
+ $options = array();
+ if (1 < count($args))
+ {
+ $options = $args[1];
+ }
+
+ $offset = 0;
+ foreach ($this->tables as $table)
+ {
+ foreach ($table->getColumns() as $column)
+ {
+ if ($name == $column->getPhpName())
+ {
+ return $this->rowOffsetGet($name, $offset, $options);
+ }
+
+ if ("{$name}Id" == $column->getPhpName())
+ {
+ $relatedTable =
$column->getTable()->getDatabaseMap()->getTable($column->getRelatedTableName());
+
+ return call_user_func(array($relatedTable->getClassName(),
'getBy'.ucfirst($relatedTable->getColumn($column->getRelatedColumnName())->getPhpName())),
$this->rowOffsetGet("{$name}Id", $offset, $options));
+ }
+
+ $offset++;
+ }
+ }
+
+ throw new sfException("Unknown record property \"$name\" on
\"".get_class($this).'"');
+ }
+
+ public function offsetGet($offset)
+ {
+ $args = func_get_args();
+
+ return call_user_func_array(array($this, '__get'), $args);
+ }
+
+ public function __set($name, $value)
+ {
+ $args = func_get_args();
+
+ $options = array();
+ if (2 < count($args))
+ {
+ $options = $args[2];
+ }
+
+ $offset = 0;
+ foreach ($this->tables as $table)
+ {
+ foreach ($table->getColumns() as $column)
+ {
+ if ($name == $column->getPhpName())
+ {
+ $this->values[$name] = $value;
+ }
+
+ if ("{$name}Id" == $column->getPhpName())
+ {
+ $relatedTable =
$column->getTable()->getDatabaseMap()->getTable($column->getRelatedTableName());
+
+ $this->values["{$name}Id"] =
$value->__get($relatedTable->getColumn($column->getRelatedColumnName())->getPhpName(),
$options);
+ }
+
+ $offset++;
+ }
+ }
+
+ return $this;
+ }
+
+ public function offsetSet($offset, $value)
+ {
+ $args = func_get_args();
+
+ return call_user_func_array(array($this, '__set'), $args);
+ }
+
+ public function __unset($name)
+ {
+ $offset = 0;
+ foreach ($this->tables as $table)
+ {
+ foreach ($table->getColumns() as $column)
+ {
+ if ($name == $column->getPhpName())
+ {
+ $this->values[$name] = null;
+ }
+
+ if ("{$name}Id" == $column->getPhpName())
+ {
+ $this->values["{$name}Id"] = null;
+ }
+
+ $offset++;
+ }
+ }
+
+ return $this;
+ }
+
+ public function offsetUnset($offset)
+ {
+ $args = func_get_args();
+
+ return call_user_func_array(array($this, '__unset'), $args);
+ }
+
+ public function clear()
+ {
+ $this->row = $this->values = array();
+
+ return $this;
+ }
+
+ protected
+ $new = true;
+
+ protected
+ $deleted = false;
+
+ public function save($connection = null)
+ {
+ if ($this->deleted)
+ {
+ throw new PropelException('You cannot save an object that has been
deleted.');
+ }
+
+ if ($this->new)
+ {
+ $this->insert($connection);
+ }
+ else
+ {
+ $this->update($connection);
+ }
+
+ $offset = 0;
+ foreach ($this->tables as $table)
+ {
+ foreach ($table->getColumns() as $column)
+ {
+ if (array_key_exists($column->getPhpName(), $this->values))
+ {
+ $this->row[$offset] = $this->values[$column->getPhpName()];
+ }
+
+ $offset++;
+ }
+ }
+
+ $this->new = false;
+ $this->values = array();
+
+ return $this;
+ }
+
+ protected function param($column)
+ {
+ $value = $this->values[$column->getPhpName()];
+
+ // Convert to DateTime or SQL zero special case
+ if (isset($value) && $column->isTemporal() && !$value instanceof DateTime)
+ {
+ // Year only: one or more digits. Convert to SQL zero special case
+ if (preg_match('/^\d+$/', $value))
+ {
+ $value .= '-0-0';
+ }
+
+ // Year and month only: one or more digits, plus separator, plus
+ // one or more digits. Convert to SQL zero special case
+ else if (preg_match('/^\d+[-\/]\d+$/', $value))
+ {
+ $value .= '-0';
+ }
+
+ // Convert to DateTime if not SQL zero special case: year plus
+ // separator plus zero to twelve (possibly zero padded) plus
+ // separator plus one or more zeros
+ if (!preg_match('/^\d+[-\/]0*(?:1[0-2]|\d)[-\/]0+$/', $value))
+ {
+ $value = new DateTime($value);
+ }
+ }
+
+ return $value;
+ }
+
+ protected function insert($connection = null)
+ {
+ if (!isset($connection))
+ {
+ $connection =
QubitTransactionFilter::getConnection(QubitRightI18n::DATABASE_NAME);
+ }
+
+ $offset = 0;
+ foreach ($this->tables as $table)
+ {
+ $criteria = new Criteria;
+ foreach ($table->getColumns() as $column)
+ {
+ if (!array_key_exists($column->getPhpName(), $this->values))
+ {
+ if ('createdAt' == $column->getPhpName() || 'updatedAt' ==
$column->getPhpName())
+ {
+ $this->values[$column->getPhpName()] = new DateTime;
+ }
+
+ if ('sourceCulture' == $column->getPhpName())
+ {
+ $this->values['sourceCulture'] = sfPropel::getDefaultCulture();
+ }
+ }
+
+ if (array_key_exists($column->getPhpName(), $this->values))
+ {
+ $criteria->add($column->getFullyQualifiedName(),
$this->param($column));
+ }
+
+ $offset++;
+ }
+
+ if (null !== $id = BasePeer::doInsert($criteria, $connection))
+ {
+ // Guess that the first primary key of the first table is auto
+ // incremented
+ if ($this->tables[0] == $table)
+ {
+ $columns = $table->getPrimaryKeyColumns();
+ $this->values[$columns[0]->getPhpName()] =
$this->keys[$columns[0]->getPhpName()] = $id;
+ }
+ }
+ }
+
+ return $this;
+ }
+
+ protected function update($connection = null)
+ {
+ if (!isset($connection))
+ {
+ $connection =
QubitTransactionFilter::getConnection(QubitRightI18n::DATABASE_NAME);
+ }
+
+ $offset = 0;
+ foreach ($this->tables as $table)
+ {
+ $criteria = new Criteria;
+ $selectCriteria = new Criteria;
+ foreach ($table->getColumns() as $column)
+ {
+ if (!array_key_exists($column->getPhpName(), $this->values))
+ {
+ if ('updatedAt' == $column->getPhpName())
+ {
+ $this->values['updatedAt'] = new DateTime;
+ }
+ }
+
+ if (array_key_exists($column->getPhpName(), $this->values))
+ {
+ if ('serialNumber' == $column->getPhpName())
+ {
+ $selectCriteria->add($column->getFullyQualifiedName(),
$this->values[$column->getPhpName()]++);
+ }
+
+ $criteria->add($column->getFullyQualifiedName(),
$this->param($column));
+ }
+
+ if ($column->isPrimaryKey())
+ {
+ $selectCriteria->add($column->getFullyQualifiedName(),
$this->keys[$column->getPhpName()]);
+ }
+
+ $offset++;
+ }
+
+ if (0 < $criteria->size())
+ {
+ BasePeer::doUpdate($selectCriteria, $criteria, $connection);
+ }
+ }
+
+ return $this;
+ }
+
+ public function delete($connection = null)
+ {
+ if ($this->deleted)
+ {
+ throw new PropelException('This object has already been deleted.');
+ }
+
+ $criteria = new Criteria;
+ $criteria->add(QubitRightI18n::ID, $this->id);
+ $criteria->add(QubitRightI18n::CULTURE, $this->culture);
+
+ self::doDelete($criteria, $connection);
+
+ $this->deleted = true;
+
+ return $this;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+
+ $pks[0] = $this->getid();
+
+ $pks[1] = $this->getculture();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order
must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+
+ $this->setid($keys[0]);
+
+ $this->setculture($keys[1]);
+
+ }
+
+ public static function addJoinrightCriteria(Criteria $criteria)
+ {
+ $criteria->addJoin(QubitRightI18n::ID, QubitRight::ID);
+
+ return $criteria;
+ }
+
+ public function __call($name, $args)
+ {
+ if ('get' == substr($name, 0, 3) || 'set' == substr($name, 0, 3))
+ {
+ $args = array_merge(array(strtolower(substr($name, 3, 1)).substr($name,
4)), $args);
+
+ return call_user_func_array(array($this, '__'.substr($name, 0, 3)),
$args);
+ }
+
+ throw new sfException('Call to undefined method
'.get_class($this)."::$name");
+ }
+}
Modified: trunk/lib/model/om/BaseTerm.php
==============================================================================
--- trunk/lib/model/om/BaseTerm.php Tue Jul 19 15:29:14 2011 (r9325)
+++ trunk/lib/model/om/BaseTerm.php Tue Jul 19 15:32:55 2011 (r9326)
@@ -234,6 +234,11 @@
return true;
}
+ if ('rights' == $name)
+ {
+ return true;
+ }
+
if ('statussRelatedBytypeId' == $name)
{
return true;
@@ -753,6 +758,23 @@
return $this->refFkValues['repositorysRelatedBydescDetailId'];
}
+ if ('rights' == $name)
+ {
+ if (!isset($this->refFkValues['rights']))
+ {
+ if (!isset($this->id))
+ {
+ $this->refFkValues['rights'] = QubitQuery::create();
+ }
+ else
+ {
+ $this->refFkValues['rights'] = self::getrightsById($this->id,
array('self' => $this) + $options);
+ }
+ }
+
+ return $this->refFkValues['rights'];
+ }
+
if ('statussRelatedBytypeId' == $name)
{
if (!isset($this->refFkValues['statussRelatedBytypeId']))
@@ -1641,6 +1663,26 @@
return self::addrepositorysRelatedBydescDetailIdCriteriaById($criteria,
$this->id);
}
+ public static function addrightsCriteriaById(Criteria $criteria, $id)
+ {
+ $criteria->add(QubitRight::COPYRIGHT_STATUS_ID, $id);
+
+ return $criteria;
+ }
+
+ public static function getrightsById($id, array $options = array())
+ {
+ $criteria = new Criteria;
+ self::addrightsCriteriaById($criteria, $id);
+
+ return QubitRight::get($criteria, $options);
+ }
+
+ public function addrightsCriteria(Criteria $criteria)
+ {
+ return self::addrightsCriteriaById($criteria, $this->id);
+ }
+
public static function addstatussRelatedBytypeIdCriteriaById(Criteria
$criteria, $id)
{
$criteria->add(QubitStatus::TYPE_ID, $id);
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.