/** * Validate Process Uid * @var string $pro_uid. Uid for process * * @author Brayan Pereyra (Cochalo) <*****@*****.**> * @copyright Colosa - Bolivia * * @return string */ public function validateProUid($pro_uid) { $pro_uid = trim($pro_uid); if ($pro_uid == '') { throw new \Exception("The project with prj_uid: '', does not exist."); } $oProcess = new \Process(); if (!$oProcess->processExists($pro_uid)) { throw new \Exception("The project with prj_uid: '{$pro_uid}', does not exist."); } return $pro_uid; }
/** * Validate Process Uid * @var string $pro_uid. Uid for process * * @author Brayan Pereyra (Cochalo) <*****@*****.**> * @copyright Colosa - Bolivia * * @return string */ public function validateProUid($pro_uid) { $pro_uid = trim($pro_uid); if ($pro_uid == '') { throw new \Exception(\G::LoadTranslation("ID_PROJECT_NOT_EXIST", array('prj_uid', ''))); } $oProcess = new \Process(); if (!$oProcess->processExists($pro_uid)) { throw new \Exception(\G::LoadTranslation("ID_PROJECT_NOT_EXIST", array('prj_uid', $pro_uid))); } return $pro_uid; }
/** * Get all Tasks of Case * Based in: processmaker/workflow/engine/classes/class.processMap.php * Method: processMap::load() * * @param string $applicationUid Unique id of Case * * return array Return an array with all Tasks of Case */ public function getTasks($applicationUid) { try { $arrayTask = array(); //Verify data $this->throwExceptionIfNotExistsCase($applicationUid, 0, $this->getFieldNameByFormatFieldName("APP_UID")); //Set variables $process = new \Process(); $application = new \Application(); $conf = new \Configurations(); $arrayApplicationData = $application->Load($applicationUid); $processUid = $arrayApplicationData["PRO_UID"]; $confEnvSetting = $conf->getFormats(); $taskUid = ""; //Get data //SQL $delimiter = \DBAdapter::getStringDelimiter(); $criteria = new \Criteria("workflow"); $criteria->addSelectColumn(\TaskPeer::TAS_UID); $criteria->addAsColumn("TAS_TITLE", "CT.CON_VALUE"); $criteria->addAsColumn("TAS_DESCRIPTION", "CD.CON_VALUE"); $criteria->addSelectColumn(\TaskPeer::TAS_START); $criteria->addSelectColumn(\TaskPeer::TAS_TYPE); $criteria->addSelectColumn(\TaskPeer::TAS_DERIVATION); $criteria->addSelectColumn(\TaskPeer::TAS_ASSIGN_TYPE); $criteria->addSelectColumn(\UsersPeer::USR_UID); $criteria->addSelectColumn(\UsersPeer::USR_USERNAME); $criteria->addSelectColumn(\UsersPeer::USR_FIRSTNAME); $criteria->addSelectColumn(\UsersPeer::USR_LASTNAME); $criteria->addAlias("CT", \ContentPeer::TABLE_NAME); $criteria->addAlias("CD", \ContentPeer::TABLE_NAME); $arrayCondition = array(); $arrayCondition[] = array(\TaskPeer::TAS_UID, "CT.CON_ID", \Criteria::EQUAL); $arrayCondition[] = array("CT.CON_CATEGORY", $delimiter . "TAS_TITLE" . $delimiter, \Criteria::EQUAL); $arrayCondition[] = array("CT.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL); $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN); $arrayCondition = array(); $arrayCondition[] = array(\TaskPeer::TAS_UID, "CD.CON_ID", \Criteria::EQUAL); $arrayCondition[] = array("CD.CON_CATEGORY", $delimiter . "TAS_DESCRIPTION" . $delimiter, \Criteria::EQUAL); $arrayCondition[] = array("CD.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL); $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN); $criteria->addJoin(\TaskPeer::TAS_LAST_ASSIGNED, \UsersPeer::USR_UID, \Criteria::LEFT_JOIN); $criteria->add(\TaskPeer::PRO_UID, $processUid, \Criteria::EQUAL); $rsCriteria = \TaskPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); //Task if ($row["TAS_TYPE"] == "NORMAL") { if (($row["TAS_TITLE"] . "" == "")) { //There is no Label in Current SYS_LANG language so try to find in English - by default $task = new \Task(); $task->setTasUid($row["TAS_UID"]); $row["TAS_TITLE"] = $task->getTasTitle(); } } else { $criteria2 = new \Criteria("workflow"); $criteria2->addSelectColumn(\SubProcessPeer::PRO_UID); $criteria2->addAsColumn("TAS_TITLE", "CT.CON_VALUE"); $criteria2->addAsColumn("TAS_DESCRIPTION", "CD.CON_VALUE"); $criteria2->addAlias("CT", \ContentPeer::TABLE_NAME); $criteria2->addAlias("CD", \ContentPeer::TABLE_NAME); $arrayCondition = array(); $arrayCondition[] = array(\SubProcessPeer::TAS_PARENT, "CT.CON_ID", \Criteria::EQUAL); $arrayCondition[] = array("CT.CON_CATEGORY", $delimiter . "TAS_TITLE" . $delimiter, \Criteria::EQUAL); $arrayCondition[] = array("CT.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL); $criteria2->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN); $arrayCondition = array(); $arrayCondition[] = array(\SubProcessPeer::TAS_PARENT, "CD.CON_ID", \Criteria::EQUAL); $arrayCondition[] = array("CD.CON_CATEGORY", $delimiter . "TAS_DESCRIPTION" . $delimiter, \Criteria::EQUAL); $arrayCondition[] = array("CD.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL); $criteria2->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN); $criteria2->add(\SubProcessPeer::PRO_PARENT, $processUid); $criteria2->add(\SubProcessPeer::TAS_PARENT, $row["TAS_UID"]); $rsCriteria2 = \SubProcessPeer::doSelectRS($criteria2); $rsCriteria2->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $rsCriteria2->next(); $row2 = $rsCriteria2->getRow(); if ($process->exists($row2["PRO_UID"])) { $row["TAS_TITLE"] = $row2["TAS_TITLE"]; $row["TAS_DESCRIPTION"] = $row2["TAS_DESCRIPTION"]; } } //Routes $routeType = ""; $arrayRoute = array(); $criteria2 = new \Criteria("workflow"); $criteria2->addAsColumn("ROU_NUMBER", \RoutePeer::ROU_CASE); $criteria2->addSelectColumn(\RoutePeer::ROU_TYPE); $criteria2->addSelectColumn(\RoutePeer::ROU_CONDITION); $criteria2->addAsColumn("TAS_UID", \RoutePeer::ROU_NEXT_TASK); $criteria2->add(\RoutePeer::PRO_UID, $processUid, \Criteria::EQUAL); $criteria2->add(\RoutePeer::TAS_UID, $row["TAS_UID"], \Criteria::EQUAL); $criteria2->addAscendingOrderByColumn("ROU_NUMBER"); $rsCriteria2 = \RoutePeer::doSelectRS($criteria2); $rsCriteria2->setFetchmode(\ResultSet::FETCHMODE_ASSOC); while ($rsCriteria2->next()) { $row2 = $rsCriteria2->getRow(); $routeType = $row2["ROU_TYPE"]; $arrayRoute[] = array( $this->getFieldNameByFormatFieldName("ROU_NUMBER") => (int)($row2["ROU_NUMBER"]), $this->getFieldNameByFormatFieldName("ROU_CONDITION") => $row2["ROU_CONDITION"] . "", $this->getFieldNameByFormatFieldName("TAS_UID") => $row2["TAS_UID"] ); } //Delegations $arrayAppDelegation = array(); $criteria2 = new \Criteria("workflow"); $criteria2->addSelectColumn(\AppDelegationPeer::DEL_INDEX); $criteria2->addSelectColumn(\AppDelegationPeer::DEL_INIT_DATE); $criteria2->addSelectColumn(\AppDelegationPeer::DEL_TASK_DUE_DATE); $criteria2->addSelectColumn(\AppDelegationPeer::DEL_FINISH_DATE); $criteria2->addSelectColumn(\UsersPeer::USR_UID); $criteria2->addSelectColumn(\UsersPeer::USR_USERNAME); $criteria2->addSelectColumn(\UsersPeer::USR_FIRSTNAME); $criteria2->addSelectColumn(\UsersPeer::USR_LASTNAME); $criteria2->addJoin(\AppDelegationPeer::USR_UID, \UsersPeer::USR_UID, \Criteria::LEFT_JOIN); $criteria2->add(\AppDelegationPeer::APP_UID, $applicationUid, \Criteria::EQUAL); $criteria2->add(\AppDelegationPeer::TAS_UID, $row["TAS_UID"], \Criteria::EQUAL); $criteria2->addAscendingOrderByColumn(\AppDelegationPeer::DEL_INDEX); $rsCriteria2 = \AppDelegationPeer::doSelectRS($criteria2); $rsCriteria2->setFetchmode(\ResultSet::FETCHMODE_ASSOC); while ($rsCriteria2->next()) { $row2 = $rsCriteria2->getRow(); $arrayAppDelegationDate = array( "DEL_INIT_DATE" => array("date" => $row2["DEL_INIT_DATE"], "dateFormated" => \G::LoadTranslation("ID_CASE_NOT_YET_STARTED")), "DEL_TASK_DUE_DATE" => array("date" => $row2["DEL_TASK_DUE_DATE"], "dateFormated" => \G::LoadTranslation("ID_CASE_NOT_YET_STARTED")), "DEL_FINISH_DATE" => array("date" => $row2["DEL_FINISH_DATE"], "dateFormated" => \G::LoadTranslation("ID_NOT_FINISHED")) ); foreach ($arrayAppDelegationDate as $key => $value) { $d = $value; if (!empty($d["date"])) { $dateTime = new \DateTime($d["date"]); $arrayAppDelegationDate[$key]["dateFormated"] = $dateTime->format($confEnvSetting["dateFormat"]); } } $appDelegationDuration = \G::LoadTranslation("ID_NOT_FINISHED"); if (!empty($row2["DEL_FINISH_DATE"]) && !empty($row2["DEL_INIT_DATE"])) { $t = strtotime($row2["DEL_FINISH_DATE"]) - strtotime($row2["DEL_INIT_DATE"]); $h = $t * (1 / 60) * (1 / 60); $m = ($h - (int)($h)) * (60 / 1); $s = ($m - (int)($m)) * (60 / 1); $h = (int)($h); $m = (int)($m); $appDelegationDuration = $h . " " . (($h == 1)? \G::LoadTranslation("ID_HOUR") : \G::LoadTranslation("ID_HOURS")); $appDelegationDuration = $appDelegationDuration . " " . $m . " " . (($m == 1)? \G::LoadTranslation("ID_MINUTE") : \G::LoadTranslation("ID_MINUTES")); $appDelegationDuration = $appDelegationDuration . " " . $s . " " . (($s == 1)? \G::LoadTranslation("ID_SECOND") : \G::LoadTranslation("ID_SECONDS")); } $arrayAppDelegation[] = array( $this->getFieldNameByFormatFieldName("DEL_INDEX") => (int)($row2["DEL_INDEX"]), $this->getFieldNameByFormatFieldName("DEL_INIT_DATE") => $arrayAppDelegationDate["DEL_INIT_DATE"]["dateFormated"], $this->getFieldNameByFormatFieldName("DEL_TASK_DUE_DATE") => $arrayAppDelegationDate["DEL_TASK_DUE_DATE"]["dateFormated"], $this->getFieldNameByFormatFieldName("DEL_FINISH_DATE") => $arrayAppDelegationDate["DEL_FINISH_DATE"]["dateFormated"], $this->getFieldNameByFormatFieldName("DEL_DURATION") => $appDelegationDuration, $this->getFieldNameByFormatFieldName("USR_UID") => $row2["USR_UID"], $this->getFieldNameByFormatFieldName("USR_USERNAME") => $row2["USR_USERNAME"] . "", $this->getFieldNameByFormatFieldName("USR_FIRSTNAME") => $row2["USR_FIRSTNAME"] . "", $this->getFieldNameByFormatFieldName("USR_LASTNAME") => $row2["USR_LASTNAME"] . "" ); } //Status $status = ""; //$criteria2 $criteria2 = new \Criteria("workflow"); $criteria2->addAsColumn("CANT", "COUNT(" . \AppDelegationPeer::APP_UID . ")"); $criteria2->addAsColumn("FINISH", "MIN(" . \AppDelegationPeer::DEL_FINISH_DATE . ")"); $criteria2->add(\AppDelegationPeer::APP_UID, $applicationUid, \Criteria::EQUAL); $criteria2->add(\AppDelegationPeer::TAS_UID, $row["TAS_UID"], \Criteria::EQUAL); $rsCriteria2 = \AppDelegationPeer::doSelectRS($criteria2); $rsCriteria2->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $rsCriteria2->next(); $row2 = $rsCriteria2->getRow(); //$criteria3 $criteria3 = new \Criteria("workflow"); $criteria3->addSelectColumn(\AppDelegationPeer::DEL_FINISH_DATE); $criteria3->add(\AppDelegationPeer::APP_UID, $applicationUid, \Criteria::EQUAL); $criteria3->add(\AppDelegationPeer::TAS_UID, $row["TAS_UID"], \Criteria::EQUAL); $criteria3->add(\AppDelegationPeer::DEL_FINISH_DATE, null, \Criteria::ISNULL); $rsCriteria3 = \AppDelegationPeer::doSelectRS($criteria3); $rsCriteria3->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $rsCriteria3->next(); $row3 = $rsCriteria3->getRow(); if ($row3) { $row2["FINISH"] = ""; } //Status if (empty($row2["FINISH"]) && !is_null($taskUid) && $row["TAS_UID"] == $taskUid) { $status = "TASK_IN_PROGRESS"; //Red } else { if (!empty($row2["FINISH"])) { $status = "TASK_COMPLETED"; //Green } else { if ($routeType != "SEC-JOIN") { if ($row2["CANT"] != 0) { $status = "TASK_IN_PROGRESS"; //Red } else { $status = "TASK_PENDING_NOT_EXECUTED"; //Gray } } else { //$status = "TASK_PARALLEL"; //Yellow if ($row3) { $status = "TASK_IN_PROGRESS"; //Red } else { $status = "TASK_PENDING_NOT_EXECUTED"; //Gray } } } } //Set data $arrayAux = $this->getTaskDataFromRecord($row); $arrayAux[$this->getFieldNameByFormatFieldName("ROUTE")][$this->getFieldNameByFormatFieldName("TYPE")] = $routeType; $arrayAux[$this->getFieldNameByFormatFieldName("ROUTE")][$this->getFieldNameByFormatFieldName("TO")] = $arrayRoute; $arrayAux[$this->getFieldNameByFormatFieldName("DELEGATIONS")] = $arrayAppDelegation; $arrayAux[$this->getFieldNameByFormatFieldName("STATUS")] = $status; $arrayTask[] = $arrayAux; } //Return return $arrayTask; } catch (\Exception $e) { throw $e; } }
/** * view in html response for status * * @param $userUid * @param $Fields * @param $type * @throws \Exception */ public function getInfoResume($userUid, $Fields, $type) { //print_r($Fields);die; /* Includes */ G::LoadClass( 'case' ); /* Prepare page before to show */ //$oCase = new \Cases(); // $participated = $oCase->userParticipatedInCase( $Fields['APP_UID'], $userUid ); // if ($RBAC->userCanAccess( 'PM_ALLCASES' ) < 0 && $participated == 0) { // /*if (strtoupper($Fields['APP_STATUS']) != 'COMPLETED') { // $oCase->thisIsTheCurrentUser($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'SHOW_MESSAGE'); // }*/ // $aMessage['MESSAGE'] = G::LoadTranslation( 'ID_NO_PERMISSION_NO_PARTICIPATED' ); // $G_PUBLISH = new Publisher(); // $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); // G::RenderPage( 'publishBlank', 'blank' ); // die(); // } $objProc = new \Process(); $aProc = $objProc->load( $Fields['PRO_UID'] ); $Fields['PRO_TITLE'] = $aProc['PRO_TITLE']; $objTask = new \Task(); if (isset($_SESSION['ACTION']) && ($_SESSION['ACTION'] == 'jump')) { $task = explode('-', $Fields['TAS_UID']); $Fields['TAS_TITLE'] = ''; for( $i = 0; $i < sizeof($task)-1; $i ++ ) { $aTask = $objTask->load( $task[$i] ); $Fields['TAS_TITLE'][] = $aTask['TAS_TITLE']; } $Fields['TAS_TITLE'] = implode(" - ", array_values($Fields['TAS_TITLE'])); } else { $aTask = $objTask->load( $Fields['TAS_UID'] ); $Fields['TAS_TITLE'] = $aTask['TAS_TITLE']; } // require_once(PATH_GULLIVER .'../thirdparty/smarty/libs/Smarty.class.php'); // $G_PUBLISH = new \Publisher(); // $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_Resume.xml', '', $Fields, '' ); // $G_PUBLISH->RenderContent(); return $Fields; }
/** * Delete Process * * @param string $processUid * @param bool $checkCases * * return bool Return true, if is succesfully * * @access public DEPRECATED public function deleteProcess($processUid, $checkCases = true) { if ($checkCases) { $process = new \Process(); $arrayCases = $process->getCasesCountInAllProcesses($processUid); $sum = 0; if (isset($arrayCases[$processUid]) && count($arrayCases[$processUid]) > 0) { foreach ($arrayCases[$processUid] as $value) { $sum = $sum + $value; } } if ($sum > 0) { throw (new \Exception("You can't delete the process, because it has $sum cases")); } } $processMap = new \processMap(); return $processMap->deleteProcess($processUid); }*/ public function deleteProcess($sProcessUID) { try { G::LoadClass('case'); G::LoadClass('reportTables'); //Instance all classes necesaries $oProcess = new Process(); $oDynaform = new Dynaform(); $oInputDocument = new InputDocument(); $oOutputDocument = new OutputDocument(); $oTrigger = new Triggers(); $oRoute = new Route(); $oGateway = new Gateway(); $oEvent = new Event(); $oSwimlaneElement = new SwimlanesElements(); $oConfiguration = new Configuration(); $oDbSource = new DbSource(); $oReportTable = new ReportTables(); $oCaseTracker = new CaseTracker(); $oCaseTrackerObject = new CaseTrackerObject(); //Delete the applications of process $oCriteria = new Criteria('workflow'); $oCriteria->add(ApplicationPeer::PRO_UID, $sProcessUID); $oDataset = ApplicationPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $oCase = new Cases(); while ($aRow = $oDataset->getRow()) { $oCase->removeCase($aRow['APP_UID']); $oDataset->next(); } //Delete the tasks of process $oCriteria = new Criteria('workflow'); $oCriteria->add(TaskPeer::PRO_UID, $sProcessUID); $oDataset = TaskPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $this->deleteTask($aRow['TAS_UID']); $oDataset->next(); } //Delete the dynaforms of process $oCriteria = new Criteria('workflow'); $oCriteria->add(DynaformPeer::PRO_UID, $sProcessUID); $oDataset = DynaformPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $oDynaform->remove($aRow['DYN_UID']); $oDataset->next(); } //Delete the input documents of process $oCriteria = new Criteria('workflow'); $oCriteria->add(InputDocumentPeer::PRO_UID, $sProcessUID); $oDataset = InputDocumentPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $oInputDocument->remove($aRow['INP_DOC_UID']); $oDataset->next(); } //Delete the output documents of process $oCriteria = new Criteria('workflow'); $oCriteria->add(OutputDocumentPeer::PRO_UID, $sProcessUID); $oDataset = OutputDocumentPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $oOutputDocument->remove($aRow['OUT_DOC_UID']); $oDataset->next(); } //Delete the triggers of process $oCriteria = new Criteria('workflow'); $oCriteria->add(TriggersPeer::PRO_UID, $sProcessUID); $oDataset = TriggersPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $oTrigger->remove($aRow['TRI_UID']); $oDataset->next(); } //Delete the routes of process $oCriteria = new Criteria('workflow'); $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID); $oDataset = RoutePeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $oRoute->remove($aRow['ROU_UID']); $oDataset->next(); } //Delete the gateways of process $oCriteria = new Criteria('workflow'); $oCriteria->add(GatewayPeer::PRO_UID, $sProcessUID); $oDataset = GatewayPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $oGateway->remove($aRow['GAT_UID']); $oDataset->next(); } //Delete the Event of process $oCriteria = new Criteria('workflow'); $oCriteria->add(EventPeer::PRO_UID, $sProcessUID); $oDataset = EventPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $oEvent->remove($aRow['EVN_UID']); $oDataset->next(); } //Delete the swimlanes elements of process $oCriteria = new Criteria('workflow'); $oCriteria->add(SwimlanesElementsPeer::PRO_UID, $sProcessUID); $oDataset = SwimlanesElementsPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $oSwimlaneElement->remove($aRow['SWI_UID']); $oDataset->next(); } //Delete the configurations of process $oCriteria = new Criteria('workflow'); $oCriteria->add(ConfigurationPeer::PRO_UID, $sProcessUID); $oDataset = ConfigurationPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $oConfiguration->remove($aRow['CFG_UID'], $aRow['OBJ_UID'], $aRow['PRO_UID'], $aRow['USR_UID'], $aRow['APP_UID']); $oDataset->next(); } //Delete the DB sources of process $oCriteria = new Criteria('workflow'); $oCriteria->add(DbSourcePeer::PRO_UID, $sProcessUID); $oDataset = DbSourcePeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { /** * note added by gustavo cruz gustavo-at-colosa-dot-com 27-01-2010 * in order to solve the bug 0004389, we use the validation function Exists * inside the remove function in order to verify if the DbSource record * exists in the Database, however there is a strange behavior within the * propel engine, when the first record is erased somehow the "_deleted" * attribute of the next row is set to true, so when propel tries to erase * it, obviously it can't and trows an error. With the "Exist" function * we ensure that if there is the record in the database, the _delete attribute must be false. * * note added by gustavo cruz gustavo-at-colosa-dot-com 28-01-2010 * I have just identified the source of the issue, when is created a $oDbSource DbSource object * it's used whenever a record is erased or removed in the db, however the problem * it's that the same object is used every time, and the delete method invoked * sets the _deleted attribute to true when its called, of course as we use * the same object, the first time works fine but trowns an error with the * next record, cos it's the same object and the delete method checks if the _deleted * attribute it's true or false, the attrib _deleted is setted to true the * first time and later is never changed, the issue seems to be part of * every remove function in the model classes, not only DbSource * i recommend that a more general solution must be achieved to resolve * this issue in every model class, to prevent future problems. */ $oDbSource->remove($aRow['DBS_UID'], $sProcessUID); $oDataset->next(); } //Delete the supervisors $oCriteria = new Criteria('workflow'); $oCriteria->add(ProcessUserPeer::PRO_UID, $sProcessUID); ProcessUserPeer::doDelete($oCriteria); //Delete the object permissions $oCriteria = new Criteria('workflow'); $oCriteria->add(ObjectPermissionPeer::PRO_UID, $sProcessUID); ObjectPermissionPeer::doDelete($oCriteria); //Delete the step supervisors $oCriteria = new Criteria('workflow'); $oCriteria->add(StepSupervisorPeer::PRO_UID, $sProcessUID); StepSupervisorPeer::doDelete($oCriteria); //Delete the report tables $oCriteria = new Criteria('workflow'); $oCriteria->add(ReportTablePeer::PRO_UID, $sProcessUID); $oDataset = ReportTablePeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $oReportTable->deleteReportTable($aRow['REP_TAB_UID']); $oDataset->next(); } //Delete case tracker configuration $oCaseTracker->remove($sProcessUID); //Delete case tracker objects $oCriteria = new Criteria('workflow'); $oCriteria->add(CaseTrackerObjectPeer::PRO_UID, $sProcessUID); ProcessUserPeer::doDelete($oCriteria); //Delete the process try { $oProcess->remove($sProcessUID); } catch (Exception $oError) { throw ($oError); } return true; } catch (Exception $oError) { throw ($oError); } }