Author: david
Date: Fri Jun 24 08:55:41 2011
New Revision: 9170

Log:
Add date and description i18n fields for relation

Added:
   trunk/lib/model/QubitRelationI18n.php   (contents, props changed)
   trunk/lib/model/map/RelationI18nTableMap.php   (contents, props changed)
   trunk/lib/model/om/BaseRelationI18n.php   (contents, props changed)
Modified:
   trunk/config/schema.yml
   trunk/data/sql/lib.model.schema.sql
   trunk/lib/model/map/RelationTableMap.php
   trunk/lib/model/om/BaseRelation.php

Modified: trunk/config/schema.yml
==============================================================================
--- trunk/config/schema.yml     Thu Jun 23 00:02:20 2011        (r9169)
+++ trunk/config/schema.yml     Fri Jun 24 08:55:41 2011        (r9170)
@@ -287,6 +287,10 @@
     start_date: bu_date
     end_date: bu_date
 
+  relation_i18n:
+    description: longvarchar
+    date: varchar(255)
+
   repository:
     id: { type: integer, required: true, primaryKey: true, foreignTable: 
actor, foreignReference: id, onDelete: cascade, inheritanceKey: true }
     identifier: varchar(255)

Modified: trunk/data/sql/lib.model.schema.sql
==============================================================================
--- trunk/data/sql/lib.model.schema.sql Thu Jun 23 00:02:20 2011        (r9169)
+++ trunk/data/sql/lib.model.schema.sql Fri Jun 24 08:55:41 2011        (r9170)
@@ -960,6 +960,7 @@
        `type_id` INTEGER,
        `start_date` DATE,
        `end_date` DATE,
+       `source_culture` VARCHAR(7)  NOT NULL,
        PRIMARY KEY (`id`),
        CONSTRAINT `relation_FK_1`
                FOREIGN KEY (`id`)
@@ -980,6 +981,26 @@
 )Engine=InnoDB;
 
 #-----------------------------------------------------------------------------
+#-- relation_i18n
+#-----------------------------------------------------------------------------
+
+DROP TABLE IF EXISTS `relation_i18n`;
+
+
+CREATE TABLE `relation_i18n`
+(
+       `description` TEXT,
+       `date` VARCHAR(255),
+       `id` INTEGER  NOT NULL,
+       `culture` VARCHAR(7)  NOT NULL,
+       PRIMARY KEY (`id`,`culture`),
+       CONSTRAINT `relation_i18n_FK_1`
+               FOREIGN KEY (`id`)
+               REFERENCES `relation` (`id`)
+               ON DELETE CASCADE
+)Engine=InnoDB;
+
+#-----------------------------------------------------------------------------
 #-- repository
 #-----------------------------------------------------------------------------
 

