/** * Put SubProcess in Process * @var string $pro_uid. Uid for Process * @var string $spr_uid. Uid for SubProcess * @var array $spr_data. Data for SubProcess * * * @author Brayan Pereyra (Cochalo) <*****@*****.**> * @copyright Colosa - Bolivia * * @return array */ public function putSubprocesss($pro_uid, $tas_uid, $spr_data) { $pro_uid = $this->validateProUid($pro_uid); $tas_uid = $this->validateTasUid($tas_uid); if (empty($spr_data)) { throw new \Exception("The request data is empty."); } if (isset($spr_data['spr_pro'])) { $spr_data['spr_pro'] = $this->validateProUid($spr_data['spr_pro']); } if (isset($spr_data['spr_tas'])) { $spr_data['spr_tas'] = $this->validateTasUid($spr_data['spr_tas']); } $dataTemp = $this->getSubprocesss($pro_uid, $tas_uid); $spr_data = array_merge($dataTemp, $spr_data); $spr_data['spr_variables_in'] = isset($spr_data['spr_variables_in']) ? $spr_data['spr_variables_in'] : array(); $oSubProcess = new \SubProcess(); $aData = array('SP_UID' => $spr_data['spr_uid'], 'PRO_UID' => $spr_data['spr_pro'], 'TAS_UID' => $spr_data['spr_tas'], 'PRO_PARENT' => $pro_uid, 'TAS_PARENT' => $tas_uid, 'SP_TYPE' => 'SIMPLE', 'SP_SYNCHRONOUS' => (int) $spr_data['spr_synchronous'], 'SP_SYNCHRONOUS_TYPE' => 'ALL', 'SP_SYNCHRONOUS_WAIT' => 0, 'SP_VARIABLES_OUT' => serialize($spr_data['spr_variables_out']), 'SP_VARIABLES_IN' => serialize($spr_data['spr_variables_in']), 'SP_GRID_IN' => ''); $oSubProcess->update($aData); $lang = defined('SYS_LANG') ? SYS_LANG : 'en'; \Content::addContent('TAS_TITLE', '', $tas_uid, $lang, $spr_data['spr_name']); }
/** * Implementation for 'POST' method for Rest API * * @param mixed $spUid Primary key * * @return array $result Returns array within multiple records or a single record depending if * a single selection was requested passing id(s) as param */ protected function post($spUid, $proUid, $tasUid, $proParent, $tasParent, $spType, $spSynchronous, $spSynchronousType, $spSynchronousWait, $spVariablesOut, $spVariablesIn, $spGridIn) { try { $result = array(); $obj = new SubProcess(); $obj->setSpUid($spUid); $obj->setProUid($proUid); $obj->setTasUid($tasUid); $obj->setProParent($proParent); $obj->setTasParent($tasParent); $obj->setSpType($spType); $obj->setSpSynchronous($spSynchronous); $obj->setSpSynchronousType($spSynchronousType); $obj->setSpSynchronousWait($spSynchronousWait); $obj->setSpVariablesOut($spVariablesOut); $obj->setSpVariablesIn($spVariablesIn); $obj->setSpGridIn($spGridIn); $obj->save(); } catch (Exception $e) { throw new RestException(412, $e->getMessage()); } }
/** * 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); } }
/** * deleteSubProcess * * @param string $sProcessUID * @param string $sTaskUID * @return boolean true * throw Exception $oError */ public function deleteSubProcess($sProcessUID = '', $sTaskUID = '') { try { $oTasks = new Tasks(); $oTasks->deleteTask($sTaskUID); $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn('SP_UID'); $oCriteria->add(SubProcessPeer::PRO_PARENT, $sProcessUID); $oCriteria->add(SubProcessPeer::TAS_PARENT, $sTaskUID); $oDataset = SubProcessPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $aRow = $oDataset->getRow(); $oSubProcess = new SubProcess(); $oSubProcess->remove($aRow['SP_UID']); return true; } catch (Exception $oError) { throw $oError; } }
/** * Validates all modified columns of given SubProcess object. * If parameter $columns is either a single column name or an array of column names * than only those columns are validated. * * NOTICE: This does not apply to primary or foreign keys for now. * * @param SubProcess $obj The object to validate. * @param mixed $cols Column name or array of column names. * * @return mixed TRUE if all columns are valid or the error message of the first invalid column. */ public static function doValidate(SubProcess $obj, $cols = null) { $columns = array(); if ($cols) { $dbMap = Propel::getDatabaseMap(SubProcessPeer::DATABASE_NAME); $tableMap = $dbMap->getTable(SubProcessPeer::TABLE_NAME); if (!is_array($cols)) { $cols = array($cols); } foreach ($cols as $colName) { if ($tableMap->containsColumn($colName)) { $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); $columns[$colName] = $obj->{$get}(); } } } else { if ($obj->isNew() || $obj->isColumnModified(SubProcessPeer::SP_TYPE)) { $columns[SubProcessPeer::SP_TYPE] = $obj->getSpType(); } if ($obj->isNew() || $obj->isColumnModified(SubProcessPeer::SP_SYNCHRONOUS)) { $columns[SubProcessPeer::SP_SYNCHRONOUS] = $obj->getSpSynchronous(); } if ($obj->isNew() || $obj->isColumnModified(SubProcessPeer::SP_SYNCHRONOUS_TYPE)) { $columns[SubProcessPeer::SP_SYNCHRONOUS_TYPE] = $obj->getSpSynchronousType(); } } return BasePeer::doValidate(SubProcessPeer::DATABASE_NAME, SubProcessPeer::TABLE_NAME, $columns); }
public function removeSupProcess($proUid, $tasUid) { try { $subProcess = \SubProcess::findByParents($proUid, $tasUid); self::log("Remove SupProcess: " . $subProcess->getSpUid()); $subProcess->delete(); self::log("Remove SupProcess Success!"); } catch (\Exception $e) { self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString()); throw $e; } }
$out = array(); for ($i = 1; $i <= count($_POST['form']['grid1']); $i++) { $out[$_POST['form']['grid1'][$i]['VAR_OUT1']] = $_POST['form']['grid1'][$i]['VAR_OUT2']; } $in = array(); for ($j = 1; $j <= count($_POST['form']['grid2']); $j++) { $in[$_POST['form']['grid2'][$j]['VAR_IN1']] = $_POST['form']['grid2'][$j]['VAR_IN2']; } require_once 'classes/model/Task.php'; $oTask = new Task(); //$aTask=$oTask->load($_POST['form']['TASKS']); //$aTask=$oTask->load($_POST['form']['PRO_UID']); $aTask = $_POST['form']['TASKS'] != 0 ? $oTask->load($_POST['form']['TASKS']) : 0; //$aTask['PRO_UID']=0; if (isset($_POST['form']['SP_SYNCHRONOUS']) && $_POST['form']['SP_SYNCHRONOUS'] == '') { $_POST['form']['SP_SYNCHRONOUS'] = '0'; } if (!isset($_POST['form']['SP_SYNCHRONOUS'])) { $_POST['form']['SP_SYNCHRONOUS'] = '0'; } require_once 'classes/model/SubProcess.php'; $oOP = new SubProcess(); $aData = array('SP_UID' => $_POST['form']['SP_UID'], 'PRO_UID' => isset($aTask['PRO_UID']) ? $aTask['PRO_UID'] : '', 'TAS_UID' => $_POST['form']['TASKS'], 'PRO_PARENT' => $_POST['form']['PRO_PARENT'], 'TAS_PARENT' => $_POST['form']['TAS_PARENT'], 'SP_TYPE' => 'SIMPLE', 'SP_SYNCHRONOUS' => $_POST['form']['SP_SYNCHRONOUS'], 'SP_SYNCHRONOUS_TYPE' => 'ALL', 'SP_SYNCHRONOUS_WAIT' => 0, 'SP_VARIABLES_OUT' => serialize($out), 'SP_VARIABLES_IN' => serialize($in), 'SP_GRID_IN' => ''); $oOP->update($aData); require_once 'classes/model/Content.php'; $lang = defined('SYS_LANG') ? SYS_LANG : 'en'; //$cont = Content::addContent( 'SP_TITLE', '', $_POST['form']['SP_UID'], $lang, $_POST['form']['SPROCESS_NAME'] ); $cont = Content::addContent('TAS_TITLE', '', $_POST['form']['TAS_PARENT'], $lang, $_POST['form']['SPROCESS_NAME']); //$cont = Content::addContent( 'TAS_TITLE', '', $_POST['form']['SP_UID'], $lang, $_POST['form']['SPROCESS_NAME'] ); //G::header('location: processes_Map?PRO_UID='. $_POST['form']['PRO_UID']); die;
/** * Create Sub Process rows from an array, removing those subprocesses with * the same UID. * @param $SubProcess array * @return void. */ function createSubProcessRowsXpdl($sProUid, $SubProcess, $tasks) { $process = new Process(); $oData->tasks = $this->getTaskRows($sProUid); foreach ($SubProcess as $key => $row) { $findTask = 0; foreach ($oData->tasks as $task => $id) { if ($row['TAS_PARENT'] == $id['TAS_UID']) { $findTask = 1; } } if ($findTask == 0) { $id = $this->findIdTask($row['TAS_PARENT'], $tasks); $SubProcess[$key]['TAS_PARENT'] = $id; } $oSubProcess = new SubProcess(); if ($oSubProcess->subProcessExists($row['SP_UID'])) { $oSubProcess->remove($row['SP_UID']); } $res = $oSubProcess->create($row); } return; }