Updates before update on BpmnWorkflow Adapter
This commit is contained in:
@@ -116,13 +116,6 @@ class BpmnWorkflow extends Project\Bpmn
|
|||||||
|
|
||||||
public function updateActivity($actUid, $data)
|
public function updateActivity($actUid, $data)
|
||||||
{
|
{
|
||||||
unset($data["BOU_ELEMENT_ID"]);
|
|
||||||
|
|
||||||
if (! self::isModified("activity", $actUid, $data)) {
|
|
||||||
self::log("Update Activity: $actUid (No Changes)");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
parent::updateActivity($actUid, $data);
|
parent::updateActivity($actUid, $data);
|
||||||
|
|
||||||
$taskData = array();
|
$taskData = array();
|
||||||
@@ -235,14 +228,6 @@ class BpmnWorkflow extends Project\Bpmn
|
|||||||
|
|
||||||
public function updateEvent($evnUid, $data)
|
public function updateEvent($evnUid, $data)
|
||||||
{
|
{
|
||||||
$data["EVN_CANCEL_ACTIVITY"] = $data["EVN_CANCEL_ACTIVITY"] ? 1 : 0;
|
|
||||||
$data["EVN_WAIT_FOR_COMPLETION"] = $data["EVN_WAIT_FOR_COMPLETION"] ? 1 : 0;
|
|
||||||
|
|
||||||
if (! self::isModified("event", $evnUid, $data)) {
|
|
||||||
self::log("Update Event: $evnUid (No Changes)");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
parent::updateEvent($evnUid, $data);
|
parent::updateEvent($evnUid, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -386,8 +386,13 @@ class Bpmn extends Handler
|
|||||||
|
|
||||||
public function updateEvent($evnUid, $data)
|
public function updateEvent($evnUid, $data)
|
||||||
{
|
{
|
||||||
$data["EVN_CANCEL_ACTIVITY"] = $data["EVN_CANCEL_ACTIVITY"] ? 1 : 0;
|
if (array_key_exists("EVN_CANCEL_ACTIVITY", $data)) {
|
||||||
$data["EVN_WAIT_FOR_COMPLETION"] = $data["EVN_WAIT_FOR_COMPLETION"] ? 1 : 0;
|
$data["EVN_CANCEL_ACTIVITY"] = $data["EVN_CANCEL_ACTIVITY"] ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists("EVN_WAIT_FOR_COMPLETION", $data)) {
|
||||||
|
$data["EVN_WAIT_FOR_COMPLETION"] = $data["EVN_WAIT_FOR_COMPLETION"] ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
self::log("Update Event: $evnUid", "With data: ", $data);
|
self::log("Update Event: $evnUid", "With data: ", $data);
|
||||||
|
|||||||
@@ -90,6 +90,16 @@ abstract class Handler
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isEquals($array, $arrayCompare)
|
||||||
|
{
|
||||||
|
ksort($array);
|
||||||
|
ksort($arrayCompare);
|
||||||
|
self::log($array, $arrayCompare);
|
||||||
|
//$ret = array_diff_assoc($array, $arrayCompare);
|
||||||
|
|
||||||
|
return (self::getChecksum($array) === self::getChecksum($arrayCompare));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log in ProcessMaker Standard Output if debug mode is enabled.
|
* Log in ProcessMaker Standard Output if debug mode is enabled.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -120,19 +120,18 @@ class Project extends Api
|
|||||||
foreach ($diagram["activities"] as $i => $activityData) {
|
foreach ($diagram["activities"] as $i => $activityData) {
|
||||||
$activityData = array_change_key_case($activityData, CASE_UPPER);
|
$activityData = array_change_key_case($activityData, CASE_UPPER);
|
||||||
unset($activityData["_EXTENDED"]);
|
unset($activityData["_EXTENDED"]);
|
||||||
|
unset($activityData["BOU_ELEMENT_ID"]);
|
||||||
|
|
||||||
// activity exists ?
|
$activity = $bwp->getActivity($activityData["ACT_UID"]);
|
||||||
if ($bwp->activityExists($activityData["ACT_UID"])) {
|
if (is_null($activity)) {
|
||||||
// then update activity
|
|
||||||
$bwp->updateActivity($activityData["ACT_UID"], $activityData);
|
|
||||||
} else {
|
|
||||||
// if not exists then create it
|
|
||||||
$oldActUid = $activityData["ACT_UID"];
|
$oldActUid = $activityData["ACT_UID"];
|
||||||
$activityData["ACT_UID"] = Hash::generateUID();
|
$activityData["ACT_UID"] = Hash::generateUID();
|
||||||
|
|
||||||
$bwp->addActivity($activityData);
|
$bwp->addActivity($activityData);
|
||||||
|
|
||||||
$result[] = array("object" => "activity", "new_uid" => $activityData["ACT_UID"], "old_uid" => $oldActUid);
|
$result[] = array("object" => "activity", "new_uid" => $activityData["ACT_UID"], "old_uid" => $oldActUid);
|
||||||
|
} elseif (! $bwp->isEquals($activity, $activityData)) {
|
||||||
|
$bwp->updateActivity($activityData["ACT_UID"], $activityData);
|
||||||
|
} else {
|
||||||
|
Logger::log("Update Activity ({$activityData["ACT_UID"]}) Skipped - No changes required");
|
||||||
}
|
}
|
||||||
|
|
||||||
$diagram["activities"][$i] = $activityData;
|
$diagram["activities"][$i] = $activityData;
|
||||||
@@ -194,17 +193,23 @@ class Project extends Api
|
|||||||
unset($eventData["_EXTENDED"]);
|
unset($eventData["_EXTENDED"]);
|
||||||
|
|
||||||
// gateway exists ?
|
// gateway exists ?
|
||||||
if ($event = $bwp->getEvent($eventData["EVN_UID"])) {
|
$event = $bwp->getEvent($eventData["EVN_UID"]);
|
||||||
// then update activity
|
if (is_null($event)) {
|
||||||
$bwp->updateEvent($eventData["EVN_UID"], $eventData);
|
|
||||||
} else {
|
|
||||||
// if not exists then create it
|
|
||||||
$oldActUid = $eventData["EVN_UID"];
|
$oldActUid = $eventData["EVN_UID"];
|
||||||
$eventData["EVN_UID"] = Hash::generateUID();
|
$eventData["EVN_UID"] = Hash::generateUID();
|
||||||
|
|
||||||
$bwp->addEvent($eventData);
|
$bwp->addEvent($eventData);
|
||||||
|
|
||||||
$result[] = array("object" => "event", "new_uid" => $eventData["EVN_UID"], "old_uid" => $oldActUid);
|
$result[] = array("object" => "event", "new_uid" => $eventData["EVN_UID"], "old_uid" => $oldActUid);
|
||||||
|
} elseif (! $bwp->isEquals($event, $eventData)) {
|
||||||
|
if (array_key_exists("EVN_CANCEL_ACTIVITY", $eventData)) {
|
||||||
|
$eventData["EVN_CANCEL_ACTIVITY"] = $eventData["EVN_CANCEL_ACTIVITY"] ? 1 : 0;
|
||||||
|
}
|
||||||
|
if (array_key_exists("EVN_WAIT_FOR_COMPLETION", $eventData)) {
|
||||||
|
$eventData["EVN_WAIT_FOR_COMPLETION"] = $eventData["EVN_WAIT_FOR_COMPLETION"] ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$bwp->updateEvent($eventData["EVN_UID"], $eventData);
|
||||||
|
} else {
|
||||||
|
Logger::log("Update Event ({$eventData["EVN_UID"]}) Skipped - No changes required");
|
||||||
}
|
}
|
||||||
|
|
||||||
$diagram["events"][$i] = $eventData;
|
$diagram["events"][$i] = $eventData;
|
||||||
|
|||||||
Reference in New Issue
Block a user