/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this BpmnProject is new, it will return * an empty collection; or if this BpmnProject has previously * been saved, it will retrieve related BpmnActivitys from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you * actually need in BpmnProject. */ public function getBpmnActivitysJoinBpmnProcess($criteria = null, $con = null) { // include the Peer class include_once 'classes/model/om/BaseBpmnActivityPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collBpmnActivitys === null) { if ($this->isNew()) { $this->collBpmnActivitys = array(); } else { $criteria->add(BpmnActivityPeer::PRJ_UID, $this->getPrjUid()); $this->collBpmnActivitys = BpmnActivityPeer::doSelectJoinBpmnProcess($criteria, $con); } } else { // the following code is to determine if a new query is // called for. If the criteria is the same as the last // one, just return the collection. $criteria->add(BpmnActivityPeer::PRJ_UID, $this->getPrjUid()); if (!isset($this->lastBpmnActivityCriteria) || !$this->lastBpmnActivityCriteria->equals($criteria)) { $this->collBpmnActivitys = BpmnActivityPeer::doSelectJoinBpmnProcess($criteria, $con); } } $this->lastBpmnActivityCriteria = $criteria; return $this->collBpmnActivitys; }
/** * Update properties of an Task * @var string $prj_uid. Uid for Process * @var string $act_uid. Uid for Activity * @var array $arrayProperty. Data for properties of Activity * * @author Brayan Pereyra (Cochalo) <*****@*****.**> * @copyright Colosa - Bolivia * * return object */ public function updateProperties($prj_uid, $act_uid, $arrayProperty) { //Copy of processmaker/workflow/engine/methods/tasks/tasks_Ajax.php //case "saveTaskData": try { if (isset($arrayProperty['properties'])) { $arrayProperty = array_change_key_case($arrayProperty['properties'], CASE_UPPER); } $prj_uid = $this->validateProUid($prj_uid); $act_uid = $this->validateActUid($act_uid); $arrayProperty["TAS_UID"] = $act_uid; $arrayProperty["PRO_UID"] = $prj_uid; $task = new \Task(); $aTaskInfo = $task->load($arrayProperty["TAS_UID"]); $bpmnActivity = \BpmnActivityPeer::retrieveByPK($act_uid); $arrayResult = array(); if ($arrayProperty["TAS_SELFSERVICE_TIMEOUT"] == "1") { if (!is_numeric($arrayProperty["TAS_SELFSERVICE_TIME"]) || $arrayProperty["TAS_SELFSERVICE_TIME"] == '') { throw new \Exception("Invalid value specified for 'tas_selfservice_time'"); } } foreach ($arrayProperty as $k => $v) { $arrayProperty[$k] = str_replace("@amp@", "&", $v); } if (isset($arrayProperty["TAS_SEND_LAST_EMAIL"])) { $arrayProperty["TAS_SEND_LAST_EMAIL"] = $arrayProperty["TAS_SEND_LAST_EMAIL"] == "TRUE" ? "TRUE" : "FALSE"; } else { if (isset($arrayProperty["SEND_EMAIL"])) { $arrayProperty["TAS_SEND_LAST_EMAIL"] = $arrayProperty["SEND_EMAIL"] == "TRUE" ? "TRUE" : "FALSE"; } else { $arrayProperty["TAS_SEND_LAST_EMAIL"] = is_null($aTaskInfo["TAS_SEND_LAST_EMAIL"]) ? "FALSE" : $aTaskInfo["TAS_SEND_LAST_EMAIL"]; } } //Validating TAS_ASSIGN_VARIABLE value if (!isset($arrayProperty["TAS_ASSIGN_TYPE"])) { $derivateType = $task->kgetassigType($arrayProperty["PRO_UID"], $arrayProperty["TAS_UID"]); if (is_null($derivateType)) { $arrayProperty["TAS_ASSIGN_TYPE"] = "BALANCED"; } else { $arrayProperty["TAS_ASSIGN_TYPE"] = $derivateType["TAS_ASSIGN_TYPE"]; } } $flagTaskIsMultipleInstance = $bpmnActivity->getActType() == "TASK" && preg_match("/^(?:EMPTY|USERTASK|MANUALTASK)\$/", $bpmnActivity->getActTaskType()) && $bpmnActivity->getActLoopType() == "PARALLEL"; $flagTaskAssignTypeIsMultipleInstance = preg_match("/^(?:MULTIPLE_INSTANCE|MULTIPLE_INSTANCE_VALUE_BASED)\$/", $arrayProperty["TAS_ASSIGN_TYPE"]); if ($flagTaskIsMultipleInstance && !$flagTaskAssignTypeIsMultipleInstance) { $arrayProperty["TAS_ASSIGN_TYPE"] = "MULTIPLE_INSTANCE"; $flagTaskAssignTypeIsMultipleInstance = true; } if ($flagTaskIsMultipleInstance && !$flagTaskAssignTypeIsMultipleInstance) { throw new \Exception(\G::LoadTranslation("ID_ACTIVITY_INVALID_ASSIGNMENT_METHOD_FOR_MULTIPLE_INSTANCE_ACTIVITY", array(strtolower("ACT_UID"), $act_uid))); } if (!$flagTaskIsMultipleInstance && $flagTaskAssignTypeIsMultipleInstance) { $arrayProperty["TAS_ASSIGN_TYPE"] = "BALANCED"; $flagTaskAssignTypeIsMultipleInstance = false; } if (!$flagTaskIsMultipleInstance && $flagTaskAssignTypeIsMultipleInstance) { throw new \Exception(\G::LoadTranslation("ID_ACTIVITY_INVALID_ASSIGNMENT_METHOD_FOR_ACTIVITY", array(strtolower("ACT_UID"), $act_uid))); } switch ($arrayProperty["TAS_ASSIGN_TYPE"]) { case 'BALANCED': case 'MANUAL': case 'REPORT_TO': $this->unsetVar($arrayProperty, "TAS_ASSIGN_VARIABLE"); $this->unsetVar($arrayProperty, "TAS_GROUP_VARIABLE"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIMEOUT"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIME"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIME_UNIT"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TRIGGER_UID"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_EXECUTION"); break; case 'EVALUATE': if (empty($arrayProperty["TAS_ASSIGN_VARIABLE"])) { throw new \Exception("Invalid value specified for 'tas_assign_variable'"); } $this->unsetVar($arrayProperty, "TAS_GROUP_VARIABLE"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIMEOUT"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIME"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIME_UNIT"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TRIGGER_UID"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_EXECUTION"); break; case 'SELF_SERVICE': case 'SELF_SERVICE_EVALUATE': if ($arrayProperty["TAS_ASSIGN_TYPE"] == "SELF_SERVICE_EVALUATE") { if (empty($arrayProperty["TAS_GROUP_VARIABLE"])) { throw new \Exception("Invalid value specified for 'tas_group_variable'"); } } else { $arrayProperty["TAS_GROUP_VARIABLE"] = ''; } $arrayProperty["TAS_ASSIGN_TYPE"] = "SELF_SERVICE"; if (!($arrayProperty["TAS_SELFSERVICE_TIMEOUT"] == 0 || $arrayProperty["TAS_SELFSERVICE_TIMEOUT"] == 1)) { throw new \Exception("Invalid value specified for 'tas_selfservice_timeout'"); } if ($arrayProperty["TAS_SELFSERVICE_TIMEOUT"] == "1") { if (empty($arrayProperty["TAS_SELFSERVICE_TIME"])) { throw new \Exception("Invalid value specified for 'tas_assign_variable'"); } if (empty($arrayProperty["TAS_SELFSERVICE_TIME_UNIT"])) { throw new \Exception("Invalid value specified for 'tas_selfservice_time_unit'"); } if (empty($arrayProperty["TAS_SELFSERVICE_TRIGGER_UID"])) { throw new \Exception("Invalid value specified for 'tas_selfservice_trigger_uid'"); } if (empty($arrayProperty["TAS_SELFSERVICE_EXECUTION"])) { throw new \Exception("Invalid value specified for 'tas_selfservice_execution'"); } } else { $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIME"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIME_UNIT"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TRIGGER_UID"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_EXECUTION"); } break; case "MULTIPLE_INSTANCE_VALUE_BASED": if (trim($arrayProperty["TAS_ASSIGN_VARIABLE"]) == "") { throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_CAN_NOT_BE_EMPTY", array(strtolower("TAS_ASSIGN_VARIABLE")))); } break; } //Validating TAS_TRANSFER_FLY value if ($arrayProperty["TAS_TRANSFER_FLY"] == "FALSE") { if (!isset($arrayProperty["TAS_DURATION"])) { throw new \Exception("Invalid value specified for 'tas_duration'"); } $valuesTimeUnit = array('DAYS', 'HOURS', 'MINUTES'); if (!isset($arrayProperty["TAS_TIMEUNIT"]) || !in_array($arrayProperty["TAS_TIMEUNIT"], $valuesTimeUnit)) { throw new \Exception("Invalid value specified for 'tas_timeunit'"); } $valuesTypeDay = array('1', '2', ''); if (!isset($arrayProperty["TAS_TYPE_DAY"]) || !in_array($arrayProperty["TAS_TYPE_DAY"], $valuesTypeDay)) { throw new \Exception("Invalid value specified for 'tas_type_day'"); } if (!isset($arrayProperty["TAS_CALENDAR"])) { throw new \Exception("Invalid value specified for 'tas_calendar'"); } } else { $this->unsetVar($arrayProperty, "TAS_DURATION"); $this->unsetVar($arrayProperty, "TAS_TIMEUNIT"); $this->unsetVar($arrayProperty, "TAS_TYPE_DAY"); $this->unsetVar($arrayProperty, "TAS_CALENDAR"); } if ($arrayProperty["TAS_SEND_LAST_EMAIL"] == "TRUE") { if (empty($arrayProperty["TAS_DEF_SUBJECT_MESSAGE"])) { throw new \Exception("Invalid value specified for 'tas_def_subject_message'"); } $valuesDefMessageType = array('template', 'text'); if (!isset($arrayProperty["TAS_DEF_MESSAGE_TYPE"]) || !in_array($arrayProperty["TAS_DEF_MESSAGE_TYPE"], $valuesDefMessageType)) { throw new \Exception("Invalid value specified for 'tas_def_message_type'"); } if ($arrayProperty["TAS_DEF_MESSAGE_TYPE"] == 'template') { if (empty($arrayProperty["TAS_DEF_MESSAGE_TEMPLATE"])) { throw new \Exception("Invalid value specified for 'tas_def_message_template'"); } $this->unsetVar($arrayProperty, "TAS_DEF_MESSAGE"); } else { if (empty($arrayProperty["TAS_DEF_MESSAGE"])) { throw new \Exception("Invalid value specified for 'tas_def_message'"); } $this->unsetVar($arrayProperty, "TAS_DEF_MESSAGE_TEMPLATE"); } //Additional configuration if (isset($arrayProperty["TAS_DEF_MESSAGE_TYPE"])) { \G::LoadClass("configuration"); $oConf = new \Configurations(); if (!isset($arrayProperty["TAS_DEF_MESSAGE_TEMPLATE"])) { $arrayProperty["TAS_DEF_MESSAGE_TEMPLATE"] = "alert_message.html"; } $oConf->aConfig = array("TAS_DEF_MESSAGE_TYPE" => $arrayProperty["TAS_DEF_MESSAGE_TYPE"], "TAS_DEF_MESSAGE_TEMPLATE" => $arrayProperty["TAS_DEF_MESSAGE_TEMPLATE"]); $oConf->saveConfig("TAS_EXTRA_PROPERTIES", $arrayProperty["TAS_UID"], "", ""); } } else { $this->unsetVar($arrayProperty, "TAS_DEF_SUBJECT_MESSAGE"); $this->unsetVar($arrayProperty, "TAS_DEF_MESSAGE_TYPE"); $this->unsetVar($arrayProperty, "TAS_DEF_MESSAGE"); $this->unsetVar($arrayProperty, "TAS_DEF_MESSAGE_TEMPLATE"); } $result = $task->update($arrayProperty); if (!empty($arrayProperty['CONSOLIDATE_DATA'])) { if (!empty($arrayProperty['CONSOLIDATE_DATA']['consolidated_dynaform'])) { G::LoadClass("consolidatedCases"); $consolidated = new \ConsolidatedCases(); $dataConso = array('con_status' => $arrayProperty['CONSOLIDATE_DATA']['consolidated_enable'], 'tas_uid' => $arrayProperty['TAS_UID'], 'dyn_uid' => $arrayProperty['CONSOLIDATE_DATA']['consolidated_dynaform'], 'pro_uid' => $arrayProperty['PRO_UID'], 'rep_uid' => $arrayProperty['CONSOLIDATE_DATA']['consolidated_report_table'], 'table_name' => $arrayProperty['CONSOLIDATE_DATA']['consolidated_table'], 'title' => $arrayProperty['CONSOLIDATE_DATA']['consolidated_title']); $consolidated->saveConsolidated($dataConso); } } $arrayResult["status"] = "OK"; if ($result == 3) { $arrayResult["status"] = "CRONCL"; } return $arrayResult; } catch (Exception $e) { throw $e; } }
/** * Get data of a Script-Task by unique id of Activity * * @param string $projectUid Unique id of Project * @param string $activityUid Unique id of Event * * return array Return an array with data of a Script-Task by unique id of Activity */ public function getScriptTaskByActivity($projectUid, $activityUid) { try { //Verify data $process = new \ProcessMaker\BusinessModel\Process(); $process->throwExceptionIfNotExistsProcess($projectUid, $this->arrayFieldNameForException["projectUid"]); //--- $obj = \BpmnActivityPeer::retrieveByPK($activityUid); if (is_null($obj)) { throw new \Exception(\G::LoadTranslation("ID_SCRIPT_TASK_DOES_NOT_ACTIVITY", array($this->arrayFieldNameForException["actUid"], $activityUid))); } //--- $criteria = new \Criteria("workflow"); $criteria->addSelectColumn(\BpmnActivityPeer::ACT_UID); $criteria->add(\BpmnActivityPeer::PRJ_UID, $projectUid, \Criteria::EQUAL); $criteria->add(\BpmnActivityPeer::ACT_UID, $activityUid, \Criteria::EQUAL); $rsCriteria = \BpmnActivityPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); if (!$rsCriteria->next()) { throw new \Exception(\G::LoadTranslation("ID_SCRIPT_TASK_ACTIVITY_NOT_BELONG_TO_PROJECT", array($arrayData["ACT_UID"], $projectUid))); } //--- $criteria = $this->getScriptTaskCriteria(); $criteria->add(\ScriptTaskPeer::PRJ_UID, $projectUid, \Criteria::EQUAL); $criteria->add(\ScriptTaskPeer::ACT_UID, $activityUid, \Criteria::EQUAL); $rsCriteria = \ScriptTaskPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); //Return return $rsCriteria->next() ? $this->getScriptTaskDataFromRecord($rsCriteria->getRow()) : array(); } catch (\Exception $e) { throw $e; } }
public function removeFlow($floUid) { $flow = \BpmnFlowPeer::retrieveByPK($floUid); parent::removeFlow($floUid); // verify case: event(start) -> activity // => find the corresponding task and unset it as start task if ($flow->getFloElementOriginType() == "bpmnEvent" && $flow->getFloElementDestType() == "bpmnActivity" ) { $bpmnFlow = \BpmnFlow::findOneBy(array( \BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $flow->getFloElementOrigin(), \BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnEvent", \BpmnFlowPeer::FLO_ELEMENT_DEST => $flow->getFloElementDest(), \BpmnFlowPeer::FLO_ELEMENT_DEST_TYPE => "bpmnActivity" )); if (is_null($bpmnFlow)) { $event = \BpmnEventPeer::retrieveByPK($flow->getFloElementOrigin()); if (!is_null($event) && $event->getEvnType() == "START" && $event->getEvnMarker() == "EMPTY") { $activity = \BpmnActivityPeer::retrieveByPK($flow->getFloElementDest()); //Remove as start Task if (!is_null($activity)) { $this->wp->setStartTask($activity->getActUid(), false); } } } //$this->updateEventStartObjects($flow->getFloElementOrigin(), ""); //WebEntry-Event - Update if (is_null($bpmnFlow)) { $this->updateWebEntryEventByEvent($flow->getFloElementOrigin(), array("WEE_STATUS" => "DISABLED")); } } elseif ($flow->getFloElementOriginType() == "bpmnActivity" && $flow->getFloElementDestType() == "bpmnEvent") { // verify case: activity -> event(end) // => find the corresponding task and unset it as start task $event = \BpmnEventPeer::retrieveByPK($flow->getFloElementDest()); if (!is_null($event) && $event->getEvnType() == "END" && $event->getEvnMarker() == "EMPTY") { $activity = \BpmnActivityPeer::retrieveByPK($flow->getFloElementOrigin()); //Remove as end Task if (! is_null($activity)) { $this->wp->setEndTask($activity->getActUid(), false); } } } else { switch ($flow->getFloElementOriginType()) { case "bpmnActivity": switch ($flow->getFloElementDestType()) { //Activity1 -> Activity2 case "bpmnActivity": $this->wp->removeRouteFromTo($flow->getFloElementOrigin(), $flow->getFloElementDest()); break; } break; case "bpmnEvent": switch ($flow->getFloElementDestType()) { //Event1 -> Event2 case "bpmnEvent": if ($flow->getFloType() == "MESSAGE") { //Delete Message-Event-Relation $messageEventRelation = new \ProcessMaker\BusinessModel\MessageEventRelation(); $messageEventRelation->deleteWhere(array( \MessageEventRelationPeer::PRJ_UID => $flow->getPrjUid(), \MessageEventRelationPeer::EVN_UID_THROW => $flow->getFloElementOrigin(), \MessageEventRelationPeer::EVN_UID_CATCH => $flow->getFloElementDest() )); } break; } break; } } // TODO Complete for other routes, activity->activity, activity->gateway and viceversa }
public function removeActivity($actUid) { try { self::log("Remove Activity: $actUid"); $activity = ActivityPeer::retrieveByPK($actUid); $activity->delete(); //TODO if the activity was removed, the related flows to that activity must be removed self::log("Remove Activity Success!"); } catch (\Exception $e) { self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString()); throw $e; } }
public static function exists($actUid) { $c = new Criteria("workflow"); $c->add(BpmnActivityPeer::ACT_UID, $actUid); return BpmnActivityPeer::doCount($c) > 0 ? true : false; }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param Connection $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(); $criteria->add(BpmnActivityPeer::ACT_UID, $pks, Criteria::IN); $objs = BpmnActivityPeer::doSelect($criteria, $con); } return $objs; }
function derivate($currentDelegation = array(), $nextDelegations = array(), $removeList = true) { //define this... if (! defined( 'TASK_FINISH_PROCESS' )) { define( 'TASK_FINISH_PROCESS', - 1 ); } if (! defined( 'TASK_FINISH_TASK' )) { define( 'TASK_FINISH_TASK', - 2 ); } $this->case = new cases(); //Get data for this DEL_INDEX current $appFields = $this->case->loadCase( $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'] ); //We close the current derivation, then we'll try to derivate to each defined route $this->case->CloseCurrentDelegation( $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'] ); //Get data for current delegation (current Task) $task = TaskPeer::retrieveByPK($currentDelegation["TAS_UID"]); $bpmnActivity = BpmnActivityPeer::retrieveByPK($currentDelegation["TAS_UID"]); $flagTaskIsMultipleInstance = false; $flagTaskAssignTypeIsMultipleInstance = false; if (!is_null($task) && !is_null($bpmnActivity)) { $flagTaskIsMultipleInstance = $bpmnActivity->getActType() == "TASK" && preg_match("/^(?:EMPTY|USERTASK|MANUALTASK)$/", $bpmnActivity->getActTaskType()) && $bpmnActivity->getActLoopType() == "PARALLEL"; $flagTaskAssignTypeIsMultipleInstance = preg_match("/^(?:MULTIPLE_INSTANCE|MULTIPLE_INSTANCE_VALUE_BASED)$/", $task->getTasAssignType()); } $currentDelegation["TAS_ASSIGN_TYPE"] = $task->getTasAssignType(); $currentDelegation["TAS_MI_COMPLETE_VARIABLE"] = $task->getTasMiCompleteVariable(); $currentDelegation["TAS_MI_INSTANCE_VARIABLE"] = $task->getTasMiInstanceVariable(); //Count how many tasks should be derivated. //$countNextTask = count($nextDelegations); //$removeList = true; foreach ($nextDelegations as $nextDel) { //BpmnEvent - END-MESSAGE-EVENT, END-EMAIL-EVENT //Check and get unique id if (preg_match("/^(.{32})\/(\-1)$/", $nextDel["TAS_UID"], $arrayMatch)) { $nextDel["TAS_UID"] = $arrayMatch[2]; $nextDel["TAS_UID_DUMMY"] = $arrayMatch[1]; } //subprocesses?? if ($nextDel['TAS_PARENT'] != '') { $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( SubProcessPeer::PRO_PARENT, $appFields['PRO_UID'] ); $oCriteria->add( SubProcessPeer::TAS_PARENT, $nextDel['TAS_PARENT'] ); if (SubProcessPeer::doCount( $oCriteria ) > 0) { $oDataset = SubProcessPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); $aSP = $oDataset->getRow(); $aSP['USR_UID'] = $nextDel['USR_UID']; $oTask = new Task(); $aTask = $oTask->load( $nextDel['TAS_PARENT'] ); $nextDel = array ('TAS_UID' => $aTask['TAS_UID'],'USR_UID' => $aSP['USR_UID'],'TAS_ASSIGN_TYPE' => $aTask['TAS_ASSIGN_TYPE'],'TAS_DEF_PROC_CODE' => $aTask['TAS_DEF_PROC_CODE'],'DEL_PRIORITY' => 3,'TAS_PARENT' => '' ); } else { continue; } } //get open threads $openThreads = $this->case->GetOpenThreads( $currentDelegation['APP_UID'] ); //if we are derivating to finish process but there are no more open thread then we are finishing only the task, we are not finishing the whole process if (($nextDel['TAS_UID'] == TASK_FINISH_PROCESS) && (($openThreads + 1) > 1)) { $nextDel['TAS_UID'] = TASK_FINISH_TASK; } $taskNextDel = TaskPeer::retrieveByPK($nextDel["TAS_UID"]); //Get data for next delegation (next Task) $bpmnActivityNextDel = BpmnActivityPeer::retrieveByPK($nextDel["TAS_UID"]); $flagTaskNextDelIsMultipleInstance = false; $flagTaskNextDelAssignTypeIsMultipleInstance = false; if (!is_null($taskNextDel) && !is_null($bpmnActivityNextDel)) { $flagTaskNextDelIsMultipleInstance = $bpmnActivityNextDel->getActType() == "TASK" && preg_match("/^(?:EMPTY|USERTASK|MANUALTASK)$/", $bpmnActivityNextDel->getActTaskType()) && $bpmnActivityNextDel->getActLoopType() == "PARALLEL"; $flagTaskNextDelAssignTypeIsMultipleInstance = preg_match("/^(?:MULTIPLE_INSTANCE|MULTIPLE_INSTANCE_VALUE_BASED)$/", $taskNextDel->getTasAssignType()); } $flagUpdateCounters = true; switch ($nextDel['TAS_UID']) { case TASK_FINISH_PROCESS: /*Close all delegations of $currentDelegation['APP_UID'] */ $this->case->closeAllDelegations( $currentDelegation['APP_UID'] ); $this->case->closeAllThreads( $currentDelegation['APP_UID'] ); //I think we need to change the APP_STATUS to completed, //BpmnEvent - END-MESSAGE-EVENT, END-EMAIL-EVENT if (isset($nextDel["TAS_UID_DUMMY"])) { $taskDummy = TaskPeer::retrieveByPK($nextDel["TAS_UID_DUMMY"]); switch ($taskDummy->getTasType()) { case "END-MESSAGE-EVENT": //Throw Message-Events - BpmnEvent - END-MESSAGE-EVENT $case = new \ProcessMaker\BusinessModel\Cases(); $case->throwMessageEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID_DUMMY"], $appFields); break; case "END-EMAIL-EVENT": //Email Event $emailEvent = new \ProcessMaker\BusinessModel\EmailEvent(); $emailEvent->emailEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID_DUMMY"], $appFields); break; } } break; case TASK_FINISH_TASK: $iAppThreadIndex = $appFields['DEL_THREAD']; $this->case->closeAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex ); break; default: //Get all siblingThreads $canDerivate = false; switch ($currentDelegation['TAS_ASSIGN_TYPE']) { case 'CANCEL_MI': case 'STATIC_MI': $arrayOpenThread = $this->case->GetAllOpenDelegation($currentDelegation); $aData = $this->case->loadCase( $currentDelegation['APP_UID'] ); if (isset( $aData['APP_DATA'][str_replace( '@@', '', $currentDelegation['TAS_MI_INSTANCE_VARIABLE'] )] )) { $sMIinstanceVar = $aData['APP_DATA'][str_replace( '@@', '', $currentDelegation['TAS_MI_INSTANCE_VARIABLE'] )]; } else { $sMIinstanceVar = $aData['APP_DATA']['TAS_MI_INSTANCE_VARIABLE']; } if (isset( $aData['APP_DATA'][str_replace( '@@', '', $currentDelegation['TAS_MI_COMPLETE_VARIABLE'] )] )) { $sMIcompleteVar = $aData['APP_DATA'][str_replace( '@@', '', $currentDelegation['TAS_MI_COMPLETE_VARIABLE'] )]; } else { $sMIcompleteVar = $aData['APP_DATA']['TAS_MI_COMPLETE_VARIABLE']; } $discriminateThread = $sMIinstanceVar - $sMIcompleteVar; // -1 because One App Delegation is closed by above Code if ($discriminateThread == count($arrayOpenThread)) { $canDerivate = true; } else { $canDerivate = false; } break; default: $routeType = $currentDelegation["ROU_TYPE"]; $routeType = ($flagTaskIsMultipleInstance && $flagTaskAssignTypeIsMultipleInstance)? "SEC-JOIN" : $routeType; switch ($routeType) { case "SEC-JOIN": $arrayOpenThread = ($flagTaskIsMultipleInstance && $flagTaskAssignTypeIsMultipleInstance)? $this->case->searchOpenPreviousTasks($currentDelegation["TAS_UID"], $currentDelegation["APP_UID"]) : array(); $arrayOpenThread = array_merge($arrayOpenThread, $this->case->getOpenSiblingThreads($nextDel["TAS_UID"], $currentDelegation["APP_UID"], $currentDelegation["DEL_INDEX"], $currentDelegation["TAS_UID"])); $canDerivate = empty($arrayOpenThread); break; default: $canDerivate = true; break; } break; } if ($canDerivate) { //Throw Message-Events $case = new \ProcessMaker\BusinessModel\Cases(); $case->throwMessageEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID"], $appFields); //Throw Email-Events $emailEvent = new \ProcessMaker\BusinessModel\EmailEvent(); $emailEvent->emailEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID"], $appFields); //Derivate $aSP = (isset($aSP))? $aSP : null; $taskNextDelAssignType = ($flagTaskNextDelIsMultipleInstance && $flagTaskNextDelAssignTypeIsMultipleInstance)? $taskNextDel->getTasAssignType() : ""; switch ($taskNextDelAssignType) { case "MULTIPLE_INSTANCE": case "MULTIPLE_INSTANCE_VALUE_BASED": $arrayUser = $this->getNextAssignedUser(array("APP_UID" => $currentDelegation["APP_UID"], "NEXT_TASK" => $taskNextDel->toArray(BasePeer::TYPE_FIELDNAME))); if (empty($arrayUser)) { throw new Exception(G::LoadTranslation("ID_NO_USERS")); } foreach ($arrayUser as $value2) { $currentDelegationAux = array_merge($currentDelegation, array("ROU_TYPE" => "PARALLEL")); $nextDelAux = array_merge($nextDel, array("USR_UID" => $value2["USR_UID"])); $iNewDelIndex = $this->doDerivation($currentDelegationAux, $nextDelAux, $appFields, $aSP); $this->derivateUpdateCounters($currentDelegationAux, $nextDelAux, $taskNextDel, $appFields, $iNewDelIndex, $aSP, $removeList); $flagUpdateCounters = false; $removeList = false; } break; default: $iNewDelIndex = $this->doDerivation($currentDelegation, $nextDel, $appFields, $aSP); break; } //Execute Script-Task $scriptTask = new \ProcessMaker\BusinessModel\ScriptTask(); $appFields["APP_DATA"] = $scriptTask->execScriptByActivityUid($nextDel["TAS_UID"], $appFields); //Create record in table APP_ASSIGN_SELF_SERVICE_VALUE $regexpTaskTypeToExclude = "SCRIPT-TASK"; if (!is_null($taskNextDel) && !preg_match("/^(?:" . $regexpTaskTypeToExclude . ")$/", $taskNextDel->getTasType())) { if ($taskNextDel->getTasAssignType() == "SELF_SERVICE" && trim($taskNextDel->getTasGroupVariable()) != "") { $nextTaskGroupVariable = trim($taskNextDel->getTasGroupVariable(), " @#"); if (isset($appFields["APP_DATA"][$nextTaskGroupVariable])) { $dataVariable = $appFields["APP_DATA"][$nextTaskGroupVariable]; $dataVariable = (is_array($dataVariable))? $dataVariable : trim($dataVariable); if (!empty($dataVariable)) { $appAssignSelfServiceValue = new AppAssignSelfServiceValue(); $appAssignSelfServiceValue->create($appFields["APP_UID"], $iNewDelIndex, array("PRO_UID" => $appFields["PRO_UID"], "TAS_UID" => $nextDel["TAS_UID"], "GRP_UID" => serialize($dataVariable))); } } } } //Check if $taskNextDel is Script-Task if (!is_null($taskNextDel) && $taskNextDel->getTasType() == "SCRIPT-TASK") { $this->case->CloseCurrentDelegation($currentDelegation["APP_UID"], $iNewDelIndex); //Get for $nextDel["TAS_UID"] your next Task $taskNextDelNextDelegations = $this->prepareInformation(array( "USER_UID" => $_SESSION["USER_LOGGED"], "APP_UID" => $_SESSION["APPLICATION"], "DEL_INDEX" => $iNewDelIndex )); //New next delegation $newNextDelegation = array(); $newNextDelegation[1] = array( "TAS_UID" => $taskNextDelNextDelegations[1]["NEXT_TASK"]["TAS_UID"], "USR_UID" => $taskNextDelNextDelegations[1]["NEXT_TASK"]["USER_ASSIGNED"]["USR_UID"], "TAS_ASSIGN_TYPE" => $taskNextDelNextDelegations[1]["NEXT_TASK"]["TAS_ASSIGN_TYPE"], "TAS_DEF_PROC_CODE" => "", "DEL_PRIORITY" => "", "TAS_PARENT" => "" ); $this->derivate($currentDelegation, $newNextDelegation, $removeList); } } else { //when the task doesnt generate a new AppDelegation $iAppThreadIndex = $appFields['DEL_THREAD']; $routeType = $currentDelegation["ROU_TYPE"]; $routeType = ($flagTaskIsMultipleInstance && $flagTaskAssignTypeIsMultipleInstance)? "SEC-JOIN" : $routeType; switch ($routeType) { case 'SEC-JOIN': $this->case->closeAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex ); break; default: if ($currentDelegation['TAS_ASSIGN_TYPE'] == 'STATIC_MI' || $currentDelegation['TAS_ASSIGN_TYPE'] == 'CANCEL_MI') { $this->case->closeAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex ); } break; } } break; } if ($flagUpdateCounters) { $this->derivateUpdateCounters($currentDelegation, $nextDel, $taskNextDel, $appFields, (isset($iNewDelIndex))? $iNewDelIndex : 0, (isset($aSP))? $aSP : null, $removeList); } $removeList = false; unset($aSP); } /* Start Block : UPDATES APPLICATION */ //Set THE APP_STATUS $appFields['APP_STATUS'] = $currentDelegation['APP_STATUS']; /* Start Block : Count the open threads of $currentDelegation['APP_UID'] */ $openThreads = $this->case->GetOpenThreads( $currentDelegation['APP_UID'] ); /////// $flag = false; if ($openThreads == 0) { //Close case $appFields["APP_STATUS"] = "COMPLETED"; $appFields["APP_FINISH_DATE"] = "now"; $this->verifyIsCaseChild($currentDelegation["APP_UID"], $currentDelegation["DEL_INDEX"]); $flag = true; } if (isset( $iNewDelIndex )) { $appFields["DEL_INDEX"] = $iNewDelIndex; $appFields["TAS_UID"] = $nextDel["TAS_UID"]; $flag = true; } if ($flag) { //Start Block : UPDATES APPLICATION $this->case->updateCase( $currentDelegation["APP_UID"], $appFields ); //End Block : UPDATES APPLICATION } }
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = BpmnActivityPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setActUid($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setPrjUid($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setProUid($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setActName($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setActType($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setActIsForCompensation($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setActStartQuantity($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setActCompletionQuantity($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setActTaskType($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setActImplementation($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setActInstantiate($arr[$keys[10]]); } if (array_key_exists($keys[11], $arr)) { $this->setActScriptType($arr[$keys[11]]); } if (array_key_exists($keys[12], $arr)) { $this->setActScript($arr[$keys[12]]); } if (array_key_exists($keys[13], $arr)) { $this->setActLoopType($arr[$keys[13]]); } if (array_key_exists($keys[14], $arr)) { $this->setActTestBefore($arr[$keys[14]]); } if (array_key_exists($keys[15], $arr)) { $this->setActLoopMaximum($arr[$keys[15]]); } if (array_key_exists($keys[16], $arr)) { $this->setActLoopCondition($arr[$keys[16]]); } if (array_key_exists($keys[17], $arr)) { $this->setActLoopCardinality($arr[$keys[17]]); } if (array_key_exists($keys[18], $arr)) { $this->setActLoopBehavior($arr[$keys[18]]); } if (array_key_exists($keys[19], $arr)) { $this->setActIsAdhoc($arr[$keys[19]]); } if (array_key_exists($keys[20], $arr)) { $this->setActIsCollapsed($arr[$keys[20]]); } if (array_key_exists($keys[21], $arr)) { $this->setActCompletionCondition($arr[$keys[21]]); } if (array_key_exists($keys[22], $arr)) { $this->setActOrdering($arr[$keys[22]]); } if (array_key_exists($keys[23], $arr)) { $this->setActCancelRemainingInstances($arr[$keys[23]]); } if (array_key_exists($keys[24], $arr)) { $this->setActProtocol($arr[$keys[24]]); } if (array_key_exists($keys[25], $arr)) { $this->setActMethod($arr[$keys[25]]); } if (array_key_exists($keys[26], $arr)) { $this->setActIsGlobal($arr[$keys[26]]); } if (array_key_exists($keys[27], $arr)) { $this->setActReferer($arr[$keys[27]]); } if (array_key_exists($keys[28], $arr)) { $this->setActDefaultFlow($arr[$keys[28]]); } if (array_key_exists($keys[29], $arr)) { $this->setActMasterDiagram($arr[$keys[29]]); } }