Adding Unit Tests to BpmnWorkflow Adapter

- Adding Activity->Gateway Flow handler
- Adding Activity->Gateway ==> Route Listener to Adapter

Now gateways with DIVERGING and CONVERGING directions are interpreted as its respective workflow route types.
This commit is contained in:
Erik Amaru Ortiz
2014-02-25 13:47:59 -04:00
parent 205f4a461f
commit 887fa6b46a
3 changed files with 163 additions and 43 deletions

View File

@@ -150,26 +150,26 @@ class BpmnWorkflow extends Project\Bpmn
public function removeGateway($gatUid)
{
$gatewayData = $this->getGateway($gatUid);
$flowsDest = \BpmnFlow::findAllBy(\BpmnFlowPeer::FLO_ELEMENT_DEST, $gatUid);
// $gatewayData = $this->getGateway($gatUid);
// $flowsDest = \BpmnFlow::findAllBy(\BpmnFlowPeer::FLO_ELEMENT_DEST, $gatUid);
foreach ($flowsDest as $flowDest) {
switch ($flowDest->getFloElementOriginType()) {
case "bpmnActivity":
$actUid = $flowDest->getFloElementOrigin();
$flowsOrigin = \BpmnFlow::findAllBy(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $gatUid);
foreach ($flowsOrigin as $flowOrigin) {
switch ($flowOrigin->getFloElementDestType()) {
case "bpmnActivity":
$toActUid = $flowOrigin->getFloElementDest();
$this->wp->removeRouteFromTo($actUid, $toActUid);
break;
}
}
break;
}
}
// foreach ($flowsDest as $flowDest) {
// switch ($flowDest->getFloElementOriginType()) {
// case "bpmnActivity":
// $actUid = $flowDest->getFloElementOrigin();
// $flowsOrigin = \BpmnFlow::findAllBy(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $gatUid);
//
// foreach ($flowsOrigin as $flowOrigin) {
// switch ($flowOrigin->getFloElementDestType()) {
// case "bpmnActivity":
// $toActUid = $flowOrigin->getFloElementDest();
// $this->wp->removeRouteFromTo($actUid, $toActUid);
// break;
// }
// }
// break;
// }
// }
parent::removeGateway($gatUid);
}
@@ -298,6 +298,10 @@ class BpmnWorkflow extends Project\Bpmn
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnGateway"
));
if ($gatewayFlows > 0) {
$this->wp->resetTaskRoutes($activity["ACT_UID"]);
}
foreach ($gatewayFlows as $gatewayFlow) {
$gatewayFlow = $gatewayFlow->toArray();

View File

@@ -195,8 +195,8 @@ class Workflow extends Handler
{
try {
self::log("Remove Task: $tasUid");
$task = new Task();
$task->remove($tasUid);
$task = new Tasks();
$task->deleteTask($tasUid);
self::log("Remove Task Success!");
} catch (\Exception $e) {
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
@@ -275,18 +275,18 @@ class Workflow extends Handler
}
if ($type != 'SEQUENTIAL' && $type != 'SEC-JOIN' && $type != 'DISCRIMINATOR') {
if ($this->getNumberOfRoutes($this->proUid, $fromTasUid, $toTasUid, $type) > 0) {
throw new \LogicException("Unexpected behaviour");
}
//if ($this->getNumberOfRoutes($this->proUid, $fromTasUid, $toTasUid, $type) > 0) {
//throw new \LogicException("Unexpected behaviour");
//}
}
//if ($delete || $type == 'SEQUENTIAL' || $type == 'SEC-JOIN' || $type == 'DISCRIMINATOR') {
$oTasks = new Tasks();
$oTasks->deleteAllRoutesOfTask($this->proUid, $fromTasUid);
//$oTasks = new Tasks();
//$oTasks->deleteAllRoutesOfTask($this->proUid, $fromTasUid);
//}
$result = $this->saveNewPattern($this->proUid, $fromTasUid, $toTasUid, $type, $delete);
self::log("Add Route Success! -> ", $result);
self::log("Add Route Success! - ROU_UID: ", $result);
return $result;
} catch (\Exception $e) {
@@ -295,6 +295,12 @@ class Workflow extends Handler
}
}
public function resetTaskRoutes($actUid)
{
$oTasks = new Tasks();
$oTasks->deleteAllRoutesOfTask($this->proUid, $actUid);
}
public function updateRoute($rouUid, $routeData)
{
$routeData['ROU_UID'] = $rouUid;