public function addRoute($taskUid, $nextTaskUid, $type, $condition = "") { try { //Verify data if ($type == "SEC-JOIN") { throw new \Exception(\G::LoadTranslation("ID_ROUTE_IS_SECJOIN")); } //Route $result = parent::addRoute($taskUid, $nextTaskUid, $type, $condition); //BPMN $arrayBpmnGatewayType = array( "EVALUATE" => "EXCLUSIVE", "SELECT" => "COMPLEX", "PARALLEL" => "PARALLEL", "PARALLEL-BY-EVALUATION" => "INCLUSIVE" ); $arrayTaskData = $this->getTask($taskUid); $activityUid = $arrayTaskData["TAS_UID"]; $activityBouX = (int)($arrayTaskData["TAS_POSX"]); $activityBouY = (int)($arrayTaskData["TAS_POSY"]); $activityBouWidth = (int)($arrayTaskData["TAS_WIDTH"]); $activityBouHeight = (int)($arrayTaskData["TAS_HEIGHT"]); switch ($type) { case "EVALUATE": case "SELECT": case "PARALLEL": case "PARALLEL-BY-EVALUATION": $result = $this->bp->getGatewayByDirectionActivityAndFlow("DIVERGING", $activityUid); if (!is_array($result)) { $gatewayUid = $this->routeToBpmnGateway( "bpmnActivity", $activityUid, $activityBouX, $activityBouY, $activityBouWidth, $activityBouHeight, "", $arrayBpmnGatewayType[$type], "DIVERGING" ); $arrayGatewayData = $this->bp->getGateway2($gatewayUid); } else { $arrayGatewayData = $result; } $gatewayUid = $arrayGatewayData["GAT_UID"]; $gatewayType = $arrayGatewayData["GAT_TYPE"]; $gatewayBouX = $arrayGatewayData["BOU_X"]; $gatewayBouY = $arrayGatewayData["BOU_Y"]; $gatewayBouWidth = $arrayGatewayData["BOU_WIDTH"]; $gatewayBouHeight = $arrayGatewayData["BOU_HEIGHT"]; if ($nextTaskUid != "-1") { $arrayTaskData = $this->getTask($nextTaskUid); $flowUid = $this->routeToBpmnFlow( "bpmnGateway", $gatewayUid, $gatewayBouX, $gatewayBouY, $gatewayBouWidth, $gatewayBouHeight, "bpmnActivity", $arrayTaskData["TAS_UID"], (int)($arrayTaskData["TAS_POSX"]), (int)($arrayTaskData["TAS_POSY"]), (int)($arrayTaskData["TAS_WIDTH"]), (int)($arrayTaskData["TAS_HEIGHT"]), $condition ); } else { $eventUid = $this->startTaskEndProcessToBpmnEvent( "bpmnGateway", $gatewayUid, $gatewayBouX, $gatewayBouY, $gatewayBouWidth, $gatewayBouHeight, "", "END", $condition ); } break; case "SEQUENTIAL": if ($nextTaskUid != "-1") { $arrayTaskData = $this->getTask($nextTaskUid); $flowUid = $this->routeToBpmnFlow( "bpmnActivity", $activityUid, $activityBouX, $activityBouY, $activityBouWidth, $activityBouHeight, "bpmnActivity", $arrayTaskData["TAS_UID"], (int)($arrayTaskData["TAS_POSX"]), (int)($arrayTaskData["TAS_POSY"]), (int)($arrayTaskData["TAS_WIDTH"]), (int)($arrayTaskData["TAS_HEIGHT"]) ); } else { $eventUid = $this->startTaskEndProcessToBpmnEvent( "bpmnActivity", $activityUid, $activityBouX, $activityBouY, $activityBouWidth, $activityBouHeight, "", "END" ); } break; } //Return return $result; } catch (\Exception $e) { throw $e; } }
public function mapBpmnFlowsToWorkflowRoutes() { //Task dummies //Delete Task Routes foreach ($this->arrayElementTaskRelation as $value) { $this->wp->resetTaskRoutes($value); } //Activities foreach ($this->getActivities() as $value) { $activity = $value; //Delete Task Routes $this->wp->resetTaskRoutes($activity["ACT_UID"]); //Flows $arrayFlow = \BpmnFlow::findAllBy(array( \BpmnFlowPeer::FLO_TYPE => array("MESSAGE", \Criteria::NOT_EQUAL), \BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $activity["ACT_UID"], \BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnActivity" )); foreach ($arrayFlow as $value2) { $flow = $value2; switch ($flow->getFloElementDestType()) { case "bpmnActivity": //Activity -> Activity $this->wp->addRoute($activity["ACT_UID"], $flow->getFloElementDest(), "SEQUENTIAL"); break; case "bpmnGateway": //Activity -> Gateway //We must find the related flows: gateway -> <object> $this->mapBpmnGatewayToWorkflowRoutes($activity["ACT_UID"], $flow->getFloElementDest()); break; case "bpmnEvent": //Activity -> Event $event = \BpmnEventPeer::retrieveByPK($flow->getFloElementDest()); if (!is_null($event)) { switch ($event->getEvnType()) { case "START": throw new \LogicException("Incorrect design" . PHP_EOL . "Given: bpmnActivity -> " . $flow->getFloElementDestType()); break; case "END": //$event->getEvnMarker(): EMPTY or MESSAGETHROW switch ($event->getEvnMarker()) { case "MESSAGETHROW": $taskUid = $this->createTaskByElement( $event->getEvnUid(), "bpmnEvent", "end-message-event" ); $result = $this->wp->addRoute($activity["ACT_UID"], $taskUid, "SEQUENTIAL"); $result = $this->wp->addRoute($taskUid, -1, "SEQUENTIAL"); break; case "EMAIL": $taskUid = $this->createTaskByElement( $event->getEvnUid(), "bpmnEvent", "end-email-event" ); $result = $this->wp->addRoute($activity["ACT_UID"], $taskUid, "SEQUENTIAL"); $result = $this->wp->addRoute($taskUid, -1, "SEQUENTIAL"); break; default: //EMPTY //This it's already implemented //and others types $result = $this->wp->addRoute($activity["ACT_UID"], -1, "SEQUENTIAL"); break; } break; default: //INTERMEDIATE //and others types $this->mapBpmnEventToWorkflowRoutes($activity["ACT_UID"], $flow->getFloElementDest()); break; } } break; } } } //Events foreach ($this->getEvents() as $value) { $event = $value; switch ($event["EVN_TYPE"]) { case "START": switch ($event["EVN_MARKER"]) { case "MESSAGECATCH": $taskUid = $this->createTaskByElement( $event["EVN_UID"], "bpmnEvent", "start-message-event" ); $this->wp->setStartTask($taskUid); $this->mapBpmnEventToWorkflowRoutes($taskUid, $event["EVN_UID"]); break; case "TIMER": $taskUid = $this->createTaskByElement( $event["EVN_UID"], "bpmnEvent", "start-timer-event" ); $this->wp->setStartTask($taskUid); $this->mapBpmnEventToWorkflowRoutes($taskUid, $event["EVN_UID"]); break; case "EMPTY": $this->updateEventActivityDefinition(\BpmnEventPeer::retrieveByPK($event["EVN_UID"]), true); break; } break; //case "END": // break; //case "INTERMEDIATE": // break; } } }