Author: david
Date: 2008-11-06 11:13:12 -0800 (Thu, 06 Nov 2008)
New Revision: 1528

Added:
   trunk/qubit/lib/model/QubitPropertyI18n.php
   trunk/qubit/lib/model/map/PropertyI18nMapBuilder.php
   trunk/qubit/lib/model/om/BasePropertyI18n.php
Modified:
   trunk/qubit/config/schema.yml
   trunk/qubit/data/fixtures/sampleData.yml
   trunk/qubit/data/sql/lib.model.schema.sql
   trunk/qubit/lib/model/map/PropertyMapBuilder.php
   trunk/qubit/lib/model/om/BaseProperty.php
Log:
Add q_property_i18n table and update sampleData.yml to write existing property 
values to i18n table.

Modified: trunk/qubit/config/schema.yml
===================================================================
--- trunk/qubit/config/schema.yml       2008-11-06 06:12:13 UTC (rev 1527)
+++ trunk/qubit/config/schema.yml       2008-11-06 19:13:12 UTC (rev 1528)
@@ -53,9 +53,11 @@
     object_id: { type: integer, required: true, foreignTable: object, 
foreignReference: id, onDelete: cascade }
     scope: varchar(255)
     name: varchar(255)
-    value: varchar(255)
     created_at:
     updated_at:
+  
+  property_i18n:
+    value: varchar(255)
 
   relation:
     id: { type: integer, required: true, primaryKey: true, foreignTable: 
object, foreignReference: id, onDelete: cascade, inheritanceKey: true }

Modified: trunk/qubit/data/fixtures/sampleData.yml
===================================================================
--- trunk/qubit/data/fixtures/sampleData.yml    2008-11-06 06:12:13 UTC (rev 
1527)
+++ trunk/qubit/data/fixtures/sampleData.yml    2008-11-06 19:13:12 UTC (rev 
1528)
@@ -3409,153 +3409,175 @@
     object_id: QubitInformationObject_134
     scope: languages
     name: information_object_language
-    value: en
+    source_culture: en
+    value: { en: 'en' }
     created_at: '2008-04-24 09:48:35'
     updated_at: '2008-04-24 09:48:35'
   QubitProperty_2:
     object_id: QubitInformationObject_134
     scope: scripts
     name: information_object_script
-    value: Latn
+    source_culture: en
+    value: { en: 'Latn' }
     created_at: '2008-04-24 09:48:35'
     updated_at: '2008-04-24 09:48:35'
   QubitProperty_3:
     object_id: QubitInformationObject_134
     scope: languages
     name: language_of_information_object_description
-    value: en
+    source_culture: en
+    value: { en: 'en' }
     created_at: '2008-04-24 09:48:35'
     updated_at: '2008-04-24 09:48:35'
   QubitProperty_4:
     object_id: QubitInformationObject_134
     scope: scripts
     name: script_of_information_object_description
-    value: Latn
+    source_culture: en
+    value: { en: 'Latn' }
     created_at: '2008-04-24 09:48:35'
     updated_at: '2008-04-24 09:48:35'
   QubitProperty_5:
     object_id: QubitActor_130
     scope: languages
     name: language_of_actor_description
-    value: en
+    source_culture: en
+    value: { en: 'en' }
     created_at: '2008-04-24 09:50:31'
     updated_at: '2008-04-24 09:50:31'
   QubitProperty_6:
     object_id: QubitActor_130
     scope: scripts
     name: script_of_actor_description
-    value: Latn
+    source_culture: en
+    value: { en: 'Latn' }
     created_at: '2008-04-24 09:50:31'
     updated_at: '2008-04-24 09:50:31'
   QubitProperty_7:
     object_id: QubitInformationObject_135
     scope: languages
     name: information_object_language
-    value: en
+    source_culture: en
+    value: { en: 'en' }
     created_at: '2008-04-24 09:54:36'
     updated_at: '2008-04-24 09:54:36'
   QubitProperty_8:
     object_id: QubitInformationObject_135
     scope: scripts
     name: information_object_script
