Se adiciona funcionalidad de lanes y lanesets para project
This commit is contained in:
@@ -671,6 +671,8 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$diagram["lanes"] = $bwp->getLanes($configList);
|
||||
$diagram["data"] = $bwp->getDataCollection($configList);
|
||||
$diagram["participants"] = $bwp->getParticipants($configList);
|
||||
$diagram["lanesets"] = $bwp->getLanesets($configList);
|
||||
$diagram["lanes"] = $bwp->getLanes($configList);
|
||||
$project["diagrams"][] = $diagram;
|
||||
}
|
||||
|
||||
@@ -726,6 +728,8 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$diagram["events"] = isset($diagram["events"])? $diagram["events"]: array();
|
||||
$diagram["data"] = isset($diagram["data"])? $diagram["data"]: array();
|
||||
$diagram["participants"] = isset($diagram["participants"])? $diagram["participants"]: array();
|
||||
$diagram["lanesets"] = isset($diagram["lanesets"])? $diagram["lanesets"]: array();
|
||||
$diagram["lanes"] = isset($diagram["lanes"])? $diagram["lanes"]: array();
|
||||
$result = array();
|
||||
|
||||
$projectData['prj_uid'] = $prjUid;
|
||||
@@ -1032,6 +1036,97 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
}
|
||||
}
|
||||
|
||||
////
|
||||
/*
|
||||
* Diagram's Laneset Handling
|
||||
*/
|
||||
$whiteList = array();
|
||||
foreach ($diagram["laneset"] as $i => $lanesetData) {
|
||||
$lanesetData = array_change_key_case($lanesetData, CASE_UPPER);
|
||||
|
||||
$dataObject = $bwp->getLaneset($lanesetData["LNS_UID"]);
|
||||
|
||||
if ($forceInsert || is_null($dataObject)) {
|
||||
if ($generateUid) {
|
||||
//Laneset
|
||||
unset($lanesetData["BOU_UID"]);
|
||||
|
||||
$uidOld = $lanesetData["LNS_UID"];
|
||||
$lanesetData["LNS_UID"] = Util\Common::generateUID();
|
||||
|
||||
$result[] = array(
|
||||
"object" => "laneset",
|
||||
"old_uid" => $uidOld,
|
||||
"new_uid" => $lanesetData["LNS_UID"]
|
||||
);
|
||||
}
|
||||
$bwp->addLaneset($lanesetData);
|
||||
} elseif (! $bwp->isEquals($dataObject, $lanesetData)) {
|
||||
$bwp->updateLanseset($lanesetData["LNS_UID"], $lanesetData);
|
||||
} else {
|
||||
Util\Logger::log("Update Laneset ({$lanesetData["LNS_UID"]}) Skipped - No changes required");
|
||||
}
|
||||
|
||||
$diagram["laneset"][$i] = $lanesetData;
|
||||
$whiteList[] = $lanesetData["LNS_UID"];
|
||||
}
|
||||
|
||||
$dataCollection = $bwp->getLanesets();
|
||||
|
||||
// looking for removed elements
|
||||
foreach ($dataCollection as $lanesetData) {
|
||||
if (! in_array($lanesetData["LNS_UID"], $whiteList)) {
|
||||
// If it is not in the white list, then remove them
|
||||
$bwp->removeLaneset($lanesetData["LNS_UID"]);
|
||||
}
|
||||
}
|
||||
|
||||
////
|
||||
/*
|
||||
* Diagram's Lane Handling
|
||||
*/
|
||||
$whiteList = array();
|
||||
foreach ($diagram["lanes"] as $i => $laneData) {
|
||||
$laneData = array_change_key_case($laneData, CASE_UPPER);
|
||||
|
||||
$dataObject = $bwp->getLane($laneData["LAN_UID"]);
|
||||
|
||||
if ($forceInsert || is_null($dataObject)) {
|
||||
if ($generateUid) {
|
||||
//Laneset
|
||||
unset($laneData["BOU_UID"]);
|
||||
|
||||
$uidOld = $laneData["LAN_UID"];
|
||||
$laneData["LAN_UID"] = Util\Common::generateUID();
|
||||
|
||||
$result[] = array(
|
||||
"object" => "lane",
|
||||
"old_uid" => $uidOld,
|
||||
"new_uid" => $laneData["LAN_UID"]
|
||||
);
|
||||
}
|
||||
$bwp->addLane($laneData);
|
||||
} elseif (! $bwp->isEquals($dataObject, $laneData)) {
|
||||
$bwp->updateLanse($laneData["LAN_UID"], $laneData);
|
||||
} else {
|
||||
Util\Logger::log("Update Lane ({$laneData["LAN_UID"]}) Skipped - No changes required");
|
||||
}
|
||||
|
||||
$diagram["lane"][$i] = $laneData;
|
||||
$whiteList[] = $laneData["LAN_UID"];
|
||||
}
|
||||
|
||||
$dataCollection = $bwp->getLanes();
|
||||
|
||||
// looking for removed elements
|
||||
foreach ($dataCollection as $laneData) {
|
||||
if (! in_array($laneData["LAN_UID"], $whiteList)) {
|
||||
// If it is not in the white list, then remove them
|
||||
$bwp->removeLane($laneData["LAN_UID"]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Diagram's Flows Handling
|
||||
*/
|
||||
|
||||
@@ -4,8 +4,6 @@ namespace ProcessMaker\Project;
|
||||
use \BpmnProject as Project;
|
||||
use \BpmnProcess as Process;
|
||||
use \BpmnDiagram as Diagram;
|
||||
use \BpmnLaneset as Laneset;
|
||||
use \BpmnLane as Lane;
|
||||
use \BpmnActivity as Activity;
|
||||
use \BpmnBound as Bound;
|
||||
use \BpmnEvent as Event;
|
||||
@@ -16,8 +14,7 @@ use \BpmnArtifact as Artifact;
|
||||
use \BpmnProjectPeer as ProjectPeer;
|
||||
use \BpmnProcessPeer as ProcessPeer;
|
||||
use \BpmnDiagramPeer as DiagramPeer;
|
||||
use \BpmnLanesetPeer as LanesetPeer;
|
||||
use \BpmnLanePeer as LanePeer;
|
||||
|
||||
use \BpmnActivityPeer as ActivityPeer;
|
||||
use \BpmnBoundPeer as BoundPeer;
|
||||
use \BpmnEventPeer as EventPeer;
|
||||
@@ -26,6 +23,10 @@ use \BpmnFlowPeer as FlowPeer;
|
||||
use \BpmnArtifactPeer as ArtifactPeer;
|
||||
use \BpmnParticipant as Participant;
|
||||
use \BpmnParticipantPeer as ParticipantPeer;
|
||||
use \BpmnLaneset as Laneset;
|
||||
use \BpmnLanesetPeer as LanesetPeer;
|
||||
use \BpmnLane as Lane;
|
||||
use \BpmnLanePeer as LanePeer;
|
||||
|
||||
use \BasePeer;
|
||||
use \Criteria as Criteria;
|
||||
@@ -78,6 +79,8 @@ class Bpmn extends Handler
|
||||
"flow" => array("PRJ_UID", "DIA_UID", "FLO_ELEMENT_DEST_PORT", "FLO_ELEMENT_ORIGIN_PORT"),
|
||||
"data" => array("PRJ_UID"),
|
||||
"participant" => array("PRJ_UID"),
|
||||
"laneset" => array(),
|
||||
"lane" => array()
|
||||
);
|
||||
|
||||
|
||||
@@ -179,7 +182,12 @@ class Bpmn extends Handler
|
||||
foreach ($this->getParticipants() as $participant) {
|
||||
$this->removeParticipant($participant["PAR_UID"]);
|
||||
}
|
||||
|
||||
foreach ($this->getLanesets() as $laneset) {
|
||||
$this->removeLaneset($laneset["LNS_UID"]);
|
||||
}
|
||||
foreach ($this->getLanes() as $lane) {
|
||||
$this->removeLane($lane["LAN_UID"]);
|
||||
}
|
||||
if ($process = $this->getProcess("object")) {
|
||||
$process->delete();
|
||||
}
|
||||
@@ -635,6 +643,8 @@ class Bpmn extends Handler
|
||||
case "bpmnArtifact": $class = "BpmnArtifact"; break;
|
||||
case "bpmnData": $class = "BpmnData"; break;
|
||||
case "bpmnParticipant": $class = "BpmnParticipant"; break;
|
||||
case "bpmnLaneset": $class = "BpmnLaneset"; break;
|
||||
case "bpmnLane": $class = "BpmnLane"; break;
|
||||
default:
|
||||
throw new \RuntimeException(sprintf("Invalid Object type, accepted types: [%s|%s|%s|%s], given %s.",
|
||||
"BpmnActivity", "BpmnBpmnGateway", "BpmnEvent", "bpmnArtifact", $data["FLO_ELEMENT_ORIGIN_TYPE"]
|
||||
@@ -655,6 +665,8 @@ class Bpmn extends Handler
|
||||
case "bpmnArtifact": $class = "BpmnArtifact"; break;
|
||||
case "bpmnData": $class = "BpmnData"; break;
|
||||
case "bpmnParticipant": $class = "BpmnParticipant"; break;
|
||||
case "bpmnLaneset": $class = "BpmnLaneset"; break;
|
||||
case "bpmnLane": $class = "BpmnLane"; break;
|
||||
default:
|
||||
throw new \RuntimeException(sprintf("Invalid Object type, accepted types: [%s|%s|%s|%s], given %s.",
|
||||
"BpmnActivity", "BpmnBpmnGateway", "BpmnEvent", "bpmnArtifact", $data["FLO_ELEMENT_DEST_TYPE"]
|
||||
@@ -1005,36 +1017,136 @@ class Bpmn extends Handler
|
||||
|
||||
public function addLane($data)
|
||||
{
|
||||
// TODO: Implement update() method.
|
||||
// setting defaults
|
||||
$processUid = $this->getProcess("object")->getProUid();
|
||||
|
||||
$data['LAN_UID'] = array_key_exists('LAN_UID', $data) ? $data['LAN_UID'] : Common::generateUID();
|
||||
$data["PRO_UID"] = $processUid;
|
||||
|
||||
try {
|
||||
self::log("Add Lane with data: ", $data);
|
||||
$lane = new Lane();
|
||||
$lane->fromArray($data, BasePeer::TYPE_FIELDNAME);
|
||||
$lane->setPrjUid($this->getUid());
|
||||
//$lane->setProUid($this->getProcess("object")->getProUid());
|
||||
$lane->save();
|
||||
self::log("Add Lane Success!");
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $lane->getLanUid();
|
||||
}
|
||||
|
||||
public function getLane($lanUid)
|
||||
public function getLane($lanUid, $retType = 'array')
|
||||
{
|
||||
// TODO: Implement update() method.
|
||||
$lane = LanePeer::retrieveByPK($lanUid);
|
||||
|
||||
if ($retType != "object" && ! empty($lane)) {
|
||||
$lane = $lane->toArray();
|
||||
$lane = self::filterArrayKeys($lane, self::$excludeFields["lane"]);
|
||||
}
|
||||
|
||||
return $lane;
|
||||
}
|
||||
|
||||
public function getLanes()
|
||||
public function getLanes($start = null, $limit = null, $filter = '', $changeCaseTo = CASE_UPPER)
|
||||
{
|
||||
// TODO: Implement update() method.
|
||||
return array();
|
||||
if (is_array($start)) {
|
||||
extract($start);
|
||||
}
|
||||
|
||||
$filter = $changeCaseTo != CASE_UPPER ? array_map("strtolower", self::$excludeFields["lane"]) : self::$excludeFields["lane"];
|
||||
|
||||
return self::filterCollectionArrayKeys(
|
||||
Lane::getAll($this->getUid(), $start, $limit, $filter, $changeCaseTo),
|
||||
$filter
|
||||
);
|
||||
}
|
||||
|
||||
public function removeLane($lanUid)
|
||||
{
|
||||
try {
|
||||
self::log("Remove Lane: $lanUid");
|
||||
|
||||
$lane = LanePeer::retrieveByPK($lanUid);
|
||||
$lane->delete();
|
||||
|
||||
// remove related object (flows)
|
||||
Flow::removeAllRelated($lanUid);
|
||||
|
||||
self::log("Remove Lane Success!");
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function addLaneset($data)
|
||||
{
|
||||
// TODO: Implement update() method.
|
||||
// setting defaults
|
||||
$processUid = $this->getProcess("object")->getProUid();
|
||||
$data['LNS_UID'] = array_key_exists('LNS_UID', $data) ? $data['LNS_UID'] : Common::generateUID();
|
||||
$data["PRO_UID"] = $processUid;
|
||||
|
||||
try {
|
||||
self::log("Add Laneset with data: ", $data);
|
||||
$laneset = new Laneset();
|
||||
$laneset->fromArray($data, BasePeer::TYPE_FIELDNAME);
|
||||
$laneset->setPrjUid($this->getUid());
|
||||
$laneset->setProUid($this->getProcess("object")->getProUid());
|
||||
$laneset->save();
|
||||
self::log("Add Laneset Success!");
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $laneset->getLnsUid();
|
||||
}
|
||||
|
||||
public function getLaneset($lnsUid)
|
||||
public function getLaneset($lnsUid, $retType = 'array')
|
||||
{
|
||||
// TODO: Implement update() method.
|
||||
$laneset = LanesetPeer::retrieveByPK($lnsUid);
|
||||
|
||||
if ($retType != "object" && ! empty($laneset)) {
|
||||
$laneset = $laneset->toArray();
|
||||
$laneset = self::filterArrayKeys($laneset, self::$excludeFields["laneset"]);
|
||||
}
|
||||
|
||||
return $laneset;
|
||||
}
|
||||
|
||||
public function getLanesets()
|
||||
public function getLanesets($start = null, $limit = null, $filter = '', $changeCaseTo = CASE_UPPER)
|
||||
{
|
||||
// TODO: Implement update() method.
|
||||
return array();
|
||||
if (is_array($start)) {
|
||||
extract($start);
|
||||
}
|
||||
$filter = $changeCaseTo != CASE_UPPER ? array_map("strtolower", self::$excludeFields["laneset"]) : self::$excludeFields["laneset"];
|
||||
return self::filterCollectionArrayKeys(
|
||||
Laneset::getAll($this->getUid(), $start, $limit, $filter, $changeCaseTo),
|
||||
$filter
|
||||
);
|
||||
}
|
||||
|
||||
public function removeLaneset($lnsUid)
|
||||
{
|
||||
try {
|
||||
self::log("Remove Laneset: $lnsUid");
|
||||
|
||||
$laneset = LanesetPeer::retrieveByPK($lnsUid);
|
||||
$laneset->delete();
|
||||
|
||||
// remove related object (flows)
|
||||
Flow::removeAllRelated($lnsUid);
|
||||
|
||||
self::log("Remove Laneset Success!");
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function isModified($element, $uid, $newData)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user