Added: trunk/lib/model/QubitRelationI18n.php
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/lib/model/QubitRelationI18n.php       Fri Jun 24 08:55:41 2011        
(r9170)
@@ -0,0 +1,17 @@
+<?php
+
+
+/**
+ * Skeleton subclass for representing a row from the 'relation_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 QubitRelationI18n extends BaseRelationI18n {
+
+} // QubitRelationI18n

Added: trunk/lib/model/map/RelationI18nTableMap.php
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/lib/model/map/RelationI18nTableMap.php        Fri Jun 24 08:55:41 
2011        (r9170)
@@ -0,0 +1,54 @@
+<?php
+
+
+/**
+ * This class defines the structure of the 'relation_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 RelationI18nTableMap extends TableMap {
+
+       /**
+        * The (dot-path) name of this class
+        */
+       const CLASS_NAME = 'lib.model.map.RelationI18nTableMap';
+
+       /**
+        * 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('relation_i18n');
+               $this->setPhpName('relationI18n');
+               $this->setClassname('QubitRelationI18n');
+               $this->setPackage('lib.model');
+               $this->setUseIdGenerator(false);
+               // columns
+               $this->addColumn('DESCRIPTION', 'description', 'LONGVARCHAR', 
false, null, null);
+               $this->addColumn('DATE', 'date', 'VARCHAR', false, 255, null);
+               $this->addForeignPrimaryKey('ID', 'id', 'INTEGER' , 'relation', 
'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('relation', 'relation', RelationMap::MANY_TO_ONE, 
array('id' => 'id', ), 'CASCADE', null);
+       } // buildRelations()
+
+} // RelationI18nTableMap

Modified: trunk/lib/model/map/RelationTableMap.php
==============================================================================
--- trunk/lib/model/map/RelationTableMap.php    Thu Jun 23 00:02:20 2011        
(r9169)
+++ trunk/lib/model/map/RelationTableMap.php    Fri Jun 24 08:55:41 2011        
(r9170)
@@ -42,6 +42,7 @@
                $this->addForeignKey('TYPE_ID', 'typeId', 'INTEGER', 'term', 
'ID', false, null, null);
                $this->addColumn('START_DATE', 'startDate', 'DATE', false, 
null, null);
                $this->addColumn('END_DATE', 'endDate', 'DATE', false, null, 
null);
+               $this->addColumn('SOURCE_CULTURE', 'sourceCulture', 'VARCHAR', 
true, 7, null);
                // validators
        } // initialize()
 
@@ -54,6 +55,7 @@
     $this->addRelation('objectRelatedBysubjectId', 'object', 
RelationMap::MANY_TO_ONE, array('subject_id' => 'id', ), null, null);
     $this->addRelation('objectRelatedByobjectId', 'object', 
RelationMap::MANY_TO_ONE, array('object_id' => 'id', ), null, null);
     $this->addRelation('term', 'term', RelationMap::MANY_TO_ONE, 
array('type_id' => 'id', ), null, null);
+    $this->addRelation('relationI18n', 'relationI18n', 
RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null);
        } // buildRelations()
 
 } // RelationTableMap

Modified: trunk/lib/model/om/BaseRelation.php
==============================================================================
--- trunk/lib/model/om/BaseRelation.php Thu Jun 23 00:02:20 2011        (r9169)
+++ trunk/lib/model/om/BaseRelation.php Fri Jun 24 08:55:41 2011        (r9170)
@@ -12,7 +12,8 @@
     OBJECT_ID = 'relation.OBJECT_ID',
     TYPE_ID = 'relation.TYPE_ID',
     START_DATE = 'relation.START_DATE',
-    END_DATE = 'relation.END_DATE';
+    END_DATE = 'relation.END_DATE',
+    SOURCE_CULTURE = 'relation.SOURCE_CULTURE';
 
   public static function addSelectColumns(Criteria $criteria)
   {
@@ -26,6 +27,7 @@
     $criteria->addSelectColumn(QubitRelation::TYPE_ID);
     $criteria->addSelectColumn(QubitRelation::START_DATE);
     $criteria->addSelectColumn(QubitRelation::END_DATE);
+    $criteria->addSelectColumn(QubitRelation::SOURCE_CULTURE);
 
     return $criteria;
   }
@@ -72,6 +74,154 @@
     $this->tables[] = 
Propel::getDatabaseMap(QubitRelation::DATABASE_NAME)->getTable(QubitRelation::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 ('relationI18ns' == $name)
+    {
+      return true;
+    }
+
+    try
+    {
+      if (!$value = 
call_user_func_array(array($this->getCurrentrelationI18n($options), '__isset'), 
$args) && !empty($options['cultureFallback']))
+      {
+        return 
call_user_func_array(array($this->getCurrentrelationI18n(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 ('relationI18ns' == $name)
+    {
+      if (!isset($this->refFkValues['relationI18ns']))
+      {
+        if (!isset($this->id))
+        {
+          $this->refFkValues['relationI18ns'] = QubitQuery::create();
+        }
+        else
+        {
+          $this->refFkValues['relationI18ns'] = 
self::getrelationI18nsById($this->id, array('self' => $this) + $options);
+        }
+      }
+
+      return $this->refFkValues['relationI18ns'];
+    }
+
+    try
+    {
+      if (1 > strlen($value = 
call_user_func_array(array($this->getCurrentrelationI18n($options), '__get'), 
$args)) && !empty($options['cultureFallback']))
+      {
+        return 
call_user_func_array(array($this->getCurrentrelationI18n(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->getCurrentrelationI18n($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->getCurrentrelationI18n($options), 
'__unset'), $args);
+
+    return $this;
+  }
+
+  public function clear()
+  {
+    foreach ($this->relationI18ns as $relationI18n)
+    {
+      $relationI18n->clear();
+    }
+
+    return parent::clear();
+  }
+
+  public function save($connection = null)
+  {
+    parent::save($connection);
+
+    foreach ($this->relationI18ns as $relationI18n)
+    {
+      $relationI18n->id = $this->id;
+
+      $relationI18n->save($connection);
+    }
+
+    return $this;
+  }
+
   public static function addJoinsubjectCriteria(Criteria $criteria)
   {
     $criteria->addJoin(QubitRelation::SUBJECT_ID, QubitObject::ID);
@@ -92,4 +242,45 @@
 
     return $criteria;
   }
+
+  public static function addrelationI18nsCriteriaById(Criteria $criteria, $id)
+  {
+    $criteria->add(QubitRelationI18n::ID, $id);
+
+    return $criteria;
+  }
+
+  public static function getrelationI18nsById($id, array $options = array())
+  {
+    $criteria = new Criteria;
+    self::addrelationI18nsCriteriaById($criteria, $id);
+
+    return QubitRelationI18n::get($criteria, $options);
+  }
+
+  public function addrelationI18nsCriteria(Criteria $criteria)
+  {
+    return self::addrelationI18nsCriteriaById($criteria, $this->id);
+  }
+
+  public function getCurrentrelationI18n(array $options = array())
+  {
+    if (!empty($options['sourceCulture']))
+    {
+      $options['culture'] = $this->sourceCulture;
+    }
+
+    if (!isset($options['culture']))
+    {
+      $options['culture'] = sfPropel::getDefaultCulture();
+    }
+
+    $relationI18ns = $this->relationI18ns->indexBy('culture');
+    if (!isset($relationI18ns[$options['culture']]))
+    {
+      $relationI18ns[$options['culture']] = new QubitRelationI18n;
+    }
+
+    return $relationI18ns[$options['culture']];
+  }
 }

Added: trunk/lib/model/om/BaseRelationI18n.php
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/lib/model/om/BaseRelationI18n.php     Fri Jun 24 08:55:41 2011        
(r9170)
@@ -0,0 +1,551 @@
+<?php
+
+abstract class BaseRelationI18n implements ArrayAccess
+{
+  const
+    DATABASE_NAME = 'propel',
+
+    TABLE_NAME = 'relation_i18n',
+
+    DESCRIPTION = 'relation_i18n.DESCRIPTION',
+    DATE = 'relation_i18n.DATE',
+    ID = 'relation_i18n.ID',
+    CULTURE = 'relation_i18n.CULTURE';
+
+  public static function addSelectColumns(Criteria $criteria)
+  {
+    $criteria->addSelectColumn(QubitRelationI18n::DESCRIPTION);
+    $criteria->addSelectColumn(QubitRelationI18n::DATE);
+    $criteria->addSelectColumn(QubitRelationI18n::ID);
+    $criteria->addSelectColumn(QubitRelationI18n::CULTURE);
+
+    return $criteria;
+  }
+
+  protected static
+    $relationI18ns = array();
+
+  protected
+    $keys = array(),
+    $row = array();
+
+  public static function getFromRow(array $row)
+  {
+    $keys = array();
+    $keys['id'] = $row[2];
+    $keys['culture'] = $row[3];
+
+    $key = serialize($keys);
+    if (!isset(self::$relationI18ns[$key]))
+    {
+      $relationI18n = new QubitRelationI18n;
+
+      $relationI18n->keys = $keys;
+      $relationI18n->row = $row;
+
+      $relationI18n->new = false;
+
+      self::$relationI18ns[$key] = $relationI18n;
+    }
+
+    return self::$relationI18ns[$key];
+  }
+
+  public static function get(Criteria $criteria, array $options = array())
+  {
+    if (!isset($options['connection']))
+    {
+      $options['connection'] = 
Propel::getConnection(QubitRelationI18n::DATABASE_NAME);
+    }
+
+    self::addSelectColumns($criteria);
+
+    return QubitQuery::createFromCriteria($criteria, 'QubitRelationI18n', 
$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(QubitRelationI18n::ID, $id);
+    $criteria->add(QubitRelationI18n::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(QubitRelationI18n::DATABASE_NAME);
+    }
+
+    $affectedRows = 0;
+
+    $affectedRows += BasePeer::doDelete($criteria, $connection);
+
+    return $affectedRows;
+  }
+
+  protected
+    $tables = array();
+
+  public function __construct()
+  {
+    $this->tables[] = 
Propel::getDatabaseMap(QubitRelationI18n::DATABASE_NAME)->getTable(QubitRelationI18n::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(QubitRelationI18n::DATABASE_NAME);
+      }
+
+      $criteria = new Criteria;
+      $criteria->add(QubitRelationI18n::ID, $this->id);
+      $criteria->add(QubitRelationI18n::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(QubitRelationI18n::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(QubitRelationI18n::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(QubitRelationI18n::ID, $this->id);
+    $criteria->add(QubitRelationI18n::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 addJoinrelationCriteria(Criteria $criteria)
+  {
+    $criteria->addJoin(QubitRelationI18n::ID, QubitRelation::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");
+  }
+}

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