-    value: Latn
+    source_culture: en
+    value: { en: 'Latn' }
     created_at: '2008-04-24 09:54:36'
     updated_at: '2008-04-24 09:54:36'
   QubitProperty_9:
     object_id: QubitInformationObject_135
     scope: languages
     name: language_of_information_object_description
-    value: en
+    source_culture: en
+    value: { en: 'en' }
     created_at: '2008-04-24 09:56:10'
     updated_at: '2008-04-24 09:56:10'
   QubitProperty_10:
     object_id: QubitInformationObject_135
     scope: scripts
     name: script_of_information_object_description
-    value: Latn
+    source_culture: en
+    value: { en: 'Latn' }
     created_at: '2008-04-24 09:56:10'
     updated_at: '2008-04-24 09:56:10'
   QubitProperty_11:
     object_id: QubitInformationObject_136
     scope: languages
     name: language_of_information_object_description
-    value: en
+    source_culture: en
+    value: { en: 'en' }
     created_at: '2008-04-24 10:00:23'
     updated_at: '2008-04-24 10:00:23'
   QubitProperty_12:
     object_id: QubitInformationObject_136
     scope: scripts
     name: script_of_information_object_description
-    value: Latn
+    source_culture: en
+    value: { en: 'Latn' }
     created_at: '2008-04-24 10:00:23'
     updated_at: '2008-04-24 10:00:23'
   QubitProperty_13:
     object_id: QubitInformationObject_145
     scope: languages
     name: information_object_language
-    value: en
+    source_culture: en
+    value: { en: 'en' }
     created_at: '2008-04-24 10:21:23'
     updated_at: '2008-04-24 10:21:23'
   QubitProperty_14:
     object_id: QubitInformationObject_145
     scope: scripts
     name: information_object_script
-    value: Latn
+    source_culture: en
+    value: { en: 'Latn' }
     created_at: '2008-04-24 10:21:23'
     updated_at: '2008-04-24 10:21:23'
   QubitProperty_15:
     object_id: QubitInformationObject_145
     scope: languages
     name: language_of_information_object_description
-    value: en
+    source_culture: en
+    value: { en: 'en' }
     created_at: '2008-04-24 10:23:02'
     updated_at: '2008-04-24 10:23:02'
   QubitProperty_16:
     object_id: QubitInformationObject_145
     scope: scripts
     name: script_of_information_object_description
-    value: Latn
+    source_culture: en
+    value: { en: 'Latn' }
     created_at: '2008-04-24 10:23:02'
     updated_at: '2008-04-24 10:23:02'
   QubitProperty_17:
     object_id: QubitRepository_129
     scope: languages
     name: language_of_repository_description
-    value: en
+    source_culture: en
+    value: { en: 'en' }
     created_at: '2008-04-24 12:03:04'
     updated_at: '2008-04-24 12:03:04'
   QubitProperty_18:
     object_id: QubitRepository_129
     scope: scripts
     name: script_of_repository_description
-    value: Latn
+    source_culture: en
+    value: { en: 'Latn' }
     created_at: '2008-04-24 12:03:04'
     updated_at: '2008-04-24 12:03:04'
   QubitProperty_19:
     object_id: QubitInformationObject_155
     scope: languages
     name: information_object_language
-    value: en
+    source_culture: en
+    value: { en: 'en' }
     created_at: '2008-04-24 12:06:48'
     updated_at: '2008-04-24 12:06:48'
   QubitProperty_20:
     object_id: QubitInformationObject_155
     scope: scripts
     name: information_object_script
-    value: Latn
+    source_culture: en
+    value: { en: 'Latn' }
     created_at: '2008-04-24 12:06:48'
     updated_at: '2008-04-24 12:06:48'
   QubitProperty_21:
     object_id: QubitInformationObject_155
     scope: languages
     name: language_of_information_object_description
