Merge branch 'master' of bitbucket.org:colosa/processmaker
This commit is contained in:
@@ -672,6 +672,8 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$diagram["artifacts"] = $bwp->getArtifacts($configList);
|
||||
$diagram["laneset"] = $bwp->getLanesets($configList);
|
||||
$diagram["lanes"] = $bwp->getLanes($configList);
|
||||
$diagram["data"] = $bwp->getDataCollection($configList);
|
||||
$diagram["participants"] = $bwp->getParticipants($configList);
|
||||
$project["diagrams"][] = $diagram;
|
||||
}
|
||||
|
||||
@@ -862,6 +864,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$bwp->removeGateway($gatewayData["GAT_UID"]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Diagram's Events Handling
|
||||
*/
|
||||
@@ -914,6 +917,99 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Diagram's Data Handling
|
||||
*/
|
||||
$whiteList = array();
|
||||
foreach ($diagram["data"] as $i => $dataObjectData) {
|
||||
$dataObjectData = array_change_key_case($dataObjectData, CASE_UPPER);
|
||||
unset($dataObjectData["_EXTENDED"]);
|
||||
|
||||
$dataObject = $bwp->getData($dataObjectData["DAT_UID"]);
|
||||
|
||||
if ($forceInsert || is_null($dataObject)) {
|
||||
if ($generateUid) {
|
||||
//Event
|
||||
unset($dataObjectData["BOU_UID"]);
|
||||
|
||||
$uidOld = $dataObjectData["DAT_UID"];
|
||||
$dataObjectData["DAT_UID"] = Util\Common::generateUID();
|
||||
|
||||
$result[] = array(
|
||||
"object" => "data",
|
||||
"old_uid" => $uidOld,
|
||||
"new_uid" => $dataObjectData["DAT_UID"]
|
||||
);
|
||||
}
|
||||
|
||||
$bwp->addData($dataObjectData);
|
||||
} elseif (! $bwp->isEquals($dataObject, $dataObjectData)) {
|
||||
$bwp->updateData($dataObjectData["DAT_UID"], $dataObjectData);
|
||||
} else {
|
||||
Util\Logger::log("Update Data ({$dataObjectData["DAT_UID"]}) Skipped - No changes required");
|
||||
}
|
||||
|
||||
$diagram["data"][$i] = $dataObjectData;
|
||||
$whiteList[] = $dataObjectData["DAT_UID"];
|
||||
}
|
||||
|
||||
$dataCollection = $bwp->getDataCollection();
|
||||
|
||||
// looking for removed elements
|
||||
foreach ($dataCollection as $dataObjectData) {
|
||||
if (! in_array($dataObjectData["DAT_UID"], $whiteList)) {
|
||||
// If it is not in the white list, then remove them
|
||||
$bwp->removeData($dataObjectData["DAT_UID"]);
|
||||
}
|
||||
}
|
||||
|
||||
////
|
||||
/*
|
||||
* Diagram's Participant Handling
|
||||
*/
|
||||
$whiteList = array();
|
||||
foreach ($diagram["participants"] as $i => $participantData) {
|
||||
$participantData = array_change_key_case($participantData, CASE_UPPER);
|
||||
unset($participantData["_EXTENDED"]);
|
||||
|
||||
$dataObject = $bwp->getParticipant($participantData["PAR_UID"]);
|
||||
|
||||
if ($forceInsert || is_null($dataObject)) {
|
||||
if ($generateUid) {
|
||||
//Event
|
||||
unset($participantData["BOU_UID"]);
|
||||
|
||||
$uidOld = $participantData["PAR_UID"];
|
||||
$participantData["PAR_UID"] = Util\Common::generateUID();
|
||||
|
||||
$result[] = array(
|
||||
"object" => "participant",
|
||||
"old_uid" => $uidOld,
|
||||
"new_uid" => $participantData["PAR_UID"]
|
||||
);
|
||||
}
|
||||
|
||||
$bwp->addParticipant($participantData);
|
||||
} elseif (! $bwp->isEquals($dataObject, $participantData)) {
|
||||
$bwp->updateParticipant($participantData["PAR_UID"], $participantData);
|
||||
} else {
|
||||
Util\Logger::log("Update Participant ({$participantData["PAR_UID"]}) Skipped - No changes required");
|
||||
}
|
||||
|
||||
$diagram["participant"][$i] = $participantData;
|
||||
$whiteList[] = $participantData["PAR_UID"];
|
||||
}
|
||||
|
||||
$dataCollection = $bwp->getParticipants();
|
||||
|
||||
// looking for removed elements
|
||||
foreach ($dataCollection as $participantData) {
|
||||
if (! in_array($participantData["PAR_UID"], $whiteList)) {
|
||||
// If it is not in the white list, then remove them
|
||||
$bwp->removeParticipant($participantData["PAR_UID"]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Diagram's Flows Handling
|
||||
|
||||
@@ -24,6 +24,8 @@ use \BpmnEventPeer as EventPeer;
|
||||
use \BpmnGatewayPeer as GatewayPeer;
|
||||
use \BpmnFlowPeer as FlowPeer;
|
||||
use \BpmnArtifactPeer as ArtifactPeer;
|
||||
use \BpmnParticipant as Participant;
|
||||
use \BpmnParticipantPeer as ParticipantPeer;
|
||||
|
||||
use \BasePeer;
|
||||
|
||||
@@ -71,7 +73,9 @@ class Bpmn extends Handler
|
||||
"PRJ_UID", "PRO_UID", "BOU_ELEMENT", "BOU_ELEMENT_TYPE", "BOU_REL_POSITION",
|
||||
"BOU_SIZE_IDENTICAL", "DIA_UID", "BOU_UID", "ELEMENT_UID"
|
||||
),
|
||||
"flow" => array("PRJ_UID", "DIA_UID", "FLO_ELEMENT_DEST_PORT", "FLO_ELEMENT_ORIGIN_PORT")
|
||||
"flow" => array("PRJ_UID", "DIA_UID", "FLO_ELEMENT_DEST_PORT", "FLO_ELEMENT_ORIGIN_PORT"),
|
||||
"data" => array("PRJ_UID"),
|
||||
"participant" => array("PRJ_UID"),
|
||||
);
|
||||
|
||||
|
||||
@@ -788,6 +792,170 @@ class Bpmn extends Handler
|
||||
}
|
||||
}
|
||||
|
||||
//////1111
|
||||
public function addData($data)
|
||||
{
|
||||
// setting defaults
|
||||
$data['DATA_UID'] = array_key_exists('DAT_UID', $data) ? $data['DAT_UID'] : Common::generateUID();
|
||||
try {
|
||||
self::log("Add BpmnData with data: ", $data);
|
||||
$bpmnData = new \BpmnData();
|
||||
$bpmnData->fromArray($data, BasePeer::TYPE_FIELDNAME);
|
||||
$bpmnData->setPrjUid($this->getUid());
|
||||
$bpmnData->setProUid($this->getProcess("object")->getProUid());
|
||||
$bpmnData->save();
|
||||
self::log("Add BpmnData Success!");
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $bpmnData->getDatUid();
|
||||
}
|
||||
|
||||
public function updateData($datUid, $data)
|
||||
{
|
||||
try {
|
||||
self::log("Update BpmnData: $datUid", "With data: ", $data);
|
||||
|
||||
$bpmnData = ArtifactPeer::retrieveByPk($datUid);
|
||||
|
||||
$bpmnData->fromArray($data);
|
||||
$bpmnData->save();
|
||||
|
||||
self::log("Update BpmnData Success!");
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function getData($datUid, $retType = 'array')
|
||||
{
|
||||
$bpmnData = ArtifactPeer::retrieveByPK($datUid);
|
||||
|
||||
if ($retType != "object" && ! empty($bpmnData)) {
|
||||
$bpmnData = $bpmnData->toArray();
|
||||
$bpmnData = self::filterArrayKeys($bpmnData, self::$excludeFields["data"]);
|
||||
}
|
||||
|
||||
return $bpmnData;
|
||||
}
|
||||
|
||||
public function getDataCollection($start = null, $limit = null, $filter = '', $changeCaseTo = CASE_UPPER)
|
||||
{
|
||||
if (is_array($start)) {
|
||||
extract($start);
|
||||
}
|
||||
|
||||
$filter = $changeCaseTo != CASE_UPPER ? array_map("strtolower", self::$excludeFields["data"]) : self::$excludeFields["data"];
|
||||
|
||||
return self::filterCollectionArrayKeys(
|
||||
\BpmnData::getAll($this->getUid(), $start, $limit, $filter, $changeCaseTo),
|
||||
$filter
|
||||
);
|
||||
}
|
||||
|
||||
public function removeData($datUid)
|
||||
{
|
||||
try {
|
||||
self::log("Remove BpmnData: $datUid");
|
||||
|
||||
$bpmnData = \BpmnDataPeer::retrieveByPK($datUid);
|
||||
$bpmnData->delete();
|
||||
|
||||
// remove related object (flows)
|
||||
Flow::removeAllRelated($datUid);
|
||||
|
||||
self::log("Remove BpmnData Success!");
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
//////2222
|
||||
|
||||
public function addParticipant($data)
|
||||
{
|
||||
// setting defaults
|
||||
$data['PAR_UID'] = array_key_exists('PAR_UID', $data) ? $data['PAR_UID'] : Common::generateUID();
|
||||
try {
|
||||
self::log("Add Participant with data: ", $data);
|
||||
$participant = new Participant();
|
||||
$participant->fromArray($data, BasePeer::TYPE_FIELDNAME);
|
||||
$participant->setPrjUid($this->getUid());
|
||||
$participant->setProUid($this->getProcess("object")->getProUid());
|
||||
$participant->save();
|
||||
self::log("Add Participant Success!");
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $participant->getParUid();
|
||||
}
|
||||
|
||||
public function updateParticipant($parUid, $data)
|
||||
{
|
||||
try {
|
||||
self::log("Update Participant: $parUid", "With data: ", $data);
|
||||
|
||||
$participant = ParticipantPeer::retrieveByPk($parUid);
|
||||
|
||||
$participant->fromArray($data);
|
||||
$participant->save();
|
||||
|
||||
self::log("Update Participant Success!");
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function getParticipant($parUid, $retType = 'array')
|
||||
{
|
||||
$participant = ParticipantPeer::retrieveByPK($parUid);
|
||||
|
||||
if ($retType != "object" && ! empty($participant)) {
|
||||
$participant = $participant->toArray();
|
||||
$participant = self::filterArrayKeys($participant, self::$excludeFields["participant"]);
|
||||
}
|
||||
|
||||
return $participant;
|
||||
}
|
||||
|
||||
public function getParticipants($start = null, $limit = null, $filter = '', $changeCaseTo = CASE_UPPER)
|
||||
{
|
||||
if (is_array($start)) {
|
||||
extract($start);
|
||||
}
|
||||
|
||||
$filter = $changeCaseTo != CASE_UPPER ? array_map("strtolower", self::$excludeFields["participant"]) : self::$excludeFields["participant"];
|
||||
|
||||
return self::filterCollectionArrayKeys(
|
||||
Participant::getAll($this->getUid(), $start, $limit, $filter, $changeCaseTo),
|
||||
$filter
|
||||
);
|
||||
}
|
||||
|
||||
public function removeParticipant($parUid)
|
||||
{
|
||||
try {
|
||||
self::log("Remove Participant: $parUid");
|
||||
|
||||
$participant = ParticipantPeer::retrieveByPK($parUid);
|
||||
$participant->delete();
|
||||
|
||||
// remove related object (flows)
|
||||
Flow::removeAllRelated($parUid);
|
||||
|
||||
self::log("Remove Participant Success!");
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function addLane($data)
|
||||
{
|
||||
// TODO: Implement update() method.
|
||||
|
||||
Reference in New Issue
Block a user