Author: sevein
Date: Fri Jul 22 13:06:46 2011
New Revision: 9348

Log:
s/right/rights, right is mysql reserverd word, + other schema adjustements

Added:
   trunk/lib/model/QubitRights.php
   trunk/lib/model/QubitRightsI18n.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/data/sql/plugins.qtAccessionPlugin.lib.model.schema.sql
   trunk/lib/model/map/ObjectTableMap.php
   trunk/lib/model/map/RightTableMap.php
   trunk/lib/model/map/TermTableMap.php
   trunk/lib/model/om/BaseTerm.php
   trunk/plugins/qtAccessionPlugin/config/schema.yml

Modified: trunk/config/schema.yml
==============================================================================
--- trunk/config/schema.yml     Fri Jul 22 10:47:56 2011        (r9347)
+++ trunk/config/schema.yml     Fri Jul 22 13:06:46 2011        (r9348)
@@ -306,14 +306,14 @@
     desc_sources: longvarchar
     desc_revision_history: longvarchar
 
-  right:
+  rights:
     id: { type: integer, required: true, primaryKey: true, foreignTable: 
object, foreignReference: id, onDelete: cascade, inheritanceKey: true }
     start_date: bu_date
     end_date: bu_date
-    basis_id: { type: integer, foreignTable: term, foreignReference: id }
-    act_id: { type: integer, foreignTable: term, foreignReference: id }
+    basis_id: { type: integer, foreignTable: term, foreignReference: id, 
onDelete: setnull }
+    act_id: { type: integer, foreignTable: term, foreignReference: id, 
onDelete: setnull }
 
-  right_i18n:
+  rights_i18n:
     copyright_note: longvarchar
 
   setting:

Modified: trunk/data/sql/lib.model.schema.sql
==============================================================================
--- trunk/data/sql/lib.model.schema.sql Fri Jul 22 10:47:56 2011        (r9347)
+++ trunk/data/sql/lib.model.schema.sql Fri Jul 22 13:06:46 2011        (r9348)
@@ -1048,13 +1048,13 @@
 )Engine=InnoDB;
 
 #-----------------------------------------------------------------------------
-#-- right
+#-- rights
 #-----------------------------------------------------------------------------
 
-DROP TABLE IF EXISTS `right`;
+DROP TABLE IF EXISTS `rights`;
 
 
-CREATE TABLE `right`
+CREATE TABLE `rights`
 (
        `id` INTEGER  NOT NULL,
        `start_date` DATE,
@@ -1063,36 +1063,38 @@
        `act_id` INTEGER,
        `source_culture` VARCHAR(7)  NOT NULL,
        PRIMARY KEY (`id`),
-       CONSTRAINT `right_FK_1`
+       CONSTRAINT `rights_FK_1`
                FOREIGN KEY (`id`)
                REFERENCES `object` (`id`)
                ON DELETE CASCADE,
-       INDEX `right_FI_2` (`basis_id`),
-       CONSTRAINT `right_FK_2`
+       INDEX `rights_FI_2` (`basis_id`),
+       CONSTRAINT `rights_FK_2`
                FOREIGN KEY (`basis_id`)
-               REFERENCES `term` (`id`),
-       INDEX `right_FI_3` (`act_id`),
-       CONSTRAINT `right_FK_3`
+               REFERENCES `term` (`id`)
+               ON DELETE SET NULL,
+       INDEX `rights_FI_3` (`act_id`),
+       CONSTRAINT `rights_FK_3`
                FOREIGN KEY (`act_id`)
                REFERENCES `term` (`id`)
+               ON DELETE SET NULL
 )Engine=InnoDB;
 
 #-----------------------------------------------------------------------------
-#-- right_i18n
+#-- rights_i18n
 #-----------------------------------------------------------------------------
 