-    value: en
+    source_culture: en
+    value: { en: 'en' }
     created_at: '2008-04-24 12:08:15'
     updated_at: '2008-04-24 12:08:15'
   QubitProperty_22:
     object_id: QubitInformationObject_155
     scope: scripts
     name: script_of_information_object_description
-    value: Latn
+    source_culture: en
+    value: { en: 'Latn' }
     created_at: '2008-04-24 12:08:15'
-    updated_at: '2008-04-24 12:08:15'
+    updated_at: '2008-04-24 12:08:15'
\ No newline at end of file

Modified: trunk/qubit/data/sql/lib.model.schema.sql
===================================================================
--- trunk/qubit/data/sql/lib.model.schema.sql   2008-11-06 06:12:13 UTC (rev 
1527)
+++ trunk/qubit/data/sql/lib.model.schema.sql   2008-11-06 19:13:12 UTC (rev 
1528)
@@ -155,9 +155,9 @@
        `object_id` INTEGER  NOT NULL,
        `scope` VARCHAR(255),
        `name` VARCHAR(255),
-       `value` VARCHAR(255),
        `created_at` DATETIME  NOT NULL,
        `updated_at` DATETIME  NOT NULL,
+       `source_culture` VARCHAR(7)  NOT NULL,
        `id` INTEGER  NOT NULL AUTO_INCREMENT,
        PRIMARY KEY (`id`),
        INDEX `q_property_FI_1` (`object_id`),
@@ -168,6 +168,25 @@
 )Type=InnoDB;
 
 #-----------------------------------------------------------------------------
+#-- q_property_i18n
+#-----------------------------------------------------------------------------
+
+DROP TABLE IF EXISTS `q_property_i18n`;
+
+
+CREATE TABLE `q_property_i18n`
+(
+       `value` VARCHAR(255),
+       `id` INTEGER  NOT NULL,
+       `culture` VARCHAR(7)  NOT NULL,
+       PRIMARY KEY (`id`,`culture`),
+       CONSTRAINT `q_property_i18n_FK_1`
+               FOREIGN KEY (`id`)
+               REFERENCES `q_property` (`id`)
+               ON DELETE CASCADE
+)Type=InnoDB;
+
+#-----------------------------------------------------------------------------
 #-- q_relation
 #-----------------------------------------------------------------------------
 

Added: trunk/qubit/lib/model/QubitPropertyI18n.php
===================================================================
--- trunk/qubit/lib/model/QubitPropertyI18n.php                         (rev 0)
+++ trunk/qubit/lib/model/QubitPropertyI18n.php 2008-11-06 19:13:12 UTC (rev 
1528)
@@ -0,0 +1,12 @@
+<?php
+
+/**
+ * Subclass for representing a row from the 'q_property_i18n' table.
+ *
+ *
+ *
+ * @package lib.model
+ */
+class QubitPropertyI18n extends BasePropertyI18n
+{
+}


Property changes on: trunk/qubit/lib/model/QubitPropertyI18n.php
___________________________________________________________________
Added: svn:keywords
   + Author Id Revision
Added: svn:eol-style
   + native

Added: trunk/qubit/lib/model/map/PropertyI18nMapBuilder.php
===================================================================
--- trunk/qubit/lib/model/map/PropertyI18nMapBuilder.php                        
        (rev 0)
