updates to enable save flow connections between activity->activity and activity->gateway
This commit is contained in:
@@ -147,7 +147,10 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
parent::addFlow($data);
|
||||
|
||||
$routeData = self::mapBpmnFlowsToWorkflowRoute($data, $flows, $gateways, $events);
|
||||
$this->wp->addRoute($routeData["from"], $routeData["to"], $routeData["type"]);
|
||||
|
||||
if ($routeData !== null) {
|
||||
$this->wp->addRoute($routeData["from"], $routeData["to"], $routeData["type"]);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@@ -258,6 +261,12 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
{
|
||||
$fromUid = $flow['FLO_ELEMENT_ORIGIN'];
|
||||
|
||||
if ($flow['FLO_ELEMENT_ORIGIN_TYPE'] != "bpmnActivity") {
|
||||
// skip flows that comes from a element that is not an Activity
|
||||
self::log("Skip map FlowsToWorkflowRoute for -> flow with FLO_UID: {$flow['FLO_UID']}, that have FLO_ELEMENT_ORIGIN: {$flow['FLO_ELEMENT_ORIGIN_TYPE']}:$fromUid");
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($flow['FLO_TYPE'] != 'SEQUENCE') {
|
||||
throw new \LogicException(sprintf(
|
||||
"Unsupported flow type: %s, ProcessMaker only support type '', Given: '%s'",
|
||||
@@ -275,8 +284,6 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
// if it is a gateway it can fork one or more routes
|
||||
//$gatFlows = BpmnModel::getBpmnCollectionBy('Flow', \BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $gatUid);
|
||||
$gatFlow = self::findInArray($gatUid, "FLO_ELEMENT_ORIGIN", $flows);
|
||||
self::log($gatUid, "FLO_ELEMENT_ORIGIN", $flows);
|
||||
self::log("==============111===================>", $gatFlow);
|
||||
|
||||
//foreach ($gatFlows as $gatFlow) {
|
||||
switch ($gatFlow['FLO_ELEMENT_DEST_TYPE']) {
|
||||
@@ -284,7 +291,6 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
// getting gateway properties
|
||||
//$gateway = BpmnModel::getBpmnObjectBy('Gateway', \BpmnGatewayPeer::GAT_UID, $gatUid);
|
||||
$gateway = self::findInArray($gatUid, "GAT_UID", $gateways);
|
||||
self::log("==============222===================>", $gateway);
|
||||
|
||||
switch ($gateway['GAT_TYPE']) {
|
||||
case 'SELECTION':
|
||||
|
||||
@@ -344,6 +344,23 @@ class Bpmn extends Handler
|
||||
return $gateway->getGatUid();
|
||||
}
|
||||
|
||||
public function updateGateway($gatUid, $data)
|
||||
{
|
||||
try {
|
||||
self::log("Update Gateway: $gatUid", "With data: ", $data);
|
||||
|
||||
$gateway = GatewayPeer::retrieveByPk($gatUid);
|
||||
|
||||
$gateway->fromArray($data);
|
||||
$gateway->save();
|
||||
|
||||
self::log("Update Gateway Success!");
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function getGateway($gatUid, $retType = 'array')
|
||||
{
|
||||
$gateway = GatewayPeer::retrieveByPK($gatUid);
|
||||
@@ -355,20 +372,41 @@ class Bpmn extends Handler
|
||||
return $gateway;
|
||||
}
|
||||
|
||||
public function getGateways($retType = 'array')
|
||||
public function getGateways($start = null, $limit = null, $filter = '', $changeCaseTo = CASE_UPPER)
|
||||
{
|
||||
return Gateway::getAll($this->getUid(), null, null, '', $retType);
|
||||
if (is_array($start)) {
|
||||
extract($start);
|
||||
}
|
||||
|
||||
return Gateway::getAll($this->getUid(), null, null, '', $changeCaseTo);
|
||||
}
|
||||
|
||||
public function removeGateway($gatUid)
|
||||
{
|
||||
try {
|
||||
self::log("Remove Gateway: $gatUid");
|
||||
|
||||
$gateway = GatewayPeer::retrieveByPK($gatUid);
|
||||
$gateway->delete();
|
||||
|
||||
self::log("Remove Gateway Success!");
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function addFlow($data)
|
||||
{
|
||||
self::log("Add Flow with data: ", $data);
|
||||
|
||||
// setting defaults
|
||||
$data['FLO_UID'] = array_key_exists('FLO_UID', $data) ? $data['FLO_UID'] : Hash::generateUID();
|
||||
$data['FLO_STATE'] = is_array($data['FLO_STATE']) ? json_encode($data['FLO_STATE']) : $data['FLO_STATE'];
|
||||
if (array_key_exists('FLO_STATE', $data)) {
|
||||
$data['FLO_STATE'] = is_array($data['FLO_STATE']) ? json_encode($data['FLO_STATE']) : $data['FLO_STATE'];
|
||||
}
|
||||
|
||||
try {
|
||||
self::log("Add Flow with data: ", $data);
|
||||
|
||||
$flow = new Flow();
|
||||
$flow->fromArray($data, BasePeer::TYPE_FIELDNAME);
|
||||
$flow->setPrjUid($this->getUid());
|
||||
@@ -382,6 +420,26 @@ class Bpmn extends Handler
|
||||
}
|
||||
}
|
||||
|
||||
public function updateFlow($floUid, $data)
|
||||
{
|
||||
self::log("Update Flow: $floUid", "With data: ", $data);
|
||||
|
||||
// setting defaults
|
||||
if (array_key_exists('FLO_STATE', $data)) {
|
||||
$data['FLO_STATE'] = is_array($data['FLO_STATE']) ? json_encode($data['FLO_STATE']) : $data['FLO_STATE'];
|
||||
}
|
||||
try {
|
||||
$flow = FlowPeer::retrieveByPk($floUid);
|
||||
$flow->fromArray($data);
|
||||
$flow->save();
|
||||
|
||||
self::log("Update Flow Success!");
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFlow($floUid, $retType = 'array')
|
||||
{
|
||||
$flow = FlowPeer::retrieveByPK($floUid);
|
||||
@@ -393,9 +451,28 @@ class Bpmn extends Handler
|
||||
return $flow;
|
||||
}
|
||||
|
||||
public function getFlows($retType = 'array')
|
||||
public function getFlows($start = null, $limit = null, $filter = '', $changeCaseTo = CASE_UPPER)
|
||||
{
|
||||
return Flow::getAll($this->getUid(), null, null, '', $retType);
|
||||
if (is_array($start)) {
|
||||
extract($start);
|
||||
}
|
||||
|
||||
return Flow::getAll($this->getUid(), null, null, '', $changeCaseTo);
|
||||
}
|
||||
|
||||
public function removeFlow($floUid)
|
||||
{
|
||||
try {
|
||||
self::log("Remove Flow: $floUid");
|
||||
|
||||
$flow = FlowPeer::retrieveByPK($floUid);
|
||||
$flow->delete();
|
||||
|
||||
self::log("Remove Flow Success!");
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function addArtifact($data)
|
||||
|
||||
@@ -275,6 +275,7 @@ class Workflow extends Handler
|
||||
$oTasks->deleteAllRoutesOfTask($this->proUid, $fromTasUid);
|
||||
//$oTasks->deleteAllGatewayOfTask($this->proUid, $fromTasUid);
|
||||
}
|
||||
self::log("Add Route Success!");
|
||||
|
||||
return $this->saveNewPattern($this->proUid, $fromTasUid, $toTasUid, $type, $delete);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user