Merge branch 'master' of bitbucket.org:colosa/processmaker

This commit is contained in:
Fernando Ontiveros
2014-02-25 11:55:59 -05:00
9 changed files with 67 additions and 13 deletions

View File

@@ -16,6 +16,24 @@ require_once 'classes/model/om/BaseBpmnFlow.php';
*/
class BpmnFlow extends BaseBpmnFlow
{
public static function removeAllRelated($elementUid)
{
$c = new Criteria('workflow');
$c1 = $c->getNewCriterion(BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $elementUid);
$c2 = $c->getNewCriterion(BpmnFlowPeer::FLO_ELEMENT_DEST, $elementUid);
$c1->addOr($c2);
$c->add($c1);
$flows = BpmnFlowPeer::doSelect($c);
foreach ($flows as $flow) {
$flow->delete();
}
}
/**
* @param $field string coming from \BpmnFlowPeer::<FIELD_NAME>
* @param $value string

View File

@@ -336,7 +336,8 @@ class FilesManager
'prf_type' => $oProcessFiles->getPrfType(),
'prf_editable' => $sEditable,
'prf_create_date' => $oProcessFiles->getPrfCreateDate(),
'prf_update_date' => $oProcessFiles->getPrfUpdateDate());
'prf_update_date' => $oProcessFiles->getPrfUpdateDate(),
'prf_content' => $content);
return $oProcessFile;
} catch (Exception $e) {
throw $e;

View File

@@ -3,7 +3,6 @@ namespace ProcessMaker\Project\Adapter;
use ProcessMaker\Project;
use ProcessMaker\Util\Hash;
use Symfony\Component\DependencyInjection\Exception\LogicException;
/**
* Class BpmnWorkflow
@@ -149,6 +148,32 @@ class BpmnWorkflow extends Project\Bpmn
$this->wp->removeTask($actUid);
}
public function removeGateway($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;
}
}
parent::removeGateway($gatUid);
}
// public function addFlow($data)
// {
// parent::addFlow($data);

View File

@@ -500,6 +500,9 @@ class Bpmn extends Handler
$gateway = GatewayPeer::retrieveByPK($gatUid);
$gateway->delete();
// remove related object (flows)
Flow::removeAllRelated($gatUid);
self::log("Remove Gateway Success!");
} catch (\Exception $e) {
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());

View File

@@ -143,7 +143,10 @@ class ProcessFilesManagerStructure
* @var string {@from body}
*/
public $prf_path;
/**
* @var string {@from body}
*/
public $prf_content;
}

View File

@@ -21,7 +21,7 @@ class BpmnWorkflowTest extends \PHPUnit_Framework_TestCase
public static function tearDownAfterClass()
{
return false;
//return false;
//cleaning DB
foreach (self::$uids as $prjUid) {
$bwap = Project\Adapter\BpmnWorkflow::load($prjUid);
@@ -328,10 +328,10 @@ class BpmnWorkflowTest extends \PHPUnit_Framework_TestCase
// cleaning
$bwap->removeActivity($actUid1);
$bwap->removeActivity($actUid2);
$bwap->removeFlow($flowUid1);
$bwap->removeFlow($flowUid2);
$bwap->removeGateway($gatUid);
$this->assertCount(0, $bwap->getActivities());
$this->assertCount(0, $bwap->getGateways());
$this->assertCount(0, $bwap->getFlows());
$wp = Project\Workflow::load($bwap->getUid());