/** * Get Case Tracker data of a Process * * @param string $processUid Unique id of Process * * return array Return an array with data of Case Tracker of a Process */ public function getCaseTracker($processUid) { try { $arrayCaseTracker = array(); //Verify data $process = new \ProcessMaker\BusinessModel\Process(); $process->throwExceptionIfNotExistsProcess($processUid, "prj_uid"); //Get data $criteria = new \Criteria(); $criteria->add(\CaseTrackerPeer::PRO_UID, $processUid, \Criteria::EQUAL); $rsCriteria = \CaseTrackerPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); if ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $arrayCaseTracker = $row; } else { $caseTracker = new \CaseTracker(); $arrayCaseTracker = array("PRO_UID" => $processUid, "CT_MAP_TYPE" => "PROCESSMAP", "CT_DERIVATION_HISTORY" => 1, "CT_MESSAGE_HISTORY" => 1); $caseTracker->create($arrayCaseTracker); } return array("map_type" => $arrayCaseTracker["CT_MAP_TYPE"], "routing_history" => (int) $arrayCaseTracker["CT_DERIVATION_HISTORY"], "message_history" => (int) $arrayCaseTracker["CT_MESSAGE_HISTORY"]); } 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 CaseTrackerPeer::populateObjects(CaseTrackerPeer::doSelectRS($criteria, $con)); }