+++ trunk/qubit/lib/model/map/PropertyI18nMapBuilder.php        2008-11-06 
19:13:12 UTC (rev 1528)
@@ -0,0 +1,42 @@
+<?php
+
+
+
+class PropertyI18nMapBuilder {
+
+       
+       const CLASS_NAME = 'lib.model.map.PropertyI18nMapBuilder';
+
+       
+       private $dbMap;
+
+       
+       public function isBuilt()
+       {
+               return ($this->dbMap !== null);
+       }
+
+       
+       public function getDatabaseMap()
+       {
+               return $this->dbMap;
+       }
+
+       
+       public function doBuild()
+       {
+               $this->dbMap = Propel::getDatabaseMap('propel');
+
+               $tMap = $this->dbMap->addTable('q_property_i18n');
+               $tMap->setPhpName('PropertyI18n');
+
+               $tMap->setUseIdGenerator(false);
+
+               $tMap->addColumn('VALUE', 'Value', 'string', 
CreoleTypes::VARCHAR, false, 255);
+
+               $tMap->addForeignPrimaryKey('ID', 'Id', 'int' , 
CreoleTypes::INTEGER, 'q_property', 'ID', true, null);
+
+               $tMap->addPrimaryKey('CULTURE', 'Culture', 'string', 
CreoleTypes::VARCHAR, true, 7);
+
+       } 
+} 
\ No newline at end of file


Property changes on: trunk/qubit/lib/model/map/PropertyI18nMapBuilder.php
___________________________________________________________________
Added: svn:keywords
   + Author Id Revision
Added: svn:eol-style
   + native

Modified: trunk/qubit/lib/model/map/PropertyMapBuilder.php
===================================================================
--- trunk/qubit/lib/model/map/PropertyMapBuilder.php    2008-11-06 06:12:13 UTC 
(rev 1527)
+++ trunk/qubit/lib/model/map/PropertyMapBuilder.php    2008-11-06 19:13:12 UTC 
(rev 1528)
@@ -38,12 +38,12 @@
 
                $tMap->addColumn('NAME', 'Name', 'string', 
CreoleTypes::VARCHAR, false, 255);
 
-               $tMap->addColumn('VALUE', 'Value', 'string', 
CreoleTypes::VARCHAR, false, 255);
-
                $tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', 
CreoleTypes::TIMESTAMP, true, null);
 
                $tMap->addColumn('UPDATED_AT', 'UpdatedAt', 'int', 
CreoleTypes::TIMESTAMP, true, null);
 
+               $tMap->addColumn('SOURCE_CULTURE', 'SourceCulture', 'string', 
CreoleTypes::VARCHAR, true, 7);
+
                $tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, 
true, null);
 
        } 

Modified: trunk/qubit/lib/model/om/BaseProperty.php
===================================================================
--- trunk/qubit/lib/model/om/BaseProperty.php   2008-11-06 06:12:13 UTC (rev 
1527)
+++ trunk/qubit/lib/model/om/BaseProperty.php   2008-11-06 19:13:12 UTC (rev 
1528)
@@ -9,9 +9,9 @@
   const OBJECT_ID = 'q_property.OBJECT_ID';
   const SCOPE = 'q_property.SCOPE';
   const NAME = 'q_property.NAME';
-  const VALUE = 'q_property.VALUE';
   const CREATED_AT = 'q_property.CREATED_AT';
   const UPDATED_AT = 'q_property.UPDATED_AT';
+  const SOURCE_CULTURE = 'q_property.SOURCE_CULTURE';
   const ID = 'q_property.ID';
 
   public static function addSelectColumns(Criteria $criteria)
@@ -19,9 +19,9 @@
     $criteria->addSelectColumn(QubitProperty::OBJECT_ID);
     $criteria->addSelectColumn(QubitProperty::SCOPE);
     $criteria->addSelectColumn(QubitProperty::NAME);
-    $criteria->addSelectColumn(QubitProperty::VALUE);
     $criteria->addSelectColumn(QubitProperty::CREATED_AT);
     $criteria->addSelectColumn(QubitProperty::UPDATED_AT);
+    $criteria->addSelectColumn(QubitProperty::SOURCE_CULTURE);
     $criteria->addSelectColumn(QubitProperty::ID);
 
     return $criteria;
@@ -130,20 +130,6 @@
     return $this;
   }
 
