From 13edcfda2ef830e1b160b31f7cd3bea874ccd3f0 Mon Sep 17 00:00:00 2001 From: Matt Gilman Date: Fri, 25 Sep 2015 17:46:58 -0400 Subject: [PATCH] NIFI-810: - Adding basic support for preventing connection when appropriate. - Updating validation when [dis]connecting processors. --- .../org/apache/nifi/web/api/dto/ProcessorDTO.java | 15 +++++++++++++++ .../apache/nifi/controller/TemplateManager.java | 1 + .../org/apache/nifi/web/api/dto/DtoFactory.java | 1 + .../src/main/webapp/js/nf/canvas/nf-actions.js | 4 +++- .../main/webapp/js/nf/canvas/nf-canvas-utils.js | 13 ++++++++++--- .../js/nf/canvas/nf-connection-configuration.js | 8 ++++++-- 6 files changed, 36 insertions(+), 6 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessorDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessorDTO.java index c65c46ab59..866d77c92b 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessorDTO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessorDTO.java @@ -36,6 +36,7 @@ public class ProcessorDTO extends NiFiComponentDTO { private String description; private Boolean supportsParallelProcessing; private Boolean supportsEventDriven; + private String inputRequirement; private ProcessorConfigDTO config; @@ -120,6 +121,20 @@ public class ProcessorDTO extends NiFiComponentDTO { this.supportsParallelProcessing = supportsParallelProcessing; } + /** + * @return the input requirement of this processor + */ + @ApiModelProperty( + value = "The input requirement for this processor." + ) + public String getInputRequirement() { + return inputRequirement; + } + + public void setInputRequirement(String inputRequirement) { + this.inputRequirement = inputRequirement; + } + /** * @return whether this processor supports event driven scheduling */ diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/TemplateManager.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/TemplateManager.java index 7b8e173ff0..a332e053f6 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/TemplateManager.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/TemplateManager.java @@ -320,6 +320,7 @@ public class TemplateManager { // remove validation errors processorDTO.setValidationErrors(null); + processorDTO.setInputRequirement(null); } } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java index 76bce6ffad..16b114e96d 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java @@ -1402,6 +1402,7 @@ public final class DtoFactory { dto.setPosition(createPositionDto(node.getPosition())); dto.setStyle(node.getStyle()); dto.setParentGroupId(node.getProcessGroup().getIdentifier()); + dto.setInputRequirement(node.getInputRequirement().name()); dto.setType(node.getProcessor().getClass().getCanonicalName()); dto.setName(node.getName()); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js index 3b47a8d757..c6ef75fa1a 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js @@ -737,7 +737,9 @@ nf.Actions = (function () { var destinationData = destination.datum(); // update the destination component accordingly - if (nf.CanvasUtils.isRemoteProcessGroup(destination)) { + if (nf.CanvasUtils.isProcessor(destination)) { + nf.Processor.reload(destinationData.component); + } else if (nf.CanvasUtils.isRemoteProcessGroup(destination)) { nf.RemoteProcessGroup.reload(destinationData.component); } } else { diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js index 9f56e30576..1be551ff36 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js @@ -1371,9 +1371,16 @@ nf.CanvasUtils = (function () { return false; } - return nf.CanvasUtils.isProcessor(selection) || nf.CanvasUtils.isProcessGroup(selection) || - nf.CanvasUtils.isRemoteProcessGroup(selection) || nf.CanvasUtils.isOutputPort(selection) || - nf.CanvasUtils.isFunnel(selection); + if (nf.CanvasUtils.isProcessGroup(selection) || nf.CanvasUtils.isRemoteProcessGroup(selection) || + nf.CanvasUtils.isOutputPort(selection) || nf.CanvasUtils.isFunnel(selection)) { + return true; + } + + // if processor, ensure it supports input + if (nf.CanvasUtils.isProcessor(selection)) { + var destinationData = selection.datum(); + return destinationData.component.inputRequirement !== 'INPUT_FORBIDDEN'; + } } }; }()); \ No newline at end of file diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection-configuration.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection-configuration.js index cc246cffa7..1bafa7d647 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection-configuration.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection-configuration.js @@ -870,7 +870,9 @@ nf.ConnectionConfiguration = (function () { } // update the destination component accordingly - if (nf.CanvasUtils.isRemoteProcessGroup(destination)) { + if (nf.CanvasUtils.isProcessor(destination)) { + nf.Processor.reload(destinationData.component); + } else if (nf.CanvasUtils.isRemoteProcessGroup(destination)) { nf.RemoteProcessGroup.reload(destinationData.component); } @@ -958,7 +960,9 @@ nf.ConnectionConfiguration = (function () { } // update the destination component accordingly - if (nf.CanvasUtils.isRemoteProcessGroup(destination)) { + if (nf.CanvasUtils.isProcessor(destination)) { + nf.Processor.reload(destinationData.component); + } else if (nf.CanvasUtils.isRemoteProcessGroup(destination)) { nf.RemoteProcessGroup.reload(destinationData.component); } }