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 01d411aafd..71c6a588d2 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); 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 30b259fcba..e9f8caac1d 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); 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 0eacac5254..4fb40b65bb 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); 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 544b12c4aa..622fcb9d99 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); 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 0ec686df87..c5f03be6eb 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); 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 d3bbd6e972..67aa4d8845 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); 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 ac5dae2776..7d3afb532d 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); 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 0e366ff16f..a129edca9c 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