nifi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bbe...@apache.org
Subject nifi git commit: NIFI-2678: - Ensuring the most recent version of each component is save for rendering on the canvas.
Date Wed, 31 Aug 2016 20:00:13 GMT
Repository: nifi
Updated Branches:
  refs/heads/master 9e10371c8 -> 96a766464


NIFI-2678: - Ensuring the most recent version of each component is save for rendering on the
canvas.

This closes #979.

Signed-off-by: Bryan Bende <bbende@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/96a76646
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/96a76646
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/96a76646

Branch: refs/heads/master
Commit: 96a766464c2b2402e73ef77ef91222069ca54ab1
Parents: 9e10371
Author: Matt Gilman <matt.c.gilman@gmail.com>
Authored: Wed Aug 31 15:03:47 2016 -0400
Committer: Bryan Bende <bbende@apache.org>
Committed: Wed Aug 31 15:59:52 2016 -0400

----------------------------------------------------------------------
 .../main/webapp/js/nf/canvas/nf-connection.js   | 24 ++++++++++----
 .../src/main/webapp/js/nf/canvas/nf-funnel.js   | 27 +++++++++++-----
 .../src/main/webapp/js/nf/canvas/nf-label.js    | 25 ++++++++++-----
 .../src/main/webapp/js/nf/canvas/nf-port.js     | 33 ++++++++++++++------
 .../webapp/js/nf/canvas/nf-process-group.js     | 26 ++++++++++-----
 .../main/webapp/js/nf/canvas/nf-processor.js    | 26 ++++++++++-----
 .../js/nf/canvas/nf-remote-process-group.js     | 26 ++++++++++-----
 .../src/main/webapp/js/nf/nf-client.js          | 19 +++++++++++
 8 files changed, 154 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/96a76646/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection.js
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection.js
index 01d411a..71c6a58 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection.js
@@ -1582,17 +1582,29 @@ nf.Connection = (function () {
                 transition = nf.Common.isDefinedAndNotNull(options.transition) ? options.transition
: transition;
             }
 
-            var set = function (connectionEntity) {
-                // add the connection
-                connectionMap.set(connectionEntity.id, $.extend({
-                    type: 'Connection'
-                }, connectionEntity));
+            var set = function (proposedConnectionEntity) {
+                var currentConnectionEntity = connectionMap.get(proposedConnectionEntity.id);
+
+                // set the connection if appropriate
+                if (nf.Client.isNewerRevision(currentConnectionEntity, proposedConnectionEntity))
{
+                    connectionMap.set(proposedConnectionEntity.id, $.extend({
+                        type: 'Connection'
+                    }, proposedConnectionEntity));
+                }
             };
 
             // determine how to handle the specified connection
             if ($.isArray(connectionEntities)) {
                 $.each(connectionMap.keys(), function (_, key) {
-                    connectionMap.remove(key);
+                    var currentConnectionEntity = connectionMap.get(key);
+                    var isPresent = $.grep(connectionEntities, function (proposedConnectionEntity)
{
+                        return proposedConnectionEntity.id === currentConnectionEntity.id;
+                    });
+
+                    // if the current connection is not present, remove it
+                    if (isPresent.length === 0) {
+                        connectionMap.remove(key);
+                    }
                 });
                 $.each(connectionEntities, function (_, connectionEntity) {
                     set(connectionEntity);

http://git-wip-us.apache.org/repos/asf/nifi/blob/96a76646/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-funnel.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-funnel.js
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-funnel.js
index 30b259f..e9f8caa 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-funnel.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-funnel.js
@@ -218,18 +218,29 @@ nf.Funnel = (function () {
                 transition = nf.Common.isDefinedAndNotNull(options.transition) ? options.transition
: transition;
             }
 
-            var set = function (funnelEntity) {
-                // add the funnel
-                funnelMap.set(funnelEntity.id, $.extend({
-                    type: 'Funnel',
-                    dimensions: dimensions
-                }, funnelEntity));
+            var set = function (proposedFunnelEntity) {
+                var currentFunnelEntity = funnelMap.get(proposedFunnelEntity.id);
+
+                // set the funnel if appropriate
+                if (nf.Client.isNewerRevision(currentFunnelEntity, proposedFunnelEntity))
{
+                    funnelMap.set(proposedFunnelEntity.id, $.extend({
+                        type: 'Funnel',
+                        dimensions: dimensions
+                    }, proposedFunnelEntity));
+                }
             };
 
-            // determine how to handle the specified funnel status
             if ($.isArray(funnelEntities)) {
                 $.each(funnelMap.keys(), function (_, key) {
-                    funnelMap.remove(key);
+                    var currentFunnelEntity = funnelMap.get(key);
+                    var isPresent = $.grep(funnelEntities, function (proposedFunnelEntity)
{
+                        return proposedFunnelEntity.id === currentFunnelEntity.id;
+                    });
+
+                    // if the current funnel is not present, remove it
+                    if (isPresent.length === 0) {
+                        funnelMap.remove(key);
+                    }
                 });
                 $.each(funnelEntities, function (_, funnelEntity) {
                     set(funnelEntity);

http://git-wip-us.apache.org/repos/asf/nifi/blob/96a76646/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-label.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-label.js
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-label.js
index 0eacac5..4fb40b6 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-label.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-label.js
@@ -399,17 +399,28 @@ nf.Label = (function () {
                 transition = nf.Common.isDefinedAndNotNull(options.transition) ? options.transition
: transition;
             }
 
-            var set = function (labelEntity) {
-                // add the label
-                labelMap.set(labelEntity.id, $.extend({
-                    type: 'Label'
-                }, labelEntity));
+            var set = function (proposedLabelEntity) {
+                var currentLabelEntity = labelMap.get(proposedLabelEntity.id);
+
+                // set the processor if appropriate
+                if (nf.Client.isNewerRevision(currentLabelEntity, proposedLabelEntity)) {
+                    labelMap.set(proposedLabelEntity.id, $.extend({
+                        type: 'Label'
+                    }, proposedLabelEntity));
+                }
             };
 
-            // determine how to handle the specified label status
             if ($.isArray(labelEntities)) {
                 $.each(labelMap.keys(), function (_, key) {
-                    labelMap.remove(key);
+                    var currentLabelEntity = labelMap.get(key);
+                    var isPresent = $.grep(labelEntities, function (proposedLabelEntity)
{
+                        return proposedLabelEntity.id === currentLabelEntity.id;
+                    });
+
+                    // if the current label is not present, remove it
+                    if (isPresent.length === 0) {
+                        labelMap.remove(key);
+                    }
                 });
                 $.each(labelEntities, function (_, labelEntity) {
                     set(labelEntity);

http://git-wip-us.apache.org/repos/asf/nifi/blob/96a76646/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port.js
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port.js
index 544b12c..622fcb9 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port.js
@@ -540,21 +540,34 @@ nf.Port = (function () {
                 dimensions = remotePortDimensions;
             }
 
-            var set = function (portEntity) {
-                // add the port
-                portMap.set(portEntity.id, $.extend({
-                    type: 'Port',
-                    dimensions: dimensions,
-                    status: {
-                        activeThreadCount: 0
-                    }
-                }, portEntity));
+            var set = function (proposedPortEntity) {
+                var currentPortEntity = portMap.get(proposedPortEntity.id);
+
+                // set the port if appropriate
+                if (nf.Client.isNewerRevision(currentPortEntity, proposedPortEntity)) {
+                    // add the port
+                    portMap.set(proposedPortEntity.id, $.extend({
+                        type: 'Port',
+                        dimensions: dimensions,
+                        status: {
+                            activeThreadCount: 0
+                        }
+                    }, proposedPortEntity));
+                }
             };
 
             // determine how to handle the specified port status
             if ($.isArray(portEntities)) {
                 $.each(portMap.keys(), function (_, key) {
-                    portMap.remove(key);
+                    var currentPortEntity = portMap.get(key);
+                    var isPresent = $.grep(portEntities, function (proposedPortEntity) {
+                        return proposedPortEntity.id === currentPortEntity.id;
+                    });
+
+                    // if the current port is not present, remove it
+                    if (isPresent.length === 0) {
+                        portMap.remove(key);
+                    }
                 });
                 $.each(portEntities, function (_, portNode) {
                     set(portNode);

http://git-wip-us.apache.org/repos/asf/nifi/blob/96a76646/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group.js
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group.js
index 0ec686d..c5f03be 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group.js
@@ -1018,18 +1018,30 @@ nf.ProcessGroup = (function () {
                 transition = nf.Common.isDefinedAndNotNull(options.transition) ? options.transition
: transition;
             }
 
-            var set = function (processGroupEntity) {
-                // add the process group
-                processGroupMap.set(processGroupEntity.id, $.extend({
-                    type: 'ProcessGroup',
-                    dimensions: dimensions
-                }, processGroupEntity));
+            var set = function (proposedProcessGroupEntity) {
+                var currentProcessGroupEntity = processGroupMap.get(proposedProcessGroupEntity.id);
+
+                // set the process group if appropriate
+                if (nf.Client.isNewerRevision(currentProcessGroupEntity, proposedProcessGroupEntity))
{
+                    processGroupMap.set(proposedProcessGroupEntity.id, $.extend({
+                        type: 'ProcessGroup',
+                        dimensions: dimensions
+                    }, proposedProcessGroupEntity));
+                }
             };
 
             // determine how to handle the specified process groups
             if ($.isArray(processGroupEntities)) {
                 $.each(processGroupMap.keys(), function (_, key) {
-                    processGroupMap.remove(key);
+                    var currentProcessGroupEntity = processGroupMap.get(key);
+                    var isPresent = $.grep(processGroupEntities, function (proposedProcessGroupEntity)
{
+                        return proposedProcessGroupEntity.id === currentProcessGroupEntity.id;
+                    });
+
+                    // if the current process group is not present, remove it
+                    if (isPresent.length === 0) {
+                        processGroupMap.remove(key);
+                    }
                 });
                 $.each(processGroupEntities, function (_, processGroupEntity) {
                     set(processGroupEntity);

http://git-wip-us.apache.org/repos/asf/nifi/blob/96a76646/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor.js
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor.js
index d3bbd6e..67aa4d8 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor.js
@@ -791,18 +791,30 @@ nf.Processor = (function () {
                 transition = nf.Common.isDefinedAndNotNull(options.transition) ? options.transition
: transition;
             }
 
-            var set = function (processorEntity) {
-                // add the processor
-                processorMap.set(processorEntity.id, $.extend({
-                    type: 'Processor',
-                    dimensions: dimensions
-                }, processorEntity));
+            var set = function (proposedProcessorEntity) {
+                var currentProcessorEntity = processorMap.get(proposedProcessorEntity.id);
+
+                // set the processor if appropriate
+                if (nf.Client.isNewerRevision(currentProcessorEntity, proposedProcessorEntity))
{
+                    processorMap.set(proposedProcessorEntity.id, $.extend({
+                        type: 'Processor',
+                        dimensions: dimensions
+                    }, proposedProcessorEntity));
+                }
             };
 
             // determine how to handle the specified processor
             if ($.isArray(processorEntities)) {
                 $.each(processorMap.keys(), function (_, key) {
-                    processorMap.remove(key);
+                    var currentProcessorEntity = processorMap.get(key);
+                    var isPresent = $.grep(processorEntities, function (proposedProcessorEntity)
{
+                        return proposedProcessorEntity.id === currentProcessorEntity.id;
+                    });
+
+                    // if the current processor is not present, remove it
+                    if (isPresent.length === 0) {
+                        processorMap.remove(key);
+                    }
                 });
                 $.each(processorEntities, function (_, processorEntity) {
                     set(processorEntity);

http://git-wip-us.apache.org/repos/asf/nifi/blob/96a76646/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group.js
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group.js
index ac5dae2..7d3afb5 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group.js
@@ -872,18 +872,30 @@ nf.RemoteProcessGroup = (function () {
                 transition = nf.Common.isDefinedAndNotNull(options.transition) ? options.transition
: transition;
             }
 
-            var set = function (remoteProcessGroupEntity) {
-                // add the remote process group
-                remoteProcessGroupMap.set(remoteProcessGroupEntity.id, $.extend({
-                    type: 'RemoteProcessGroup',
-                    dimensions: dimensions
-                }, remoteProcessGroupEntity));
+            var set = function (proposedRemoteProcessGroupEntity) {
+                var currentRemoteProcessGroupEntity = remoteProcessGroupMap.get(proposedRemoteProcessGroupEntity.id);
+
+                // set the remote process group if appropriate
+                if (nf.Client.isNewerRevision(currentRemoteProcessGroupEntity, proposedRemoteProcessGroupEntity))
{
+                    remoteProcessGroupMap.set(proposedRemoteProcessGroupEntity.id, $.extend({
+                        type: 'RemoteProcessGroup',
+                        dimensions: dimensions
+                    }, proposedRemoteProcessGroupEntity));
+                }
             };
 
             // determine how to handle the specified remote process groups
             if ($.isArray(remoteProcessGroupEntities)) {
                 $.each(remoteProcessGroupMap.keys(), function (_, key) {
-                    remoteProcessGroupMap.remove(key);
+                    var currentRemoteProcessGroupEntity = remoteProcessGroupMap.get(key);
+                    var isPresent = $.grep(remoteProcessGroupEntities, function (proposedRemoteProcessGroupEntity)
{
+                        return proposedRemoteProcessGroupEntity.id === currentRemoteProcessGroupEntity.id;
+                    });
+
+                    // if the current remote process group is not present, remove it
+                    if (isPresent.length === 0) {
+                        remoteProcessGroupMap.remove(key);
+                    }
                 });
                 $.each(remoteProcessGroupEntities, function (_, remoteProcessGroupEntity)
{
                     set(remoteProcessGroupEntity);

http://git-wip-us.apache.org/repos/asf/nifi/blob/96a76646/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-client.js
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-client.js
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-client.js
index 0e366ff..a129edc 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-client.js
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-client.js
@@ -45,6 +45,25 @@ nf.Client = (function() {
                 'clientId': clientId,
                 'version': d.revision.version
             };
+        },
+
+        /**
+         * Determines whether the proposedData is newer than the currentData.
+         *
+         * @param currentData Maybe be null, if the proposedData is new to this canvas
+         * @param proposedData Maybe not be null
+         * @return {boolean} whether proposedData is newer than currentData
+         */
+        isNewerRevision: function (currentData, proposedData) {
+            if (nf.Common.isDefinedAndNotNull(currentData)) {
+                var currentRevision = currentData.revision;
+                var proposedRevision = proposedData.revision;
+
+                // return whether the proposed revision is newer
+                return proposedRevision.version > currentRevision.version;
+            } else {
+                return true;
+            }
         }
     };
 }());
\ No newline at end of file


Mime
View raw message