-  protected $value = null;
-
-  public function getValue()
-  {
-    return $this->value;
-  }
-
-  public function setValue($value)
-  {
-    $this->value = $value;
-
-    return $this;
-  }
-
   protected $createdAt = null;
 
   public function getCreatedAt(array $options = array())
@@ -194,6 +180,20 @@
     return $this;
   }
 
+  protected $sourceCulture = null;
+
+  public function getSourceCulture()
+  {
+    return $this->sourceCulture;
+  }
+
+  public function setSourceCulture($sourceCulture)
+  {
+    $this->sourceCulture = $sourceCulture;
+
+    return $this;
+  }
+
   protected $id = null;
 
   public function getId()
@@ -224,9 +224,9 @@
     $this->columnValues['objectId'] = $this->objectId;
     $this->columnValues['scope'] = $this->scope;
     $this->columnValues['name'] = $this->name;
-    $this->columnValues['value'] = $this->value;
     $this->columnValues['createdAt'] = $this->createdAt;
     $this->columnValues['updatedAt'] = $this->updatedAt;
+    $this->columnValues['sourceCulture'] = $this->sourceCulture;
     $this->columnValues['id'] = $this->id;
 
     return $this;
@@ -237,9 +237,9 @@
     $this->objectId = $results->getInt($columnOffset++);
     $this->scope = $results->getString($columnOffset++);
     $this->name = $results->getString($columnOffset++);
-    $this->value = $results->getString($columnOffset++);
     $this->createdAt = $results->getTimestamp($columnOffset++, null);
     $this->updatedAt = $results->getTimestamp($columnOffset++, null);
+    $this->sourceCulture = $results->getString($columnOffset++);
     $this->id = $results->getInt($columnOffset++);
 
     $this->new = false;
@@ -287,6 +287,13 @@
     $this->new = false;
     $this->resetModified();
 
+    foreach ($this->propertyI18ns as $propertyI18n)
+    {
+      $propertyI18n->setId($this->id);
+
+      $affectedRows += $propertyI18n->save($connection);
+    }
+
     return $affectedRows;
   }
 
@@ -311,11 +318,6 @@
       $criteria->add(QubitProperty::NAME, $this->name);
     }
 
-    if ($this->isColumnModified('value'))
-    {
-      $criteria->add(QubitProperty::VALUE, $this->value);
-    }
-
     if (!$this->isColumnModified('createdAt'))
     {
       $this->createdAt = time();
@@ -328,6 +330,12 @@
     }
     $criteria->add(QubitProperty::UPDATED_AT, $this->updatedAt);
 
+    if (!$this->isColumnModified('sourceCulture'))
+    {
+      $this->sourceCulture = sfPropel::getDefaultCulture();
+    }
+    $criteria->add(QubitProperty::SOURCE_CULTURE, $this->sourceCulture);
+
     if ($this->isColumnModified('id'))
     {
       $criteria->add(QubitProperty::ID, $this->id);
@@ -366,11 +374,6 @@
       $criteria->add(QubitProperty::NAME, $this->name);
     }
 
-    if ($this->isColumnModified('value'))
-    {
-      $criteria->add(QubitProperty::VALUE, $this->value);
-    }
-
     if ($this->isColumnModified('createdAt'))
     {
       $criteria->add(QubitProperty::CREATED_AT, $this->createdAt);
@@ -382,6 +385,11 @@
     }
     $criteria->add(QubitProperty::UPDATED_AT, $this->updatedAt);
 
+    if ($this->isColumnModified('sourceCulture'))
+    {
+      $criteria->add(QubitProperty::SOURCE_CULTURE, $this->sourceCulture);
+    }
+
     if ($this->isColumnModified('id'))
     {
       $criteria->add(QubitProperty::ID, $this->id);
@@ -452,6 +460,88 @@
 
     return $this;
   }
