diff --git a/workflow/engine/classes/Cases.php b/workflow/engine/classes/Cases.php
index 8dae33f5a..fdcf97fde 100644
--- a/workflow/engine/classes/Cases.php
+++ b/workflow/engine/classes/Cases.php
@@ -1856,14 +1856,16 @@ class Cases
* This function updates a row in APP_DELEGATION
*
* @name closeAllDelegations
- * @param string $sAppUid
+ * @param string $appUid
+ *
* @return void
+ * @throws Exception
*/
- public function closeAllThreads($sAppUid)
+ public function closeAllThreads($appUid)
{
try {
$c = new Criteria();
- $c->add(AppThreadPeer::APP_UID, $sAppUid);
+ $c->add(AppThreadPeer::APP_UID, $appUid);
$c->add(AppThreadPeer::APP_THREAD_STATUS, 'OPEN');
$rowObj = AppThreadPeer::doSelect($c);
foreach ($rowObj as $appThread) {
@@ -1878,11 +1880,12 @@ class Cases
throw (new PropelException('The row cannot be created!', new PropelException($msg)));
}
}
- //update searchindex
+
+ /** Update search index */
if ($this->appSolr != null) {
- $this->appSolr->updateApplicationSearchIndex($sAppUid);
+ $this->appSolr->updateApplicationSearchIndex($appUid);
}
- } catch (exception $e) {
+ } catch (Exception $e) {
throw ($e);
}
}
@@ -1915,19 +1918,22 @@ class Cases
/**
* With this function we can change status to CLOSED in APP_DELEGATION
*
- * @name closeAllDelegations
- * @param string $sAppUid
- * @return
+ * @param string $appUid
+ *
+ * @return void
+ * @throws Exception
*/
- public function closeAllDelegations($sAppUid)
+ public function closeAllDelegations($appUid)
{
try {
- $c = new Criteria();
- $c->add(AppDelegationPeer::APP_UID, $sAppUid);
- $c->add(AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN');
- $rowObj = AppDelegationPeer::doSelect($c);
+ $criteria = new Criteria();
+ $criteria->add(AppDelegationPeer::APP_UID, $appUid);
+ $criteria->add(AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN');
+ $rowObj = AppDelegationPeer::doSelect($criteria);
+ $data = [];
foreach ($rowObj as $appDel) {
$appDel->setDelThreadStatus('CLOSED');
+ $appDel->setDelFinishDate('now');
if ($appDel->Validate()) {
$appDel->Save();
} else {
@@ -1937,12 +1943,31 @@ class Cases
}
throw (new PropelException('The row cannot be created!', new PropelException($msg)));
}
+
+ /*----------------------------------********---------------------------------*/
+ $delIndex = $appDel->getDelIndex();
+ $inbox = new ListInbox();
+ $inbox->remove($appUid, $delIndex);
+ $data['DEL_THREAD_STATUS'] = 'CLOSED';
+ $data['APP_UID'] = $appUid;
+ $data['DEL_INDEX'] = $delIndex;
+ $data['USR_UID'] = $appDel->getUsrUid();
+ $listParticipatedLast = new ListParticipatedLast();
+ $listParticipatedLast->refresh($data);
+ /*----------------------------------********---------------------------------*/
+
+ /** This case is subProcess? */
+ if (SubApplication::isCaseSubProcess($appUid)) {
+ $route = new Derivation();
+ $route->verifyIsCaseChild($appUid, $delIndex);
+ }
}
- //update searchindex
+
+ /** Update search index */
if ($this->appSolr != null) {
- $this->appSolr->updateApplicationSearchIndex($sAppUid);
+ $this->appSolr->updateApplicationSearchIndex($appUid);
}
- } catch (exception $e) {
+ } catch (Exception $e) {
throw ($e);
}
}
@@ -1950,18 +1975,19 @@ class Cases
/**
* With this we can change the status to CLOSED in APP_DELEGATION
*
- * @name CloseCurrentDelegation
- * @param string $sAppUid
- * @param string $iDelIndex
- * @return Fields
+ * @param string $appUid
+ * @param string $delIndex
+ *
+ * @return void
+ * @throws Exception
*/
- public function CloseCurrentDelegation($sAppUid, $iDelIndex)
+ public function CloseCurrentDelegation($appUid, $delIndex)
{
try {
- $c = new Criteria();
- $c->add(AppDelegationPeer::APP_UID, $sAppUid);
- $c->add(AppDelegationPeer::DEL_INDEX, $iDelIndex);
- $rowObj = AppDelegationPeer::doSelect($c);
+ $criteria = new Criteria();
+ $criteria->add(AppDelegationPeer::APP_UID, $appUid);
+ $criteria->add(AppDelegationPeer::DEL_INDEX, $delIndex);
+ $rowObj = AppDelegationPeer::doSelect($criteria);
$user = '';
foreach ($rowObj as $appDel) {
$appDel->setDelThreadStatus('CLOSED');
@@ -1977,17 +2003,30 @@ class Cases
throw (new PropelException('The row cannot be created!', new PropelException($msg)));
}
}
+
/*----------------------------------********---------------------------------*/
$inbox = new ListInbox();
- $inbox->remove($sAppUid, $iDelIndex);
+ $data = [];
+ $inbox->remove($appUid, $delIndex);
$data['DEL_THREAD_STATUS'] = 'CLOSED';
- $data['APP_UID'] = $sAppUid;
- $data['DEL_INDEX'] = $iDelIndex;
+ $data['APP_UID'] = $appUid;
+ $data['DEL_INDEX'] = $delIndex;
$data['USR_UID'] = $user;
$listParticipatedLast = new ListParticipatedLast();
$listParticipatedLast->refresh($data);
/*----------------------------------********---------------------------------*/
- } catch (exception $e) {
+
+ /** This case is subProcess? */
+ if (SubApplication::isCaseSubProcess($appUid)) {
+ $route = new Derivation();
+ $route->verifyIsCaseChild($appUid, $delIndex);
+ }
+
+ /** Update searchindex */
+ if ($this->appSolr != null) {
+ $this->appSolr->updateApplicationSearchIndex($appUid);
+ }
+ } catch (Exception $e) {
throw ($e);
}
}
@@ -4125,103 +4164,94 @@ class Cases
}
/**
- * cancel a case
+ * Cancel case without matter the threads
+ * if the force is true, we will cancel it does not matter the threads
+ * if the force is false, we will to cancel one thread
*
- * @name cancelCase
- * @param string $sApplicationUID
- * @param string $iIndex
- * @param string $user_logged
- * @return void
- */
- public function cancelCase($sApplicationUID, $iIndex, $user_logged)
+ * @param string $appUid
+ * @param integer $delIndex
+ * @param string $usrUid
+ *
+ * @return boolean|string
+ */
+ public function cancelCase($appUid, $delIndex = null, $usrUid = null)
{
- $this->getExecuteTriggerProcess($sApplicationUID, 'CANCELED');
+ /** Execute a trigger when a case is cancelled */
+ $this->getExecuteTriggerProcess($appUid, 'CANCELED');
- $oApplication = new Application();
- $aFields = $oApplication->load($sApplicationUID);
+ $caseFields = $this->loadCase($appUid);
+ $appStatusCurrent = $caseFields['APP_STATUS'];
- $appData = self::unserializeData($aFields['APP_DATA']);
- $appData = G::array_merges(G::getSystemConstants(), $appData);
+ /** Update the status CANCELLED in the tables related */
+ $caseFields['APP_STATUS'] = Application::APP_STATUS_CANCELLED;
+ $this->updateCase($appUid, $caseFields);
- $appStatusCurrent = $aFields['APP_STATUS'];
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID);
- $oCriteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL);
- $resAppDel = AppDelegationPeer::doCount($oCriteria);
-
- $this->CloseCurrentDelegation($sApplicationUID, $iIndex);
- if ($resAppDel == 1) {
- $aFields['APP_STATUS'] = 'CANCELLED';
- $oApplication->update($aFields);
-
- require_once 'classes/model/AdditionalTables.php';
- $oReportTables = new ReportTables();
- $addtionalTables = new additionalTables();
- $oReportTables->updateTables($aFields['PRO_UID'], $aFields['APP_UID'], $aFields['APP_NUMBER'], $appData);
- $addtionalTables->updateReportTables($aFields['PRO_UID'], $aFields['APP_UID'], $aFields['APP_NUMBER'], $appData, $aFields['APP_STATUS']);
- }
- $oAppDel = new AppDelegation();
- $oAppDel->Load($sApplicationUID, $iIndex);
- $aAppDel = $oAppDel->toArray(BasePeer::TYPE_FIELDNAME);
- $this->closeAppThread($sApplicationUID, $aAppDel['DEL_THREAD']);
+ /** Close the thread(s) in APP_DELEGATION and APP_THREAD */
+ $indexesClosed = self::closeCaseThreads($appUid, $delIndex);
+ /** Create a register in APP_DELAY */
$delay = new AppDelay();
- $array['PRO_UID'] = $aFields['PRO_UID'];
- $array['APP_UID'] = $sApplicationUID;
- $c = new Criteria('workflow');
- $c->clearSelectColumns();
- $c->addSelectColumn(AppThreadPeer::APP_THREAD_INDEX);
- $c->add(AppThreadPeer::APP_UID, $sApplicationUID);
- $c->add(AppThreadPeer::DEL_INDEX, $iIndex);
- $oDataset = AppThreadPeer::doSelectRS($c);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $aRow = $oDataset->getRow();
- $array['APP_THREAD_INDEX'] = $aRow['APP_THREAD_INDEX'];
- $array['APP_DEL_INDEX'] = $iIndex;
- $array['APP_TYPE'] = 'CANCEL';
+ foreach ($indexesClosed as $value){
+ $dataList = [];
+ $rowDelay = AppDelay::buildAppDelayRow(
+ $caseFields['PRO_UID'],
+ $caseFields['PRO_ID'],
+ $appUid,
+ $caseFields['APP_NUMBER'],
+ $value['DEL_INDEX'],
+ $value['DEL_THREAD'],
+ AppDelay::APP_TYPE_CANCEL,
+ Application::APP_STATUS_CANCELLED,
+ is_null($usrUid) ? '' : $usrUid
+ );
+ $delay->create($rowDelay);
- $c = new Criteria('workflow');
- $c->clearSelectColumns();
- $c->addSelectColumn(ApplicationPeer::APP_STATUS);
- $c->add(ApplicationPeer::APP_UID, $sApplicationUID);
- $oDataset = ApplicationPeer::doSelectRS($c);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $aRow1 = $oDataset->getRow();
- $array['APP_STATUS'] = $aRow1['APP_STATUS'];
+ /*----------------------------------********---------------------------------*/
+ $dataList = [
+ 'APP_UID' => $appUid,
+ 'DEL_INDEX' => $value['DEL_INDEX'],
+ 'USR_UID' => $rowDelay['APP_DELEGATION_USER'],
+ 'APP_STATUS_CURRENT' => $appStatusCurrent
+ ];
- $array['APP_DELEGATION_USER'] = $user_logged;
- $array['APP_ENABLE_ACTION_USER'] = $user_logged;
- $array['APP_ENABLE_ACTION_DATE'] = date('Y-m-d H:i:s');
- $array['APP_NUMBER'] = $oApplication->getAppNumber();
- $delay->create($array);
+ $dataList = array_merge($caseFields, $dataList);
+ $listCanceled = new ListCanceled();
+ $listCanceled->create($dataList);
+ /*----------------------------------********---------------------------------*/
+ }
+ }
- //Before cancel a case verify if is a child case
- $oCriteria2 = new Criteria('workflow');
- $oCriteria2->add(SubApplicationPeer::APP_UID, $sApplicationUID);
- $oCriteria2->add(SubApplicationPeer::SA_STATUS, 'ACTIVE');
- if (SubApplicationPeer::doCount($oCriteria2) > 0) {
- $oDerivation = new Derivation();
- $oDerivation->verifyIsCaseChild($sApplicationUID, $iIndex);
+ /**
+ * This function will be close the one or all threads
+ *
+ * @param string $appUid
+ * @param integer $delIndex, if is null we will to close all threads
+ *
+ * @return array
+ */
+ private function closeCaseThreads($appUid, $delIndex = null)
+ {
+ $delegation = new AppDelegation();
+ $result = [];
+
+ /** Close all the threads in APP_DELEGATION and APP_THREAD */
+ if (is_null($delIndex)) {
+ /*----------------------------------********---------------------------------*/
+ $result = $delegation->LoadParallel($appUid);
+ $this->closeAllDelegations($appUid);
+ $this->closeAllThreads($appUid);
+ /*----------------------------------********---------------------------------*/
+
+ } else {
+ /** Close the specific delIndex in APP_DELEGATION and APP_THREAD */
+ $this->CloseCurrentDelegation($appUid, $delIndex);
+ $resultDelegation = $delegation->Load($appUid, $delIndex);
+ $this->closeAppThread($appUid, $result['DEL_THREAD']);
+ $result[] = $resultDelegation;
}
- //update searchindex
- if ($this->appSolr != null) {
- $this->appSolr->updateApplicationSearchIndex($sApplicationUID);
- }
- /*----------------------------------********---------------------------------*/
- $data = array(
- 'APP_UID' => $sApplicationUID,
- 'DEL_INDEX' => $iIndex,
- 'USR_UID' => $user_logged,
- 'APP_STATUS_CURRENT' => $appStatusCurrent
- );
- $data = array_merge($aFields, $data);
- $oListCanceled = new ListCanceled();
- $oListCanceled->create($data);
- /*----------------------------------********---------------------------------*/
+ return $result;
}
/**
diff --git a/workflow/engine/classes/WsBase.php b/workflow/engine/classes/WsBase.php
index e8bfade79..1a89fd6fa 100644
--- a/workflow/engine/classes/WsBase.php
+++ b/workflow/engine/classes/WsBase.php
@@ -2939,7 +2939,6 @@ class WsBase
}
$result = new WsResponse(0, G::loadTranslation('ID_COMMAND_EXECUTED_SUCCESSFULLY'));
-
$g->sessionVarRestore();
return $result;
@@ -3066,14 +3065,7 @@ class WsBase
$case->removeCase($caseUid);
//Response
- $res = new WsResponse(0, G::LoadTranslation("ID_COMMAND_EXECUTED_SUCCESSFULLY"));
-
- $result = array(
- "status_code" => $res->status_code,
- "message" => $res->message,
- "timestamp" => $res->timestamp
- );
-
+ $result = self::messageExecuteSuccessfully();
$g->sessionVarRestore();
return $result;
@@ -3093,7 +3085,7 @@ class WsBase
* @param int delIndex : Delegation index of the case.
* @param string userUid : The unique ID of the user who will cancel the case.
*
- * @return $result will return an object
+ * @return array | object
*/
public function cancelCase($caseUid, $delIndex, $userUid)
{
@@ -3107,62 +3099,68 @@ class WsBase
$_SESSION["USER_LOGGED"] = $userUid;
if (empty($caseUid)) {
- $result = new WsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " caseUid");
-
$g->sessionVarRestore();
- return $result;
- }
-
- if (empty($delIndex)) {
- $result = new WsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " delIndex");
-
- $g->sessionVarRestore();
-
- return $result;
- }
-
- if (empty($userUid)) {
- $result = new WsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " userUid");
-
- $g->sessionVarRestore();
-
- return $result;
- }
-
- $oApplication = new Application();
- $aFields = $oApplication->load($caseUid);
- if ($aFields['APP_STATUS'] == 'DRAFT') {
- $result = new WsResponse(100, G::LoadTranslation("ID_CASE_IN_STATUS") . " DRAFT");
- $g->sessionVarRestore();
- return $result;
- }
- $oAppThread = new AppThread();
- $cant = $oAppThread->countStatus($caseUid, 'OPEN');
- if ($cant > 1) {
- $result = new WsResponse(100, G::LoadTranslation("ID_CASE_CANCELLED_PARALLEL"));
- $g->sessionVarRestore();
- return $result;
+ return self::messageRequiredField('caseUid');
}
$case = new Cases();
- $case->cancelCase($caseUid, $delIndex, $userUid);
+ $statusCase = $case->loadCase($caseUid)['APP_STATUS'];
+ if ($statusCase !== 'TO_DO') {
+ $g->sessionVarRestore();
- //Response
- $res = new WsResponse(0, G::LoadTranslation("ID_COMMAND_EXECUTED_SUCCESSFULLY"));
+ return self::messageIllegalValues('ID_CASE_IN_STATUS', ' ' . $statusCase);
+ }
- $result = array(
- "status_code" => $res->status_code,
- "message" => $res->message,
- "timestamp" => $res->timestamp
- );
+ /** If those parameters are null we will to force the cancelCase */
+ if (is_null($delIndex) && is_null($userUid)) {
+ /*----------------------------------********---------------------------------*/
+ $case->cancelCase($caseUid, null, null);
+ $result = self::messageExecuteSuccessfully();
+ $g->sessionVarRestore();
+ return $result;
+ /*----------------------------------********---------------------------------*/
+ }
+
+ /** We will to continue with review the threads */
+ if (empty($delIndex)) {
+ $g->sessionVarRestore();
+
+ return self::messageRequiredField('delIndex');
+ }
+
+ $delegation = new AppDelegation();
+ $indexOpen = $delegation->LoadParallel($caseUid, $delIndex);
+ if (empty($indexOpen)) {
+ $g->sessionVarRestore();
+
+ return self::messageIllegalValues('ID_CASE_DELEGATION_ALREADY_CLOSED');
+ }
+
+ if (empty($userUid)) {
+ $g->sessionVarRestore();
+
+ return self::messageRequiredField('userUid');
+ }
+
+ if (AppThread::countStatus($caseUid, 'OPEN') > 1) {
+ $g->sessionVarRestore();
+
+ return self::messageIllegalValues("ID_CASE_CANCELLED_PARALLEL");
+ }
+
+
+ /** Cancel case */
+ $case->cancelCase($caseUid, (int)$delIndex, $userUid);
+
+ //Define the result of the cancelCase
+ $result = self::messageExecuteSuccessfully();
$g->sessionVarRestore();
return $result;
} catch (Exception $e) {
$result = new WsResponse(100, $e->getMessage());
-
$g->sessionVarRestore();
return $result;
@@ -3228,15 +3226,9 @@ class WsBase
$case->pauseCase($caseUid, $delIndex, $userUid, $unpauseDate);
//Response
- $res = new WsResponse(0, G::LoadTranslation("ID_COMMAND_EXECUTED_SUCCESSFULLY"));
-
- $result = array(
- "status_code" => $res->status_code,
- "message" => $res->message,
- "timestamp" => $res->timestamp
- );
-
+ $result = self::messageExecuteSuccessfully();
$g->sessionVarRestore();
+
return $result;
} catch (Exception $e) {
$result = new WsResponse(100, $e->getMessage());
@@ -3295,14 +3287,7 @@ class WsBase
$case->unpauseCase($caseUid, $delIndex, $userUid);
//Response
- $res = new WsResponse(0, G::LoadTranslation("ID_COMMAND_EXECUTED_SUCCESSFULLY"));
-
- $result = array(
- "status_code" => $res->status_code,
- "message" => $res->message,
- "timestamp" => $res->timestamp
- );
-
+ $result = self::messageExecuteSuccessfully();
$g->sessionVarRestore();
return $result;
@@ -3409,4 +3394,52 @@ class WsBase
return $result;
}
}
+
+ /**
+ * Define the message for the required fields
+ *
+ * @param string $field
+ * @param integer code
+ *
+ * @return object
+ */
+ private function messageRequiredField($field, $code = 100)
+ {
+ $result = new WsResponse($code, G::LoadTranslation("ID_REQUIRED_FIELD") . ' ' . $field);
+
+ return $result;
+ }
+
+ /**
+ * Define the message for the required fields
+ *
+ * @param string $translationId
+ * @param string $field
+ * @param integer code
+ *
+ * @return object
+ */
+ private function messageIllegalValues($translationId, $field = '', $code = 100)
+ {
+ $result = new WsResponse($code, G::LoadTranslation($translationId) . $field);
+
+ return $result;
+ }
+
+ /**
+ * Define the result when it's execute successfully
+ *
+ * @return object
+ */
+ private function messageExecuteSuccessfully()
+ {
+ $res = new WsResponse(0, G::LoadTranslation("ID_COMMAND_EXECUTED_SUCCESSFULLY"));
+ $result = [
+ "status_code" => $res->status_code,
+ "message" => $res->message,
+ "timestamp" => $res->timestamp
+ ];
+
+ return $result;
+ }
}
diff --git a/workflow/engine/classes/class.pmFunctions.php b/workflow/engine/classes/class.pmFunctions.php
index 67b9410c3..91aab7488 100644
--- a/workflow/engine/classes/class.pmFunctions.php
+++ b/workflow/engine/classes/class.pmFunctions.php
@@ -2766,7 +2766,7 @@ function PMFDeleteCase ($caseUid)
function PMFCancelCase ($caseUid, $delIndex, $userUid)
{
$ws = new WsBase();
- $result = $ws->cancelCase( $caseUid, $delIndex, $userUid );
+ $result = $ws->cancelCase($caseUid, $delIndex, $userUid);
if ($result->status_code == 0) {
if (isset($_SESSION['APPLICATION']) && isset($_SESSION['INDEX'])) {
@@ -2775,10 +2775,17 @@ function PMFCancelCase ($caseUid, $delIndex, $userUid)
G::header('Location: ../cases/casesListExtJsRedirector');
die();
} else {
- die(G::LoadTranslation('ID_PM_FUNCTION_CHANGE_CASE', SYS_LANG, array('PMFCancelCase', G::LoadTranslation('ID_CANCELLED'))));
+ die(
+ G::LoadTranslation(
+ 'ID_PM_FUNCTION_CHANGE_CASE',
+ SYS_LANG,
+ ['PMFCancelCase', G::LoadTranslation('ID_CANCELLED')]
+ )
+ );
}
}
}
+
return 1;
} else {
return 0;
diff --git a/workflow/engine/classes/model/AppDelay.php b/workflow/engine/classes/model/AppDelay.php
index d2aa9dc85..ab249d325 100644
--- a/workflow/engine/classes/model/AppDelay.php
+++ b/workflow/engine/classes/model/AppDelay.php
@@ -1,12 +1,4 @@
fromArray($aData, BasePeer::TYPE_FIELDNAME);
- if ($oAppDelay->validate()) {
- $oConnection->begin();
- $iResult = $oAppDelay->save();
- $oConnection->commit();
- return $aData['APP_DELAY_UID'];
+ $appDelay = new AppDelay();
+ $appDelay->fromArray($data, BasePeer::TYPE_FIELDNAME);
+ if ($appDelay->validate()) {
+ $connection->begin();
+ $result = $appDelay->save();
+ $connection->commit();
+
+ return $data['APP_DELAY_UID'];
} else {
- $sMessage = '';
- $aValidationFailures = $oAppDelay->getValidationFailures();
- foreach ($aValidationFailures as $oValidationFailure) {
- $sMessage .= $oValidationFailure->getMessage() . '
';
+ $message = '';
+ $validationFailures = $appDelay->getValidationFailures();
+ foreach ($validationFailures as $validationFailure) {
+ $message .= $validationFailure->getMessage() . '
';
}
- throw(new Exception('The registry cannot be created!
'.$sMessage));
+ throw(new Exception('The registry cannot be created!
' . $message));
}
- } catch (Exception $oError) {
- $oConnection->rollback();
- throw($oError);
+ } catch (Exception $error) {
+ $connection->rollback();
+ throw($error);
}
}
/**
* Update the application delay registry
- * @param array $aData
+ *
+ * @param array $data
+ *
* @return string
+ * @throws Exception
**/
- public function update($aData)
+ public function update($data)
{
- $oConnection = Propel::getConnection(AppDelayPeer::DATABASE_NAME);
+ $connection = Propel::getConnection(AppDelayPeer::DATABASE_NAME);
try {
- $oAppDelay = AppDelayPeer::retrieveByPK($aData['APP_DELAY_UID']);
- if (!is_null($oAppDelay)) {
- $oAppDelay->fromArray($aData, BasePeer::TYPE_FIELDNAME);
- if ($oAppDelay->validate()) {
- $oConnection->begin();
- $iResult = $oAppDelay->save();
- $oConnection->commit();
- return $iResult;
+ $appDelay = AppDelayPeer::retrieveByPK($data['APP_DELAY_UID']);
+ if (!is_null($appDelay)) {
+ $appDelay->fromArray($data, BasePeer::TYPE_FIELDNAME);
+ if ($appDelay->validate()) {
+ $connection->begin();
+ $result = $appDelay->save();
+ $connection->commit();
+ return $result;
} else {
- $sMessage = '';
- $aValidationFailures = $oAppDelay->getValidationFailures();
- foreach ($aValidationFailures as $oValidationFailure) {
- $sMessage .= $oValidationFailure->getMessage() . '
';
+ $message = '';
+ $validationFailures = $appDelay->getValidationFailures();
+ foreach ($validationFailures as $validationFailure) {
+ $message .= $validationFailure->getMessage() . '
';
}
- throw(new Exception('The registry cannot be updated!
'.$sMessage));
+ throw(new Exception('The registry cannot be updated!
'.$message));
}
} else {
throw(new Exception('This row doesn\'t exist!'));
}
- } catch (Exception $oError) {
- $oConnection->rollback();
- throw($oError);
+ } catch (Exception $error) {
+ $connection->rollback();
+ throw($error);
}
}
+ /**
+ * Review if the application in a specific index is paused
+ *
+ * @param string $appUid
+ * @param integer $delIndex
+ *
+ * @return boolean
+ */
public function isPaused($appUid, $delIndex)
{
- $oCriteria = new Criteria('workflow');
- $oCriteria->add(AppDelayPeer::APP_UID, $appUid);
- $oCriteria->add(AppDelayPeer::APP_DEL_INDEX, $delIndex);
- $oCriteria->add(AppDelayPeer::APP_TYPE, 'PAUSE');
- $oCriteria->add(
- $oCriteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, 0, Criteria::EQUAL)->addOr(
- $oCriteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, null, Criteria::ISNULL))
+ $criteria = new Criteria('workflow');
+ $criteria->add(AppDelayPeer::APP_UID, $appUid);
+ $criteria->add(AppDelayPeer::APP_DEL_INDEX, $delIndex);
+ $criteria->add(AppDelayPeer::APP_TYPE, AppDelay::APP_TYPE_PAUSE);
+ $criteria->add(
+ $criteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, 0, Criteria::EQUAL)->addOr(
+ $criteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, null, Criteria::ISNULL))
);
- $oDataset = AppDelayPeer::doSelectRS($oCriteria);
- $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- $oDataset->next();
- $aRow = $oDataset->getRow();
+ $dataset = AppDelayPeer::doSelectRS($criteria);
+ $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $dataset->next();
+ $row = $dataset->getRow();
- if ($aRow) {
+ if ($row) {
return true;
} else {
return false;
@@ -117,20 +127,74 @@ class AppDelay extends BaseAppDelay
* Verify if the case is Paused or cancelled
*
* @param $appUid string
- * @return $oDataset array
+ *
+ * @return array|null
*/
public function getCasesCancelOrPaused($appUid)
{
- $oCriteria = new Criteria( 'workflow' );
- $oCriteria->addSelectColumn( AppDelayPeer::APP_UID );
- $oCriteria->addSelectColumn( AppDelayPeer::APP_DEL_INDEX );
- $oCriteria->add( AppDelayPeer::APP_UID, $appUid );
- $oCriteria->add( $oCriteria->getNewCriterion( AppDelayPeer::APP_TYPE, 'PAUSE' )->addOr( $oCriteria->getNewCriterion( AppDelayPeer::APP_TYPE, 'CANCEL' ) ) );
- $oCriteria->addAscendingOrderByColumn( AppDelayPeer::APP_ENABLE_ACTION_DATE );
- $oDataset = AppDelayPeer::doSelectRS( $oCriteria );
- $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
- $oDataset->next();
- return $oDataset->getRow();
+ $criteria = new Criteria('workflow');
+ $criteria->addSelectColumn(AppDelayPeer::APP_UID);
+ $criteria->addSelectColumn(AppDelayPeer::APP_DEL_INDEX);
+ $criteria->add(AppDelayPeer::APP_UID, $appUid);
+ $criteria->add(
+ $criteria->getNewCriterion(AppDelayPeer::APP_TYPE, AppDelay::APP_TYPE_PAUSE)->addOr(
+ $criteria->getNewCriterion(AppDelayPeer::APP_TYPE, AppDelay::APP_TYPE_CANCEL)
+ )
+ );
+ $criteria->addAscendingOrderByColumn(AppDelayPeer::APP_ENABLE_ACTION_DATE);
+ $dataset = AppDelayPeer::doSelectRS($criteria);
+ $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $dataset->next();
+
+ return $dataset->getRow();
+ }
+
+ /**
+ * Build the row for the appDelay to be inserted
+ *
+ * @param string $proUid
+ * @param integer $proId
+ * @param string $appUid
+ * @param integer $appNumber
+ * @param integer $appThreadIndex
+ * @param integer $delIndex
+ * @param string $appType
+ * @param string $appStatus
+ * @param string $usrUid
+ *
+ * @return array
+ */
+ public static function buildAppDelayRow(
+ $proUid = '',
+ $proId = 0,
+ $appUid = '',
+ $appNumber = 0,
+ $appThreadIndex = 0,
+ $delIndex = 0,
+ $appType = 'CANCEL',
+ $appStatus = 'CANCELLED',
+ $usrUid = ''
+ ) {
+ $row = [];
+ $row['PRO_UID'] = $proUid;
+ $row['PRO_ID'] = $proId;
+ $row['APP_UID'] = $appUid;
+ $row['APP_NUMBER'] = $appNumber;
+ $row['APP_THREAD_INDEX'] = $appThreadIndex;
+ $row['APP_DEL_INDEX'] = $delIndex;
+ $row['APP_TYPE'] = $appType;
+ $row['APP_STATUS'] = $appStatus;
+ $row['APP_ENABLE_ACTION_DATE'] = date('Y-m-d H:i:s');
+
+ //Define the user that execute the insert
+ if (empty($usrUid)) {
+ global $RBAC;
+ $usrUid = $RBAC->aUserInfo['USER_INFO']['USR_UID'];
+ }
+ $row['APP_DELEGATION_USER'] = $usrUid;
+ $row['APP_ENABLE_ACTION_USER'] = $usrUid;
+
+ return $row;
}
}
diff --git a/workflow/engine/classes/model/AppDelegation.php b/workflow/engine/classes/model/AppDelegation.php
index 89e9d892a..25b3c708b 100644
--- a/workflow/engine/classes/model/AppDelegation.php
+++ b/workflow/engine/classes/model/AppDelegation.php
@@ -331,16 +331,17 @@ class AppDelegation extends BaseAppDelegation
}
}
- /* Load the Application Delegation row specified in [app_id] column value.
+ /**
+ * Load the Application Delegation row specified in [app_id] column value.
+ *
+ * @param string $appUid the uid of the application
+ * @param integer $index the index of the delegation
*
- * @param string $AppUid the uid of the application
- * @param string $index the index of the delegation
* @return array $Fields the fields
*/
-
- public function LoadParallel($AppUid, $index = "")
+ public function LoadParallel($appUid, $index = 0)
{
- $aCases = array();
+ $cases = [];
$c = new Criteria('workflow');
$c->addSelectColumn(AppDelegationPeer::APP_UID);
@@ -348,41 +349,33 @@ class AppDelegation extends BaseAppDelegation
$c->addSelectColumn(AppDelegationPeer::PRO_UID);
$c->addSelectColumn(AppDelegationPeer::TAS_UID);
$c->addSelectColumn(AppDelegationPeer::USR_UID);
+ $c->addSelectColumn(AppDelegationPeer::DEL_THREAD);
$c->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
$c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE);
$c->addSelectColumn(AppDelegationPeer::DEL_TASK_DUE_DATE);
$c->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
$c->addSelectColumn(AppDelegationPeer::DEL_PREVIOUS);
-
$c->add(AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN');
- $c->add(AppDelegationPeer::APP_UID, $AppUid);
- if (!empty($index)) {
+ $c->add(AppDelegationPeer::APP_UID, $appUid);
+
+ if ($index > 0) {
$c->add(AppDelegationPeer::DEL_INDEX, $index);
}
+
$c->addDescendingOrderByColumn(AppDelegationPeer::DEL_INDEX);
$rs = AppDelegationPeer::doSelectRS($c);
- $row= $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ $row = $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$rs->next();
$row = $rs->getRow();
while (is_array($row)) {
- $case = array();
- $case['TAS_UID'] = $row['TAS_UID'];
- $case['USR_UID'] = $row['USR_UID'];
- $case['DEL_INDEX'] = $row['DEL_INDEX'];
- $case['TAS_UID'] = $row['TAS_UID'];
- $case['DEL_DELEGATE_DATE'] = $row['DEL_DELEGATE_DATE'];
- $case['DEL_INIT_DATE'] = $row['DEL_INIT_DATE'];
- $case['DEL_TASK_DUE_DATE'] = $row['DEL_TASK_DUE_DATE'];
- $case['DEL_FINISH_DATE'] = $row['DEL_FINISH_DATE'];
- $case['DEL_PREVIOUS'] = $row['DEL_PREVIOUS'];
- $aCases[] = $case;
+ $cases[] = $row;
$rs->next();
$row = $rs->getRow();
}
- return $aCases;
+ return $cases;
}
/**
diff --git a/workflow/engine/classes/model/AppThread.php b/workflow/engine/classes/model/AppThread.php
index fe9cf57ae..94fc2d7ee 100644
--- a/workflow/engine/classes/model/AppThread.php
+++ b/workflow/engine/classes/model/AppThread.php
@@ -115,13 +115,23 @@ class AppThread extends BaseAppThread
}
}
- public function countStatus($appUid, $status='OPEN'){
+ /**
+ * Count the open threads
+ *
+ * @param string $appUid
+ * @param string $status
+ *
+ * @return integer
+ */
+ public static function countStatus($appUid, $status = 'OPEN')
+ {
$c = new Criteria('workflow');
$c->clearSelectColumns();
- $c->addSelectColumn( AppThreadPeer::APP_THREAD_PARENT );
- $c->add(AppThreadPeer::APP_UID, $appUid );
- $c->add(AppThreadPeer::APP_THREAD_STATUS , $status );
+ $c->addSelectColumn(AppThreadPeer::APP_THREAD_PARENT);
+ $c->add(AppThreadPeer::APP_UID, $appUid);
+ $c->add(AppThreadPeer::APP_THREAD_STATUS, $status);
$cant = AppThreadPeer::doCount($c);
+
return $cant;
}
}
diff --git a/workflow/engine/classes/model/Application.php b/workflow/engine/classes/model/Application.php
index aca145a31..7f070355d 100644
--- a/workflow/engine/classes/model/Application.php
+++ b/workflow/engine/classes/model/Application.php
@@ -46,9 +46,10 @@ class Application extends BaseApplication
* This value goes in the content table
* @var string
*/
+ const APP_STATUS_CANCELLED = 'CANCELLED';
+ public static $app_status_values = ['DRAFT' => 1, 'TO_DO' => 2, 'COMPLETED' => 3, 'CANCELLED' => 4];
protected $app_title_content = '';
protected $app_description_content = '';
- public static $app_status_values = ['DRAFT' => 1, 'TO_DO' => 2, 'COMPLETED' => 3, 'CANCELLED' => 4];
/**
* Get the [app_title_content] column value.
diff --git a/workflow/engine/classes/model/ListCanceled.php b/workflow/engine/classes/model/ListCanceled.php
index 317f6feb8..f3e318d0d 100644
--- a/workflow/engine/classes/model/ListCanceled.php
+++ b/workflow/engine/classes/model/ListCanceled.php
@@ -2,29 +2,17 @@
require_once 'classes/model/om/BaseListCanceled.php';
-
-/**
- * Skeleton subclass for representing a row from the 'LIST_CANCELED' table.
- *
- *
- *
- * You should add additional methods to this class to meet the
- * application requirements. This class will only be generated as
- * long as it does not already exist in the output directory.
- *
- * @package classes.model
- */
-// @codingStandardsIgnoreStart
class ListCanceled extends BaseListCanceled implements ListInterface
{
use ListBaseTrait;
- // @codingStandardsIgnoreEnd
/**
* Create List Canceled Table
*
- * @param type $data
- * @return type
+ * @param array $data
+ *
+ * @return void
+ * @throws Exception
*
*/
public function create($data)
@@ -182,16 +170,17 @@ class ListCanceled extends BaseListCanceled implements ListInterface
/**
* Remove List Canceled
*
- * @param type $seqName
- * @return type
- * @throws type
+ * @param string $appUid
+ *
+ * @return void
+ * @throws Exception
*
*/
- public function remove($app_uid)
+ public function remove($appUid)
{
$con = Propel::getConnection(ListCanceledPeer::DATABASE_NAME);
try {
- $this->setAppUid($app_uid);
+ $this->setAppUid($appUid);
$con->begin();
$this->delete();
$con->commit();
@@ -351,4 +340,5 @@ class ListCanceled extends BaseListCanceled implements ListInterface
return $this->getCountListFromPeer
(ListCanceledPeer::class, $usrUid, $filters);
}
+
} // ListCanceled
diff --git a/workflow/engine/classes/model/SubApplication.php b/workflow/engine/classes/model/SubApplication.php
index 50d824472..5043fe883 100644
--- a/workflow/engine/classes/model/SubApplication.php
+++ b/workflow/engine/classes/model/SubApplication.php
@@ -111,5 +111,22 @@ class SubApplication extends BaseSubApplication
}
return false;
}
+
+ /**
+ * Verify if is a case related to the subProcess
+ *
+ * @param string $appUid
+ *
+ * @return boolean
+ */
+ public static function isCaseSubProcess($appUid)
+ {
+ $criteria = new Criteria('workflow');
+ $criteria->add(SubApplicationPeer::APP_UID, $appUid);
+ $criteria->add(SubApplicationPeer::SA_STATUS, 'ACTIVE');
+ $dataset = SubApplicationPeer::doSelectOne($criteria);
+
+ return !is_null($dataset);
+ }
}
diff --git a/workflow/engine/classes/model/map/ListCanceledMapBuilder.php b/workflow/engine/classes/model/map/ListCanceledMapBuilder.php
index 27c1b357b..944cb4c1c 100644
--- a/workflow/engine/classes/model/map/ListCanceledMapBuilder.php
+++ b/workflow/engine/classes/model/map/ListCanceledMapBuilder.php
@@ -67,6 +67,8 @@ class ListCanceledMapBuilder
$tMap->addPrimaryKey('APP_UID', 'AppUid', 'string', CreoleTypes::VARCHAR, true, 32);
+ $tMap->addPrimaryKey('DEL_INDEX', 'DelIndex', 'int', CreoleTypes::INTEGER, true, null);
+
$tMap->addColumn('USR_UID', 'UsrUid', 'string', CreoleTypes::VARCHAR, true, 32);
$tMap->addColumn('TAS_UID', 'TasUid', 'string', CreoleTypes::VARCHAR, true, 32);
@@ -83,8 +85,6 @@ class ListCanceledMapBuilder
$tMap->addColumn('APP_CANCELED_DATE', 'AppCanceledDate', 'int', CreoleTypes::TIMESTAMP, false, null);
- $tMap->addColumn('DEL_INDEX', 'DelIndex', 'int', CreoleTypes::INTEGER, true, null);
-
$tMap->addColumn('DEL_PREVIOUS_USR_UID', 'DelPreviousUsrUid', 'string', CreoleTypes::VARCHAR, false, 32);
$tMap->addColumn('DEL_CURRENT_USR_USERNAME', 'DelCurrentUsrUsername', 'string', CreoleTypes::VARCHAR, false, 100);
diff --git a/workflow/engine/classes/model/om/BaseListCanceled.php b/workflow/engine/classes/model/om/BaseListCanceled.php
index 255a578cf..cd7557417 100644
--- a/workflow/engine/classes/model/om/BaseListCanceled.php
+++ b/workflow/engine/classes/model/om/BaseListCanceled.php
@@ -33,6 +33,12 @@ abstract class BaseListCanceled extends BaseObject implements Persistent
*/
protected $app_uid = '';
+ /**
+ * The value for the del_index field.
+ * @var int
+ */
+ protected $del_index = 0;
+
/**
* The value for the usr_uid field.
* @var string
@@ -81,12 +87,6 @@ abstract class BaseListCanceled extends BaseObject implements Persistent
*/
protected $app_canceled_date;
- /**
- * The value for the del_index field.
- * @var int
- */
- protected $del_index = 0;
-
/**
* The value for the del_previous_usr_uid field.
* @var string
@@ -178,6 +178,17 @@ abstract class BaseListCanceled extends BaseObject implements Persistent
return $this->app_uid;
}
+ /**
+ * Get the [del_index] column value.
+ *
+ * @return int
+ */
+ public function getDelIndex()
+ {
+
+ return $this->del_index;
+ }
+
/**
* Get the [usr_uid] column value.
*
@@ -287,17 +298,6 @@ abstract class BaseListCanceled extends BaseObject implements Persistent
}
}
- /**
- * Get the [del_index] column value.
- *
- * @return int
- */
- public function getDelIndex()
- {
-
- return $this->del_index;
- }
-
/**
* Get the [del_previous_usr_uid] column value.
*
@@ -504,6 +504,28 @@ abstract class BaseListCanceled extends BaseObject implements Persistent
} // setAppUid()
+ /**
+ * Set the value of [del_index] column.
+ *
+ * @param int $v new value
+ * @return void
+ */
+ public function setDelIndex($v)
+ {
+
+ // Since the native PHP type for this column is integer,
+ // we will cast the input value to an int (if it is not).
+ if ($v !== null && !is_int($v) && is_numeric($v)) {
+ $v = (int) $v;
+ }
+
+ if ($this->del_index !== $v || $v === 0) {
+ $this->del_index = $v;
+ $this->modifiedColumns[] = ListCanceledPeer::DEL_INDEX;
+ }
+
+ } // setDelIndex()
+
/**
* Set the value of [usr_uid] column.
*
@@ -687,28 +709,6 @@ abstract class BaseListCanceled extends BaseObject implements Persistent
} // setAppCanceledDate()
- /**
- * Set the value of [del_index] column.
- *
- * @param int $v new value
- * @return void
- */
- public function setDelIndex($v)
- {
-
- // Since the native PHP type for this column is integer,
- // we will cast the input value to an int (if it is not).
- if ($v !== null && !is_int($v) && is_numeric($v)) {
- $v = (int) $v;
- }
-
- if ($this->del_index !== $v || $v === 0) {
- $this->del_index = $v;
- $this->modifiedColumns[] = ListCanceledPeer::DEL_INDEX;
- }
-
- } // setDelIndex()
-
/**
* Set the value of [del_previous_usr_uid] column.
*
@@ -991,23 +991,23 @@ abstract class BaseListCanceled extends BaseObject implements Persistent
$this->app_uid = $rs->getString($startcol + 0);
- $this->usr_uid = $rs->getString($startcol + 1);
+ $this->del_index = $rs->getInt($startcol + 1);
- $this->tas_uid = $rs->getString($startcol + 2);
+ $this->usr_uid = $rs->getString($startcol + 2);
- $this->pro_uid = $rs->getString($startcol + 3);
+ $this->tas_uid = $rs->getString($startcol + 3);
- $this->app_number = $rs->getInt($startcol + 4);
+ $this->pro_uid = $rs->getString($startcol + 4);
- $this->app_title = $rs->getString($startcol + 5);
+ $this->app_number = $rs->getInt($startcol + 5);
- $this->app_pro_title = $rs->getString($startcol + 6);
+ $this->app_title = $rs->getString($startcol + 6);
- $this->app_tas_title = $rs->getString($startcol + 7);
+ $this->app_pro_title = $rs->getString($startcol + 7);
- $this->app_canceled_date = $rs->getTimestamp($startcol + 8, null);
+ $this->app_tas_title = $rs->getString($startcol + 8);
- $this->del_index = $rs->getInt($startcol + 9);
+ $this->app_canceled_date = $rs->getTimestamp($startcol + 9, null);
$this->del_previous_usr_uid = $rs->getString($startcol + 10);
@@ -1244,31 +1244,31 @@ abstract class BaseListCanceled extends BaseObject implements Persistent
return $this->getAppUid();
break;
case 1:
- return $this->getUsrUid();
+ return $this->getDelIndex();
break;
case 2:
- return $this->getTasUid();
+ return $this->getUsrUid();
break;
case 3:
- return $this->getProUid();
+ return $this->getTasUid();
break;
case 4:
- return $this->getAppNumber();
+ return $this->getProUid();
break;
case 5:
- return $this->getAppTitle();
+ return $this->getAppNumber();
break;
case 6:
- return $this->getAppProTitle();
+ return $this->getAppTitle();
break;
case 7:
- return $this->getAppTasTitle();
+ return $this->getAppProTitle();
break;
case 8:
- return $this->getAppCanceledDate();
+ return $this->getAppTasTitle();
break;
case 9:
- return $this->getDelIndex();
+ return $this->getAppCanceledDate();
break;
case 10:
return $this->getDelPreviousUsrUid();
@@ -1324,15 +1324,15 @@ abstract class BaseListCanceled extends BaseObject implements Persistent
$keys = ListCanceledPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getAppUid(),
- $keys[1] => $this->getUsrUid(),
- $keys[2] => $this->getTasUid(),
- $keys[3] => $this->getProUid(),
- $keys[4] => $this->getAppNumber(),
- $keys[5] => $this->getAppTitle(),
- $keys[6] => $this->getAppProTitle(),
- $keys[7] => $this->getAppTasTitle(),
- $keys[8] => $this->getAppCanceledDate(),
- $keys[9] => $this->getDelIndex(),
+ $keys[1] => $this->getDelIndex(),
+ $keys[2] => $this->getUsrUid(),
+ $keys[3] => $this->getTasUid(),
+ $keys[4] => $this->getProUid(),
+ $keys[5] => $this->getAppNumber(),
+ $keys[6] => $this->getAppTitle(),
+ $keys[7] => $this->getAppProTitle(),
+ $keys[8] => $this->getAppTasTitle(),
+ $keys[9] => $this->getAppCanceledDate(),
$keys[10] => $this->getDelPreviousUsrUid(),
$keys[11] => $this->getDelCurrentUsrUsername(),
$keys[12] => $this->getDelCurrentUsrFirstname(),
@@ -1379,31 +1379,31 @@ abstract class BaseListCanceled extends BaseObject implements Persistent
$this->setAppUid($value);
break;
case 1:
- $this->setUsrUid($value);
+ $this->setDelIndex($value);
break;
case 2:
- $this->setTasUid($value);
+ $this->setUsrUid($value);
break;
case 3:
- $this->setProUid($value);
+ $this->setTasUid($value);
break;
case 4:
- $this->setAppNumber($value);
+ $this->setProUid($value);
break;
case 5:
- $this->setAppTitle($value);
+ $this->setAppNumber($value);
break;
case 6:
- $this->setAppProTitle($value);
+ $this->setAppTitle($value);
break;
case 7:
- $this->setAppTasTitle($value);
+ $this->setAppProTitle($value);
break;
case 8:
- $this->setAppCanceledDate($value);
+ $this->setAppTasTitle($value);
break;
case 9:
- $this->setDelIndex($value);
+ $this->setAppCanceledDate($value);
break;
case 10:
$this->setDelPreviousUsrUid($value);
@@ -1466,39 +1466,39 @@ abstract class BaseListCanceled extends BaseObject implements Persistent
}
if (array_key_exists($keys[1], $arr)) {
- $this->setUsrUid($arr[$keys[1]]);
+ $this->setDelIndex($arr[$keys[1]]);
}
if (array_key_exists($keys[2], $arr)) {
- $this->setTasUid($arr[$keys[2]]);
+ $this->setUsrUid($arr[$keys[2]]);
}
if (array_key_exists($keys[3], $arr)) {
- $this->setProUid($arr[$keys[3]]);
+ $this->setTasUid($arr[$keys[3]]);
}
if (array_key_exists($keys[4], $arr)) {
- $this->setAppNumber($arr[$keys[4]]);
+ $this->setProUid($arr[$keys[4]]);
}
if (array_key_exists($keys[5], $arr)) {
- $this->setAppTitle($arr[$keys[5]]);
+ $this->setAppNumber($arr[$keys[5]]);
}
if (array_key_exists($keys[6], $arr)) {
- $this->setAppProTitle($arr[$keys[6]]);
+ $this->setAppTitle($arr[$keys[6]]);
}
if (array_key_exists($keys[7], $arr)) {
- $this->setAppTasTitle($arr[$keys[7]]);
+ $this->setAppProTitle($arr[$keys[7]]);
}
if (array_key_exists($keys[8], $arr)) {
- $this->setAppCanceledDate($arr[$keys[8]]);
+ $this->setAppTasTitle($arr[$keys[8]]);
}
if (array_key_exists($keys[9], $arr)) {
- $this->setDelIndex($arr[$keys[9]]);
+ $this->setAppCanceledDate($arr[$keys[9]]);
}
if (array_key_exists($keys[10], $arr)) {
@@ -1560,6 +1560,10 @@ abstract class BaseListCanceled extends BaseObject implements Persistent
$criteria->add(ListCanceledPeer::APP_UID, $this->app_uid);
}
+ if ($this->isColumnModified(ListCanceledPeer::DEL_INDEX)) {
+ $criteria->add(ListCanceledPeer::DEL_INDEX, $this->del_index);
+ }
+
if ($this->isColumnModified(ListCanceledPeer::USR_UID)) {
$criteria->add(ListCanceledPeer::USR_UID, $this->usr_uid);
}
@@ -1592,10 +1596,6 @@ abstract class BaseListCanceled extends BaseObject implements Persistent
$criteria->add(ListCanceledPeer::APP_CANCELED_DATE, $this->app_canceled_date);
}
- if ($this->isColumnModified(ListCanceledPeer::DEL_INDEX)) {
- $criteria->add(ListCanceledPeer::DEL_INDEX, $this->del_index);
- }
-
if ($this->isColumnModified(ListCanceledPeer::DEL_PREVIOUS_USR_UID)) {
$criteria->add(ListCanceledPeer::DEL_PREVIOUS_USR_UID, $this->del_previous_usr_uid);
}
@@ -1657,28 +1657,40 @@ abstract class BaseListCanceled extends BaseObject implements Persistent
$criteria = new Criteria(ListCanceledPeer::DATABASE_NAME);
$criteria->add(ListCanceledPeer::APP_UID, $this->app_uid);
+ $criteria->add(ListCanceledPeer::DEL_INDEX, $this->del_index);
return $criteria;
}
/**
- * Returns the primary key for this object (row).
- * @return string
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
*/
public function getPrimaryKey()
{
- return $this->getAppUid();
+ $pks = array();
+
+ $pks[0] = $this->getAppUid();
+
+ $pks[1] = $this->getDelIndex();
+
+ return $pks;
}
/**
- * Generic method to set the primary key (app_uid column).
+ * Set the [composite] primary key.
*
- * @param string $key Primary key.
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
* @return void
*/
- public function setPrimaryKey($key)
+ public function setPrimaryKey($keys)
{
- $this->setAppUid($key);
+
+ $this->setAppUid($keys[0]);
+
+ $this->setDelIndex($keys[1]);
+
}
/**
@@ -1710,8 +1722,6 @@ abstract class BaseListCanceled extends BaseObject implements Persistent
$copyObj->setAppCanceledDate($this->app_canceled_date);
- $copyObj->setDelIndex($this->del_index);
-
$copyObj->setDelPreviousUsrUid($this->del_previous_usr_uid);
$copyObj->setDelCurrentUsrUsername($this->del_current_usr_username);
@@ -1739,6 +1749,8 @@ abstract class BaseListCanceled extends BaseObject implements Persistent
$copyObj->setAppUid(''); // this is a pkey column, so set to default value
+ $copyObj->setDelIndex('0'); // this is a pkey column, so set to default value
+
}
/**
diff --git a/workflow/engine/classes/model/om/BaseListCanceledPeer.php b/workflow/engine/classes/model/om/BaseListCanceledPeer.php
index 777713c3a..aeed53bad 100644
--- a/workflow/engine/classes/model/om/BaseListCanceledPeer.php
+++ b/workflow/engine/classes/model/om/BaseListCanceledPeer.php
@@ -34,6 +34,9 @@ abstract class BaseListCanceledPeer
/** the column name for the APP_UID field */
const APP_UID = 'LIST_CANCELED.APP_UID';
+ /** the column name for the DEL_INDEX field */
+ const DEL_INDEX = 'LIST_CANCELED.DEL_INDEX';
+
/** the column name for the USR_UID field */
const USR_UID = 'LIST_CANCELED.USR_UID';
@@ -58,9 +61,6 @@ abstract class BaseListCanceledPeer
/** the column name for the APP_CANCELED_DATE field */
const APP_CANCELED_DATE = 'LIST_CANCELED.APP_CANCELED_DATE';
- /** the column name for the DEL_INDEX field */
- const DEL_INDEX = 'LIST_CANCELED.DEL_INDEX';
-
/** the column name for the DEL_PREVIOUS_USR_UID field */
const DEL_PREVIOUS_USR_UID = 'LIST_CANCELED.DEL_PREVIOUS_USR_UID';
@@ -105,9 +105,9 @@ abstract class BaseListCanceledPeer
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
- BasePeer::TYPE_PHPNAME => array ('AppUid', 'UsrUid', 'TasUid', 'ProUid', 'AppNumber', 'AppTitle', 'AppProTitle', 'AppTasTitle', 'AppCanceledDate', 'DelIndex', 'DelPreviousUsrUid', 'DelCurrentUsrUsername', 'DelCurrentUsrFirstname', 'DelCurrentUsrLastname', 'DelDelegateDate', 'DelInitDate', 'DelDueDate', 'DelPriority', 'ProId', 'UsrId', 'TasId', ),
- BasePeer::TYPE_COLNAME => array (ListCanceledPeer::APP_UID, ListCanceledPeer::USR_UID, ListCanceledPeer::TAS_UID, ListCanceledPeer::PRO_UID, ListCanceledPeer::APP_NUMBER, ListCanceledPeer::APP_TITLE, ListCanceledPeer::APP_PRO_TITLE, ListCanceledPeer::APP_TAS_TITLE, ListCanceledPeer::APP_CANCELED_DATE, ListCanceledPeer::DEL_INDEX, ListCanceledPeer::DEL_PREVIOUS_USR_UID, ListCanceledPeer::DEL_CURRENT_USR_USERNAME, ListCanceledPeer::DEL_CURRENT_USR_FIRSTNAME, ListCanceledPeer::DEL_CURRENT_USR_LASTNAME, ListCanceledPeer::DEL_DELEGATE_DATE, ListCanceledPeer::DEL_INIT_DATE, ListCanceledPeer::DEL_DUE_DATE, ListCanceledPeer::DEL_PRIORITY, ListCanceledPeer::PRO_ID, ListCanceledPeer::USR_ID, ListCanceledPeer::TAS_ID, ),
- BasePeer::TYPE_FIELDNAME => array ('APP_UID', 'USR_UID', 'TAS_UID', 'PRO_UID', 'APP_NUMBER', 'APP_TITLE', 'APP_PRO_TITLE', 'APP_TAS_TITLE', 'APP_CANCELED_DATE', 'DEL_INDEX', 'DEL_PREVIOUS_USR_UID', 'DEL_CURRENT_USR_USERNAME', 'DEL_CURRENT_USR_FIRSTNAME', 'DEL_CURRENT_USR_LASTNAME', 'DEL_DELEGATE_DATE', 'DEL_INIT_DATE', 'DEL_DUE_DATE', 'DEL_PRIORITY', 'PRO_ID', 'USR_ID', 'TAS_ID', ),
+ BasePeer::TYPE_PHPNAME => array ('AppUid', 'DelIndex', 'UsrUid', 'TasUid', 'ProUid', 'AppNumber', 'AppTitle', 'AppProTitle', 'AppTasTitle', 'AppCanceledDate', 'DelPreviousUsrUid', 'DelCurrentUsrUsername', 'DelCurrentUsrFirstname', 'DelCurrentUsrLastname', 'DelDelegateDate', 'DelInitDate', 'DelDueDate', 'DelPriority', 'ProId', 'UsrId', 'TasId', ),
+ BasePeer::TYPE_COLNAME => array (ListCanceledPeer::APP_UID, ListCanceledPeer::DEL_INDEX, ListCanceledPeer::USR_UID, ListCanceledPeer::TAS_UID, ListCanceledPeer::PRO_UID, ListCanceledPeer::APP_NUMBER, ListCanceledPeer::APP_TITLE, ListCanceledPeer::APP_PRO_TITLE, ListCanceledPeer::APP_TAS_TITLE, ListCanceledPeer::APP_CANCELED_DATE, ListCanceledPeer::DEL_PREVIOUS_USR_UID, ListCanceledPeer::DEL_CURRENT_USR_USERNAME, ListCanceledPeer::DEL_CURRENT_USR_FIRSTNAME, ListCanceledPeer::DEL_CURRENT_USR_LASTNAME, ListCanceledPeer::DEL_DELEGATE_DATE, ListCanceledPeer::DEL_INIT_DATE, ListCanceledPeer::DEL_DUE_DATE, ListCanceledPeer::DEL_PRIORITY, ListCanceledPeer::PRO_ID, ListCanceledPeer::USR_ID, ListCanceledPeer::TAS_ID, ),
+ BasePeer::TYPE_FIELDNAME => array ('APP_UID', 'DEL_INDEX', 'USR_UID', 'TAS_UID', 'PRO_UID', 'APP_NUMBER', 'APP_TITLE', 'APP_PRO_TITLE', 'APP_TAS_TITLE', 'APP_CANCELED_DATE', 'DEL_PREVIOUS_USR_UID', 'DEL_CURRENT_USR_USERNAME', 'DEL_CURRENT_USR_FIRSTNAME', 'DEL_CURRENT_USR_LASTNAME', 'DEL_DELEGATE_DATE', 'DEL_INIT_DATE', 'DEL_DUE_DATE', 'DEL_PRIORITY', 'PRO_ID', 'USR_ID', 'TAS_ID', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, )
);
@@ -118,9 +118,9 @@ abstract class BaseListCanceledPeer
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
- BasePeer::TYPE_PHPNAME => array ('AppUid' => 0, 'UsrUid' => 1, 'TasUid' => 2, 'ProUid' => 3, 'AppNumber' => 4, 'AppTitle' => 5, 'AppProTitle' => 6, 'AppTasTitle' => 7, 'AppCanceledDate' => 8, 'DelIndex' => 9, 'DelPreviousUsrUid' => 10, 'DelCurrentUsrUsername' => 11, 'DelCurrentUsrFirstname' => 12, 'DelCurrentUsrLastname' => 13, 'DelDelegateDate' => 14, 'DelInitDate' => 15, 'DelDueDate' => 16, 'DelPriority' => 17, 'ProId' => 18, 'UsrId' => 19, 'TasId' => 20, ),
- BasePeer::TYPE_COLNAME => array (ListCanceledPeer::APP_UID => 0, ListCanceledPeer::USR_UID => 1, ListCanceledPeer::TAS_UID => 2, ListCanceledPeer::PRO_UID => 3, ListCanceledPeer::APP_NUMBER => 4, ListCanceledPeer::APP_TITLE => 5, ListCanceledPeer::APP_PRO_TITLE => 6, ListCanceledPeer::APP_TAS_TITLE => 7, ListCanceledPeer::APP_CANCELED_DATE => 8, ListCanceledPeer::DEL_INDEX => 9, ListCanceledPeer::DEL_PREVIOUS_USR_UID => 10, ListCanceledPeer::DEL_CURRENT_USR_USERNAME => 11, ListCanceledPeer::DEL_CURRENT_USR_FIRSTNAME => 12, ListCanceledPeer::DEL_CURRENT_USR_LASTNAME => 13, ListCanceledPeer::DEL_DELEGATE_DATE => 14, ListCanceledPeer::DEL_INIT_DATE => 15, ListCanceledPeer::DEL_DUE_DATE => 16, ListCanceledPeer::DEL_PRIORITY => 17, ListCanceledPeer::PRO_ID => 18, ListCanceledPeer::USR_ID => 19, ListCanceledPeer::TAS_ID => 20, ),
- BasePeer::TYPE_FIELDNAME => array ('APP_UID' => 0, 'USR_UID' => 1, 'TAS_UID' => 2, 'PRO_UID' => 3, 'APP_NUMBER' => 4, 'APP_TITLE' => 5, 'APP_PRO_TITLE' => 6, 'APP_TAS_TITLE' => 7, 'APP_CANCELED_DATE' => 8, 'DEL_INDEX' => 9, 'DEL_PREVIOUS_USR_UID' => 10, 'DEL_CURRENT_USR_USERNAME' => 11, 'DEL_CURRENT_USR_FIRSTNAME' => 12, 'DEL_CURRENT_USR_LASTNAME' => 13, 'DEL_DELEGATE_DATE' => 14, 'DEL_INIT_DATE' => 15, 'DEL_DUE_DATE' => 16, 'DEL_PRIORITY' => 17, 'PRO_ID' => 18, 'USR_ID' => 19, 'TAS_ID' => 20, ),
+ BasePeer::TYPE_PHPNAME => array ('AppUid' => 0, 'DelIndex' => 1, 'UsrUid' => 2, 'TasUid' => 3, 'ProUid' => 4, 'AppNumber' => 5, 'AppTitle' => 6, 'AppProTitle' => 7, 'AppTasTitle' => 8, 'AppCanceledDate' => 9, 'DelPreviousUsrUid' => 10, 'DelCurrentUsrUsername' => 11, 'DelCurrentUsrFirstname' => 12, 'DelCurrentUsrLastname' => 13, 'DelDelegateDate' => 14, 'DelInitDate' => 15, 'DelDueDate' => 16, 'DelPriority' => 17, 'ProId' => 18, 'UsrId' => 19, 'TasId' => 20, ),
+ BasePeer::TYPE_COLNAME => array (ListCanceledPeer::APP_UID => 0, ListCanceledPeer::DEL_INDEX => 1, ListCanceledPeer::USR_UID => 2, ListCanceledPeer::TAS_UID => 3, ListCanceledPeer::PRO_UID => 4, ListCanceledPeer::APP_NUMBER => 5, ListCanceledPeer::APP_TITLE => 6, ListCanceledPeer::APP_PRO_TITLE => 7, ListCanceledPeer::APP_TAS_TITLE => 8, ListCanceledPeer::APP_CANCELED_DATE => 9, ListCanceledPeer::DEL_PREVIOUS_USR_UID => 10, ListCanceledPeer::DEL_CURRENT_USR_USERNAME => 11, ListCanceledPeer::DEL_CURRENT_USR_FIRSTNAME => 12, ListCanceledPeer::DEL_CURRENT_USR_LASTNAME => 13, ListCanceledPeer::DEL_DELEGATE_DATE => 14, ListCanceledPeer::DEL_INIT_DATE => 15, ListCanceledPeer::DEL_DUE_DATE => 16, ListCanceledPeer::DEL_PRIORITY => 17, ListCanceledPeer::PRO_ID => 18, ListCanceledPeer::USR_ID => 19, ListCanceledPeer::TAS_ID => 20, ),
+ BasePeer::TYPE_FIELDNAME => array ('APP_UID' => 0, 'DEL_INDEX' => 1, 'USR_UID' => 2, 'TAS_UID' => 3, 'PRO_UID' => 4, 'APP_NUMBER' => 5, 'APP_TITLE' => 6, 'APP_PRO_TITLE' => 7, 'APP_TAS_TITLE' => 8, 'APP_CANCELED_DATE' => 9, 'DEL_PREVIOUS_USR_UID' => 10, 'DEL_CURRENT_USR_USERNAME' => 11, 'DEL_CURRENT_USR_FIRSTNAME' => 12, 'DEL_CURRENT_USR_LASTNAME' => 13, 'DEL_DELEGATE_DATE' => 14, 'DEL_INIT_DATE' => 15, 'DEL_DUE_DATE' => 16, 'DEL_PRIORITY' => 17, 'PRO_ID' => 18, 'USR_ID' => 19, 'TAS_ID' => 20, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, )
);
@@ -224,6 +224,8 @@ abstract class BaseListCanceledPeer
$criteria->addSelectColumn(ListCanceledPeer::APP_UID);
+ $criteria->addSelectColumn(ListCanceledPeer::DEL_INDEX);
+
$criteria->addSelectColumn(ListCanceledPeer::USR_UID);
$criteria->addSelectColumn(ListCanceledPeer::TAS_UID);
@@ -240,8 +242,6 @@ abstract class BaseListCanceledPeer
$criteria->addSelectColumn(ListCanceledPeer::APP_CANCELED_DATE);
- $criteria->addSelectColumn(ListCanceledPeer::DEL_INDEX);
-
$criteria->addSelectColumn(ListCanceledPeer::DEL_PREVIOUS_USR_UID);
$criteria->addSelectColumn(ListCanceledPeer::DEL_CURRENT_USR_USERNAME);
@@ -479,6 +479,9 @@ abstract class BaseListCanceledPeer
$comparison = $criteria->getComparison(ListCanceledPeer::APP_UID);
$selectCriteria->add(ListCanceledPeer::APP_UID, $criteria->remove(ListCanceledPeer::APP_UID), $comparison);
+ $comparison = $criteria->getComparison(ListCanceledPeer::DEL_INDEX);
+ $selectCriteria->add(ListCanceledPeer::DEL_INDEX, $criteria->remove(ListCanceledPeer::DEL_INDEX), $comparison);
+
} else {
$criteria = $values->buildCriteria(); // gets full criteria
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
@@ -540,7 +543,22 @@ abstract class BaseListCanceledPeer
} else {
// it must be the primary key
$criteria = new Criteria(self::DATABASE_NAME);
- $criteria->add(ListCanceledPeer::APP_UID, (array) $values, Criteria::IN);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey
+ // values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ $vals = array();
+ foreach ($values as $value) {
+
+ $vals[0][] = $value[0];
+ $vals[1][] = $value[1];
+ }
+
+ $criteria->add(ListCanceledPeer::APP_UID, $vals[0], Criteria::IN);
+ $criteria->add(ListCanceledPeer::DEL_INDEX, $vals[1], Criteria::IN);
}
// Set the correct dbName
@@ -600,51 +618,23 @@ abstract class BaseListCanceledPeer
}
/**
- * Retrieve a single object by pkey.
- *
- * @param mixed $pk the primary key.
- * @param Connection $con the connection to use
+ * Retrieve object using using composite pkey values.
+ * @param string $app_uid
+ * @param int $del_index
+ * @param Connection $con
* @return ListCanceled
*/
- public static function retrieveByPK($pk, $con = null)
+ public static function retrieveByPK($app_uid, $del_index, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
-
- $criteria = new Criteria(ListCanceledPeer::DATABASE_NAME);
-
- $criteria->add(ListCanceledPeer::APP_UID, $pk);
-
-
+ $criteria = new Criteria();
+ $criteria->add(ListCanceledPeer::APP_UID, $app_uid);
+ $criteria->add(ListCanceledPeer::DEL_INDEX, $del_index);
$v = ListCanceledPeer::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(ListCanceledPeer::APP_UID, $pks, Criteria::IN);
- $objs = ListCanceledPeer::doSelect($criteria, $con);
- }
- return $objs;
+ return !empty($v) ? $v[0] : null;
}
}
diff --git a/workflow/engine/config/schema.xml b/workflow/engine/config/schema.xml
index eb8b6899f..2a269b656 100644
--- a/workflow/engine/config/schema.xml
+++ b/workflow/engine/config/schema.xml
@@ -4624,6 +4624,7 @@
+
@@ -4632,7 +4633,6 @@
-
diff --git a/workflow/engine/data/mysql/schema.sql b/workflow/engine/data/mysql/schema.sql
index 3804849f8..7be66fdb1 100644
--- a/workflow/engine/data/mysql/schema.sql
+++ b/workflow/engine/data/mysql/schema.sql
@@ -2569,6 +2569,7 @@ DROP TABLE IF EXISTS `LIST_CANCELED`;
CREATE TABLE `LIST_CANCELED`
(
`APP_UID` VARCHAR(32) default '' NOT NULL,
+ `DEL_INDEX` INTEGER default 0 NOT NULL,
`USR_UID` VARCHAR(32) default '' NOT NULL,
`TAS_UID` VARCHAR(32) default '' NOT NULL,
`PRO_UID` VARCHAR(32) default '' NOT NULL,
@@ -2577,7 +2578,6 @@ CREATE TABLE `LIST_CANCELED`
`APP_PRO_TITLE` MEDIUMTEXT,
`APP_TAS_TITLE` MEDIUMTEXT,
`APP_CANCELED_DATE` DATETIME,
- `DEL_INDEX` INTEGER default 0 NOT NULL,
`DEL_PREVIOUS_USR_UID` VARCHAR(32) default '',
`DEL_CURRENT_USR_USERNAME` VARCHAR(100) default '',
`DEL_CURRENT_USR_FIRSTNAME` VARCHAR(50) default '',
@@ -2589,7 +2589,7 @@ CREATE TABLE `LIST_CANCELED`
`PRO_ID` INTEGER default 0,
`USR_ID` INTEGER default 0,
`TAS_ID` INTEGER default 0,
- PRIMARY KEY (`APP_UID`),
+ PRIMARY KEY (`APP_UID`,`DEL_INDEX`),
KEY `INDEX_PRO_ID`(`PRO_ID`),
KEY `INDEX_USR_ID`(`USR_ID`),
KEY `INDEX_TAS_ID`(`TAS_ID`),