/** * get pmtables list * * @param string $httpData->start * @param string $httpData->limit * @param string $httpData->textFilter */ public function getList($httpData) { G::LoadClass('configuration'); G::LoadClass('processMap'); G::LoadClass('pmTable'); $configurations = new Configurations(); $processMap = new processMap(); // setting parameters $config = $configurations->getConfiguration('additionalTablesList', 'pageSize', '', $_SESSION['USER_LOGGED']); $env = $configurations->getConfiguration('ENVIRONMENT_SETTINGS', ''); $limit_size = isset($config->pageSize) ? $config['pageSize'] : 20; $start = isset($httpData->start) ? $httpData->start : 0; $limit = isset($httpData->limit) ? $httpData->limit : $limit_size; $filter = isset($httpData->textFilter) ? $httpData->textFilter : ''; $pro_uid = isset($httpData->pro_uid) ? $httpData->pro_uid : null; if ($pro_uid !== null) { $process = $pro_uid == '' ? array('not_equal' => $pro_uid) : array('equal' => $pro_uid); $addTables = AdditionalTables::getAll($start, $limit, $filter, $process); $c = $processMap->getReportTablesCriteria($pro_uid); $oDataset = RoutePeer::doSelectRS($c); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $reportTablesOldList = array(); while ($oDataset->next()) { $reportTablesOldList[] = $oDataset->getRow(); } $addTables['count'] += count($reportTablesOldList); foreach ($reportTablesOldList as $i => $oldRepTab) { $addTables['rows'][] = array('ADD_TAB_UID' => $oldRepTab['REP_TAB_UID'], 'PRO_UID' => $oldRepTab['PRO_UID'], 'DBS_UID' => $oldRepTab['REP_TAB_CONNECTION'] == 'wf' ? 'workflow' : 'rp', 'ADD_TAB_DESCRIPTION' => $oldRepTab['REP_TAB_TITLE'], 'ADD_TAB_NAME' => $oldRepTab['REP_TAB_NAME'], 'ADD_TAB_TYPE' => $oldRepTab['REP_TAB_TYPE'], 'TYPE' => 'CLASSIC'); } } else { $addTables = AdditionalTables::getAll($start, $limit, $filter); } foreach ($addTables['rows'] as $i => $table) { try { $con = Propel::getConnection(pmTable::resolveDbSource($table['DBS_UID'])); $stmt = $con->createStatement(); $rs = $stmt->executeQuery('SELECT COUNT(*) AS NUM_ROWS from ' . $table['ADD_TAB_NAME']); if ($rs->next()) { $r = $rs->getRow(); $addTables['rows'][$i]['NUM_ROWS'] = $r['NUM_ROWS']; } else { $addTables['rows'][$i]['NUM_ROWS'] = 0; } //removing the prefix "PMT" to allow alphabetical order (just in view) if (substr($addTables['rows'][$i]['ADD_TAB_NAME'], 0, 4) == 'PMT_') { $addTables['rows'][$i]['ADD_TAB_NAME'] = substr($addTables['rows'][$i]['ADD_TAB_NAME'], 4); } } catch (Exception $e) { $addTables['rows'][$i]['NUM_ROWS'] = G::LoadTranslation('ID_TABLE_NOT_FOUND'); } } return $addTables; }
/** * prepareInformation * * @param array $arrayData Data * @param string $taskUid Unique id of Task * * return array Return array */ public function prepareInformation(array $arrayData, $taskUid = "") { try { if (!class_exists("Cases")) { G::LoadClass("case"); } $this->case = new Cases(); $task = new Task(); $arrayNextTask = array(); $arrayNextTaskDefault = array(); $i = 0; //SELECT * //FROM APP_DELEGATION AS A //LEFT JOIN TASK AS T ON(T.TAS_UID = A.TAS_UID) //LEFT JOIN ROUTE AS R ON(R.TAS_UID = A.TAS_UID) //WHERE //APP_UID = '$arrayData["APP_UID"]' //AND DEL_INDEX = '$arrayData["DEL_INDEX"]' $criteria = new Criteria("workflow"); $criteria->addSelectColumn(RoutePeer::TAS_UID); $criteria->addSelectColumn(RoutePeer::ROU_NEXT_TASK); $criteria->addSelectColumn(RoutePeer::ROU_TYPE); $criteria->addSelectColumn(RoutePeer::ROU_DEFAULT); $criteria->addSelectColumn(RoutePeer::ROU_CONDITION); if ($taskUid != "") { $criteria->add(RoutePeer::TAS_UID, $taskUid, Criteria::EQUAL); $criteria->addAscendingOrderByColumn(RoutePeer::ROU_CASE); $rsCriteria = RoutePeer::doSelectRS($criteria); } else { $criteria->addJoin(AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN); $criteria->addJoin(AppDelegationPeer::TAS_UID, RoutePeer::TAS_UID, Criteria::LEFT_JOIN); $criteria->add(AppDelegationPeer::APP_UID, $arrayData["APP_UID"], Criteria::EQUAL); $criteria->add(AppDelegationPeer::DEL_INDEX, $arrayData["DEL_INDEX"], Criteria::EQUAL); $criteria->addAscendingOrderByColumn(RoutePeer::ROU_CASE); $rsCriteria = AppDelegationPeer::doSelectRS($criteria); } $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); $flagDefault = false; while ($rsCriteria->next()) { $arrayRouteData = G::array_merges($rsCriteria->getRow(), $arrayData); if ((int)($arrayRouteData["ROU_DEFAULT"]) == 1) { $arrayNextTaskDefault = $arrayRouteData; $flagDefault = true; continue; } $flagContinue = true; //Evaluate the condition if there are conditions defined if (isset($arrayRouteData["ROU_CONDITION"]) && trim($arrayRouteData["ROU_CONDITION"]) != "" && ($arrayRouteData["ROU_TYPE"] != "SELECT" || $arrayRouteData["ROU_TYPE"] == "PARALLEL-BY-EVALUATION")) { G::LoadClass("pmScript"); $arrayApplicationData = $this->case->loadCase($arrayData["APP_UID"]); $pmScript = new PMScript(); $pmScript->setFields($arrayApplicationData["APP_DATA"]); $pmScript->setScript($arrayRouteData["ROU_CONDITION"]); $flagContinue = $pmScript->evaluate(); } if (isset($arrayRouteData["ROU_CONDITION"]) && trim($arrayRouteData["ROU_CONDITION"]) == "" && $arrayRouteData["ROU_NEXT_TASK"] != "-1") { $arrayTaskData = $task->load($arrayRouteData["ROU_NEXT_TASK"]); if ($arrayTaskData["TAS_TYPE"] == "GATEWAYTOGATEWAY") { $flagContinue = false; } } if ($arrayRouteData["ROU_TYPE"] == "EVALUATE" && count($arrayNextTask) > 0) { $flagContinue = false; } if ($flagContinue) { $arrayNextTask[++$i] = $this->prepareInformationTask($arrayRouteData); } } if (count($arrayNextTask) == 0 && count($arrayNextTaskDefault) > 0) { $arrayNextTask[++$i] = $this->prepareInformationTask($arrayNextTaskDefault); } //Check Task GATEWAYTOGATEWAY or END-MESSAGE-EVENT or END-EMAIL-EVENT $arrayNextTaskBackup = $arrayNextTask; $arrayNextTask = array(); $i = 0; foreach ($arrayNextTaskBackup as $value) { $arrayNextTaskData = $value; if ($arrayNextTaskData["NEXT_TASK"]["TAS_UID"] != "-1" && in_array($arrayNextTaskData["NEXT_TASK"]["TAS_TYPE"], array("GATEWAYTOGATEWAY", "END-MESSAGE-EVENT", "END-EMAIL-EVENT")) ) { $arrayAux = $this->prepareInformation($arrayData, $arrayNextTaskData["NEXT_TASK"]["TAS_UID"]); foreach ($arrayAux as $value2) { $arrayNextTask[++$i] = $value2; } } else { if (in_array($arrayNextTaskData["TAS_TYPE"], array("END-MESSAGE-EVENT", "END-EMAIL-EVENT")) && $arrayNextTaskData["NEXT_TASK"]["TAS_UID"] == "-1" ) { $arrayNextTaskData["NEXT_TASK"]["TAS_UID"] = $arrayNextTaskData["TAS_UID"] . "/" . $arrayNextTaskData["NEXT_TASK"]["TAS_UID"]; } $arrayNextTask[++$i] = $arrayNextTaskData; } } //1. There is no rule if (count($arrayNextTask) == 0) { $oProcess = new Process(); $oProcessFieds = $oProcess->Load( $_SESSION['PROCESS'] ); if(isset($oProcessFieds['PRO_BPMN']) && $oProcessFieds['PRO_BPMN'] == 1){ throw new Exception(G::LoadTranslation("ID_NO_DERIVATION_BPMN_RULE")); }else{ throw new Exception(G::LoadTranslation("ID_NO_DERIVATION_RULE")); } } //Return return $arrayNextTask; } catch (Exception $e) { throw $e; } }
/** * this function remove all Process except the PROCESS ROW * * @param string $sProUid * @return boolean */ public function removeProcessRows ($sProUid) { try { //Instance all classes necesaries $oProcess = new Process(); $oDynaform = new Dynaform(); $oInputDocument = new InputDocument(); $oOutputDocument = new OutputDocument(); $oTrigger = new Triggers(); $oStepTrigger = new StepTrigger(); $oRoute = new Route(); $oStep = new Step(); $oSubProcess = new SubProcess(); $oCaseTracker = new CaseTracker(); $oCaseTrackerObject = new CaseTrackerObject(); $oObjectPermission = new ObjectPermission(); $oSwimlaneElement = new SwimlanesElements(); $oConnection = new DbSource(); $oStage = new Stage(); $oEvent = new Event(); $oCaseScheduler = new CaseScheduler(); $oConfig = new Configuration(); //Delete the tasks of process $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( TaskPeer::PRO_UID, $sProUid ); $oDataset = TaskPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); $oTask = new Task(); while ($aRow = $oDataset->getRow()) { $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( StepTriggerPeer::TAS_UID, $aRow['TAS_UID'] ); StepTriggerPeer::doDelete( $oCriteria ); if ($oTask->taskExists( $aRow['TAS_UID'] )) { $oTask->remove( $aRow['TAS_UID'] ); } $oDataset->next(); } //Delete the dynaforms of process $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( DynaformPeer::PRO_UID, $sProUid ); $oDataset = DynaformPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $sWildcard = PATH_DYNAFORM . $aRow['PRO_UID'] . PATH_SEP . $aRow['DYN_UID'] . '_tmp*'; foreach (glob( $sWildcard ) as $fn) { @unlink( $fn ); } $sWildcard = PATH_DYNAFORM . $aRow['PRO_UID'] . PATH_SEP . $aRow['DYN_UID'] . '.*'; foreach (glob( $sWildcard ) as $fn) { @unlink( $fn ); } if ($oDynaform->dynaformExists( $aRow['DYN_UID'] )) { $oDynaform->remove( $aRow['DYN_UID'] ); } $oDataset->next(); } //Delete the input documents of process $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( InputDocumentPeer::PRO_UID, $sProUid ); $oDataset = InputDocumentPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { if ($oInputDocument->InputExists( $aRow['INP_DOC_UID'] )) { $oInputDocument->remove( $aRow['INP_DOC_UID'] ); } $oDataset->next(); } //Delete the output documents of process $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( OutputDocumentPeer::PRO_UID, $sProUid ); $oDataset = OutputDocumentPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { if ($oOutputDocument->OutputExists( $aRow['OUT_DOC_UID'] )) { $oOutputDocument->remove( $aRow['OUT_DOC_UID'] ); } $oDataset->next(); } //Delete the steps $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( StepPeer::PRO_UID, $sProUid ); $oDataset = StepPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { //Delete the steptrigger of process /*$oCriteria = new Criteria('workflow'); $oCriteria->add(StepTriggerPeer::STEP_UID, $aRow['STEP_UID']); $oDataseti = StepTriggerPeer::doSelectRS($oCriteria); $oDataseti->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataseti->next(); while ($aRowi = $oDataseti->getRow()) { if ($oStepTrigger->stepTriggerExists($aRowi['STEP_UID'], $aRowi['TAS_UID'], $aRowi['TRI_UID'], $aRowi['ST_TYPE'])) $oStepTrigger->remove($aRowi['STEP_UID'], $aRowi['TAS_UID'], $aRowi['TRI_UID'], $aRowi['ST_TYPE']); $oDataseti->next(); }*/ $oStep->remove( $aRow['STEP_UID'] ); $oDataset->next(); } //Delete the StepSupervisor $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( StepSupervisorPeer::PRO_UID, $sProUid ); $oDataset = StepSupervisorPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { if ($oStep->StepExists( $aRow['STEP_UID'] )) { $oStep->remove( $aRow['STEP_UID'] ); } $oDataset->next(); } //Delete the triggers of process $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( TriggersPeer::PRO_UID, $sProUid ); $oDataset = TriggersPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { if ($oTrigger->TriggerExists( $aRow['TRI_UID'] )) { $oTrigger->remove( $aRow['TRI_UID'] ); } $oDataset->next(); } //Delete the routes of process $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( RoutePeer::PRO_UID, $sProUid ); $oDataset = RoutePeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { if ($oRoute->routeExists( $aRow['ROU_UID'] )) { $oRoute->remove( $aRow['ROU_UID'] ); } $oDataset->next(); } //Delete the swimlanes elements of process $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( SwimlanesElementsPeer::PRO_UID, $sProUid ); $oDataset = SwimlanesElementsPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { if ($oSwimlaneElement->swimlanesElementsExists( $aRow['SWI_UID'] )) { $oSwimlaneElement->remove( $aRow['SWI_UID'] ); } $oDataset->next(); } //Delete the DB connections of process $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( DbSourcePeer::PRO_UID, $sProUid ); $oDataset = DbSourcePeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { if ($oConnection->Exists( $aRow['DBS_UID'], $aRow['PRO_UID'] )) { $oConnection->remove( $aRow['DBS_UID'], $aRow['PRO_UID'] ); } $oDataset->next(); } //Delete the sub process of process $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( SubProcessPeer::PRO_PARENT, $sProUid ); $oDataset = SubProcessPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { if ($oSubProcess->subProcessExists( $aRow['SP_UID'] )) { $oSubProcess->remove( $aRow['SP_UID'] ); } $oDataset->next(); } //Delete the caseTracker of process $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( CaseTrackerPeer::PRO_UID, $sProUid ); $oDataset = CaseTrackerPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { if ($oCaseTracker->caseTrackerExists( $aRow['PRO_UID'] )) { $oCaseTracker->remove( $aRow['PRO_UID'] ); } $oDataset->next(); } //Delete the caseTrackerObject of process $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( CaseTrackerObjectPeer::PRO_UID, $sProUid ); $oDataset = CaseTrackerObjectPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { if ($oCaseTrackerObject->caseTrackerObjectExists( $aRow['CTO_UID'] )) { $oCaseTrackerObject->remove( $aRow['CTO_UID'] ); } $oDataset->next(); } //Delete the ObjectPermission of process $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( ObjectPermissionPeer::PRO_UID, $sProUid ); $oDataset = ObjectPermissionPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { if ($oObjectPermission->Exists( $aRow['OP_UID'] )) { $oObjectPermission->remove( $aRow['OP_UID'] ); } $oDataset->next(); } //Delete the Stage of process $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( StagePeer::PRO_UID, $sProUid ); $oDataset = StagePeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { if ($oStage->Exists( $aRow['STG_UID'] )) { $oStage->remove( $aRow['STG_UID'] ); } $oDataset->next(); } //Delete the Event of process $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( EventPeer::PRO_UID, $sProUid ); $oDataset = EventPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { if ($oEvent->Exists( $aRow['EVN_UID'] )) { $oEvent->remove( $aRow['EVN_UID'] ); } $oDataset->next(); if ($oEvent->existsByTaskUidFrom( $aRow['TAS_UID'] )) { $aRowEvent = $oEvent->getRowByTaskUidFrom( $aRow['TAS_UID'] ); $oEvent->remove( $aRowEvent['EVN_UID'] ); } $oDataset->next(); } //Delete the CaseScheduler of process $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( CaseSchedulerPeer::PRO_UID, $sProUid ); $oDataset = CaseSchedulerPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { if ($oCaseScheduler->Exists( $aRow['SCH_UID'] )) { $oCaseScheduler->remove( $aRow['SCH_UID'] ); } $oDataset->next(); } //Delete the TaskExtraProperties of the process $oCriteria = new Criteria( 'workflow' ); $oCriteria->addSelectColumn( ConfigurationPeer::CFG_UID ); $oCriteria->addSelectColumn( ConfigurationPeer::OBJ_UID ); $oCriteria->addSelectColumn( ConfigurationPeer::CFG_VALUE ); $oCriteria->addSelectColumn( TaskPeer::PRO_UID ); $oCriteria->addSelectColumn( ConfigurationPeer::USR_UID ); $oCriteria->addSelectColumn( ConfigurationPeer::APP_UID ); $oCriteria->add( TaskPeer::PRO_UID, $sProUid ); $oCriteria->add( ConfigurationPeer::CFG_UID, 'TAS_EXTRA_PROPERTIES' ); $oCriteria->addJoin( ConfigurationPeer::OBJ_UID, TaskPeer::TAS_UID ); $oDataset = ConfigurationPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { if ($oConfig->exists($aRow['CFG_UID'], $aRow['OBJ_UID'], $aRow['PRO_UID'], $aRow['USR_UID'], $aRow['APP_UID'])) { $oConfig->remove( $aRow['CFG_UID'], $aRow['OBJ_UID'], $aRow['PRO_UID'], $aRow['USR_UID'], $aRow['APP_UID'] ); } $oDataset->next(); } return true; } catch (Exception $oError) { throw ($oError); } }
/** * 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 RoutePeer::populateObjects(RoutePeer::doSelectRS($criteria, $con)); }
/** * saveNewPattern * * @param string $sProcessUID Default value empty * @param string $sTaskUID Default value empty * @param string $sNextTask Default value empty * @param string $sType Default value empty * @param boolean $sDelete * @return array void */ public function saveNewPattern($sProcessUID = '', $sTaskUID = '', $sNextTask = '', $sType = '', $sDelete = '') { try { $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn('COUNT(*) AS ROUTE_NUMBER'); $oCriteria->addSelectColumn('GAT_UID AS GATEWAY_UID'); $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID); $oCriteria->add(RoutePeer::TAS_UID, $sTaskUID); $oCriteria->add(RoutePeer::ROU_TYPE, $sType); $oDataset = RoutePeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $aRow = $oDataset->getRow(); $aFields['PRO_UID'] = $sProcessUID; $aFields['TAS_UID'] = $sTaskUID; $aFields['ROU_NEXT_TASK'] = $sNextTask; $aFields['ROU_TYPE'] = $sType; $aFields['ROU_CASE'] = (int) $aRow['ROUTE_NUMBER'] + 1; $sGatewayUID = $aRow['GATEWAY_UID']; if ($sDelete && $sGatewayUID != '') { $oGateway = new Gateway(); $oGateway->remove($sGatewayUID); } //Getting Gateway UID after saving gateway //if($sType != 'SEQUENTIAL' && $sGatewayUID == '' && $sDelete == '1') if ($sType != 'SEQUENTIAL') { $oProcessMap = new processMap(); $sGatewayUID = $oProcessMap->saveNewGateway($sProcessUID, $sTaskUID, $sNextTask); } $aFields['GAT_UID'] = isset($sGatewayUID) ? $sGatewayUID : ''; $oRoute = new Route(); $oRoute->create($aFields); } catch (Exception $oError) { throw $oError; } }
/** * This function returns the threads open in a task * get an array with all sibling threads open from next task * * @param string $nextTaskUid * @param string $applicationUid * @param string $delIndex * @param string $currentTaskUid * * return array Return $arrayThread */ public function getOpenSiblingThreads($nextTaskUid, $applicationUid, $delIndex, $currentTaskUid) { try { //Get all tasks that are previous to my NextTask, we want to know if there are pending task for my nexttask //we need to filter only seq joins going to my next task //and we are removing the current task from the search $arrayThread = array(); $criteria = new Criteria("workflow"); $criteria->add(RoutePeer::TAS_UID, $currentTaskUid, Criteria::NOT_EQUAL); $criteria->add(RoutePeer::ROU_NEXT_TASK, $nextTaskUid, Criteria::EQUAL); $criteria->add(RoutePeer::ROU_TYPE, "SEC-JOIN", Criteria::EQUAL); $rsCriteria = RoutePeer::doSelectRS($criteria); $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $arrayPrevious = $this->searchOpenPreviousTasks($row["TAS_UID"], $applicationUid); if (is_array($arrayPrevious) && !empty($arrayPrevious)) { $arrayThread = array_merge($arrayThread, $arrayPrevious); } } //Return return $arrayThread; } catch (Exception $e) { throw $e; } }
public function deleteProcess($sProcessUID, $flagRemoveCases = true) { 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(); //Update PROCESS_FILES_CHECKED $configuration = \ConfigurationPeer::retrieveByPK("PROCESS_FILES_CHECKED", "", "", "", ""); if (!is_null($configuration)) { $arrayProjectUid = unserialize($configuration->getCfgValue()); unset($arrayProjectUid[$sProcessUID]); $conf = new \Configuration(); $result = $conf->update(array("CFG_UID" => "PROCESS_FILES_CHECKED", "OBJ_UID" => "", "CFG_VALUE" => serialize($arrayProjectUid), "PRO_UID" => "", "USR_UID" => "", "APP_UID" => "")); } //Delete the applications of process if ($flagRemoveCases) { $case = new \Cases(); $criteria = new \Criteria("workflow"); $criteria->addSelectColumn(\ApplicationPeer::APP_UID); $criteria->add(\ApplicationPeer::PRO_UID, $sProcessUID, \Criteria::EQUAL); $rsCriteria = \ApplicationPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $result = $case->removeCase($row["APP_UID"]); } } //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']); $oTasks = new \Tasks(); $oTasks->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 SubProcess $criteria = new \Criteria("workflow"); $criteria->add(\SubProcessPeer::PRO_PARENT, $sProcessUID, \Criteria::EQUAL); $result = \SubProcessPeer::doDelete($criteria); //Delete WebEntries $webEntry = new \ProcessMaker\BusinessModel\WebEntry(); $criteria = new \Criteria("workflow"); $criteria->addSelectColumn(\WebEntryPeer::WE_UID); $criteria->add(\WebEntryPeer::PRO_UID, $sProcessUID, \Criteria::EQUAL); $rsCriteria = \WebEntryPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $webEntry->delete($row["WE_UID"]); } //Delete WebEntry-Events $webEntryEvent = new \ProcessMaker\BusinessModel\WebEntryEvent(); $criteria = new \Criteria("workflow"); $criteria->addSelectColumn(\WebEntryEventPeer::WEE_UID); $criteria->add(\WebEntryEventPeer::PRJ_UID, $sProcessUID, \Criteria::EQUAL); $rsCriteria = \WebEntryEventPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $webEntryEvent->delete($row["WEE_UID"]); } //Delete MessageTypes $messageType = new \ProcessMaker\BusinessModel\MessageType(); $criteria = new \Criteria("workflow"); $criteria->addSelectColumn(\MessageTypePeer::MSGT_UID); $criteria->add(\MessageTypePeer::PRJ_UID, $sProcessUID, \Criteria::EQUAL); $rsCriteria = \MessageTypePeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $messageType->delete($row["MSGT_UID"]); } //Delete Message-Event-Relation $messageEventRelation = new \ProcessMaker\BusinessModel\MessageEventRelation(); $messageEventRelation->deleteWhere(array(\MessageEventRelationPeer::PRJ_UID => $sProcessUID)); //Delete Message-Event-Task-Relation $elementTaskRelation = new \ProcessMaker\BusinessModel\ElementTaskRelation(); $elementTaskRelation->deleteWhere(array(\ElementTaskRelationPeer::PRJ_UID => $sProcessUID)); //Delete Message-Event-Definition $messageEventDefinition = new \ProcessMaker\BusinessModel\MessageEventDefinition(); $criteria = new \Criteria("workflow"); $criteria->addSelectColumn(\MessageEventDefinitionPeer::MSGED_UID); $criteria->add(\MessageEventDefinitionPeer::PRJ_UID, $sProcessUID, \Criteria::EQUAL); $rsCriteria = \MessageEventDefinitionPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $messageEventDefinition->delete($row["MSGED_UID"]); } //Delete Script-Task $scriptTask = new \ProcessMaker\BusinessModel\ScriptTask(); $scriptTask->deleteWhere(array(\ScriptTaskPeer::PRJ_UID => array($sProcessUID, \Criteria::EQUAL))); //Delete Timer-Event $timerEvent = new \ProcessMaker\BusinessModel\TimerEvent(); $timerEvent->deleteWhere(array(\TimerEventPeer::PRJ_UID => array($sProcessUID, \Criteria::EQUAL))); //Delete Email-Event $emailEvent = new \ProcessMaker\BusinessModel\EmailEvent(); $criteria = new \Criteria("workflow"); $criteria->addSelectColumn(\EmailEventPeer::EMAIL_EVENT_UID); $criteria->add(\EmailEventPeer::PRJ_UID, $sProcessUID, \Criteria::EQUAL); $rsCriteria = \EmailEventPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $emailEvent->delete($sProcessUID, $row["EMAIL_EVENT_UID"], false); } //Delete files Manager $filesManager = new \ProcessMaker\BusinessModel\FilesManager(); $criteria = new \Criteria("workflow"); $criteria->addSelectColumn(\ProcessFilesPeer::PRF_UID); $criteria->add(\ProcessFilesPeer::PRO_UID, $sProcessUID, \Criteria::EQUAL); $rsCriteria = \ProcessFilesPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $filesManager->deleteProcessFilesManager($sProcessUID, $row["PRF_UID"]); } //Delete the actions by email $oCriteria = new Criteria('workflow'); $oCriteria->add(\AbeConfigurationPeer::PRO_UID, $sProcessUID); \AbeConfigurationPeer::doDelete($oCriteria); //Delete the process try { $oProcess->remove($sProcessUID); } catch (\Exception $oError) { throw $oError; } return true; } catch (\Exception $oError) { throw $oError; } }
G::LoadClass('configuration'); G::LoadClass('processMap'); $configigurations = new Configurations(); $oProcessMap = new processMap(); $config = $configigurations->getConfiguration('additionalTablesList', 'pageSize', '', $_SESSION['USER_LOGGED']); $env = $configigurations->getConfiguration('ENVIRONMENT_SETTINGS', ''); $limit_size = isset($config['pageSize']) ? $config['pageSize'] : 20; $start = isset($_REQUEST['start']) ? $_REQUEST['start'] : 0; $limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : $limit_size; $filter = isset($_REQUEST['textFilter']) ? $_REQUEST['textFilter'] : ''; $pro_uid = isset($_REQUEST['pro_uid']) ? $_REQUEST['pro_uid'] : ''; $process = $pro_uid == '' ? array('not_equal' => $pro_uid) : array('equal' => $pro_uid); $addTab = AdditionalTables::getAll($start, $limit, $filter, $process); if ($pro_uid != '') { $c = $oProcessMap->getReportTablesCriteria($pro_uid); $oDataset = RoutePeer::doSelectRS($c); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $reportTablesOldList = array(); while ($oDataset->next()) { $reportTablesOldList[] = $oDataset->getRow(); } $addTab['count'] += count($reportTablesOldList); foreach ($reportTablesOldList as $i => $oldRepTab) { $addTab['rows'][] = array('ADD_TAB_UID' => $oldRepTab['REP_TAB_UID'], 'PRO_UID' => $oldRepTab['PRO_UID'], 'ADD_TAB_DESCRIPTION' => $oldRepTab['REP_TAB_TITLE'], 'ADD_TAB_NAME' => $oldRepTab['REP_TAB_NAME'], 'ADD_TAB_TYPE' => $oldRepTab['REP_TAB_TYPE'], 'TYPE' => 'CLASSIC'); } } echo G::json_encode($addTab); break; case 'updateTag': require_once 'classes/model/AdditionalTables.php'; $oAdditionalTables = new AdditionalTables();
public static function getAll($proUid = null, $start = null, $limit = null, $filter = '', $changeCaseTo = CASE_UPPER) { $c = new Criteria('workflow'); $c->addSelectColumn("ROUTE.*"); if (! is_null($proUid)) { $c->add(RoutePeer::PRO_UID, $proUid, Criteria::EQUAL); } $rs = RoutePeer::doSelectRS($c); $rs->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $routes = array(); while ($rs->next()) { $routes[] = $changeCaseTo !== CASE_UPPER ? array_change_key_case($rs->getRow(), CASE_LOWER) : $rs->getRow(); } return $routes; }
/** * Get Routes for any Process,route type,route next task * @param string $sProUid, $sTaskUid * @return array * by Girish */ public function getRouteByType($sProUid, $sRouteNextTaskUid, $sRouteType) { try { $aRoutes = array(); $oCriteria = new Criteria('workflow'); $oCriteria->add(RoutePeer::PRO_UID, $sProUid); $oCriteria->add(RoutePeer::ROU_NEXT_TASK, $sRouteNextTaskUid); $oCriteria->add(RoutePeer::ROU_TYPE, $sRouteType); $oDataset = RoutePeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $aRoutes[] = $aRow; $oDataset->next(); } return $aRoutes; } catch (Exception $oError) { throw $oError; } }
} } G::LoadSystem('inputfilter'); $filter = new InputFilter(); $form = $_POST['form']; $form = $filter->xssFilterHard($form); //$tasUid = $form['TASKS']; $tasUid = $form['TAS_PARENT']; $spSynchronous = $form['SP_SYNCHRONOUS']; require_once 'classes/model/Route.php'; require_once 'classes/model/Task.php'; $oRoute = new Route(); $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(RoutePeer::ROU_NEXT_TASK); $oCriteria->add(RoutePeer::TAS_UID, $tasUid); $oDataset = RoutePeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $sw = 1; // if there are more step we're looking them and we're checking TAS_ASSIGN_TYPE field while ($oDataset->next() && $sw) { $aRow = $oDataset->getRow(); $oCriteria1 = new Criteria('workflow'); $oCriteria1->addSelectColumn(TaskPeer::TAS_ASSIGN_TYPE); $oCriteria1->add(TaskPeer::PRO_UID, $form['PRO_PARENT']); $oCriteria1->add(TaskPeer::TAS_UID, $aRow['ROU_NEXT_TASK']); $oDataset1 = TaskPeer::doSelectRS($oCriteria1); $oDataset1->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset1->next(); $aRow1 = $oDataset1->getRow(); if ($spSynchronous && $aRow1['TAS_ASSIGN_TYPE'] == 'MANUAL') { $sw = 0;
/** * 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; } }
public static function getElementOriginToElementDest($floOrigin, $floCondition = '', $floDestType = '') { $criFlow = new Criteria("workflow"); $criFlow->addSelectColumn(BpmnFlowPeer::FLO_ELEMENT_ORIGIN); $criFlow->addSelectColumn(BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE); $criFlow->addSelectColumn(BpmnFlowPeer::FLO_ELEMENT_DEST); $criFlow->addSelectColumn(BpmnFlowPeer::FLO_ELEMENT_DEST_TYPE); $criFlow->addSelectColumn(BpmnFlowPeer::FLO_CONDITION); $criFlow->add(BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $floOrigin, Criteria::EQUAL); if ($floCondition != '') { $criFlow->add(BpmnFlowPeer::FLO_CONDITION, $floCondition, Criteria::EQUAL); } if ($floDestType != '') { $criFlow->add(BpmnFlowPeer::FLO_ELEMENT_DEST_TYPE, $floDestType, Criteria::EQUAL); } $rsCriFlow = RoutePeer::doSelectRS($criFlow); $rsCriFlow->setFetchmode(ResultSet::FETCHMODE_ASSOC); return $rsCriFlow; }
/** * 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); } }
/** * Throw Events for the Case * * @param string $currentTask Task uid * * @return void */ private function throwAllRouteInFlow($currentTask, $appFields) { $criFlow = new Criteria("workflow"); $criFlow->addSelectColumn(BpmnFlowPeer::FLO_ELEMENT_ORIGIN); $criFlow->addSelectColumn(BpmnFlowPeer::FLO_ELEMENT_DEST); $criFlow->add(BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $currentTask, Criteria::EQUAL); $rsCriFlow = RoutePeer::doSelectRS($criFlow); $rsCriFlow->setFetchmode(ResultSet::FETCHMODE_ASSOC); if ($rsCriFlow->next()) { $continue = true; $row = $rsCriFlow->getRow(); } while ($continue) { $origin = $row["FLO_ELEMENT_ORIGIN"]; $destiny = $row["FLO_ELEMENT_DEST"]; $this->throwEventsElemntOriginToElementDest($destiny, $appFields); $currentDestiny = $destiny; $continue = false; if ($rsCriFlow->next()) { $continue = true; $row = $rsCriFlow->getRow(); } else { //Search the next $criFlow = new Criteria("workflow"); $criFlow->addSelectColumn(BpmnFlowPeer::FLO_ELEMENT_ORIGIN); $criFlow->addSelectColumn(BpmnFlowPeer::FLO_ELEMENT_DEST); $criFlow->add(BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $currentDestiny, Criteria::EQUAL); $rsCriFlow = RoutePeer::doSelectRS($criFlow); $rsCriFlow->setFetchmode(ResultSet::FETCHMODE_ASSOC); $continue = false; if ($rsCriFlow->next()) { $continue = true; $row = $rsCriFlow->getRow(); } } } return $currentDestiny; }