-DROP TABLE IF EXISTS `right_i18n`;
+DROP TABLE IF EXISTS `rights_i18n`;
 
 
-CREATE TABLE `right_i18n`
+CREATE TABLE `rights_i18n`
 (
        `copyright_note` TEXT,
        `id` INTEGER  NOT NULL,
        `culture` VARCHAR(7)  NOT NULL,
        PRIMARY KEY (`id`,`culture`),
-       CONSTRAINT `right_i18n_FK_1`
+       CONSTRAINT `rights_i18n_FK_1`
                FOREIGN KEY (`id`)
-               REFERENCES `right` (`id`)
+               REFERENCES `rights` (`id`)
                ON DELETE CASCADE
 )Engine=InnoDB;
 

Modified: trunk/data/sql/plugins.qtAccessionPlugin.lib.model.schema.sql
==============================================================================
--- trunk/data/sql/plugins.qtAccessionPlugin.lib.model.schema.sql       Fri Jul 
22 10:47:56 2011        (r9347)
+++ trunk/data/sql/plugins.qtAccessionPlugin.lib.model.schema.sql       Fri Jul 
22 13:06:46 2011        (r9348)
@@ -31,19 +31,23 @@
        INDEX `accession_FI_2` (`acquisition_type_id`),
        CONSTRAINT `accession_FK_2`
                FOREIGN KEY (`acquisition_type_id`)
-               REFERENCES `term` (`id`),
+               REFERENCES `term` (`id`)
+               ON DELETE SET NULL,
        INDEX `accession_FI_3` (`processing_priority_id`),
        CONSTRAINT `accession_FK_3`
                FOREIGN KEY (`processing_priority_id`)
-               REFERENCES `term` (`id`),
+               REFERENCES `term` (`id`)
+               ON DELETE SET NULL,
        INDEX `accession_FI_4` (`processing_status_id`),
        CONSTRAINT `accession_FK_4`
                FOREIGN KEY (`processing_status_id`)
-               REFERENCES `term` (`id`),
+               REFERENCES `term` (`id`)
+               ON DELETE SET NULL,
        INDEX `accession_FI_5` (`resource_type_id`),
        CONSTRAINT `accession_FK_5`
                FOREIGN KEY (`resource_type_id`)
                REFERENCES `term` (`id`)
+               ON DELETE SET NULL
 )Engine=InnoDB;
 
 #-----------------------------------------------------------------------------
@@ -103,6 +107,7 @@
        CONSTRAINT `deaccession_FK_3`
                FOREIGN KEY (`scope_id`)
                REFERENCES `term` (`id`)
+               ON DELETE SET NULL
 )Engine=InnoDB;
 
 #-----------------------------------------------------------------------------

