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)
|
||||
{
|
||||
unset($data["BOU_ELEMENT_ID"]);
|
||||
|
||||
if (! self::isModified("activity", $actUid, $data)) {
|
||||
self::log("Update Activity: $actUid (No Changes)");
|
||||
return false;
|
||||
}
|
||||
|
||||
parent::updateActivity($actUid, $data);
|
||||
|
||||
$taskData = array();
|
||||
@@ -235,14 +228,6 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -386,8 +386,13 @@ class Bpmn extends Handler
|
||||
|
||||
public function updateEvent($evnUid, $data)
|
||||
{
|
||||
if (array_key_exists("EVN_CANCEL_ACTIVITY", $data)) {
|
||||
$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 {
|
||||
self::log("Update Event: $evnUid", "With data: ", $data);
|
||||
|
||||
@@ -90,6 +90,16 @@ abstract class Handler
|
||||
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.
|
||||
*
|
||||
|
||||
@@ -120,19 +120,18 @@ class Project extends Api
|
||||
foreach ($diagram["activities"] as $i => $activityData) {
|
||||
$activityData = array_change_key_case($activityData, CASE_UPPER);
|
||||
unset($activityData["_EXTENDED"]);
|
||||
unset($activityData["BOU_ELEMENT_ID"]);
|
||||
|
||||
// activity exists ?
|
||||
if ($bwp->activityExists($activityData["ACT_UID"])) {
|
||||
// then update activity
|
||||
$bwp->updateActivity($activityData["ACT_UID"], $activityData);
|
||||
} else {
|
||||
// if not exists then create it
|
||||
$activity = $bwp->getActivity($activityData["ACT_UID"]);
|
||||
if (is_null($activity)) {
|
||||
$oldActUid = $activityData["ACT_UID"];
|
||||
$activityData["ACT_UID"] = Hash::generateUID();
|
||||
|
||||
$bwp->addActivity($activityData);
|
||||
|
||||
$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;
|
||||
@@ -194,17 +193,23 @@ class Project extends Api
|
||||
unset($eventData["_EXTENDED"]);
|
||||
|
||||
// gateway exists ?
|
||||
if ($event = $bwp->getEvent($eventData["EVN_UID"])) {
|
||||
// then update activity
|
||||
$bwp->updateEvent($eventData["EVN_UID"], $eventData);
|
||||
} else {
|
||||
// if not exists then create it
|
||||
$event = $bwp->getEvent($eventData["EVN_UID"]);
|
||||
if (is_null($event)) {
|
||||
$oldActUid = $eventData["EVN_UID"];
|
||||
$eventData["EVN_UID"] = Hash::generateUID();
|
||||
|
||||
$bwp->addEvent($eventData);
|
||||
|
||||
$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;
|
||||
|
||||
Reference in New Issue
Block a user