FIX for BpmnWorkflow Adapter class, now the set and unset of start and end tasks on workflow layer, are listening on addFlows and removeFlow methods

This commit is contained in:
Erik Amaru Ortiz
2014-02-13 16:40:00 -04:00
parent 20d2511e9e
commit 96e51f5e5b
3 changed files with 71 additions and 43 deletions

View File

@@ -23,9 +23,11 @@ class BpmnWorkflow extends Project\Bpmn
public static function load($prjUid)
{
$parent = parent::load($prjUid);
$me = new self();
$parent = parent::load($prjUid);
//return new BpmnWorkflow();
$me = new BpmnWorkflow();
$me->project = $parent->project;
$me->prjUid = $parent->project->getPrjUid();
@@ -175,7 +177,34 @@ class BpmnWorkflow extends Project\Bpmn
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"
) {
$event = \BpmnEventPeer::retrieveByPK($flow->getFloElementOrigin());
if (! is_null($event) && $event->getEvnType() == "START") {
$activity = \BpmnActivityPeer::retrieveByPK($flow->getFloElementDest());
$this->wp->setStartTask($activity->getActUid(), false);
}
} 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") {
$activity = \BpmnActivityPeer::retrieveByPK($flow->getFloElementOrigin());
if (! is_null($activity)) {
$this->wp->setEndTask($activity->getActUid(), false);
}
}
}
}
public function addEvent($data)
@@ -189,28 +218,28 @@ class BpmnWorkflow extends Project\Bpmn
public function removeEvent($evnUid)
{
$event = \BpmnEventPeer::retrieveByPK($evnUid);
switch ($event->getEvnType()) {
case "START":
$flow = \BpmnFlow::findOneBy(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $event->getEvnUid());
if (! is_null($flow) && $flow->getFloElementDestType() == "bpmnActivity") {
$activity = \BpmnActivityPeer::retrieveByPK($flow->getFloElementDest());
if (! is_null($activity)) {
$this->wp->setStartTask($activity->getActUid(), false);
}
}
break;
case "END":
$flow = \BpmnFlow::findOneBy(\BpmnFlowPeer::FLO_ELEMENT_DEST, $event->getEvnUid());
if (! is_null($flow) && $flow->getFloElementOriginType() == "bpmnActivity") {
$activity = \BpmnActivityPeer::retrieveByPK($flow->getFloElementOrigin());
if (! is_null($activity)) {
$this->wp->setEndTask($activity->getActUid(), false);
}
}
break;
}
// $event = \BpmnEventPeer::retrieveByPK($evnUid);
//
// switch ($event->getEvnType()) {
// case "START":
// $flow = \BpmnFlow::findOneBy(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $event->getEvnUid());
// if (! is_null($flow) && $flow->getFloElementDestType() == "bpmnActivity") {
// $activity = \BpmnActivityPeer::retrieveByPK($flow->getFloElementDest());
// if (! is_null($activity)) {
// $this->wp->setStartTask($activity->getActUid(), false);
// }
// }
// break;
// case "END":
// $flow = \BpmnFlow::findOneBy(\BpmnFlowPeer::FLO_ELEMENT_DEST, $event->getEvnUid());
// if (! is_null($flow) && $flow->getFloElementOriginType() == "bpmnActivity") {
// $activity = \BpmnActivityPeer::retrieveByPK($flow->getFloElementOrigin());
// if (! is_null($activity)) {
// $this->wp->setEndTask($activity->getActUid(), false);
// }
// }
// break;
// }
parent::removeEvent($evnUid);
}
@@ -288,8 +317,11 @@ class BpmnWorkflow extends Project\Bpmn
break;
case 'bpmnEvent':
$evnUid = $flow['FLO_ELEMENT_DEST'];
self::log('=======++++++++=========>', $evnUid, "EVN_UID", $events);
$events = self::findInArray($evnUid, "EVN_UID", $events);
if (! empty($events)) {
$event = $events[0];
@@ -321,9 +353,19 @@ class BpmnWorkflow extends Project\Bpmn
return $result;
}
// public function getActivities()
// {
// return parent::getActivities();
// }
public function remove()
{
parent::remove();
$this->wp->remove();
}
public function hello($s)
{
echo "--->".$s;
}
}

View File

@@ -132,9 +132,9 @@ class Project extends Api
$bwp->addActivity($activityData);
$result[] = array("object" => "activity", "new_uid" => $activityData["ACT_UID"], "old_uid" => $oldActUid);
$diagram["activities"][$i] = $activityData;
}
$diagram["activities"][$i] = $activityData;
$whiteList[] = $activityData["ACT_UID"];
}
@@ -168,9 +168,9 @@ class Project extends Api
$bwp->addGateway($gatewayData);
$result[] = array("object" => "gateway", "new_uid" => $gatewayData["GAT_UID"], "old_uid" => $oldActUid);
$diagram["gateways"][$i] = $gatewayData;
}
$diagram["gateways"][$i] = $gatewayData;
$whiteList[] = $gatewayData["GAT_UID"];
}
@@ -203,9 +203,9 @@ class Project extends Api
$bwp->addEvent($eventData);
$result[] = array("object" => "event", "new_uid" => $eventData["EVN_UID"], "old_uid" => $oldActUid);
$diagram["events"][$i] = $eventData;
}
$diagram["events"][$i] = $eventData;
$whiteList[] = $eventData["EVN_UID"];
}
@@ -226,7 +226,7 @@ class Project extends Api
$whiteList = array();
foreach ($diagram["flows"] as $i => $flowData) {
$diagram["flows"][$i] = $flowData = array_change_key_case($flowData, CASE_UPPER);
$flowData = array_change_key_case($flowData, CASE_UPPER);
// if it is a new flow record
if (! \BpmnFlow::exists($flowData["FLO_UID"])) {
@@ -244,9 +244,9 @@ class Project extends Api
}
$result[] = array("object" => "flow", "new_uid" => $flowData["FLO_UID"], "old_uid" => $oldFloUid);
$diagram["flows"][$i] = $flowData;
}
$diagram["flows"][$i] = $flowData;
$whiteList[] = $flowData["FLO_UID"];
}

View File

@@ -884,20 +884,6 @@ try {
$RBAC = &RBAC::getSingleton( PATH_DATA, session_id() );
$RBAC->sSystem = 'PROCESSMAKER';
// if (\System::isDebugMode()) {
// $applicationAspectKernel = \Kernel\ApplicationAspectKernel::getInstance();
// $applicationAspectKernel->init(array(
// 'debug' => true, // Use 'false' for production mode
// // Cache directory
// 'cacheDir' => sys_get_temp_dir() . DIRECTORY_SEPARATOR, // Adjust this path if needed
// // Include paths restricts the directories where aspects should be applied, or empty for all source files
// 'includePaths' => array(
// PATH_HOME . 'engine/src/'
// )
// ));
// }
// define and send Headers for all pages
if (! defined( 'EXECUTE_BY_CRON' )) {
header( "Expires: " . gmdate( "D, d M Y H:i:s", mktime( 0, 0, 0, date( 'm' ), date( 'd' ) - 1, date( 'Y' ) ) ) . " GMT" );