From 5e337a0dbc38a07b5526f8a7f0a57a3f6f380bc8 Mon Sep 17 00:00:00 2001 From: Dante Date: Sun, 20 Dec 2015 13:56:19 -0400 Subject: [PATCH] GI-212-A --- .../model/map/GmailRelabelingMapBuilder.php | 4 +- .../classes/model/om/BaseGmailRelabeling.php | 151 ++++++++++++------ .../model/om/BaseGmailRelabelingPeer.php | 93 ++++++++--- workflow/engine/config/schema.xml | 3 +- workflow/engine/data/mysql/schema.sql | 4 +- 5 files changed, 180 insertions(+), 75 deletions(-) diff --git a/workflow/engine/classes/model/map/GmailRelabelingMapBuilder.php b/workflow/engine/classes/model/map/GmailRelabelingMapBuilder.php index 306ca3d6c..0c49a665c 100644 --- a/workflow/engine/classes/model/map/GmailRelabelingMapBuilder.php +++ b/workflow/engine/classes/model/map/GmailRelabelingMapBuilder.php @@ -65,7 +65,9 @@ class GmailRelabelingMapBuilder $tMap->setUseIdGenerator(false); - $tMap->addColumn('CREATE_DATE', 'CreateDate', 'int', CreoleTypes::TIMESTAMP, false, null); + $tMap->addPrimaryKey('LABELING_UID', 'LabelingUid', 'int', CreoleTypes::INTEGER, true, null); + + $tMap->addColumn('CREATE_DATE', 'CreateDate', 'int', CreoleTypes::TIMESTAMP, true, null); $tMap->addColumn('APP_UID', 'AppUid', 'string', CreoleTypes::VARCHAR, true, 32); diff --git a/workflow/engine/classes/model/om/BaseGmailRelabeling.php b/workflow/engine/classes/model/om/BaseGmailRelabeling.php index d8b5441b5..22ff50b98 100644 --- a/workflow/engine/classes/model/om/BaseGmailRelabeling.php +++ b/workflow/engine/classes/model/om/BaseGmailRelabeling.php @@ -27,6 +27,12 @@ abstract class BaseGmailRelabeling extends BaseObject implements Persistent */ protected static $peer; + /** + * The value for the labeling_uid field. + * @var int + */ + protected $labeling_uid; + /** * The value for the create_date field. * @var int @@ -83,6 +89,17 @@ abstract class BaseGmailRelabeling extends BaseObject implements Persistent */ protected $alreadyInValidation = false; + /** + * Get the [labeling_uid] column value. + * + * @return int + */ + public function getLabelingUid() + { + + return $this->labeling_uid; + } + /** * Get the [optionally formatted] [create_date] column value. * @@ -181,6 +198,28 @@ abstract class BaseGmailRelabeling extends BaseObject implements Persistent return $this->msg_error; } + /** + * Set the value of [labeling_uid] column. + * + * @param int $v new value + * @return void + */ + public function setLabelingUid($v) + { + + // Since the native PHP type for this column is integer, + // we will cast the input value to an int (if it is not). + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->labeling_uid !== $v) { + $this->labeling_uid = $v; + $this->modifiedColumns[] = GmailRelabelingPeer::LABELING_UID; + } + + } // setLabelingUid() + /** * Set the value of [create_date] column. * @@ -359,26 +398,28 @@ abstract class BaseGmailRelabeling extends BaseObject implements Persistent { try { - $this->create_date = $rs->getTimestamp($startcol + 0, null); + $this->labeling_uid = $rs->getInt($startcol + 0); - $this->app_uid = $rs->getString($startcol + 1); + $this->create_date = $rs->getTimestamp($startcol + 1, null); - $this->del_index = $rs->getInt($startcol + 2); + $this->app_uid = $rs->getString($startcol + 2); - $this->current_last_index = $rs->getInt($startcol + 3); + $this->del_index = $rs->getInt($startcol + 3); - $this->unassigned = $rs->getInt($startcol + 4); + $this->current_last_index = $rs->getInt($startcol + 4); - $this->status = $rs->getString($startcol + 5); + $this->unassigned = $rs->getInt($startcol + 5); - $this->msg_error = $rs->getString($startcol + 6); + $this->status = $rs->getString($startcol + 6); + + $this->msg_error = $rs->getString($startcol + 7); $this->resetModified(); $this->setNew(false); // FIXME - using NUM_COLUMNS may be clearer. - return $startcol + 7; // 7 = GmailRelabelingPeer::NUM_COLUMNS - GmailRelabelingPeer::NUM_LAZY_LOAD_COLUMNS). + return $startcol + 8; // 8 = GmailRelabelingPeer::NUM_COLUMNS - GmailRelabelingPeer::NUM_LAZY_LOAD_COLUMNS). } catch (Exception $e) { throw new PropelException("Error populating GmailRelabeling object", $e); @@ -583,24 +624,27 @@ abstract class BaseGmailRelabeling extends BaseObject implements Persistent { switch($pos) { case 0: - return $this->getCreateDate(); + return $this->getLabelingUid(); break; case 1: - return $this->getAppUid(); + return $this->getCreateDate(); break; case 2: - return $this->getDelIndex(); + return $this->getAppUid(); break; case 3: - return $this->getCurrentLastIndex(); + return $this->getDelIndex(); break; case 4: - return $this->getUnassigned(); + return $this->getCurrentLastIndex(); break; case 5: - return $this->getStatus(); + return $this->getUnassigned(); break; case 6: + return $this->getStatus(); + break; + case 7: return $this->getMsgError(); break; default: @@ -623,13 +667,14 @@ abstract class BaseGmailRelabeling extends BaseObject implements Persistent { $keys = GmailRelabelingPeer::getFieldNames($keyType); $result = array( - $keys[0] => $this->getCreateDate(), - $keys[1] => $this->getAppUid(), - $keys[2] => $this->getDelIndex(), - $keys[3] => $this->getCurrentLastIndex(), - $keys[4] => $this->getUnassigned(), - $keys[5] => $this->getStatus(), - $keys[6] => $this->getMsgError(), + $keys[0] => $this->getLabelingUid(), + $keys[1] => $this->getCreateDate(), + $keys[2] => $this->getAppUid(), + $keys[3] => $this->getDelIndex(), + $keys[4] => $this->getCurrentLastIndex(), + $keys[5] => $this->getUnassigned(), + $keys[6] => $this->getStatus(), + $keys[7] => $this->getMsgError(), ); return $result; } @@ -662,24 +707,27 @@ abstract class BaseGmailRelabeling extends BaseObject implements Persistent { switch($pos) { case 0: - $this->setCreateDate($value); + $this->setLabelingUid($value); break; case 1: - $this->setAppUid($value); + $this->setCreateDate($value); break; case 2: - $this->setDelIndex($value); + $this->setAppUid($value); break; case 3: - $this->setCurrentLastIndex($value); + $this->setDelIndex($value); break; case 4: - $this->setUnassigned($value); + $this->setCurrentLastIndex($value); break; case 5: - $this->setStatus($value); + $this->setUnassigned($value); break; case 6: + $this->setStatus($value); + break; + case 7: $this->setMsgError($value); break; } // switch() @@ -706,31 +754,35 @@ abstract class BaseGmailRelabeling extends BaseObject implements Persistent $keys = GmailRelabelingPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { - $this->setCreateDate($arr[$keys[0]]); + $this->setLabelingUid($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { - $this->setAppUid($arr[$keys[1]]); + $this->setCreateDate($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { - $this->setDelIndex($arr[$keys[2]]); + $this->setAppUid($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { - $this->setCurrentLastIndex($arr[$keys[3]]); + $this->setDelIndex($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { - $this->setUnassigned($arr[$keys[4]]); + $this->setCurrentLastIndex($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { - $this->setStatus($arr[$keys[5]]); + $this->setUnassigned($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { - $this->setMsgError($arr[$keys[6]]); + $this->setStatus($arr[$keys[6]]); + } + + if (array_key_exists($keys[7], $arr)) { + $this->setMsgError($arr[$keys[7]]); } } @@ -744,6 +796,10 @@ abstract class BaseGmailRelabeling extends BaseObject implements Persistent { $criteria = new Criteria(GmailRelabelingPeer::DATABASE_NAME); + if ($this->isColumnModified(GmailRelabelingPeer::LABELING_UID)) { + $criteria->add(GmailRelabelingPeer::LABELING_UID, $this->labeling_uid); + } + if ($this->isColumnModified(GmailRelabelingPeer::CREATE_DATE)) { $criteria->add(GmailRelabelingPeer::CREATE_DATE, $this->create_date); } @@ -788,33 +844,30 @@ abstract class BaseGmailRelabeling extends BaseObject implements Persistent { $criteria = new Criteria(GmailRelabelingPeer::DATABASE_NAME); + $criteria->add(GmailRelabelingPeer::LABELING_UID, $this->labeling_uid); return $criteria; } /** - * Returns NULL since this table doesn't have a primary key. - * This method exists only for BC and is deprecated! - * @return null + * Returns the primary key for this object (row). + * @return int */ public function getPrimaryKey() { - return null; + return $this->getLabelingUid(); } /** - * Dummy primary key setter. + * Generic method to set the primary key (labeling_uid column). * - * This function only exists to preserve backwards compatibility. It is no longer - * needed or required by the Persistent interface. It will be removed in next BC-breaking - * release of Propel. - * - * @deprecated + * @param int $key Primary key. + * @return void */ - public function setPrimaryKey($pk) - { - // do nothing, because this object doesn't have any primary keys - } + public function setPrimaryKey($key) + { + $this->setLabelingUid($key); + } /** * Sets contents of passed object to values from current object. @@ -846,6 +899,8 @@ abstract class BaseGmailRelabeling extends BaseObject implements Persistent $copyObj->setNew(true); + $copyObj->setLabelingUid(NULL); // this is a pkey column, so set to default value + } /** diff --git a/workflow/engine/classes/model/om/BaseGmailRelabelingPeer.php b/workflow/engine/classes/model/om/BaseGmailRelabelingPeer.php index e095b1b08..ee23b25a1 100644 --- a/workflow/engine/classes/model/om/BaseGmailRelabelingPeer.php +++ b/workflow/engine/classes/model/om/BaseGmailRelabelingPeer.php @@ -25,12 +25,15 @@ abstract class BaseGmailRelabelingPeer const CLASS_DEFAULT = 'classes.model.GmailRelabeling'; /** The total number of columns. */ - const NUM_COLUMNS = 7; + const NUM_COLUMNS = 8; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; + /** the column name for the LABELING_UID field */ + const LABELING_UID = 'GMAIL_RELABELING.LABELING_UID'; + /** the column name for the CREATE_DATE field */ const CREATE_DATE = 'GMAIL_RELABELING.CREATE_DATE'; @@ -63,10 +66,10 @@ abstract class BaseGmailRelabelingPeer * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ private static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('CreateDate', 'AppUid', 'DelIndex', 'CurrentLastIndex', 'Unassigned', 'Status', 'MsgError', ), - BasePeer::TYPE_COLNAME => array (GmailRelabelingPeer::CREATE_DATE, GmailRelabelingPeer::APP_UID, GmailRelabelingPeer::DEL_INDEX, GmailRelabelingPeer::CURRENT_LAST_INDEX, GmailRelabelingPeer::UNASSIGNED, GmailRelabelingPeer::STATUS, GmailRelabelingPeer::MSG_ERROR, ), - BasePeer::TYPE_FIELDNAME => array ('CREATE_DATE', 'APP_UID', 'DEL_INDEX', 'CURRENT_LAST_INDEX', 'UNASSIGNED', 'STATUS', 'MSG_ERROR', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) + BasePeer::TYPE_PHPNAME => array ('LabelingUid', 'CreateDate', 'AppUid', 'DelIndex', 'CurrentLastIndex', 'Unassigned', 'Status', 'MsgError', ), + BasePeer::TYPE_COLNAME => array (GmailRelabelingPeer::LABELING_UID, GmailRelabelingPeer::CREATE_DATE, GmailRelabelingPeer::APP_UID, GmailRelabelingPeer::DEL_INDEX, GmailRelabelingPeer::CURRENT_LAST_INDEX, GmailRelabelingPeer::UNASSIGNED, GmailRelabelingPeer::STATUS, GmailRelabelingPeer::MSG_ERROR, ), + BasePeer::TYPE_FIELDNAME => array ('LABELING_UID', 'CREATE_DATE', 'APP_UID', 'DEL_INDEX', 'CURRENT_LAST_INDEX', 'UNASSIGNED', 'STATUS', 'MSG_ERROR', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) ); /** @@ -76,10 +79,10 @@ abstract class BaseGmailRelabelingPeer * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ private static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('CreateDate' => 0, 'AppUid' => 1, 'DelIndex' => 2, 'CurrentLastIndex' => 3, 'Unassigned' => 4, 'Status' => 5, 'MsgError' => 6, ), - BasePeer::TYPE_COLNAME => array (GmailRelabelingPeer::CREATE_DATE => 0, GmailRelabelingPeer::APP_UID => 1, GmailRelabelingPeer::DEL_INDEX => 2, GmailRelabelingPeer::CURRENT_LAST_INDEX => 3, GmailRelabelingPeer::UNASSIGNED => 4, GmailRelabelingPeer::STATUS => 5, GmailRelabelingPeer::MSG_ERROR => 6, ), - BasePeer::TYPE_FIELDNAME => array ('CREATE_DATE' => 0, 'APP_UID' => 1, 'DEL_INDEX' => 2, 'CURRENT_LAST_INDEX' => 3, 'UNASSIGNED' => 4, 'STATUS' => 5, 'MSG_ERROR' => 6, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) + BasePeer::TYPE_PHPNAME => array ('LabelingUid' => 0, 'CreateDate' => 1, 'AppUid' => 2, 'DelIndex' => 3, 'CurrentLastIndex' => 4, 'Unassigned' => 5, 'Status' => 6, 'MsgError' => 7, ), + BasePeer::TYPE_COLNAME => array (GmailRelabelingPeer::LABELING_UID => 0, GmailRelabelingPeer::CREATE_DATE => 1, GmailRelabelingPeer::APP_UID => 2, GmailRelabelingPeer::DEL_INDEX => 3, GmailRelabelingPeer::CURRENT_LAST_INDEX => 4, GmailRelabelingPeer::UNASSIGNED => 5, GmailRelabelingPeer::STATUS => 6, GmailRelabelingPeer::MSG_ERROR => 7, ), + BasePeer::TYPE_FIELDNAME => array ('LABELING_UID' => 0, 'CREATE_DATE' => 1, 'APP_UID' => 2, 'DEL_INDEX' => 3, 'CURRENT_LAST_INDEX' => 4, 'UNASSIGNED' => 5, 'STATUS' => 6, 'MSG_ERROR' => 7, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) ); /** @@ -180,6 +183,8 @@ abstract class BaseGmailRelabelingPeer public static function addSelectColumns(Criteria $criteria) { + $criteria->addSelectColumn(GmailRelabelingPeer::LABELING_UID); + $criteria->addSelectColumn(GmailRelabelingPeer::CREATE_DATE); $criteria->addSelectColumn(GmailRelabelingPeer::APP_UID); @@ -196,8 +201,8 @@ abstract class BaseGmailRelabelingPeer } - const COUNT = 'COUNT(*)'; - const COUNT_DISTINCT = 'COUNT(DISTINCT *)'; + const COUNT = 'COUNT(GMAIL_RELABELING.LABELING_UID)'; + const COUNT_DISTINCT = 'COUNT(DISTINCT GMAIL_RELABELING.LABELING_UID)'; /** * Returns the number of rows matching criteria. @@ -406,6 +411,9 @@ abstract class BaseGmailRelabelingPeer if ($values instanceof Criteria) { $criteria = clone $values; // rename for clarity + $comparison = $criteria->getComparison(GmailRelabelingPeer::LABELING_UID); + $selectCriteria->add(GmailRelabelingPeer::LABELING_UID, $criteria->remove(GmailRelabelingPeer::LABELING_UID), $comparison); + } else { $criteria = $values->buildCriteria(); // gets full criteria $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) @@ -463,22 +471,11 @@ abstract class BaseGmailRelabelingPeer $criteria = clone $values; // rename for clarity } elseif ($values instanceof GmailRelabeling) { - $criteria = $values->buildCriteria(); + $criteria = $values->buildPkeyCriteria(); } else { // it must be the primary key $criteria = new Criteria(self::DATABASE_NAME); - // primary key is composite; we therefore, expect - // the primary key passed to be an array of pkey - // values - if (count($values) == count($values, COUNT_RECURSIVE)) { - // array is not multi-dimensional - $values = array($values); - } - $vals = array(); - foreach ($values as $value) { - - } - + $criteria->add(GmailRelabelingPeer::LABELING_UID, (array) $values, Criteria::IN); } // Set the correct dbName @@ -536,6 +533,54 @@ abstract class BaseGmailRelabelingPeer return BasePeer::doValidate(GmailRelabelingPeer::DATABASE_NAME, GmailRelabelingPeer::TABLE_NAME, $columns); } + + /** + * Retrieve a single object by pkey. + * + * @param mixed $pk the primary key. + * @param Connection $con the connection to use + * @return GmailRelabeling + */ + public static function retrieveByPK($pk, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $criteria = new Criteria(GmailRelabelingPeer::DATABASE_NAME); + + $criteria->add(GmailRelabelingPeer::LABELING_UID, $pk); + + + $v = GmailRelabelingPeer::doSelect($criteria, $con); + + return !empty($v) > 0 ? $v[0] : null; + } + + /** + * Retrieve multiple objects by pkey. + * + * @param array $pks List of primary keys + * @param Connection $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function retrieveByPKs($pks, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(); + $criteria->add(GmailRelabelingPeer::LABELING_UID, $pks, Criteria::IN); + $objs = GmailRelabelingPeer::doSelect($criteria, $con); + } + return $objs; + } } diff --git a/workflow/engine/config/schema.xml b/workflow/engine/config/schema.xml index cb5ce52cc..ec3cb1160 100755 --- a/workflow/engine/config/schema.xml +++ b/workflow/engine/config/schema.xml @@ -5261,7 +5261,8 @@ - + + diff --git a/workflow/engine/data/mysql/schema.sql b/workflow/engine/data/mysql/schema.sql index d80c0b358..bdc4a09f3 100755 --- a/workflow/engine/data/mysql/schema.sql +++ b/workflow/engine/data/mysql/schema.sql @@ -2938,13 +2938,15 @@ CREATE TABLE `NOTIFICATION_DEVICE` #----------------------------------------------------------------------------- CREATE TABLE `GMAIL_RELABELING` ( - `CREATE_DATE` DATETIME NOT NULL DEFAULT '', + `LABELING_ID` INTEGER NOT NULL AUTO_INCREMENT, + `CREATE_DATE` DATETIME NOT NULL DEFAULT '', `APP_UID` VARCHAR(32) NOT NULL DEFAULT '', `DEL_INDEX` INT(11) NOT NULL DEFAULT '0', `CURRENT_LAST_INDEX` INT(11) NOT NULL DEFAULT '0', `UNASSIGNED` INT(11) NOT NULL DEFAULT '0', `STATUS` VARCHAR(32) NOT NULL DEFAULT 'pending', `MSG_ERROR` TEXT NULL, + PRIMARY KEY (`LABELING_ID`), KEY `indexStatus` (`STATUS`) )ENGINE=InnoDB DEFAULT CHARSET='utf8' COMMENT='Task to synchronize Gmail Labels'; # This restores the fkey checks, after having unset them earlier