/** * This method add a new or update a Route record * * @param $fromTasUid * @param $toTasUid * @param $type * @param string $condition * @return string * @throws \Exception */ public function addRoute($fromTasUid, $toTasUid, $type, $condition = "", $default = 0, $eventUidOrigin = "") { try { $validTypes = array("SEQUENTIAL", "SELECT", "EVALUATE", "PARALLEL", "PARALLEL-BY-EVALUATION", "SEC-JOIN", "DISCRIMINATOR"); if (!in_array($type, $validTypes)) { throw new \Exception("Invalid Route type, given: {$type}, expected: [" . implode(",", $validTypes) . "]"); } if ($type != 'SEQUENTIAL' && $type != 'SEC-JOIN' && $type != 'DISCRIMINATOR') { //if ($this->getNumberOfRoutes($this->proUid, $fromTasUid, $toTasUid, $type) > 0) { //throw new \LogicException("Unexpected behaviour"); //} } //if ($type == 'SEQUENTIAL' || $type == 'SEC-JOIN' || $type == 'DISCRIMINATOR') { //$oTasks = new Tasks(); //$oTasks->deleteAllRoutesOfTask($this->proUid, $fromTasUid); //} if ($toTasUid == "-1") { $route = \Route::findOneBy(array(\RoutePeer::TAS_UID => $fromTasUid, \RoutePeer::ROU_NEXT_TASK => $toTasUid, \RoutePeer::ROU_ELEMENT_ORIGIN => $eventUidOrigin)); } else { $route = \Route::findOneBy(array(\RoutePeer::TAS_UID => $fromTasUid, \RoutePeer::ROU_NEXT_TASK => $toTasUid)); } if (is_null($route)) { $result = $this->saveNewPattern($this->proUid, $fromTasUid, $toTasUid, $type, $condition, $default, $eventUidOrigin); } else { $result = $this->updateRoute($route->getRouUid(), array("TAS_UID" => $fromTasUid, "ROU_NEXT_TASK" => $toTasUid, "ROU_TYPE" => $type, "ROU_DEFAULT" => $default, "ROU_CONDITION" => $condition)); } return $result; } catch (\Exception $e) { self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString()); throw $e; } }
public function updateRouteOrder($data) { foreach ($data as $i => $r) { $aData = array_change_key_case($r, CASE_UPPER); $route = Route::findOneBy(array(RoutePeer::PRO_UID => $aData['PRO_UID'], RoutePeer::ROU_NEXT_TASK => $aData['ROU_NEXT_TASK'])); if (!empty($route)) { $aData['ROU_UID'] = $route->getRouUid(); $this->update($aData); unset($aData); } } }