Added: trunk/lib/model/QubitRights.php
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/lib/model/QubitRights.php     Fri Jul 22 13:06:46 2011        (r9348)
@@ -0,0 +1,17 @@
+<?php
+
+
+/**
+ * Skeleton subclass for representing a row from the 'rights' 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 QubitRights extends BaseRights {
+
+} // QubitRights

Added: trunk/lib/model/QubitRightsI18n.php
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/lib/model/QubitRightsI18n.php Fri Jul 22 13:06:46 2011        (r9348)
@@ -0,0 +1,17 @@
+<?php
+
+
+/**
+ * Skeleton subclass for representing a row from the 'rights_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 QubitRightsI18n extends BaseRightsI18n {
+
+} // QubitRightsI18n

Modified: trunk/lib/model/map/ObjectTableMap.php
==============================================================================
--- trunk/lib/model/map/ObjectTableMap.php      Fri Jul 22 10:47:56 2011        
(r9347)
+++ trunk/lib/model/map/ObjectTableMap.php      Fri Jul 22 13:06:46 2011        
(r9348)
@@ -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('right', 'right', RelationMap::ONE_TO_ONE, array('id' 
=> 'id', ), 'CASCADE', null);
+    $this->addRelation('rights', 'rights', 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);

Modified: trunk/lib/model/map/RightTableMap.php
==============================================================================
--- trunk/lib/model/map/RightTableMap.php       Fri Jul 22 10:47:56 2011        
(r9347)
+++ trunk/lib/model/map/RightTableMap.php       Fri Jul 22 13:06:46 2011        
(r9348)
@@ -51,8 +51,8 @@
        public function buildRelations()
        {
     $this->addRelation('object', 'object', RelationMap::MANY_TO_ONE, 
array('id' => 'id', ), 'CASCADE', null);
-    $this->addRelation('termRelatedBybasisId', 'term', 
RelationMap::MANY_TO_ONE, array('basis_id' => 'id', ), null, null);
-    $this->addRelation('termRelatedByactId', 'term', RelationMap::MANY_TO_ONE, 
array('act_id' => 'id', ), null, null);
+    $this->addRelation('termRelatedBybasisId', 'term', 
RelationMap::MANY_TO_ONE, array('basis_id' => 'id', ), 'SET NULL', null);
+    $this->addRelation('termRelatedByactId', 'term', RelationMap::MANY_TO_ONE, 
array('act_id' => 'id', ), 'SET NULL', null);
     $this->addRelation('rightI18n', 'rightI18n', RelationMap::ONE_TO_MANY, 
array('id' => 'id', ), 'CASCADE', null);
        } // buildRelations()
 

Modified: trunk/lib/model/map/TermTableMap.php
==============================================================================
--- trunk/lib/model/map/TermTableMap.php        Fri Jul 22 10:47:56 2011        
(r9347)
+++ trunk/lib/model/map/TermTableMap.php        Fri Jul 22 13:06:46 2011        
(r9348)
@@ -80,18 +80,18 @@
     $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('rightRelatedBybasisId', 'right', 
RelationMap::ONE_TO_MANY, array('id' => 'basis_id', ), null, null);
-    $this->addRelation('rightRelatedByactId', 'right', 
RelationMap::ONE_TO_MANY, array('id' => 'act_id', ), null, null);
+    $this->addRelation('rightsRelatedBybasisId', 'rights', 
RelationMap::ONE_TO_MANY, array('id' => 'basis_id', ), 'SET NULL', null);
+    $this->addRelation('rightsRelatedByactId', 'rights', 
RelationMap::ONE_TO_MANY, array('id' => 'act_id', ), 'SET 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);
     $this->addRelation('termRelatedByparentId', 'term', 
RelationMap::ONE_TO_MANY, array('id' => 'parent_id', ), null, null);
     $this->addRelation('termI18n', 'termI18n', RelationMap::ONE_TO_MANY, 
array('id' => 'id', ), 'CASCADE', null);
-    $this->addRelation('accessionRelatedByacquisitionTypeId', 'accession', 
RelationMap::ONE_TO_MANY, array('id' => 'acquisition_type_id', ), null, null);
-    $this->addRelation('accessionRelatedByprocessingPriorityId', 'accession', 
RelationMap::ONE_TO_MANY, array('id' => 'processing_priority_id', ), null, 
null);
-    $this->addRelation('accessionRelatedByprocessingStatusId', 'accession', 
RelationMap::ONE_TO_MANY, array('id' => 'processing_status_id', ), null, null);
-    $this->addRelation('accessionRelatedByresourceTypeId', 'accession', 
RelationMap::ONE_TO_MANY, array('id' => 'resource_type_id', ), null, null);
-    $this->addRelation('deaccession', 'deaccession', RelationMap::ONE_TO_MANY, 
array('id' => 'scope_id', ), null, null);
+    $this->addRelation('accessionRelatedByacquisitionTypeId', 'accession', 
RelationMap::ONE_TO_MANY, array('id' => 'acquisition_type_id', ), 'SET NULL', 
null);
+    $this->addRelation('accessionRelatedByprocessingPriorityId', 'accession', 
RelationMap::ONE_TO_MANY, array('id' => 'processing_priority_id', ), 'SET 
NULL', null);
+    $this->addRelation('accessionRelatedByprocessingStatusId', 'accession', 
RelationMap::ONE_TO_MANY, array('id' => 'processing_status_id', ), 'SET NULL', 
null);
+    $this->addRelation('accessionRelatedByresourceTypeId', 'accession', 
RelationMap::ONE_TO_MANY, array('id' => 'resource_type_id', ), 'SET NULL', 
null);
+    $this->addRelation('deaccession', 'deaccession', RelationMap::ONE_TO_MANY, 
array('id' => 'scope_id', ), 'SET NULL', null);
        } // buildRelations()
 
 } // TermTableMap

Added: trunk/lib/model/om/BaseRights.php
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/lib/model/om/BaseRights.php   Fri Jul 22 13:06:46 2011        (r9348)
@@ -0,0 +1,277 @@
+<?php
+
+abstract class BaseRights extends QubitObject implements ArrayAccess
+{
+  const
+    DATABASE_NAME = 'propel',
+
+    TABLE_NAME = 'rights',
+
+    ID = 'rights.ID',
+    START_DATE = 'rights.START_DATE',
+    END_DATE = 'rights.END_DATE',
+    BASIS_ID = 'rights.BASIS_ID',
+    ACT_ID = 'rights.ACT_ID',
+    SOURCE_CULTURE = 'rights.SOURCE_CULTURE';
+
+  public static function addSelectColumns(Criteria $criteria)
+  {
+    parent::addSelectColumns($criteria);
+
+    $criteria->addJoin(QubitRights::ID, QubitObject::ID);
+
+    $criteria->addSelectColumn(QubitRights::ID);
+    $criteria->addSelectColumn(QubitRights::START_DATE);
+    $criteria->addSelectColumn(QubitRights::END_DATE);
+    $criteria->addSelectColumn(QubitRights::BASIS_ID);
+    $criteria->addSelectColumn(QubitRights::ACT_ID);
+    $criteria->addSelectColumn(QubitRights::SOURCE_CULTURE);
+
+    return $criteria;
+  }
+
+  public static function get(Criteria $criteria, array $options = array())
+  {
+    if (!isset($options['connection']))
+    {
+      $options['connection'] = 
Propel::getConnection(QubitRights::DATABASE_NAME);
+    }
+
+    self::addSelectColumns($criteria);
+
+    return QubitQuery::createFromCriteria($criteria, 'QubitRights', $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(QubitRights::ID, $id);
+
+    if (1 == count($query = self::get($criteria, $options)))
+    {
+      return $query[0];
+    }
+  }
+
+  public function __construct()
+  {
+    parent::__construct();
+
+    $this->tables[] = 
Propel::getDatabaseMap(QubitRights::DATABASE_NAME)->getTable(QubitRights::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 ('rightsI18ns' == $name)
+    {
+      return true;
+    }
+
+    try
+    {
+      if (!$value = 
call_user_func_array(array($this->getCurrentrightsI18n($options), '__isset'), 
$args) && !empty($options['cultureFallback']))
+      {
+        return 
call_user_func_array(array($this->getCurrentrightsI18n(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 ('rightsI18ns' == $name)
+    {
+      if (!isset($this->refFkValues['rightsI18ns']))
+      {
+        if (!isset($this->id))
+        {
+          $this->refFkValues['rightsI18ns'] = QubitQuery::create();
+        }
+        else
+        {
+          $this->refFkValues['rightsI18ns'] = 
self::getrightsI18nsById($this->id, array('self' => $this) + $options);
+        }
+      }
+
+      return $this->refFkValues['rightsI18ns'];
+    }
+
+    try
+    {
+      if (1 > strlen($value = 
call_user_func_array(array($this->getCurrentrightsI18n($options), '__get'), 
$args)) && !empty($options['cultureFallback']))
+      {
+        return 
call_user_func_array(array($this->getCurrentrightsI18n(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->getCurrentrightsI18n($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->getCurrentrightsI18n($options), 
'__unset'), $args);
+
+    return $this;
+  }
+
+  public function clear()
+  {
+    foreach ($this->rightsI18ns as $rightsI18n)
+    {
+      $rightsI18n->clear();
+    }
+
+    return parent::clear();
+  }
+
+  public function save($connection = null)
+  {
+    parent::save($connection);
+
+    foreach ($this->rightsI18ns as $rightsI18n)
+    {
+      $rightsI18n->id = $this->id;
+
+      $rightsI18n->save($connection);
+    }
+
+    return $this;
+  }
+
+  public static function addJoinbasisCriteria(Criteria $criteria)
+  {
+    $criteria->addJoin(QubitRights::BASIS_ID, QubitTerm::ID);
+
+    return $criteria;
+  }
+
+  public static function addJoinactCriteria(Criteria $criteria)
+  {
+    $criteria->addJoin(QubitRights::ACT_ID, QubitTerm::ID);
+
+    return $criteria;
+  }
+
+  public static function addrightsI18nsCriteriaById(Criteria $criteria, $id)
+  {
+    $criteria->add(QubitRightsI18n::ID, $id);
+
+    return $criteria;
+  }
+
+  public static function getrightsI18nsById($id, array $options = array())
+  {
+    $criteria = new Criteria;
+    self::addrightsI18nsCriteriaById($criteria, $id);
+
+    return QubitRightsI18n::get($criteria, $options);
+  }
+
+  public function addrightsI18nsCriteria(Criteria $criteria)
+  {
+    return self::addrightsI18nsCriteriaById($criteria, $this->id);
+  }
+
+  public function getCurrentrightsI18n(array $options = array())
+  {
+    if (!empty($options['sourceCulture']))
+    {
+      $options['culture'] = $this->sourceCulture;
+    }
+
+    if (!isset($options['culture']))
+    {
+      $options['culture'] = sfPropel::getDefaultCulture();
+    }
+
+    $rightsI18ns = $this->rightsI18ns->indexBy('culture');
+    if (!isset($rightsI18ns[$options['culture']]))
+    {
+      $rightsI18ns[$options['culture']] = new QubitRightsI18n;
+    }
+
+    return $rightsI18ns[$options['culture']];
+  }
+}

Added: trunk/lib/model/om/BaseRightsI18n.php
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/lib/model/om/BaseRightsI18n.php       Fri Jul 22 13:06:46 2011        
(r9348)
@@ -0,0 +1,549 @@
+<?php
+
+abstract class BaseRightsI18n implements ArrayAccess
+{
+  const
+    DATABASE_NAME = 'propel',
+
+    TABLE_NAME = 'rights_i18n',
+
+    COPYRIGHT_NOTE = 'rights_i18n.COPYRIGHT_NOTE',
+    ID = 'rights_i18n.ID',
+    CULTURE = 'rights_i18n.CULTURE';
+
+  public static function addSelectColumns(Criteria $criteria)
+  {
+    $criteria->addSelectColumn(QubitRightsI18n::COPYRIGHT_NOTE);
+    $criteria->addSelectColumn(QubitRightsI18n::ID);
+    $criteria->addSelectColumn(QubitRightsI18n::CULTURE);
+
+    return $criteria;
+  }
+
+  protected static
+    $rightsI18ns = 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::$rightsI18ns[$key]))
+    {
+      $rightsI18n = new QubitRightsI18n;
+
+      $rightsI18n->keys = $keys;
+      $rightsI18n->row = $row;
+
+      $rightsI18n->new = false;
+
+      self::$rightsI18ns[$key] = $rightsI18n;
+    }
+
+    return self::$rightsI18ns[$key];
+  }
+
+  public static function get(Criteria $criteria, array $options = array())
+  {
+    if (!isset($options['connection']))
+    {
+      $options['connection'] = 
Propel::getConnection(QubitRightsI18n::DATABASE_NAME);
+    }
+
+    self::addSelectColumns($criteria);
+
+    return QubitQuery::createFromCriteria($criteria, 'QubitRightsI18n', 
$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(QubitRightsI18n::ID, $id);
+    $criteria->add(QubitRightsI18n::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(QubitRightsI18n::DATABASE_NAME);
+    }
+
+    $affectedRows = 0;
+
+    $affectedRows += BasePeer::doDelete($criteria, $connection);
+
+    return $affectedRows;
+  }
+
+  protected
+    $tables = array();
+
+  public function __construct()
+  {
+    $this->tables[] = 
Propel::getDatabaseMap(QubitRightsI18n::DATABASE_NAME)->getTable(QubitRightsI18n::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(QubitRightsI18n::DATABASE_NAME);
+      }
+
+      $criteria = new Criteria;
+      $criteria->add(QubitRightsI18n::ID, $this->id);
+      $criteria->add(QubitRightsI18n::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(QubitRightsI18n::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(QubitRightsI18n::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(QubitRightsI18n::ID, $this->id);
+    $criteria->add(QubitRightsI18n::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 addJoinrightsCriteria(Criteria $criteria)
+  {
+    $criteria->addJoin(QubitRightsI18n::ID, QubitRights::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     Fri Jul 22 10:47:56 2011        (r9347)
+++ trunk/lib/model/om/BaseTerm.php     Fri Jul 22 13:06:46 2011        (r9348)
@@ -229,12 +229,12 @@
       return true;
     }
 
-    if ('rightsRelatedBybasisId' == $name)
+    if ('rightssRelatedBybasisId' == $name)
     {
       return true;
     }
 
-    if ('rightsRelatedByactId' == $name)
+    if ('rightssRelatedByactId' == $name)
     {
       return true;
     }
@@ -741,38 +741,38 @@
       return $this->refFkValues['repositorysRelatedBydescDetailId'];
     }
 
-    if ('rightsRelatedBybasisId' == $name)
+    if ('rightssRelatedBybasisId' == $name)
     {
-      if (!isset($this->refFkValues['rightsRelatedBybasisId']))
+      if (!isset($this->refFkValues['rightssRelatedBybasisId']))
       {
         if (!isset($this->id))
         {
-          $this->refFkValues['rightsRelatedBybasisId'] = QubitQuery::create();
+          $this->refFkValues['rightssRelatedBybasisId'] = QubitQuery::create();
         }
         else
         {
-          $this->refFkValues['rightsRelatedBybasisId'] = 
self::getrightsRelatedBybasisIdById($this->id, array('self' => $this) + 
$options);
+          $this->refFkValues['rightssRelatedBybasisId'] = 
self::getrightssRelatedBybasisIdById($this->id, array('self' => $this) + 
$options);
         }
       }
 
-      return $this->refFkValues['rightsRelatedBybasisId'];
+      return $this->refFkValues['rightssRelatedBybasisId'];
     }
 
-    if ('rightsRelatedByactId' == $name)
+    if ('rightssRelatedByactId' == $name)
     {
-      if (!isset($this->refFkValues['rightsRelatedByactId']))
+      if (!isset($this->refFkValues['rightssRelatedByactId']))
       {
         if (!isset($this->id))
         {
-          $this->refFkValues['rightsRelatedByactId'] = QubitQuery::create();
+          $this->refFkValues['rightssRelatedByactId'] = QubitQuery::create();
         }
         else
         {
-          $this->refFkValues['rightsRelatedByactId'] = 
self::getrightsRelatedByactIdById($this->id, array('self' => $this) + $options);
+          $this->refFkValues['rightssRelatedByactId'] = 
self::getrightssRelatedByactIdById($this->id, array('self' => $this) + 
$options);
         }
       }
 
-      return $this->refFkValues['rightsRelatedByactId'];
+      return $this->refFkValues['rightssRelatedByactId'];
     }
 
     if ('statussRelatedBytypeId' == $name)
@@ -1643,44 +1643,44 @@
     return self::addrepositorysRelatedBydescDetailIdCriteriaById($criteria, 
$this->id);
   }
 
-  public static function addrightsRelatedBybasisIdCriteriaById(Criteria 
$criteria, $id)
+  public static function addrightssRelatedBybasisIdCriteriaById(Criteria 
$criteria, $id)
   {
-    $criteria->add(QubitRight::BASIS_ID, $id);
+    $criteria->add(QubitRights::BASIS_ID, $id);
 
     return $criteria;
   }
 
-  public static function getrightsRelatedBybasisIdById($id, array $options = 
array())
+  public static function getrightssRelatedBybasisIdById($id, array $options = 
array())
   {
     $criteria = new Criteria;
-    self::addrightsRelatedBybasisIdCriteriaById($criteria, $id);
+    self::addrightssRelatedBybasisIdCriteriaById($criteria, $id);
 
-    return QubitRight::get($criteria, $options);
+    return QubitRights::get($criteria, $options);
   }
 
-  public function addrightsRelatedBybasisIdCriteria(Criteria $criteria)
+  public function addrightssRelatedBybasisIdCriteria(Criteria $criteria)
   {
-    return self::addrightsRelatedBybasisIdCriteriaById($criteria, $this->id);
+    return self::addrightssRelatedBybasisIdCriteriaById($criteria, $this->id);
   }
 
-  public static function addrightsRelatedByactIdCriteriaById(Criteria 
$criteria, $id)
+  public static function addrightssRelatedByactIdCriteriaById(Criteria 
$criteria, $id)
   {
-    $criteria->add(QubitRight::ACT_ID, $id);
+    $criteria->add(QubitRights::ACT_ID, $id);
 
     return $criteria;
   }
 
-  public static function getrightsRelatedByactIdById($id, array $options = 
array())
+  public static function getrightssRelatedByactIdById($id, array $options = 
array())
   {
     $criteria = new Criteria;
-    self::addrightsRelatedByactIdCriteriaById($criteria, $id);
+    self::addrightssRelatedByactIdCriteriaById($criteria, $id);
 
-    return QubitRight::get($criteria, $options);
+    return QubitRights::get($criteria, $options);
   }
 
-  public function addrightsRelatedByactIdCriteria(Criteria $criteria)
+  public function addrightssRelatedByactIdCriteria(Criteria $criteria)
   {
-    return self::addrightsRelatedByactIdCriteriaById($criteria, $this->id);
+    return self::addrightssRelatedByactIdCriteriaById($criteria, $this->id);
   }
 
   public static function addstatussRelatedBytypeIdCriteriaById(Criteria 
$criteria, $id)

Modified: trunk/plugins/qtAccessionPlugin/config/schema.yml
==============================================================================
--- trunk/plugins/qtAccessionPlugin/config/schema.yml   Fri Jul 22 10:47:56 
2011        (r9347)
+++ trunk/plugins/qtAccessionPlugin/config/schema.yml   Fri Jul 22 13:06:46 
2011        (r9348)
@@ -3,12 +3,12 @@
 
   accession:
     id: { type: integer, required: true, primaryKey: true, foreignTable: 
object, foreignReference: id, onDelete: cascade, inheritanceKey: true }
-    acquisition_type_id: { type: integer, foreignTable: term, 
foreignReference: id }
+    acquisition_type_id: { type: integer, foreignTable: term, 
foreignReference: id, onDelete: setnull }
     date: bu_date
     identifier: { type: varchar(255), index: unique }
-    processing_priority_id: { type: integer, foreignTable: term, 
foreignReference: id }
-    processing_status_id: { type: integer, foreignTable: term, 
foreignReference: id }
-    resource_type_id: { type: integer, foreignTable: term, foreignReference: 
id }
+    processing_priority_id: { type: integer, foreignTable: term, 
foreignReference: id, onDelete: setnull }
+    processing_status_id: { type: integer, foreignTable: term, 
foreignReference: id, onDelete: setnull }
+    resource_type_id: { type: integer, foreignTable: term, foreignReference: 
id, onDelete: setnull }
     created_at:
     updated_at:
 
@@ -27,7 +27,7 @@
     accession_id: { type: integer, foreignTable: accession, foreignReference: 
id, onDelete: cascade }
     date: bu_date
     identifier: varchar(255)
-    scope_id: { type: integer, foreignTable: term, foreignReference: id }
+    scope_id: { type: integer, foreignTable: term, foreignReference: id, 
onDelete: setnull }
     created_at:
     updated_at:
 

-- 
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.

Reply via email to