diff --git a/features/backend/projects/case_scheduler/main_tests_case_scheduler.feature b/features/backend/projects/case_scheduler/main_tests_case_scheduler.feature index 6ff008da0..bee8dfa2b 100644 --- a/features/backend/projects/case_scheduler/main_tests_case_scheduler.feature +++ b/features/backend/projects/case_scheduler/main_tests_case_scheduler.feature @@ -20,7 +20,7 @@ Scenario Outline: Get the case schedulers list when there are exactly case sched | test_description | project | record | | Get case scheduler of process Test Michelangelo | 1265557095225ff5c688f46031700471 | 0 | - | Get case scheduler of process Process Complete BPMN | 1455892245368ebeb11c1a5001393784 | 2 | + | Get case scheduler of process Process Complete BPMN | 1455892245368ebeb11c1a5001393784 | 1 | Scenario Outline: Create any case scheduler for a project @@ -110,7 +110,7 @@ Scenario: Create a new case scheduler with same name And the response status message should have the following text "Duplicate" -Scenario Outline: Get the case schedulers list when there are exactly 16 after 18 case schedulers in each process +Scenario Outline: Get the case schedulers list when there are exactly 16 after 17 case schedulers in each process Given I request "project//case-schedulers" Then the response status code should be 200 And the response charset is "UTF-8" @@ -122,7 +122,7 @@ Scenario Outline: Get the case schedulers list when there are exactly 16 after 1 | test_description | project | record | | Get case scheduler of process Test Michelangelo | 1265557095225ff5c688f46031700471 | 16 | - | Get case scheduler of process Process Complete BPMN | 1455892245368ebeb11c1a5001393784 | 18 | + | Get case scheduler of process Process Complete BPMN | 1455892245368ebeb11c1a5001393784 | 17 | Scenario Outline: Update the case schedulers for a project and then check if the values had changed diff --git a/features/backend/projects/project_export_import/main_tests_project_export_import.feature b/features/backend/projects/project_export_import/main_tests_project_export_import.feature index 374cf5678..af0f471f3 100644 --- a/features/backend/projects/project_export_import/main_tests_project_export_import.feature +++ b/features/backend/projects/project_export_import/main_tests_project_export_import.feature @@ -152,7 +152,7 @@ Scenario: Delete a Project created previously in this script Scenario Outline: Import a process Given POST upload a project file "" to "project/import?option=&option_group=merge" - Then the response status code should be 200 + Then the response status code should be 201 And the response charset is "UTF-8" And the content type is "application/json" And the type is "object" @@ -426,7 +426,7 @@ Scenario: Get a list of projects Scenario Outline: Import a process Given POST upload a project file "" to "project/import?option=" - Then the response status code should be 200 + Then the response status code should be 201 And the response charset is "UTF-8" And the content type is "application/json" And the type is "object" @@ -455,7 +455,7 @@ Scenario: Delete a Project created previously in this script "Export process emp Scenario: Import a process "Export process empty" Given POST upload a project file "Export_process_empty.pmx" to "project/import?option=create" - Then the response status code should be 200 + Then the response status code should be 201 And the response charset is "UTF-8" And the content type is "application/json" And the type is "object" diff --git a/gulliver/thirdparty/phing/system/io/FileSystem.php b/gulliver/thirdparty/phing/system/io/FileSystem.php index 71133779f..af6fb0abe 100755 --- a/gulliver/thirdparty/phing/system/io/FileSystem.php +++ b/gulliver/thirdparty/phing/system/io/FileSystem.php @@ -149,7 +149,7 @@ abstract class FileSystem { * by the given abstract pathname, or zero if it does not exist or some * other I/O error occurs. */ - function getBooleanAttributes($f) { + function getBooleanAttributes(&$f = null) { throw new Exception("SYSTEM ERROR method getBooleanAttributes() not implemented by fs driver"); } diff --git a/gulliver/thirdparty/phing/system/io/UnixFileSystem.php b/gulliver/thirdparty/phing/system/io/UnixFileSystem.php index 449b4e6eb..85f467d0e 100755 --- a/gulliver/thirdparty/phing/system/io/UnixFileSystem.php +++ b/gulliver/thirdparty/phing/system/io/UnixFileSystem.php @@ -191,7 +191,7 @@ class UnixFileSystem extends FileSystem { /* -- most of the following is mapped to the php natives wrapped by FileSystem */ /* -- Attribute accessors -- */ - function getBooleanAttributes(&$f) { + function getBooleanAttributes(&$f = null) { //$rv = getBooleanAttributes0($f); $name = $f->getName(); $hidden = (strlen($name) > 0) && ($name{0} == '.'); diff --git a/workflow/engine/classes/class.case.php b/workflow/engine/classes/class.case.php index 004b44c38..17dcab0ff 100755 --- a/workflow/engine/classes/class.case.php +++ b/workflow/engine/classes/class.case.php @@ -986,11 +986,13 @@ class Cases unset($Fields['APP_DESCRIPTION']); } if (isset($Fields["APP_STATUS"]) && $Fields["APP_STATUS"] == "COMPLETED") { - $Fields['USR_UID'] = $Fields['CURRENT_USER_UID']; - $listCompleted = new ListCompleted(); - $listCompleted->create($Fields); - $listMyInbox = new ListMyInbox(); - $listMyInbox->refresh($Fields); + if (isset($Fields['CURRENT_USER_UID'])) { + $Fields['USR_UID'] = $Fields['CURRENT_USER_UID']; + $listCompleted = new ListCompleted(); + $listCompleted->create($Fields); + $listMyInbox = new ListMyInbox(); + $listMyInbox->refresh($Fields); + } } $oApp->update($Fields); diff --git a/workflow/engine/classes/class.dbConnections.php b/workflow/engine/classes/class.dbConnections.php index 2a027c125..3e3d709a7 100755 --- a/workflow/engine/classes/class.dbConnections.php +++ b/workflow/engine/classes/class.dbConnections.php @@ -154,8 +154,9 @@ class dbConnections $result = DbSourcePeer::doSelectRS( $c ); $result->next(); $row = $result->getRow(); + while ($row = $result->getRow()) { - if (trim( $pProUid ) == trim( $row[1] )) { + if ((trim( $pProUid ) == trim( $row[1] )) && ($row[2] == 'mysql')) { $connections[] = Array ('DBS_UID' => $row[0],'DBS_NAME' => '[' . $row[3] . '] ' . $row[2] . ': ' . $row[4] ); } diff --git a/workflow/engine/classes/class.pmTable.php b/workflow/engine/classes/class.pmTable.php index 0d1748964..005a7a3ac 100755 --- a/workflow/engine/classes/class.pmTable.php +++ b/workflow/engine/classes/class.pmTable.php @@ -40,6 +40,7 @@ class PmTable private $schemaFile = ''; private $tableName; private $columns; + private $primaryKey= array(); private $baseDir = ''; private $targetDir = ''; private $configDir = ''; @@ -182,7 +183,7 @@ class PmTable * Build the pmTable with all dependencies */ public function build () - { + { $this->prepare(); $this->preparePropelIniFile(); $this->buildSchema(); @@ -400,7 +401,7 @@ class PmTable * Save the xml schema for propel */ public function saveSchema () - { + { $this->dom->save( $this->configDir . $this->schemaFilename ); } @@ -671,8 +672,29 @@ class PmTable $sql = "SELECT * FROM $tableBackup"; $rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC); + // array the primary keys + foreach($this->columns as $value) { + if ($value->field_key == 1) { + $this->primaryKey[] = $value->field_name; + } + } + + $flagPrimaryKey = 1; while ($rs->next()) { $row = $rs->getRow(); + if ($flagPrimaryKey) { + // verify row has all primary keys + $keys = 0; + foreach ($row as $colName => $value) { + if (in_array($colName,$this->primaryKey)){ + $keys++; + } + } + if ($keys != count($this->primaryKey)) { + return $stmt->executeQuery(str_replace($table, $tableBackup, $queryStack["drop"])); + } + $flagPrimaryKey = 0; + } $oTable = new $tableFileName(); $oTable->fromArray($row, BasePeer::TYPE_FIELDNAME); diff --git a/workflow/engine/classes/class.system.php b/workflow/engine/classes/class.system.php index 9306710ec..5874faa0d 100755 --- a/workflow/engine/classes/class.system.php +++ b/workflow/engine/classes/class.system.php @@ -973,8 +973,7 @@ class System $arrayEmailServerDefault = $emailServer->getEmailServerDefault(); if (count($arrayEmailServerDefault) > 0) { - //Return - return $arrayDataEmailServerConfig = array( + $arrayDataEmailServerConfig = array( "MESS_ENGINE" => $arrayEmailServerDefault["MESS_ENGINE"], "MESS_SERVER" => $arrayEmailServerDefault["MESS_SERVER"], "MESS_PORT" => (int)($arrayEmailServerDefault["MESS_PORT"]), @@ -993,6 +992,9 @@ class System "MESS_EXECUTE_EVERY" => "", "MESS_SEND_MAX" => "" ); + + //Return + return $arrayDataEmailServerConfig; } else { G::LoadClass("configuration"); diff --git a/workflow/engine/classes/model/Dynaform.php b/workflow/engine/classes/model/Dynaform.php index dcbb584ea..35a0a651a 100755 --- a/workflow/engine/classes/model/Dynaform.php +++ b/workflow/engine/classes/model/Dynaform.php @@ -517,13 +517,14 @@ class Dynaform extends BaseDynaform return $G_FORM->fields; } - public function verifyExistingName ($sName, $sProUid) + public function verifyExistingName ($sName, $sProUid, $sDynUid) { $sNameDyanform = urldecode( $sName ); $sProUid = urldecode( $sProUid ); $oCriteria = new Criteria( 'workflow' ); $oCriteria->addSelectColumn( DynaformPeer::DYN_UID ); $oCriteria->add( DynaformPeer::PRO_UID, $sProUid ); + $oCriteria->add( DynaformPeer::DYN_UID, $sDynUid ); $oDataset = DynaformPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $flag = true; @@ -532,14 +533,16 @@ class Dynaform extends BaseDynaform $oCriteria1 = new Criteria( 'workflow' ); $oCriteria1->addSelectColumn( 'COUNT(*) AS DYNAFORMS' ); $oCriteria1->add( ContentPeer::CON_CATEGORY, 'DYN_TITLE' ); - $oCriteria1->add( ContentPeer::CON_ID, $aRow['DYN_UID'] ); + $oCriteria1->add( ContentPeer::CON_ID, $sDynUid, Criteria::NOT_EQUAL); $oCriteria1->add( ContentPeer::CON_VALUE, $sNameDyanform ); $oCriteria1->add( ContentPeer::CON_LANG, SYS_LANG ); + $oCriteria1->add( DynaformPeer::PRO_UID, $sProUid); + $oCriteria1->addJoin( ContentPeer::CON_ID, DynaformPeer::DYN_UID, Criteria::INNER_JOIN ); $oDataset1 = ContentPeer::doSelectRS( $oCriteria1 ); $oDataset1->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset1->next(); $aRow1 = $oDataset1->getRow(); - if ($aRow1['DYNAFORMS']) { + if ($aRow1['DYNAFORMS'] == 1) { $flag = false; break; } diff --git a/workflow/engine/classes/model/Message.php b/workflow/engine/classes/model/Message.php new file mode 100644 index 000000000..dade974a9 --- /dev/null +++ b/workflow/engine/classes/model/Message.php @@ -0,0 +1,19 @@ +dbMap !== null); + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public function getDatabaseMap() + { + return $this->dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @return void + * @throws PropelException + */ + public function doBuild() + { + $this->dbMap = Propel::getDatabaseMap('workflow'); + + $tMap = $this->dbMap->addTable('MESSAGE_DETAIL'); + $tMap->setPhpName('MessageDetail'); + + $tMap->setUseIdGenerator(false); + + $tMap->addPrimaryKey('MD_UID', 'MdUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('MES_UID', 'MesUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('MD_TYPE', 'MdType', 'string', CreoleTypes::VARCHAR, false, 32); + + $tMap->addColumn('MD_NAME', 'MdName', 'string', CreoleTypes::VARCHAR, false, 255); + + } // doBuild() + +} // MessageDetailMapBuilder diff --git a/workflow/engine/classes/model/map/MessageMapBuilder.php b/workflow/engine/classes/model/map/MessageMapBuilder.php new file mode 100644 index 000000000..99d19ca16 --- /dev/null +++ b/workflow/engine/classes/model/map/MessageMapBuilder.php @@ -0,0 +1,78 @@ +dbMap !== null); + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public function getDatabaseMap() + { + return $this->dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @return void + * @throws PropelException + */ + public function doBuild() + { + $this->dbMap = Propel::getDatabaseMap('workflow'); + + $tMap = $this->dbMap->addTable('MESSAGE'); + $tMap->setPhpName('Message'); + + $tMap->setUseIdGenerator(false); + + $tMap->addPrimaryKey('MES_UID', 'MesUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('PRJ_UID', 'PrjUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('MES_NAME', 'MesName', 'string', CreoleTypes::VARCHAR, false, 255); + + $tMap->addColumn('MES_CONDITION', 'MesCondition', 'string', CreoleTypes::VARCHAR, false, 255); + + } // doBuild() + +} // MessageMapBuilder diff --git a/workflow/engine/classes/model/om/BaseMessage.php b/workflow/engine/classes/model/om/BaseMessage.php new file mode 100644 index 000000000..67195e2f1 --- /dev/null +++ b/workflow/engine/classes/model/om/BaseMessage.php @@ -0,0 +1,684 @@ +mes_uid; + } + + /** + * Get the [prj_uid] column value. + * + * @return string + */ + public function getPrjUid() + { + + return $this->prj_uid; + } + + /** + * Get the [mes_name] column value. + * + * @return string + */ + public function getMesName() + { + + return $this->mes_name; + } + + /** + * Get the [mes_condition] column value. + * + * @return string + */ + public function getMesCondition() + { + + return $this->mes_condition; + } + + /** + * Set the value of [mes_uid] column. + * + * @param string $v new value + * @return void + */ + public function setMesUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->mes_uid !== $v) { + $this->mes_uid = $v; + $this->modifiedColumns[] = MessagePeer::MES_UID; + } + + } // setMesUid() + + /** + * Set the value of [prj_uid] column. + * + * @param string $v new value + * @return void + */ + public function setPrjUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->prj_uid !== $v) { + $this->prj_uid = $v; + $this->modifiedColumns[] = MessagePeer::PRJ_UID; + } + + } // setPrjUid() + + /** + * Set the value of [mes_name] column. + * + * @param string $v new value + * @return void + */ + public function setMesName($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->mes_name !== $v || $v === '') { + $this->mes_name = $v; + $this->modifiedColumns[] = MessagePeer::MES_NAME; + } + + } // setMesName() + + /** + * Set the value of [mes_condition] column. + * + * @param string $v new value + * @return void + */ + public function setMesCondition($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->mes_condition !== $v || $v === '') { + $this->mes_condition = $v; + $this->modifiedColumns[] = MessagePeer::MES_CONDITION; + } + + } // setMesCondition() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (1-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos. + * @param int $startcol 1-based offset column which indicates which restultset column to start with. + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate(ResultSet $rs, $startcol = 1) + { + try { + + $this->mes_uid = $rs->getString($startcol + 0); + + $this->prj_uid = $rs->getString($startcol + 1); + + $this->mes_name = $rs->getString($startcol + 2); + + $this->mes_condition = $rs->getString($startcol + 3); + + $this->resetModified(); + + $this->setNew(false); + + // FIXME - using NUM_COLUMNS may be clearer. + return $startcol + 4; // 4 = MessagePeer::NUM_COLUMNS - MessagePeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating Message object", $e); + } + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param Connection $con + * @return void + * @throws PropelException + * @see BaseObject::setDeleted() + * @see BaseObject::isDeleted() + */ + public function delete($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(MessagePeer::DATABASE_NAME); + } + + try { + $con->begin(); + MessagePeer::doDelete($this, $con); + $this->setDeleted(true); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * wraps the doSave() worker method in a transaction. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update + * @throws PropelException + * @see doSave() + */ + public function save($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(MessagePeer::DATABASE_NAME); + } + + try { + $con->begin(); + $affectedRows = $this->doSave($con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update and any referring + * @throws PropelException + * @see save() + */ + protected function doSave($con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + // If this object has been modified, then save it to the database. + if ($this->isModified()) { + if ($this->isNew()) { + $pk = MessagePeer::doInsert($this, $con); + $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which + // should always be true here (even though technically + // BasePeer::doInsert() can insert multiple rows). + + $this->setNew(false); + } else { + $affectedRows += MessagePeer::doUpdate($this, $con); + } + $this->resetModified(); // [HL] After being saved an object is no longer 'modified' + } + + $this->alreadyInSave = false; + } + return $affectedRows; + } // doSave() + + /** + * Array of ValidationFailed objects. + * @var array ValidationFailed[] + */ + protected $validationFailures = array(); + + /** + * Gets any ValidationFailed objects that resulted from last call to validate(). + * + * + * @return array ValidationFailed[] + * @see validate() + */ + public function getValidationFailures() + { + return $this->validationFailures; + } + + /** + * Validates the objects modified field values and all objects related to this table. + * + * If $columns is either a column name or an array of column names + * only those columns are validated. + * + * @param mixed $columns Column name or an array of column names. + * @return boolean Whether all columns pass validation. + * @see doValidate() + * @see getValidationFailures() + */ + public function validate($columns = null) + { + $res = $this->doValidate($columns); + if ($res === true) { + $this->validationFailures = array(); + return true; + } else { + $this->validationFailures = $res; + return false; + } + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; + array of ValidationFailed objects otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = MessagePeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = MessagePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->getByPosition($pos); + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch($pos) { + case 0: + return $this->getMesUid(); + break; + case 1: + return $this->getPrjUid(); + break; + case 2: + return $this->getMesName(); + break; + case 3: + return $this->getMesCondition(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME) + { + $keys = MessagePeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getMesUid(), + $keys[1] => $this->getPrjUid(), + $keys[2] => $this->getMesName(), + $keys[3] => $this->getMesCondition(), + ); + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name peer name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = MessagePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setMesUid($value); + break; + case 1: + $this->setPrjUid($value); + break; + case 2: + $this->setMesName($value); + break; + case 3: + $this->setMesCondition($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, + * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = MessagePeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) { + $this->setMesUid($arr[$keys[0]]); + } + + if (array_key_exists($keys[1], $arr)) { + $this->setPrjUid($arr[$keys[1]]); + } + + if (array_key_exists($keys[2], $arr)) { + $this->setMesName($arr[$keys[2]]); + } + + if (array_key_exists($keys[3], $arr)) { + $this->setMesCondition($arr[$keys[3]]); + } + + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(MessagePeer::DATABASE_NAME); + + if ($this->isColumnModified(MessagePeer::MES_UID)) { + $criteria->add(MessagePeer::MES_UID, $this->mes_uid); + } + + if ($this->isColumnModified(MessagePeer::PRJ_UID)) { + $criteria->add(MessagePeer::PRJ_UID, $this->prj_uid); + } + + if ($this->isColumnModified(MessagePeer::MES_NAME)) { + $criteria->add(MessagePeer::MES_NAME, $this->mes_name); + } + + if ($this->isColumnModified(MessagePeer::MES_CONDITION)) { + $criteria->add(MessagePeer::MES_CONDITION, $this->mes_condition); + } + + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(MessagePeer::DATABASE_NAME); + + $criteria->add(MessagePeer::MES_UID, $this->mes_uid); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return string + */ + public function getPrimaryKey() + { + return $this->getMesUid(); + } + + /** + * Generic method to set the primary key (mes_uid column). + * + * @param string $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setMesUid($key); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of Message (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false) + { + + $copyObj->setPrjUid($this->prj_uid); + + $copyObj->setMesName($this->mes_name); + + $copyObj->setMesCondition($this->mes_condition); + + + $copyObj->setNew(true); + + $copyObj->setMesUid(NULL); // this is a pkey column, so set to default value + + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return Message Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + return $copyObj; + } + + /** + * Returns a peer instance associated with this om. + * + * Since Peer classes are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + * + * @return MessagePeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new MessagePeer(); + } + return self::$peer; + } +} + diff --git a/workflow/engine/classes/model/om/BaseMessageDetail.php b/workflow/engine/classes/model/om/BaseMessageDetail.php new file mode 100644 index 000000000..e8cc7c83d --- /dev/null +++ b/workflow/engine/classes/model/om/BaseMessageDetail.php @@ -0,0 +1,684 @@ +md_uid; + } + + /** + * Get the [mes_uid] column value. + * + * @return string + */ + public function getMesUid() + { + + return $this->mes_uid; + } + + /** + * Get the [md_type] column value. + * + * @return string + */ + public function getMdType() + { + + return $this->md_type; + } + + /** + * Get the [md_name] column value. + * + * @return string + */ + public function getMdName() + { + + return $this->md_name; + } + + /** + * Set the value of [md_uid] column. + * + * @param string $v new value + * @return void + */ + public function setMdUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->md_uid !== $v) { + $this->md_uid = $v; + $this->modifiedColumns[] = MessageDetailPeer::MD_UID; + } + + } // setMdUid() + + /** + * Set the value of [mes_uid] column. + * + * @param string $v new value + * @return void + */ + public function setMesUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->mes_uid !== $v) { + $this->mes_uid = $v; + $this->modifiedColumns[] = MessageDetailPeer::MES_UID; + } + + } // setMesUid() + + /** + * Set the value of [md_type] column. + * + * @param string $v new value + * @return void + */ + public function setMdType($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->md_type !== $v || $v === '') { + $this->md_type = $v; + $this->modifiedColumns[] = MessageDetailPeer::MD_TYPE; + } + + } // setMdType() + + /** + * Set the value of [md_name] column. + * + * @param string $v new value + * @return void + */ + public function setMdName($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->md_name !== $v || $v === '') { + $this->md_name = $v; + $this->modifiedColumns[] = MessageDetailPeer::MD_NAME; + } + + } // setMdName() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (1-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos. + * @param int $startcol 1-based offset column which indicates which restultset column to start with. + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate(ResultSet $rs, $startcol = 1) + { + try { + + $this->md_uid = $rs->getString($startcol + 0); + + $this->mes_uid = $rs->getString($startcol + 1); + + $this->md_type = $rs->getString($startcol + 2); + + $this->md_name = $rs->getString($startcol + 3); + + $this->resetModified(); + + $this->setNew(false); + + // FIXME - using NUM_COLUMNS may be clearer. + return $startcol + 4; // 4 = MessageDetailPeer::NUM_COLUMNS - MessageDetailPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating MessageDetail object", $e); + } + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param Connection $con + * @return void + * @throws PropelException + * @see BaseObject::setDeleted() + * @see BaseObject::isDeleted() + */ + public function delete($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(MessageDetailPeer::DATABASE_NAME); + } + + try { + $con->begin(); + MessageDetailPeer::doDelete($this, $con); + $this->setDeleted(true); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * wraps the doSave() worker method in a transaction. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update + * @throws PropelException + * @see doSave() + */ + public function save($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(MessageDetailPeer::DATABASE_NAME); + } + + try { + $con->begin(); + $affectedRows = $this->doSave($con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update and any referring + * @throws PropelException + * @see save() + */ + protected function doSave($con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + // If this object has been modified, then save it to the database. + if ($this->isModified()) { + if ($this->isNew()) { + $pk = MessageDetailPeer::doInsert($this, $con); + $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which + // should always be true here (even though technically + // BasePeer::doInsert() can insert multiple rows). + + $this->setNew(false); + } else { + $affectedRows += MessageDetailPeer::doUpdate($this, $con); + } + $this->resetModified(); // [HL] After being saved an object is no longer 'modified' + } + + $this->alreadyInSave = false; + } + return $affectedRows; + } // doSave() + + /** + * Array of ValidationFailed objects. + * @var array ValidationFailed[] + */ + protected $validationFailures = array(); + + /** + * Gets any ValidationFailed objects that resulted from last call to validate(). + * + * + * @return array ValidationFailed[] + * @see validate() + */ + public function getValidationFailures() + { + return $this->validationFailures; + } + + /** + * Validates the objects modified field values and all objects related to this table. + * + * If $columns is either a column name or an array of column names + * only those columns are validated. + * + * @param mixed $columns Column name or an array of column names. + * @return boolean Whether all columns pass validation. + * @see doValidate() + * @see getValidationFailures() + */ + public function validate($columns = null) + { + $res = $this->doValidate($columns); + if ($res === true) { + $this->validationFailures = array(); + return true; + } else { + $this->validationFailures = $res; + return false; + } + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; + array of ValidationFailed objects otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = MessageDetailPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = MessageDetailPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->getByPosition($pos); + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch($pos) { + case 0: + return $this->getMdUid(); + break; + case 1: + return $this->getMesUid(); + break; + case 2: + return $this->getMdType(); + break; + case 3: + return $this->getMdName(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME) + { + $keys = MessageDetailPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getMdUid(), + $keys[1] => $this->getMesUid(), + $keys[2] => $this->getMdType(), + $keys[3] => $this->getMdName(), + ); + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name peer name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = MessageDetailPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setMdUid($value); + break; + case 1: + $this->setMesUid($value); + break; + case 2: + $this->setMdType($value); + break; + case 3: + $this->setMdName($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, + * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = MessageDetailPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) { + $this->setMdUid($arr[$keys[0]]); + } + + if (array_key_exists($keys[1], $arr)) { + $this->setMesUid($arr[$keys[1]]); + } + + if (array_key_exists($keys[2], $arr)) { + $this->setMdType($arr[$keys[2]]); + } + + if (array_key_exists($keys[3], $arr)) { + $this->setMdName($arr[$keys[3]]); + } + + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(MessageDetailPeer::DATABASE_NAME); + + if ($this->isColumnModified(MessageDetailPeer::MD_UID)) { + $criteria->add(MessageDetailPeer::MD_UID, $this->md_uid); + } + + if ($this->isColumnModified(MessageDetailPeer::MES_UID)) { + $criteria->add(MessageDetailPeer::MES_UID, $this->mes_uid); + } + + if ($this->isColumnModified(MessageDetailPeer::MD_TYPE)) { + $criteria->add(MessageDetailPeer::MD_TYPE, $this->md_type); + } + + if ($this->isColumnModified(MessageDetailPeer::MD_NAME)) { + $criteria->add(MessageDetailPeer::MD_NAME, $this->md_name); + } + + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(MessageDetailPeer::DATABASE_NAME); + + $criteria->add(MessageDetailPeer::MD_UID, $this->md_uid); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return string + */ + public function getPrimaryKey() + { + return $this->getMdUid(); + } + + /** + * Generic method to set the primary key (md_uid column). + * + * @param string $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setMdUid($key); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of MessageDetail (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false) + { + + $copyObj->setMesUid($this->mes_uid); + + $copyObj->setMdType($this->md_type); + + $copyObj->setMdName($this->md_name); + + + $copyObj->setNew(true); + + $copyObj->setMdUid(NULL); // this is a pkey column, so set to default value + + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return MessageDetail Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + return $copyObj; + } + + /** + * Returns a peer instance associated with this om. + * + * Since Peer classes are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + * + * @return MessageDetailPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new MessageDetailPeer(); + } + return self::$peer; + } +} + diff --git a/workflow/engine/classes/model/om/BaseMessageDetailPeer.php b/workflow/engine/classes/model/om/BaseMessageDetailPeer.php new file mode 100644 index 000000000..26505a39c --- /dev/null +++ b/workflow/engine/classes/model/om/BaseMessageDetailPeer.php @@ -0,0 +1,582 @@ + array ('MdUid', 'MesUid', 'MdType', 'MdName', ), + BasePeer::TYPE_COLNAME => array (MessageDetailPeer::MD_UID, MessageDetailPeer::MES_UID, MessageDetailPeer::MD_TYPE, MessageDetailPeer::MD_NAME, ), + BasePeer::TYPE_FIELDNAME => array ('MD_UID', 'MES_UID', 'MD_TYPE', 'MD_NAME', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('MdUid' => 0, 'MesUid' => 1, 'MdType' => 2, 'MdName' => 3, ), + BasePeer::TYPE_COLNAME => array (MessageDetailPeer::MD_UID => 0, MessageDetailPeer::MES_UID => 1, MessageDetailPeer::MD_TYPE => 2, MessageDetailPeer::MD_NAME => 3, ), + BasePeer::TYPE_FIELDNAME => array ('MD_UID' => 0, 'MES_UID' => 1, 'MD_TYPE' => 2, 'MD_NAME' => 3, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) + ); + + /** + * @return MapBuilder the map builder for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getMapBuilder() + { + include_once 'classes/model/map/MessageDetailMapBuilder.php'; + return BasePeer::getMapBuilder('classes.model.map.MessageDetailMapBuilder'); + } + /** + * Gets a map (hash) of PHP names to DB column names. + * + * @return array The PHP to DB name map for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this. + */ + public static function getPhpNameMap() + { + if (self::$phpNameMap === null) { + $map = MessageDetailPeer::getTableMap(); + $columns = $map->getColumns(); + $nameMap = array(); + foreach ($columns as $column) { + $nameMap[$column->getPhpName()] = $column->getColumnName(); + } + self::$phpNameMap = $nameMap; + } + return self::$phpNameMap; + } + /** + * Translates a fieldname to another type + * + * @param string $name field name + * @param string $fromType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @param string $toType One of the class type constants + * @return string translated name of the field. + */ + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + /** + * Returns an array of of field names. + * + * @param string $type The type of fieldnames to return: + * One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return array A list of field names + */ + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + /** + * Convenience method which changes table.column to alias.column. + * + * Using this method you can maintain SQL abstraction while using column aliases. + * + * $c->addAlias("alias1", TablePeer::TABLE_NAME); + * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); + * + * @param string $alias The alias for the current table. + * @param string $column The column name for current table. (i.e. MessageDetailPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(MessageDetailPeer::TABLE_NAME.'.', $alias.'.', $column); + } + + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param criteria object containing the columns to add. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria) + { + + $criteria->addSelectColumn(MessageDetailPeer::MD_UID); + + $criteria->addSelectColumn(MessageDetailPeer::MES_UID); + + $criteria->addSelectColumn(MessageDetailPeer::MD_TYPE); + + $criteria->addSelectColumn(MessageDetailPeer::MD_NAME); + + } + + const COUNT = 'COUNT(MESSAGE_DETAIL.MD_UID)'; + const COUNT_DISTINCT = 'COUNT(DISTINCT MESSAGE_DETAIL.MD_UID)'; + + /** + * Returns the number of rows matching criteria. + * + * @param Criteria $criteria + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCount(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(MessageDetailPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(MessageDetailPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach ($criteria->getGroupByColumns() as $column) { + $criteria->addSelectColumn($column); + } + + $rs = MessageDetailPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + /** + * Method to select one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param Connection $con + * @return MessageDetail + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectOne(Criteria $criteria, $con = null) + { + $critcopy = clone $criteria; + $critcopy->setLimit(1); + $objects = MessageDetailPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + /** + * Method to do selects. + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con + * @return array Array of selected Objects + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelect(Criteria $criteria, $con = null) + { + return MessageDetailPeer::populateObjects(MessageDetailPeer::doSelectRS($criteria, $con)); + } + /** + * Prepares the Criteria object and uses the parent doSelect() + * method to get a ResultSet. + * + * Use this method directly if you want to just get the resultset + * (instead of an array of objects). + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return ResultSet The resultset object with numerically-indexed fields. + * @see BasePeer::doSelect() + */ + public static function doSelectRS(Criteria $criteria, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if (!$criteria->getSelectColumns()) { + $criteria = clone $criteria; + MessageDetailPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + // BasePeer returns a Creole ResultSet, set to return + // rows indexed numerically. + return BasePeer::doSelect($criteria, $con); + } + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(ResultSet $rs) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = MessageDetailPeer::getOMClass(); + $cls = Propel::import($cls); + // populate the object(s) + while ($rs->next()) { + + $obj = new $cls(); + $obj->hydrate($rs); + $results[] = $obj; + + } + return $results; + } + /** + * Returns the TableMap related to this peer. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + /** + * The class that the Peer will make instances of. + * + * This uses a dot-path notation which is tranalted into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @return string path.to.ClassName + */ + public static function getOMClass() + { + return MessageDetailPeer::CLASS_DEFAULT; + } + + /** + * Method perform an INSERT on the database, given a MessageDetail or Criteria object. + * + * @param mixed $values Criteria or MessageDetail object containing data that is used to create the INSERT statement. + * @param Connection $con the connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from MessageDetail object + } + + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->begin(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + + return $pk; + } + + /** + * Method perform an UPDATE on the database, given a MessageDetail or Criteria object. + * + * @param mixed $values Criteria or MessageDetail object containing data create the UPDATE statement. + * @param Connection $con The connection to use (specify Connection exert more control over transactions). + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doUpdate($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(MessageDetailPeer::MD_UID); + $selectCriteria->add(MessageDetailPeer::MD_UID, $criteria->remove(MessageDetailPeer::MD_UID), $comparison); + + } else { + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Method to DELETE all rows from the MESSAGE_DETAIL table. + * + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + $affectedRows += BasePeer::doDeleteAll(MessageDetailPeer::TABLE_NAME, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a MessageDetail or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or MessageDetail object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param Connection $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(MessageDetailPeer::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } elseif ($values instanceof MessageDetail) { + + $criteria = $values->buildPkeyCriteria(); + } else { + // it must be the primary key + $criteria = new Criteria(self::DATABASE_NAME); + $criteria->add(MessageDetailPeer::MD_UID, (array) $values, Criteria::IN); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + + $affectedRows += BasePeer::doDelete($criteria, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Validates all modified columns of given MessageDetail object. + * If parameter $columns is either a single column name or an array of column names + * than only those columns are validated. + * + * NOTICE: This does not apply to primary or foreign keys for now. + * + * @param MessageDetail $obj The object to validate. + * @param mixed $cols Column name or array of column names. + * + * @return mixed TRUE if all columns are valid or the error message of the first invalid column. + */ + public static function doValidate(MessageDetail $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(MessageDetailPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(MessageDetailPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(MessageDetailPeer::DATABASE_NAME, MessageDetailPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param mixed $pk the primary key. + * @param Connection $con the connection to use + * @return MessageDetail + */ + public static function retrieveByPK($pk, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $criteria = new Criteria(MessageDetailPeer::DATABASE_NAME); + + $criteria->add(MessageDetailPeer::MD_UID, $pk); + + + $v = MessageDetailPeer::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(MessageDetailPeer::MD_UID, $pks, Criteria::IN); + $objs = MessageDetailPeer::doSelect($criteria, $con); + } + return $objs; + } +} + + +// static code to register the map builder for this Peer with the main Propel class +if (Propel::isInit()) { + // the MapBuilder classes register themselves with Propel during initialization + // so we need to load them here. + try { + BaseMessageDetailPeer::getMapBuilder(); + } catch (Exception $e) { + Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); + } +} else { + // even if Propel is not yet initialized, the map builder class can be registered + // now and then it will be loaded when Propel initializes. + require_once 'classes/model/map/MessageDetailMapBuilder.php'; + Propel::registerMapBuilder('classes.model.map.MessageDetailMapBuilder'); +} + diff --git a/workflow/engine/classes/model/om/BaseMessagePeer.php b/workflow/engine/classes/model/om/BaseMessagePeer.php new file mode 100644 index 000000000..270117300 --- /dev/null +++ b/workflow/engine/classes/model/om/BaseMessagePeer.php @@ -0,0 +1,582 @@ + array ('MesUid', 'PrjUid', 'MesName', 'MesCondition', ), + BasePeer::TYPE_COLNAME => array (MessagePeer::MES_UID, MessagePeer::PRJ_UID, MessagePeer::MES_NAME, MessagePeer::MES_CONDITION, ), + BasePeer::TYPE_FIELDNAME => array ('MES_UID', 'PRJ_UID', 'MES_NAME', 'MES_CONDITION', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('MesUid' => 0, 'PrjUid' => 1, 'MesName' => 2, 'MesCondition' => 3, ), + BasePeer::TYPE_COLNAME => array (MessagePeer::MES_UID => 0, MessagePeer::PRJ_UID => 1, MessagePeer::MES_NAME => 2, MessagePeer::MES_CONDITION => 3, ), + BasePeer::TYPE_FIELDNAME => array ('MES_UID' => 0, 'PRJ_UID' => 1, 'MES_NAME' => 2, 'MES_CONDITION' => 3, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) + ); + + /** + * @return MapBuilder the map builder for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getMapBuilder() + { + include_once 'classes/model/map/MessageMapBuilder.php'; + return BasePeer::getMapBuilder('classes.model.map.MessageMapBuilder'); + } + /** + * Gets a map (hash) of PHP names to DB column names. + * + * @return array The PHP to DB name map for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this. + */ + public static function getPhpNameMap() + { + if (self::$phpNameMap === null) { + $map = MessagePeer::getTableMap(); + $columns = $map->getColumns(); + $nameMap = array(); + foreach ($columns as $column) { + $nameMap[$column->getPhpName()] = $column->getColumnName(); + } + self::$phpNameMap = $nameMap; + } + return self::$phpNameMap; + } + /** + * Translates a fieldname to another type + * + * @param string $name field name + * @param string $fromType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @param string $toType One of the class type constants + * @return string translated name of the field. + */ + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + /** + * Returns an array of of field names. + * + * @param string $type The type of fieldnames to return: + * One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return array A list of field names + */ + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + /** + * Convenience method which changes table.column to alias.column. + * + * Using this method you can maintain SQL abstraction while using column aliases. + * + * $c->addAlias("alias1", TablePeer::TABLE_NAME); + * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); + * + * @param string $alias The alias for the current table. + * @param string $column The column name for current table. (i.e. MessagePeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(MessagePeer::TABLE_NAME.'.', $alias.'.', $column); + } + + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param criteria object containing the columns to add. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria) + { + + $criteria->addSelectColumn(MessagePeer::MES_UID); + + $criteria->addSelectColumn(MessagePeer::PRJ_UID); + + $criteria->addSelectColumn(MessagePeer::MES_NAME); + + $criteria->addSelectColumn(MessagePeer::MES_CONDITION); + + } + + const COUNT = 'COUNT(MESSAGE.MES_UID)'; + const COUNT_DISTINCT = 'COUNT(DISTINCT MESSAGE.MES_UID)'; + + /** + * Returns the number of rows matching criteria. + * + * @param Criteria $criteria + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCount(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(MessagePeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(MessagePeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach ($criteria->getGroupByColumns() as $column) { + $criteria->addSelectColumn($column); + } + + $rs = MessagePeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + /** + * Method to select one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param Connection $con + * @return Message + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectOne(Criteria $criteria, $con = null) + { + $critcopy = clone $criteria; + $critcopy->setLimit(1); + $objects = MessagePeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + /** + * Method to do selects. + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con + * @return array Array of selected Objects + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelect(Criteria $criteria, $con = null) + { + return MessagePeer::populateObjects(MessagePeer::doSelectRS($criteria, $con)); + } + /** + * Prepares the Criteria object and uses the parent doSelect() + * method to get a ResultSet. + * + * Use this method directly if you want to just get the resultset + * (instead of an array of objects). + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return ResultSet The resultset object with numerically-indexed fields. + * @see BasePeer::doSelect() + */ + public static function doSelectRS(Criteria $criteria, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if (!$criteria->getSelectColumns()) { + $criteria = clone $criteria; + MessagePeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + // BasePeer returns a Creole ResultSet, set to return + // rows indexed numerically. + return BasePeer::doSelect($criteria, $con); + } + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(ResultSet $rs) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = MessagePeer::getOMClass(); + $cls = Propel::import($cls); + // populate the object(s) + while ($rs->next()) { + + $obj = new $cls(); + $obj->hydrate($rs); + $results[] = $obj; + + } + return $results; + } + /** + * Returns the TableMap related to this peer. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + /** + * The class that the Peer will make instances of. + * + * This uses a dot-path notation which is tranalted into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @return string path.to.ClassName + */ + public static function getOMClass() + { + return MessagePeer::CLASS_DEFAULT; + } + + /** + * Method perform an INSERT on the database, given a Message or Criteria object. + * + * @param mixed $values Criteria or Message object containing data that is used to create the INSERT statement. + * @param Connection $con the connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from Message object + } + + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->begin(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + + return $pk; + } + + /** + * Method perform an UPDATE on the database, given a Message or Criteria object. + * + * @param mixed $values Criteria or Message object containing data create the UPDATE statement. + * @param Connection $con The connection to use (specify Connection exert more control over transactions). + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doUpdate($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(MessagePeer::MES_UID); + $selectCriteria->add(MessagePeer::MES_UID, $criteria->remove(MessagePeer::MES_UID), $comparison); + + } else { + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Method to DELETE all rows from the MESSAGE table. + * + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + $affectedRows += BasePeer::doDeleteAll(MessagePeer::TABLE_NAME, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a Message or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or Message object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param Connection $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(MessagePeer::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } elseif ($values instanceof Message) { + + $criteria = $values->buildPkeyCriteria(); + } else { + // it must be the primary key + $criteria = new Criteria(self::DATABASE_NAME); + $criteria->add(MessagePeer::MES_UID, (array) $values, Criteria::IN); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + + $affectedRows += BasePeer::doDelete($criteria, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Validates all modified columns of given Message object. + * If parameter $columns is either a single column name or an array of column names + * than only those columns are validated. + * + * NOTICE: This does not apply to primary or foreign keys for now. + * + * @param Message $obj The object to validate. + * @param mixed $cols Column name or array of column names. + * + * @return mixed TRUE if all columns are valid or the error message of the first invalid column. + */ + public static function doValidate(Message $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(MessagePeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(MessagePeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(MessagePeer::DATABASE_NAME, MessagePeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param mixed $pk the primary key. + * @param Connection $con the connection to use + * @return Message + */ + public static function retrieveByPK($pk, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $criteria = new Criteria(MessagePeer::DATABASE_NAME); + + $criteria->add(MessagePeer::MES_UID, $pk); + + + $v = MessagePeer::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(MessagePeer::MES_UID, $pks, Criteria::IN); + $objs = MessagePeer::doSelect($criteria, $con); + } + return $objs; + } +} + + +// static code to register the map builder for this Peer with the main Propel class +if (Propel::isInit()) { + // the MapBuilder classes register themselves with Propel during initialization + // so we need to load them here. + try { + BaseMessagePeer::getMapBuilder(); + } catch (Exception $e) { + Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); + } +} else { + // even if Propel is not yet initialized, the map builder class can be registered + // now and then it will be loaded when Propel initializes. + require_once 'classes/model/map/MessageMapBuilder.php'; + Propel::registerMapBuilder('classes.model.map.MessageMapBuilder'); +} + diff --git a/workflow/engine/config/schema.xml b/workflow/engine/config/schema.xml index 5e5a94a26..e824afeab 100755 --- a/workflow/engine/config/schema.xml +++ b/workflow/engine/config/schema.xml @@ -4176,7 +4176,18 @@ - + + + + + +
+ + + + + +
diff --git a/workflow/engine/controllers/pmTablesProxy.php b/workflow/engine/controllers/pmTablesProxy.php index 6554fc2a0..666ad0694 100755 --- a/workflow/engine/controllers/pmTablesProxy.php +++ b/workflow/engine/controllers/pmTablesProxy.php @@ -116,13 +116,19 @@ class pmTablesProxy extends HttpProxyController $proUid = $_POST['PRO_UID']; $dbConn = new DbConnections(); $dbConnections = $dbConn->getConnectionsProUid( $proUid ); - $defaultConnections = array (array ('DBS_UID' => 'workflow','DBS_NAME' => 'Workflow' - ),array ('DBS_UID' => 'rp','DBS_NAME' => 'REPORT' - ) - ); + + $workSpace = new workspaceTools(SYS_SYS); + $workspaceDB = $workSpace->getDBInfo(); + if ($workspaceDB['DB_NAME'] == $workspaceDB['DB_RBAC_NAME']) { + $defaultConnections = array (array ('DBS_UID' => 'workflow','DBS_NAME' => 'Workflow')); + } else { + $defaultConnections = array (array ('DBS_UID' => 'workflow','DBS_NAME' => 'Workflow'), + array ('DBS_UID' => 'rp','DBS_NAME' => 'REPORT')); + } + $dbConnections = array_merge( $defaultConnections, $dbConnections ); - + return $dbConnections; } @@ -208,13 +214,11 @@ class pmTablesProxy extends HttpProxyController $result = new StdClass(); try { - $result = new stdClass(); ob_start(); $data = (array) $httpData; $data['PRO_UID'] = trim( $data['PRO_UID'] ); $data['columns'] = G::json_decode( stripslashes( $httpData->columns ) ); //decofing data columns - $isReportTable = $data['PRO_UID'] != '' ? true : false; $oAdditionalTables = new AdditionalTables(); $oFields = new Fields(); @@ -252,7 +256,6 @@ class pmTablesProxy extends HttpProxyController ) ) )); } } - //backward compatility foreach ($columns as $i => $column) { if (in_array( strtoupper( $columns[$i]->field_name ), $reservedWordsSql ) || in_array( strtolower( $columns[$i]->field_name ), $reservedWordsPhp )) { @@ -318,7 +321,6 @@ class pmTablesProxy extends HttpProxyController $oCriteria->add( FieldsPeer::ADD_TAB_UID, $data['REP_TAB_UID'] ); FieldsPeer::doDelete( $oCriteria ); } - // Updating pmtable fields foreach ($columns as $i => $column) { $field = array ( @@ -747,7 +749,7 @@ class pmTablesProxy extends HttpProxyController */ public function exportCSV ($httpData) { - + $result = new StdClass(); try { $link = ''; diff --git a/workflow/engine/data/mssql/schema.sql b/workflow/engine/data/mssql/schema.sql index ce41277de..669421f6b 100755 --- a/workflow/engine/data/mssql/schema.sql +++ b/workflow/engine/data/mssql/schema.sql @@ -3278,3 +3278,82 @@ CREATE TABLE APP_ASSIGN_SELF_SERVICE_VALUE GRP_UID VARCHAR(32) DEFAULT '' NOT NULL ); +/* ---------------------------------------------------------------------- */ +/* MESSAGE */ +/* ---------------------------------------------------------------------- */ + + +IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = 'MESSAGE') +BEGIN + DECLARE @reftable_108 nvarchar(60), @constraintname_108 nvarchar(60) + DECLARE refcursor CURSOR FOR + select reftables.name tablename, cons.name constraintname + from sysobjects tables, + sysobjects reftables, + sysobjects cons, + sysreferences ref + where tables.id = ref.rkeyid + and cons.id = ref.constid + and reftables.id = ref.fkeyid + and tables.name = 'MESSAGE' + OPEN refcursor + FETCH NEXT from refcursor into @reftable_108, @constraintname_108 + while @@FETCH_STATUS = 0 + BEGIN + exec ('alter table '+@reftable_108+' drop constraint '+@constraintname_108) + FETCH NEXT from refcursor into @reftable_108, @constraintname_108 + END + CLOSE refcursor + DEALLOCATE refcursor + DROP TABLE [MESSAGE] +END + + +CREATE TABLE [MESSAGE] +( + [MES_UID] VARCHAR(32) NOT NULL, + [PRJ_UID] VARCHAR(32) NOT NULL, + [MES_NAME] VARCHAR(255) default '' NULL, + [MES_CONDITION] VARCHAR(255) default '' NULL, + CONSTRAINT MESSAGE_PK PRIMARY KEY ([MES_UID]) +); + +/* ---------------------------------------------------------------------- */ +/* MESSAGE_DETAIL */ +/* ---------------------------------------------------------------------- */ + + +IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = 'MESSAGE_DETAIL') +BEGIN + DECLARE @reftable_109 nvarchar(60), @constraintname_109 nvarchar(60) + DECLARE refcursor CURSOR FOR + select reftables.name tablename, cons.name constraintname + from sysobjects tables, + sysobjects reftables, + sysobjects cons, + sysreferences ref + where tables.id = ref.rkeyid + and cons.id = ref.constid + and reftables.id = ref.fkeyid + and tables.name = 'MESSAGE_DETAIL' + OPEN refcursor + FETCH NEXT from refcursor into @reftable_109, @constraintname_109 + while @@FETCH_STATUS = 0 + BEGIN + exec ('alter table '+@reftable_109+' drop constraint '+@constraintname_109) + FETCH NEXT from refcursor into @reftable_109, @constraintname_109 + END + CLOSE refcursor + DEALLOCATE refcursor + DROP TABLE [MESSAGE_DETAIL] +END + + +CREATE TABLE [MESSAGE_DETAIL] +( + [MD_UID] VARCHAR(32) NOT NULL, + [MES_UID] VARCHAR(32) NOT NULL, + [MD_TYPE] VARCHAR(32) default '' NULL, + [MD_NAME] VARCHAR(255) default '' NULL, + CONSTRAINT MESSAGE_DETAIL_PK PRIMARY KEY ([MD_UID]) +); \ No newline at end of file diff --git a/workflow/engine/data/mysql/schema.sql b/workflow/engine/data/mysql/schema.sql index bad2c1239..3973bb11d 100755 --- a/workflow/engine/data/mysql/schema.sql +++ b/workflow/engine/data/mysql/schema.sql @@ -486,10 +486,10 @@ CREATE TABLE `ROUTE` `ROU_PARENT` VARCHAR(32) default '0' NOT NULL, `PRO_UID` VARCHAR(32) default '' NOT NULL, `TAS_UID` VARCHAR(32) default '' NOT NULL, - `ROU_NEXT_TASK` VARCHAR(32) default '0' NOT NULL, +`ROU_NEXT_TASK` VARCHAR(32) default '0' NOT NULL, `ROU_CASE` INTEGER default 0 NOT NULL, `ROU_TYPE` VARCHAR(25) default 'SEQUENTIAL' NOT NULL, - `ROU_DEFAULT` INTEGER default 0 NOT NULL, + `ROU_DEFAULT` INTEGER default 0 NOT NULL, `ROU_CONDITION` VARCHAR(512) default '' NOT NULL, `ROU_TO_LAST_USER` VARCHAR(20) default 'FALSE' NOT NULL, `ROU_OPTIONAL` VARCHAR(20) default 'FALSE' NOT NULL, @@ -1207,7 +1207,7 @@ CREATE TABLE `APP_HISTORY` `PRO_UID` VARCHAR(32) default '' NOT NULL, `TAS_UID` VARCHAR(32) default '' NOT NULL, `DYN_UID` VARCHAR(32) default '' NOT NULL, - `OBJ_TYPE` VARCHAR(20) default 'DYNAFORM' NOT NULL, + `OBJ_TYPE` VARCHAR(20) default 'DYNAFORM' NOT NULL, `USR_UID` VARCHAR(32) default '' NOT NULL, `APP_STATUS` VARCHAR(100) default '' NOT NULL, `HISTORY_DATE` DATETIME, @@ -2380,6 +2380,36 @@ CREATE TABLE `LIST_UNASSIGNED_GROUP` `TYP_UID` VARCHAR(32) default '' NOT NULL, PRIMARY KEY (`UNA_UID`,`USR_UID`,`TYPE`) )ENGINE=InnoDB DEFAULT CHARSET='utf8' COMMENT='Unassiged list'; +#----------------------------------------------------------------------------- +#-- MESSAGE +#----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS `MESSAGE`; + + +CREATE TABLE `MESSAGE` +( + `MES_UID` VARCHAR(32) NOT NULL, + `PRJ_UID` VARCHAR(32) NOT NULL, + `MES_NAME` VARCHAR(255) default '', + `MES_CONDITION` VARCHAR(255) default '', + PRIMARY KEY (`MES_UID`) +)ENGINE=InnoDB ; +#----------------------------------------------------------------------------- +#-- MESSAGE_DETAIL +#----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS `MESSAGE_DETAIL`; + + +CREATE TABLE `MESSAGE_DETAIL` +( + `MD_UID` VARCHAR(32) NOT NULL, + `MES_UID` VARCHAR(32) NOT NULL, + `MD_TYPE` VARCHAR(32) default '', + `MD_NAME` VARCHAR(255) default '', + PRIMARY KEY (`MD_UID`) +)ENGINE=InnoDB ; # This restores the fkey checks, after having unset them earlier SET FOREIGN_KEY_CHECKS = 1; @@ -2388,6 +2418,7 @@ SET FOREIGN_KEY_CHECKS = 1; #----------------------------------------------------------------------------- DROP TABLE IF EXISTS `EMAIL_SERVER`; + CREATE TABLE `EMAIL_SERVER` ( `MESS_UID` VARCHAR(32) default '' NOT NULL, diff --git a/workflow/engine/data/oracle/schema.sql b/workflow/engine/data/oracle/schema.sql index 3f4af465e..b565ade06 100755 --- a/workflow/engine/data/oracle/schema.sql +++ b/workflow/engine/data/oracle/schema.sql @@ -1850,3 +1850,42 @@ CREATE TABLE APP_ASSIGN_SELF_SERVICE_VALUE GRP_UID VARCHAR2(32) DEFAULT '' NOT NULL ); + +/* ----------------------------------------------------------------------- + MESSAGE + ----------------------------------------------------------------------- */ + +DROP TABLE "MESSAGE" CASCADE CONSTRAINTS; + + +CREATE TABLE "MESSAGE" +( + "MES_UID" VARCHAR2(32) NOT NULL, + "PRJ_UID" VARCHAR2(32) NOT NULL, + "MES_NAME" VARCHAR2(255) default '', + "MES_CONDITION" VARCHAR2(255) default '' +); + + ALTER TABLE "MESSAGE" + ADD CONSTRAINT "MESSAGE_PK" + PRIMARY KEY ("MES_UID"); + + +/* ----------------------------------------------------------------------- + MESSAGE_DETAIL + ----------------------------------------------------------------------- */ + +DROP TABLE "MESSAGE_DETAIL" CASCADE CONSTRAINTS; + + +CREATE TABLE "MESSAGE_DETAIL" +( + "MD_UID" VARCHAR2(32) NOT NULL, + "MES_UID" VARCHAR2(32) NOT NULL, + "MD_TYPE" VARCHAR2(32) default '', + "MD_NAME" VARCHAR2(255) default '' +); + + ALTER TABLE "MESSAGE_DETAIL" + ADD CONSTRAINT "MESSAGE_DETAIL_PK" + PRIMARY KEY ("MD_UID"); diff --git a/workflow/engine/js/dynaformEditor/core/dynaformEditor.js b/workflow/engine/js/dynaformEditor/core/dynaformEditor.js old mode 100644 new mode 100755 index 3323e41ed..b25401c9b --- a/workflow/engine/js/dynaformEditor/core/dynaformEditor.js +++ b/workflow/engine/js/dynaformEditor/core/dynaformEditor.js @@ -856,6 +856,13 @@ var dynaformEditor={ /*getField("ENABLETEMPLATE","dynaforms_Properties").checked=(prop.ENABLETEMPLATE=="1");*/ getField("MODE","dynaforms_Properties").value=prop.MODE; }, + refreshPropertiesDynTitle:function() + { + var form=this.views["properties"].getElementsByTagName("form")[0]; + var prop=this.ajax.get_properties(this.A,this.dynUid); + getField("A","dynaforms_Properties").value=prop.A; + getField("DYN_TITLE","dynaforms_Properties").value=prop.DYN_TITLE; + }, // Internal functions runScripts:function(scripts) { diff --git a/workflow/engine/methods/dynaforms/dynaforms_Ajax.php b/workflow/engine/methods/dynaforms/dynaforms_Ajax.php index 6ba97be6b..5d21861c2 100755 --- a/workflow/engine/methods/dynaforms/dynaforms_Ajax.php +++ b/workflow/engine/methods/dynaforms/dynaforms_Ajax.php @@ -26,6 +26,11 @@ * * @author David Callizaya */ +if (isset($_POST['dynaformName'])) { + $dynaForm = new Dynaform(); + $res = $dynaForm->verifyExistingName($_POST['dynaformName'], $_POST['proUid'], $_POST['dynaformUid']); + print ($res) ? 1 : 0; +} global $_DBArray; if (! isset( $_DBArray )) { $_DBArray = array (); diff --git a/workflow/engine/methods/dynaforms/dynaforms_Save.php b/workflow/engine/methods/dynaforms/dynaforms_Save.php index 43789e86e..8a64a7774 100755 --- a/workflow/engine/methods/dynaforms/dynaforms_Save.php +++ b/workflow/engine/methods/dynaforms/dynaforms_Save.php @@ -158,13 +158,13 @@ if (isset( $sfunction ) && $sfunction == 'lookforNameDynaform') { $copyDynGrdDescription = $row["CON_VALUE"]; //Create grid - $aDataAux = $aData; + $dynaformGrid = new dynaform(); + $aDataAux = $aData; $aDataAux["DYN_TYPE"] = "grid"; - $aDataAux["DYN_TITLE"] = $copyDynGrdTitle; + $aDataAux["DYN_TITLE"] = $copyDynGrdTitle . ((!$dynaformGrid->verifyExistingName($copyDynGrdTitle, $dynaform->getProUid()))? " (" . $dynaform->getDynTitle() . ")" : ""); $aDataAux["DYN_DESCRIPTION"] = $copyDynGrdDescription; - $dynaformGrid = new dynaform(); $aFields = $dynaformGrid->create($aDataAux); $dynaformGridUid = $dynaformGrid->getDynUid(); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/DynaForm.php b/workflow/engine/src/ProcessMaker/BusinessModel/DynaForm.php index bfcc6bf10..08827276a 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/DynaForm.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/DynaForm.php @@ -602,15 +602,15 @@ class DynaForm $dynGrdDescriptionCopyImport = $row["CON_VALUE"]; //Create Grid + $dynaFormGrid = new \Dynaform(); + $arrayDataAux = array( "PRO_UID" => $processUid, - "DYN_TITLE" => $dynGrdTitleCopyImport, + "DYN_TITLE" => $dynGrdTitleCopyImport . (($this->existsTitle($processUid, $dynGrdTitleCopyImport))? " (" . $arrayData["DYN_TITLE"] . ")" : ""), "DYN_DESCRIPTION" => $dynGrdDescriptionCopyImport, "DYN_TYPE" => "grid" ); - $dynaFormGrid = new \Dynaform(); - $dynaFormGridUid = $dynaFormGrid->create($arrayDataAux); //Copy files of the DynaForm Grid @@ -1124,6 +1124,5 @@ class DynaForm throw $e; } } - } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Message.php b/workflow/engine/src/ProcessMaker/BusinessModel/Message.php new file mode 100644 index 000000000..fbef2d874 --- /dev/null +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Message.php @@ -0,0 +1,415 @@ +existsName($processUid, $arrayData["MES_NAME"]); + + $this->throwExceptionFieldDefinition($arrayData); + + //Create + $cnn = \Propel::getConnection("workflow"); + try { + $message = new \Message(); + + $sPkMessage = \ProcessMaker\Util\Common::generateUID(); + + $message->setMesUid($sPkMessage); + $message->setPrjUid($processUid); + + if ($message->validate()) { + $cnn->begin(); + + if (isset($arrayData["MES_NAME"])) { + $message->setMesName($arrayData["MES_NAME"]); + } else { + throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$mes_name' ))); + } + if (isset($arrayData["MES_DETAIL"])) { + + foreach ($arrayData["MES_DETAIL"] as $i => $type) { + $messageDetail = new \MessageDetail(); + + $sPkMessageDetail = \ProcessMaker\Util\Common::generateUID(); + + $messageDetail->setMdUid($sPkMessageDetail); + $messageDetail->setMdType($type["md_type"]); + $messageDetail->setMdName($type["md_name"]); + $messageDetail->setMesUid($sPkMessage); + $messageDetail->save(); + } + } + + $message->save(); + $cnn->commit(); + } else { + + $msg = ""; + + foreach ($message->getValidationFailures() as $validationFailure) { + $msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage(); + } + + throw new \Exception(\G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . "\n" . $msg); + } + + } catch (\Exception $e) { + $cnn->rollback(); + + throw $e; + } + + //Return + $message = $this->getMessage($processUid, $sPkMessage); + + return $message; + + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Update Message + * + * @param string $processUid Unique id of Process + * @param string $messageUid Unique id of Message + * @param array $arrayData Data + * + * return array Return data of the Message updated + */ + public function update($processUid, $messageUid, $arrayData) + { + try { + //Verify data + Validator::proUid($processUid, '$prj_uid'); + $arrayData = array_change_key_case($arrayData, CASE_UPPER); + + $this->throwExceptionFieldDefinition($arrayData); + + //Update + $cnn = \Propel::getConnection("workflow"); + try { + $message = \MessagePeer::retrieveByPK($messageUid); + + if (is_null($message)) { + throw new \Exception('mes_uid: '.$messageUid. ' '.\G::LoadTranslation("ID_DOES_NOT_EXIST")); + } else { + $cnn->begin(); + if (isset($arrayData["MES_NAME"])) { + $this->existsName($processUid, $arrayData["MES_NAME"]); + $message->setMesName($arrayData["MES_NAME"]); + } + if (isset($arrayData["MES_DETAIL"])) { + + foreach ($arrayData["MES_DETAIL"] as $i => $type) { + + $messageDetail = \MessageDetailPeer::retrieveByPK($type["md_uid"]); + if (is_null($messageDetail)) { + throw new \Exception('md_uid: '.$type["md_uid"]. ' '.\G::LoadTranslation("ID_DOES_NOT_EXIST")); + } else { + $messageDetail->setMdType($type["md_type"]); + $messageDetail->setMdName($type["md_name"]); + + $messageDetail->save(); + } + } + } + $message->save(); + $cnn->commit(); + } + + } catch (\Exception $e) { + $cnn->rollback(); + + throw $e; + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Delete Message + * + * @param string $processUid Unique id of Process + * @param string $messageUid Unique id of Message + * + * return void + */ + public function delete($processUid, $messageUid) + { + try { + //Verify data + Validator::proUid($processUid, '$prj_uid'); + + $this->throwExceptionIfNotExistsMessage($messageUid); + + //Delete + $criteria = new \Criteria("workflow"); + + $criteria->add(\MessagePeer::MES_UID, $messageUid); + + \MessagePeer::doDelete($criteria); + + //Delete Detail + $criteriaDetail = new \Criteria("workflow"); + + $criteriaDetail->add(\MessageDetailPeer::MES_UID, $messageUid); + + \MessageDetailPeer::doDelete($criteriaDetail); + + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get data of a Message + * @param string $processUid Unique id of Process + * @param string $messageUid Unique id of Message + * + * return array Return an array with data of a Message + */ + public function getMessage($processUid, $messageUid) + { + try { + //Verify data + Validator::proUid($processUid, '$prj_uid'); + + $this->throwExceptionIfNotExistsMessage($messageUid); + + //Get data + $criteria = new \Criteria("workflow"); + + $criteria->addSelectColumn(\MessagePeer::MES_UID); + $criteria->addSelectColumn(\MessagePeer::MES_NAME); + $criteria->addSelectColumn(\MessagePeer::PRJ_UID); + + $criteria->add(\MessagePeer::PRJ_UID, $processUid, \Criteria::EQUAL); + $criteria->add(\MessagePeer::MES_UID, $messageUid, \Criteria::EQUAL); + + $rsCriteria = \MessagePeer::doSelectRS($criteria); + + $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + + $rsCriteria->next(); + $arrayMessage = array(); + + while ($aRow = $rsCriteria->getRow()) { + $oCriteriaU = new \Criteria('workflow'); + $oCriteriaU->setDistinct(); + $oCriteriaU->addSelectColumn(\MessageDetailPeer::MD_UID); + $oCriteriaU->addSelectColumn(\MessageDetailPeer::MD_NAME); + $oCriteriaU->addSelectColumn(\MessageDetailPeer::MD_TYPE); + $oCriteriaU->add(\MessageDetailPeer::MES_UID, $aRow['MES_UID']); + $oDatasetU = \MessageDetailPeer::doSelectRS($oCriteriaU); + $oDatasetU->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $aType = array(); + while ($oDatasetU->next()) { + $aRowU = $oDatasetU->getRow(); + $aType[] = array('md_uid' => $aRowU['MD_UID'], + 'md_name' => $aRowU['MD_NAME'], + 'md_type' => $aRowU['MD_TYPE']); + + } + $arrayMessage = array('mes_uid' => $aRow['MES_UID'], + 'prj_uid' => $aRow['PRJ_UID'], + 'mes_name' => $aRow['MES_NAME'], + 'mes_detail' => $aType); + $rsCriteria->next(); + } + //Return + return $arrayMessage; + + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get data of Message + * + * @param string $processUid Unique id of Message + * + * return array Return an array with data of a Message + */ + public function getMessages($processUid) + { + try { + //Verify data + Validator::proUid($processUid, '$prj_uid'); + + //Get data + $criteria = new \Criteria("workflow"); + + $criteria->addSelectColumn(\MessagePeer::MES_UID); + $criteria->addSelectColumn(\MessagePeer::MES_NAME); + $criteria->addSelectColumn(\MessagePeer::PRJ_UID); + + $criteria->add(\MessagePeer::PRJ_UID, $processUid, \Criteria::EQUAL); + + $rsCriteria = \MessagePeer::doSelectRS($criteria); + + $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + + $rsCriteria->next(); + $arrayMessages = array(); + + while ($aRow = $rsCriteria->getRow()) { + $oCriteriaU = new \Criteria('workflow'); + $oCriteriaU->setDistinct(); + $oCriteriaU->addSelectColumn(\MessageDetailPeer::MD_UID); + $oCriteriaU->addSelectColumn(\MessageDetailPeer::MD_NAME); + $oCriteriaU->addSelectColumn(\MessageDetailPeer::MD_TYPE); + $oCriteriaU->add(\MessageDetailPeer::MES_UID, $aRow['MES_UID']); + $oDatasetU = \MessageDetailPeer::doSelectRS($oCriteriaU); + $oDatasetU->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $aType = array(); + while ($oDatasetU->next()) { + $aRowU = $oDatasetU->getRow(); + $aType[] = array('md_uid' => $aRowU['MD_UID'], + 'md_name' => $aRowU['MD_NAME'], + 'mes_type' => $aRowU['MD_TYPE']); + + } + $arrayMessages[] = array('mes_uid' => $aRow['MES_UID'], + 'prj_uid' => $aRow['PRJ_UID'], + 'mes_name' => $aRow['MES_NAME'], + 'mes_detail' => $aType); + $rsCriteria->next(); + } + //Return + return $arrayMessages; + + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Verify field definition + * + * @param array $aData Unique id of Message to exclude + * + */ + public function throwExceptionFieldDefinition($aData) + { + try { + if (isset($aData["MES_NAME"])) { + Validator::isString($aData['MES_NAME'], '$mes_name'); + Validator::isNotEmpty($aData['MES_NAME'], '$mes_name'); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Verify if exists the name of a message + * + * @param string $processUid Unique id of Process + * @param string $messageName Name + * + */ + public function existsName($processUid, $messageName) + { + try { + $criteria = new \Criteria("workflow"); + $criteria->addSelectColumn(\MessagePeer::MES_UID); + $criteria->add(\MessagePeer::MES_NAME, $messageName, \Criteria::EQUAL); + $criteria->add(\MessagePeer::PRJ_UID, $processUid, \Criteria::EQUAL); + $rsCriteria = \MessagePeer::doSelectRS($criteria); + $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $rsCriteria->next(); + if ($rsCriteria->getRow()) { + throw new \Exception(\G::LoadTranslation("DYNAFIELD_ALREADY_EXIST")); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get required variables in the SQL + * + * @param string $sql SQL + * + * return array Return an array with required variables in the SQL + */ + public function sqlGetRequiredVariables($sql) + { + try { + $arrayVariableRequired = array(); + + preg_match_all("/@[@%#\?\x24\=]([A-Za-z_]\w*)/", $sql, $arrayMatch, PREG_SET_ORDER); + + foreach ($arrayMatch as $value) { + $arrayVariableRequired[] = $value[1]; + } + + return $arrayVariableRequired; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Verify if some required variable in the SQL is missing in the variables + * + * @param string $variableName Variable name + * @param string $variableSql SQL + * @param array $arrayVariable The variables + * + * return void Throw exception if some required variable in the SQL is missing in the variables + */ + public function throwExceptionIfSomeRequiredVariableSqlIsMissingInVariables($variableName, $variableSql, array $arrayVariable) + { + try { + $arrayResult = array_diff(array_unique($this->sqlGetRequiredVariables($variableSql)), array_keys($arrayVariable)); + + if (count($arrayResult) > 0) { + throw new \Exception(\G::LoadTranslation("ID_PROCESS_VARIABLE_REQUIRED_VARIABLES_FOR_QUERY", array($variableName, implode(", ", $arrayResult)))); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Verify if does not exist the message in table MESSAGE + * + * @param string $messageUid Unique id of variable + * + * return void Throw exception if does not exist the message in table MESSAGE + */ + public function throwExceptionIfNotExistsMessage($messageUid) + { + try { + $obj = \MessagePeer::retrieveByPK($messageUid); + + if (is_null($obj)) { + throw new \Exception('mes_uid: '.$messageUid. ' '.\G::LoadTranslation("ID_DOES_NOT_EXIST")); + } + } catch (\Exception $e) { + throw $e; + } + } +} + diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Project/Message.php b/workflow/engine/src/ProcessMaker/Services/Api/Project/Message.php new file mode 100644 index 000000000..5c7d100b5 --- /dev/null +++ b/workflow/engine/src/ProcessMaker/Services/Api/Project/Message.php @@ -0,0 +1,111 @@ +getMessages($prj_uid); + + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * @url GET /:prj_uid/message/:mes_uid + * + * @param string $mes_uid {@min 32}{@max 32} + * @param string $prj_uid {@min 32}{@max 32} + */ + public function doGetMessage($mes_uid, $prj_uid) + { + try { + $message = new \ProcessMaker\BusinessModel\Message(); + + $response = $message->getMessage($prj_uid, $mes_uid); + + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * @url POST /:prj_uid/message + * + * @param string $prj_uid {@min 32}{@max 32} + * @param array $request_data + * + * @status 201 + */ + public function doPostMessage($prj_uid, $request_data) + { + try { + $request_data = (array)($request_data); + $message = new \ProcessMaker\BusinessModel\Message(); + + $arrayData = $message->create($prj_uid, $request_data); + + $response = $arrayData; + + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * @url PUT /:prj_uid/message/:mes_uid + * + * @param string $prj_uid {@min 32}{@max 32} + * @param string $mes_uid {@min 32}{@max 32} + * @param array $request_data + */ + public function doPutMessage($prj_uid, $mes_uid, array $request_data) + { + try { + $request_data = (array)($request_data); + $message = new \ProcessMaker\BusinessModel\Message(); + + $message->update($prj_uid, $mes_uid, $request_data); + + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * @url DELETE /:prj_uid/message/:mes_uid + * + * @param string $prj_uid {@min 32}{@max 32} + * @param string $mes_uid {@min 32}{@max 32} + */ + public function doDeleteMessage($prj_uid, $mes_uid) + { + try { + $message = new \ProcessMaker\BusinessModel\Message(); + + $message->delete($prj_uid, $mes_uid); + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } +} + diff --git a/workflow/engine/src/ProcessMaker/Services/api.ini b/workflow/engine/src/ProcessMaker/Services/api.ini index 54225a990..5f0dfbbb5 100644 --- a/workflow/engine/src/ProcessMaker/Services/api.ini +++ b/workflow/engine/src/ProcessMaker/Services/api.ini @@ -37,6 +37,7 @@ debug = 1 trigger-wizard = "ProcessMaker\Services\Api\Project\TriggerWizard" category = "ProcessMaker\Services\Api\ProcessCategory" process-variable = "ProcessMaker\Services\Api\Project\Variable" + message = "ProcessMaker\Services\Api\Project\Message" [alias: projects] project = "ProcessMaker\Services\Api\Project" @@ -92,4 +93,4 @@ debug = 1 email = "ProcessMaker\Services\Api\EmailServer" [alias: emails] - email = "ProcessMaker\Services\Api\EmailServer" \ No newline at end of file + email = "ProcessMaker\Services\Api\EmailServer" diff --git a/workflow/engine/xmlform/dynaforms/dynaforms_Properties.xml b/workflow/engine/xmlform/dynaforms/dynaforms_Properties.xml index 503644db5..15b117c1a 100755 --- a/workflow/engine/xmlform/dynaforms/dynaforms_Properties.xml +++ b/workflow/engine/xmlform/dynaforms/dynaforms_Properties.xml @@ -73,8 +73,34 @@ -