+
+  public static function addPropertyI18nsCriteriaById(Criteria $criteria, $id)
+  {
+    $criteria->add(QubitPropertyI18n::ID, $id);
+
+    return $criteria;
+  }
+
+  public static function getPropertyI18nsById($id, array $options = array())
+  {
+    $criteria = new Criteria;
+    self::addPropertyI18nsCriteriaById($criteria, $id);
+
+    return QubitPropertyI18n::get($criteria, $options);
+  }
+
+  public function addPropertyI18nsCriteria(Criteria $criteria)
+  {
+    return self::addPropertyI18nsCriteriaById($criteria, $this->id);
+  }
+
+  protected $propertyI18ns = null;
+
+  public function getPropertyI18ns(array $options = array())
+  {
+    if (!isset($this->propertyI18ns))
+    {
+      if (!isset($this->id))
+      {
+        $this->propertyI18ns = QubitQuery::create();
+      }
+      else
+      {
+        $this->propertyI18ns = self::getPropertyI18nsById($this->id, 
array('self' => $this) + $options);
+      }
+    }
+
+    return $this->propertyI18ns;
+  }
+
+  public function getValue(array $options = array())
+  {
+    $value = $this->getCurrentPropertyI18n($options)->getValue();
+    if (!empty($options['cultureFallback']) && strlen($value) < 1)
+    {
+      $value = $this->getCurrentPropertyI18n(array('sourceCulture' => true) + 
$options)->getValue();
+    }
+
+    return $value;
+  }
+
+  public function setValue($value, array $options = array())
+  {
+    $this->getCurrentPropertyI18n($options)->setValue($value);
+
+    return $this;
+  }
+
+  public function getCurrentPropertyI18n(array $options = array())
+  {
+    if (!empty($options['sourceCulture']))
+    {
+      $options['culture'] = $this->sourceCulture;
+    }
+
+    if (!isset($options['culture']))
+    {
+      $options['culture'] = sfPropel::getDefaultCulture();
+    }
+
+    if (!isset($this->propertyI18ns[$options['culture']]))
+    {
+      if (null === $propertyI18n = 
QubitPropertyI18n::getByIdAndCulture($this->id, $options['culture'], $options))
+      {
+        $propertyI18n = new QubitPropertyI18n;
+        $propertyI18n->setCulture($options['culture']);
+      }
+      $this->propertyI18ns[$options['culture']] = $propertyI18n;
+    }
+
+    return $this->propertyI18ns[$options['culture']];
+  }
 }
 
 BasePeer::getMapBuilder('lib.model.map.PropertyMapBuilder');

