diff --git a/workflow/engine/classes/class.processes.php b/workflow/engine/classes/class.processes.php index 5d8eb46ea..435dd6fd2 100755 --- a/workflow/engine/classes/class.processes.php +++ b/workflow/engine/classes/class.processes.php @@ -202,6 +202,18 @@ class Processes return $oOutput->outputExists( $sUid ); } + /** + * verify if the object exists + * + * @param string $sUid + * @return boolean + */ + public function processVariableExists ($sUid = '') + { + $oProcessVariable = new ProcessVariables(); + return $oProcessVariable->ProcessVariableExists( $sUid ); + } + /** * verify if the object exists * @@ -638,6 +650,19 @@ class Processes } } + /** + * get an unused process variables GUID + * + * @return $sProUid + */ + public function getUnusedProcessVariableGUID () + { + do { + $sNewUid = G::generateUniqueID(); + } while ($this->processVariableExists( $sNewUid )); + return $sNewUid; + } + /** * change the GUID for a serialized process * @@ -2111,6 +2136,29 @@ class Processes } } + /** + * Renew all the unique id for "Process User" + * + * @param $data Object with the data + * + * return void + */ + public function renewAllProcessVariableUid(&$data) + { + try { + $map = array (); + foreach ($data->processVariables as $key => $val) { + if (isset( $val['VAR_UID'] )) { + $newGuid = $this->getUnusedProcessVariableGUID(); + $map[$val['VAR_UID']] = $newGuid; + $data->processVariables[$key]['VAR_UID'] = $newGuid; + } + } + + } catch (Exception $e) { + throw $e; + } + } /** * Renew the GUID's for all the Uids for all the elements * @@ -2140,6 +2188,7 @@ class Processes $this->renewAllEvent( $oData ); $this->renewAllCaseScheduler( $oData ); $this->renewAllProcessUserUid($oData); + $this->renewAllProcessVariableUid($oData); } /** diff --git a/workflow/engine/classes/model/ProcessVariables.php b/workflow/engine/classes/model/ProcessVariables.php old mode 100644 new mode 100755 index b473d619f..6d1f2a4a2 --- a/workflow/engine/classes/model/ProcessVariables.php +++ b/workflow/engine/classes/model/ProcessVariables.php @@ -64,4 +64,26 @@ class ProcessVariables extends BaseProcessVariables { throw($oError); } } + + /** + * verify if process variable row specified in [sUid] exists. + * + * @param string $sUid the uid + */ + public function ProcessVariableExists($sUid) + { + $con = Propel::getConnection(ProcessVariablesPeer::DATABASE_NAME); + + try { + $oObj = ProcessVariablesPeer::retrieveByPk($sUid); + + if (is_object($oObj) && get_class($oObj) == 'ProcessVariables') { + return true; + } else { + return false; + } + } catch (Exception $oError) { + throw ($oError); + } + } } // ProcessVariables