Added: trunk/qubit/lib/model/om/BasePropertyI18n.php
===================================================================
--- trunk/qubit/lib/model/om/BasePropertyI18n.php                               
(rev 0)
+++ trunk/qubit/lib/model/om/BasePropertyI18n.php       2008-11-06 19:13:12 UTC 
(rev 1528)
@@ -0,0 +1,333 @@
+<?php
+
+abstract class BasePropertyI18n
+{
+  const DATABASE_NAME = 'propel';
+
+  const TABLE_NAME = 'q_property_i18n';
+
+  const VALUE = 'q_property_i18n.VALUE';
+  const ID = 'q_property_i18n.ID';
+  const CULTURE = 'q_property_i18n.CULTURE';
+
+  public static function addSelectColumns(Criteria $criteria)
+  {
+    $criteria->addSelectColumn(QubitPropertyI18n::VALUE);
+    $criteria->addSelectColumn(QubitPropertyI18n::ID);
+    $criteria->addSelectColumn(QubitPropertyI18n::CULTURE);
+
+    return $criteria;
+  }
+
+  protected static $propertyI18ns = array();
+
+  public static function getFromResultSet(ResultSet $resultSet)
+  {
+    if (!isset(self::$propertyI18ns[$key = 
serialize(array($resultSet->getInt(2), $resultSet->getString(3)))]))
+    {
+      $propertyI18n = new QubitPropertyI18n;
+      $propertyI18n->hydrate($resultSet);
+
+      self::$propertyI18ns[$key] = $propertyI18n;
+    }
+
+    return self::$propertyI18ns[$key];
+  }
+
+  public static function get(Criteria $criteria, array $options = array())
+  {
+    if (!isset($options['connection']))
+    {
+      $options['connection'] = 
Propel::getConnection(QubitPropertyI18n::DATABASE_NAME);
+    }
+
+    self::addSelectColumns($criteria);
+
+    return QubitQuery::createFromCriteria($criteria, 'QubitPropertyI18n', 
$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)->offsetGet(0, array('defaultValue' 
=> null));
+  }
+
+  public static function getByIdAndCulture($id, $culture, array $options = 
array())
+  {
+    $criteria = new Criteria;
+    $criteria->add(QubitPropertyI18n::ID, $id);
+    $criteria->add(QubitPropertyI18n::CULTURE, $culture);
+
+    return self::get($criteria, $options)->offsetGet(0, array('defaultValue' 
=> null));
+  }
+
+  public static function doDelete(Criteria $criteria, $connection = null)
+  {
+    if (!isset($connection))
+    {
+      $connection = 
QubitTransactionFilter::getConnection(QubitPropertyI18n::DATABASE_NAME);
+    }
+
+    $affectedRows = 0;
+
+    $affectedRows += BasePeer::doDelete($criteria, $connection);
+
+    return $affectedRows;
+  }
+
+  protected $value = null;
+
+  public function getValue()
+  {
+    return $this->value;
+  }
+
+  public function setValue($value)
+  {
+    $this->value = $value;
+
+    return $this;
+  }
+
+  protected $id = null;
+
+  public function getId()
+  {
+    return $this->id;
+  }
+
+  public function setId($id)
+  {
+    $this->id = $id;
+
+    return $this;
+  }
+
+  protected $culture = null;
+
+  public function getCulture()
+  {
+    return $this->culture;
+  }
+
+  public function setCulture($culture)
+  {
+    $this->culture = $culture;
+
+    return $this;
+  }
+
+  protected $new = true;
+
+  protected $deleted = false;
+
+  protected $columnValues = null;
+
+  protected function isColumnModified($name)
+  {
+    return $this->$name != $this->columnValues[$name];
+  }
+
+  protected function resetModified()
+  {
+    $this->columnValues['value'] = $this->value;
+    $this->columnValues['id'] = $this->id;
+    $this->columnValues['culture'] = $this->culture;
+
+    return $this;
+  }
+
+  public function hydrate(ResultSet $results, $columnOffset = 1)
+  {
+    $this->value = $results->getString($columnOffset++);
+    $this->id = $results->getInt($columnOffset++);
+    $this->culture = $results->getString($columnOffset++);
+
+    $this->new = false;
+    $this->resetModified();
+
+    return $columnOffset;
+  }
+
+  public function refresh(array $options = array())
+  {
+    if (!isset($options['connection']))
+    {
+      $options['connection'] = 
Propel::getConnection(QubitPropertyI18n::DATABASE_NAME);
+    }
+
+    $criteria = new Criteria;
+    $criteria->add(QubitPropertyI18n::ID, $this->id);
+    $criteria->add(QubitPropertyI18n::CULTURE, $this->culture);
+
+    self::addSelectColumns($criteria);
+
+    $resultSet = BasePeer::doSelect($criteria, $options['connection']);
+    $resultSet->next();
+
+    return $this->hydrate($resultSet);
+  }
+
+  public function save($connection = null)
+  {
+    if ($this->deleted)
+    {
+      throw new PropelException('You cannot save an object that has been 
deleted.');
+    }
+
+    $affectedRows = 0;
+
+    if ($this->new)
+    {
+      $affectedRows += $this->insert($connection);
+    }
+    else
+    {
+      $affectedRows += $this->update($connection);
+    }
+
+    $this->new = false;
+    $this->resetModified();
+
+    return $affectedRows;
+  }
+
+  protected function insert($connection = null)
+  {
+    $affectedRows = 0;
+
+    $criteria = new Criteria;
+
+    if ($this->isColumnModified('value'))
+    {
+      $criteria->add(QubitPropertyI18n::VALUE, $this->value);
+    }
+
+    if ($this->isColumnModified('id'))
+    {
+      $criteria->add(QubitPropertyI18n::ID, $this->id);
+    }
+
+    if ($this->isColumnModified('culture'))
+    {
+      $criteria->add(QubitPropertyI18n::CULTURE, $this->culture);
+    }
+
+    if (!isset($connection))
+    {
+      $connection = 
QubitTransactionFilter::getConnection(QubitPropertyI18n::DATABASE_NAME);
+    }
+
+    BasePeer::doInsert($criteria, $connection);
+    $affectedRows += 1;
+
+    return $affectedRows;
+  }
+
+  protected function update($connection = null)
+  {
+    $affectedRows = 0;
+
+    $criteria = new Criteria;
+
+    if ($this->isColumnModified('value'))
+    {
+      $criteria->add(QubitPropertyI18n::VALUE, $this->value);
+    }
+
+    if ($this->isColumnModified('id'))
+    {
+      $criteria->add(QubitPropertyI18n::ID, $this->id);
+    }
+
+    if ($this->isColumnModified('culture'))
+    {
+      $criteria->add(QubitPropertyI18n::CULTURE, $this->culture);
+    }
+
+    if ($criteria->size() > 0)
+    {
+      $selectCriteria = new Criteria;
+      $selectCriteria->add(QubitPropertyI18n::ID, $this->id);
+      $selectCriteria->add(QubitPropertyI18n::CULTURE, $this->culture);
+
+      if (!isset($connection))
+      {
+        $connection = 
QubitTransactionFilter::getConnection(QubitPropertyI18n::DATABASE_NAME);
+      }
+
+      $affectedRows += BasePeer::doUpdate($selectCriteria, $criteria, 
$connection);
+    }
+
+    return $affectedRows;
+  }
+
+  public function delete($connection = null)
+  {
+    if ($this->deleted)
+    {
+      throw new PropelException('This object has already been deleted.');
+    }
+
+    $affectedRows = 0;
+
+    $criteria = new Criteria;
+    $criteria->add(QubitPropertyI18n::ID, $this->id);
+    $criteria->add(QubitPropertyI18n::CULTURE, $this->culture);
+
+    $affectedRows += self::doDelete($criteria, $connection);
+
+    $this->deleted = true;
+
+    return $affectedRows;
+  }
+
+       
+       public function getPrimaryKey()
+       {
+               $pks = array();
+
+               $pks[0] = $this->getId();
+
+               $pks[1] = $this->getCulture();
+
+               return $pks;
+       }
+
+       
+       public function setPrimaryKey($keys)
+       {
+
+               $this->setId($keys[0]);
+
+               $this->setCulture($keys[1]);
+
+       }
+
+  public static function addJoinPropertyCriteria(Criteria $criteria)
+  {
+    $criteria->addJoin(QubitPropertyI18n::ID, QubitProperty::ID);
+
+    return $criteria;
+  }
+
+  public function getProperty(array $options = array())
+  {
+    return $this->property = QubitProperty::getById($this->id, $options);
+  }
+
+  public function setProperty(QubitProperty $property)
+  {
+    $this->id = $property->getId();
+
+    return $this;
+  }
+}
+
+BasePeer::getMapBuilder('lib.model.map.PropertyI18nMapBuilder');


Property changes on: trunk/qubit/lib/model/om/BasePropertyI18n.php
___________________________________________________________________
Added: svn:keywords
   + Author Id Revision
Added: svn:eol-style
   + native


--~--~---------~--~----~------------~-------~--~----~
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.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to