From c0f5fcb48437e4d3c148bd2742a9fc92eb49630a Mon Sep 17 00:00:00 2001 From: Bence Simon Date: Thu, 2 Apr 2020 17:15:04 +0200 Subject: [PATCH] NIFI-7188 Extending UI search with filters and refactoring existing solution This closes #4123. Signed-off-by: Peter Turcsanyi --- nifi-docs/src/main/asciidoc/user-guide.adoc | 103 +- .../nifi-web/nifi-web-api/pom.xml | 12 + .../apache/nifi/web/NiFiServiceFacade.java | 3 +- .../nifi/web/StandardNiFiServiceFacade.java | 4 +- .../org/apache/nifi/web/api/FlowResource.java | 7 +- .../nifi/web/controller/ControllerFacade.java | 34 +- .../controller/ControllerSearchService.java | 731 ++--------- .../AttributeBasedComponentMatcher.java | 60 + .../nifi/web/search/ComponentMatcher.java | 41 + .../web/search/ComponentMatcherFactory.java | 88 ++ .../attributematchers/AttributeMatcher.java | 56 + .../BackPressureMatcher.java | 56 + .../attributematchers/BasicMatcher.java | 37 + .../attributematchers/ConnectionMatcher.java | 39 + .../ConnectionRelationshipMatcher.java | 31 + .../ConnectivityMatcher.java | 42 + .../ControllerServiceNodeMatcher.java | 41 + .../attributematchers/ExecutionMatcher.java | 36 + .../attributematchers/ExpirationMatcher.java | 49 + .../attributematchers/ExtendedMatcher.java | 38 + .../attributematchers/LabelMatcher.java | 37 + .../ParameterContextMatcher.java | 39 + .../attributematchers/ParameterMatcher.java | 42 + .../PortScheduledStateMatcher.java | 54 + .../attributematchers/PrioritiesMatcher.java | 33 + .../ProcessGroupMatcher.java | 41 + .../ProcessorMetadataMatcher.java | 33 + .../attributematchers/PropertyMatcher.java | 67 + .../attributematchers/PublicPortMatcher.java | 42 + .../RelationshipMatcher.java | 31 + .../RemoteProcessGroupMatcher.java | 41 + .../ScheduledStateMatcher.java | 59 + .../attributematchers/SchedulingMatcher.java | 54 + .../attributematchers/SearchableMatcher.java | 65 + .../attributematchers/TargetUriMatcher.java | 31 + .../TransmissionStatusMatcher.java | 48 + .../VariableRegistryMatcher.java | 44 + .../web/search/query/MapBasedSearchQuery.java | 69 + .../search/query/RegexSearchQueryParser.java | 60 + .../nifi/web/search/query/SearchQuery.java | 72 ++ .../web/search/query/SearchQueryParser.java | 38 + ...AbstractComponentSearchResultEnricher.java | 85 ++ .../ComponentSearchResultEnricher.java | 33 + .../ComponentSearchResultEnricherFactory.java | 42 + .../GeneralComponentSearchResultEnricher.java | 36 + .../ParameterSearchResultEnricher.java | 38 + .../ProcessGroupSearchResultEnricher.java | 37 + .../main/resources/nifi-web-api-context.xml | 156 ++- ...stractControllerSearchIntegrationTest.java | 361 ++++++ .../web/controller/ComponentMockUtil.java | 470 +++++++ .../web/controller/ControllerFacadeTest.java | 111 ++ .../ControllerSearchServiceFilterTest.java | 239 ++++ ...ontrollerSearchServiceIntegrationTest.java | 603 +++++++++ ...ControllerSearchServiceRegressionTest.java | 605 +++++++++ .../ControllerSearchServiceTest.java | 1129 ++++++++--------- .../web/controller/SearchResultMatcher.java | 124 ++ .../AttributeBasedComponentMatcherTest.java | 127 ++ .../AbstractAttributeMatcherTest.java | 65 + .../AttributeMatcherTest.java | 171 +++ .../BackPressureMatcherTest.java | 92 ++ .../attributematchers/BasicMatcherTest.java | 53 + .../ConnectionMatcherTest.java | 51 + .../ConnectionRelationshipMatcherTest.java | 71 ++ .../ConnectivityMatcherTest.java | 95 ++ .../ControllerServiceNodeMatcherTest.java | 55 + .../ExecutionMatcherTest.java | 79 ++ .../ExpirationMatcherTest.java | 106 ++ .../ExtendedMatcherTest.java | 58 + .../attributematchers/LabelMatcherTest.java | 48 + .../ParameterContextMatcherTest.java | 49 + .../ParameterMatcherTest.java | 76 ++ .../PortScheduledStateMatcherTest.java | 140 ++ .../PrioritiesMatcherTest.java | 81 ++ .../ProcessGroupMatcherTest.java | 55 + .../ProcessorMetadataMatcherTest.java | 100 ++ .../PropertyMatcherTest.java | 113 ++ .../PublicPortMatcherTest.java | 70 + .../RelationshipMatcherTest.java | 71 ++ .../RemoteProcessGroupMatcherTest.java | 56 + .../ScheduledStateMatcherTest.java | 194 +++ .../SchedulingMatcherTest.java | 103 ++ .../SearchableMatcherTest.java | 117 ++ .../TargetUriMatcherTest.java | 49 + .../TransmissionStatusMatcherTest.java | 92 ++ .../VariableRegistryMatcherTest.java | 91 ++ .../query/RegexSearchQueryParserTest.java | 89 ++ .../ComponentSearchResultEnricherTest.java | 146 +++ .../resources/nifi-web-api-test-context.xml | 32 + .../nf-ng-canvas-flow-status-controller.js | 3 +- 89 files changed, 8171 insertions(+), 1204 deletions(-) create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/AttributeBasedComponentMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/ComponentMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/ComponentMatcherFactory.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/AttributeMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/BackPressureMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/BasicMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/ConnectionMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/ConnectionRelationshipMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/ConnectivityMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/ControllerServiceNodeMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/ExecutionMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/ExpirationMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/ExtendedMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/LabelMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/ParameterContextMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/ParameterMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/PortScheduledStateMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/PrioritiesMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/ProcessGroupMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/ProcessorMetadataMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/PropertyMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/PublicPortMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/RelationshipMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/RemoteProcessGroupMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/ScheduledStateMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/SchedulingMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/SearchableMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/TargetUriMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/TransmissionStatusMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/VariableRegistryMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/query/MapBasedSearchQuery.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/query/RegexSearchQueryParser.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/query/SearchQuery.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/query/SearchQueryParser.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/resultenrichment/AbstractComponentSearchResultEnricher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/resultenrichment/ComponentSearchResultEnricher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/resultenrichment/ComponentSearchResultEnricherFactory.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/resultenrichment/GeneralComponentSearchResultEnricher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/resultenrichment/ParameterSearchResultEnricher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/resultenrichment/ProcessGroupSearchResultEnricher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/controller/AbstractControllerSearchIntegrationTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/controller/ComponentMockUtil.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/controller/ControllerFacadeTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/controller/ControllerSearchServiceFilterTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/controller/ControllerSearchServiceIntegrationTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/controller/ControllerSearchServiceRegressionTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/controller/SearchResultMatcher.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/AttributeBasedComponentMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/AbstractAttributeMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/AttributeMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/BackPressureMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/BasicMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/ConnectionMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/ConnectionRelationshipMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/ConnectivityMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/ControllerServiceNodeMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/ExecutionMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/ExpirationMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/ExtendedMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/LabelMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/ParameterContextMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/ParameterMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/PortScheduledStateMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/PrioritiesMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/ProcessGroupMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/ProcessorMetadataMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/PropertyMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/PublicPortMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/RelationshipMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/RemoteProcessGroupMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/ScheduledStateMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/SchedulingMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/SearchableMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/TargetUriMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/TransmissionStatusMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/VariableRegistryMatcherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/query/RegexSearchQueryParserTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/resultenrichment/ComponentSearchResultEnricherTest.java create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/resources/nifi-web-api-test-context.xml diff --git a/nifi-docs/src/main/asciidoc/user-guide.adoc b/nifi-docs/src/main/asciidoc/user-guide.adoc index 7e173d1aa18b..10a1c225026b 100644 --- a/nifi-docs/src/main/asciidoc/user-guide.adoc +++ b/nifi-docs/src/main/asciidoc/user-guide.adoc @@ -161,8 +161,7 @@ The Operate Palette sits to the left-hand side of the screen. It consists of but used by DFMs to manage the flow, as well as by administrators who manage user access and configure system properties, such as how many system resources should be provided to the application. -On the right side of the canvas is Search, and the Global Menu. You can use Search to easily find components on the -canvas and to search by component name, type, identifier, configuration properties, and their values. The Global Menu +On the right side of the canvas is Search, and the Global Menu. For more information on search refer to <>. The Global Menu contains options that allow you to manipulate existing components on the canvas: image::global-menu.png[NiFi Global Menu] @@ -1652,6 +1651,106 @@ and select "Align horizontally" to achieve these results: image:align-horizontally-after.png["Align Horizontally Example Before"] +[[search]] +== Search Components in DataFlow + +NiFi UI provides searching functionality in order to help easily find components on the canvas. You can use search to find components by name, type, identifier, configuration properties, and their values. Search also makes it possible to refine and narrow the search result based on certain conditions using Filters and Keywords. + +[caption="Example 1: "] +.The result will contain components that match for "processor1". +===================================================================== +processor1 +===================================================================== + +=== Filters + +Filters can be added to the search box as key-value pairs where the keys are predefined and check certain conditions based on the given value. The syntax is "key:value". + +[caption="Example 2: "] +.The search will be executed under Process Groups (directly or via contained Process Groups) containing the string "myGroup" in their name or id. The result will contain components that match for "processor1". +===================================================================== +group:myGroup processor1 +===================================================================== + +Filters can be used together with other search terms and multiple filters can be used. The only constraint is that the search must start with the filters. Unknown filters or known filters with unknown values are ignored. If the same filter key appears multiple times, the first will be used. The order of different filters has no effect on the result. + +[caption="Example 3: "] +.Search will be restricted to the currently active process group (and process groups within that). The result will contain components that match for "import" but property matches will be excluded. +===================================================================== +scope:here properties:exclude import +===================================================================== + +The supported filters are the following: + +*scope*: This filter narrows the scope of the search based on the user's currently active Process Group. The only valid value is "here". The usage of this filter looks like "scope:here". Any other value is considered as invalid, thus the filter will be ignored during search. + +*group*: This filter narrows the scope of the search based on the provided Process Group name or id. Search will be restricted to groups (and their components - including subgroups and their components) the names or ids of which match the filter value. If no group matches the filter, the result list will be empty. + +*properties*: With this, users can prevent property matches to appear in the search result. Valid values are: "no", "none", "false", "exclude" and "0". + +=== Keywords + +Users can use pre-defined (case-insensitive) keywords in the search box that will check certain conditions. + +[caption="Example 4: "] +."disabled" will be treated both as keyword and regular search term. The result will contain disabled Ports and Processors as all other components that match for "disabled" in any way. +===================================================================== +disabled +===================================================================== + +Keywords can be used with filters (see below) but not with other search terms (otherwise they won't be treated as keywords) and only one keyword can be used at a time. Note however that keywords will also be treated as general search terms at the same time. + +[caption="Example 5: "] +.Search will be restricted to the currently selected process group (and its sub process groups). "invalid" here (as it is alone after the filter) will be treated both as a keyword and a regular search term. The result will contain invalid Processors and Ports as well as all other components that match for "invalid" in any way. +===================================================================== +scope:here invalid +===================================================================== + +The supported keywords are the following: + +- *Scheduled state* + +** *disabled*: Adds disabled Ports and Processors to the result list. + +** *invalid*: Adds Ports and Processors to the result list where the component is invalid. + +** *running*: Adds running Ports and Processors to the result list. + +** *stopped*: Adds stopped Ports and Processors to the result list. + +** *validating*: Adds Processors to the result list that are validating at the time. + +- *Scheduling strategy* + +** *event*: Adds Processors to the result list where the Scheduling Strategy is "Event Driven". + +** *timer*: Adds Processors to the result list where the Scheduling Strategy is "Timer Driven". + +- *Execution* + +** *primary:* Adds Processors to the result list that are set to run on the primary node only (whether if the Processor is currently running or not). + +- *Back pressure* + +** *back pressure*: Adds Connections to the result list that are applying back pressure at the time. + +** *pressure*: See "back pressure". + +- *Expiration* + +** *expiration*: Adds Connections to the result list that contain expired Flow Files. + +** *expires*: See "expiration". + +- *Transmission* + +** *not transmitting*: Adds Remote Process Groups to the result list that are not transmitting data at the time. + +** *transmitting*: Adds Remote Process Groups to the result list that are transmitting data at the time. + +** *transmission disabled*: See "not transmitting". + +** *transmitting enabled*: See "transmitting". [[monitoring]] == Monitoring of DataFlow diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/pom.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/pom.xml index 30e93a56db7e..30bb589db05a 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/pom.xml +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/pom.xml @@ -395,10 +395,22 @@ 1.0.1.RELEASE provided + + org.springframework + spring-test + 4.3.26.RELEASE + test + org.spockframework spock-core test + + org.hamcrest + hamcrest-all + 1.3 + test + diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java index 6897c90f825b..51074517685d 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java @@ -197,9 +197,10 @@ public interface NiFiServiceFacade { * Searches the controller for the specified query string. * * @param query query + * @param activeGroupId the id of the group currently selected in the editor * @return results */ - SearchResultsDTO searchController(String query); + SearchResultsDTO searchController(String query, String activeGroupId); /** * Submits a provenance request. diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java index edaee668b600..c49212382564 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java @@ -3106,8 +3106,8 @@ public ProvenanceEventDTO submitReplay(final Long eventId) { // ----------------------------------------- @Override - public SearchResultsDTO searchController(final String query) { - return controllerFacade.search(query); + public SearchResultsDTO searchController(final String query, final String activeGroupId) { + return controllerFacade.search(query, activeGroupId); } @Override diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java index d67e455ff10a..707221410bf6 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java @@ -884,11 +884,14 @@ public Response activateControllerServices( @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") } ) - public Response searchFlow(@QueryParam("q") @DefaultValue(StringUtils.EMPTY) String value) throws InterruptedException { + public Response searchFlow( + @QueryParam("q") @DefaultValue(StringUtils.EMPTY) String value, + @QueryParam("a") @DefaultValue(StringUtils.EMPTY) String activeGroupId + ) throws InterruptedException { authorizeFlow(); // query the controller - final SearchResultsDTO results = serviceFacade.searchController(value); + final SearchResultsDTO results = serviceFacade.searchController(value, activeGroupId); // create the entity final SearchResultsEntity entity = new SearchResultsEntity(); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java index c4ac5eb5eb8d..3859daaa22a7 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java @@ -78,7 +78,6 @@ import org.apache.nifi.provenance.search.SearchTerm; import org.apache.nifi.provenance.search.SearchTerms; import org.apache.nifi.provenance.search.SearchableField; -import org.apache.nifi.registry.VariableRegistry; import org.apache.nifi.registry.flow.VersionedProcessGroup; import org.apache.nifi.remote.PublicPort; import org.apache.nifi.remote.RemoteGroupPort; @@ -109,6 +108,8 @@ import org.apache.nifi.web.api.dto.status.ControllerStatusDTO; import org.apache.nifi.web.api.dto.status.StatusHistoryDTO; import org.apache.nifi.web.api.entity.ControllerServiceEntity; +import org.apache.nifi.web.search.query.SearchQuery; +import org.apache.nifi.web.search.query.SearchQueryParser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -147,7 +148,7 @@ public class ControllerFacade implements Authorizable { // properties private NiFiProperties properties; private DtoFactory dtoFactory; - private VariableRegistry variableRegistry; + private SearchQueryParser searchQueryParser; private ControllerSearchService controllerSearchService; private ProcessGroup getRootGroup() { @@ -1614,15 +1615,22 @@ private void setComponentDetails(final ProvenanceEventDTO dto) { /** * Searches this controller for the specified term. * - * @param search search + * @param searchLiteral search string specified by the user + * @param activeGroupId the identifier of the currently visited group * @return result */ - public SearchResultsDTO search(final String search) { + public SearchResultsDTO search(final String searchLiteral, final String activeGroupId) { final ProcessGroup rootGroup = getRootGroup(); + final ProcessGroup activeGroup = (activeGroupId == null) + ? rootGroup + : flowController.getFlowManager().getGroup(activeGroupId); final SearchResultsDTO results = new SearchResultsDTO(); + final SearchQuery searchQuery = searchQueryParser.parse(searchLiteral, NiFiUserUtils.getNiFiUser(), rootGroup, activeGroup); - controllerSearchService.search(results, search, rootGroup); - controllerSearchService.searchParameters(results, search); + if (!StringUtils.isEmpty(searchQuery.getTerm())) { + controllerSearchService.search(searchQuery, results); + controllerSearchService.searchParameters(searchQuery, results); + } return results; } @@ -1631,7 +1639,6 @@ public void verifyComponentTypes(VersionedProcessGroup versionedFlow) { flowController.verifyComponentTypesInSnippet(versionedFlow); } - public ProcessorDiagnosticsDTO getProcessorDiagnostics(final ProcessorNode processor, final ProcessorStatus processorStatus, final BulletinRepository bulletinRepository, final Function serviceEntityFactory) { return dtoFactory.createProcessorDiagnosticsDto(processor, processorStatus, bulletinRepository, flowController, serviceEntityFactory); @@ -1640,28 +1647,29 @@ public ProcessorDiagnosticsDTO getProcessorDiagnostics(final ProcessorNode proce /* * setters */ + public void setFlowController(FlowController flowController) { this.flowController = flowController; } - public void setProperties(NiFiProperties properties) { - this.properties = properties; + public void setFlowService(FlowService flowService) { + this.flowService = flowService; } public void setAuthorizer(Authorizer authorizer) { this.authorizer = authorizer; } - public void setFlowService(FlowService flowService) { - this.flowService = flowService; + public void setProperties(NiFiProperties properties) { + this.properties = properties; } public void setDtoFactory(DtoFactory dtoFactory) { this.dtoFactory = dtoFactory; } - public void setVariableRegistry(VariableRegistry variableRegistry) { - this.variableRegistry = variableRegistry; + public void setSearchQueryParser(SearchQueryParser searchQueryParser) { + this.searchQueryParser = searchQueryParser; } public void setControllerSearchService(ControllerSearchService controllerSearchService) { diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerSearchService.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerSearchService.java index 7204762a96f0..ba25a98e11be 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerSearchService.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerSearchService.java @@ -16,688 +16,221 @@ */ package org.apache.nifi.web.controller; -import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.nifi.authorization.Authorizer; import org.apache.nifi.authorization.RequestAction; +import org.apache.nifi.authorization.resource.Authorizable; import org.apache.nifi.authorization.user.NiFiUser; -import org.apache.nifi.authorization.user.NiFiUserUtils; -import org.apache.nifi.components.PropertyDescriptor; -import org.apache.nifi.components.validation.ValidationStatus; -import org.apache.nifi.connectable.Connectable; import org.apache.nifi.connectable.Connection; import org.apache.nifi.connectable.Funnel; import org.apache.nifi.connectable.Port; import org.apache.nifi.controller.FlowController; import org.apache.nifi.controller.ProcessorNode; -import org.apache.nifi.controller.ScheduledState; import org.apache.nifi.controller.label.Label; -import org.apache.nifi.controller.queue.FlowFileQueue; import org.apache.nifi.controller.service.ControllerServiceNode; -import org.apache.nifi.flowfile.FlowFilePrioritizer; import org.apache.nifi.groups.ProcessGroup; import org.apache.nifi.groups.RemoteProcessGroup; -import org.apache.nifi.nar.NarCloseable; import org.apache.nifi.parameter.Parameter; import org.apache.nifi.parameter.ParameterContext; -import org.apache.nifi.parameter.ParameterContextManager; -import org.apache.nifi.processor.DataUnit; -import org.apache.nifi.processor.Processor; -import org.apache.nifi.processor.Relationship; -import org.apache.nifi.registry.ComponentVariableRegistry; -import org.apache.nifi.registry.VariableDescriptor; -import org.apache.nifi.registry.VariableRegistry; -import org.apache.nifi.remote.PublicPort; -import org.apache.nifi.scheduling.ExecutionNode; -import org.apache.nifi.scheduling.SchedulingStrategy; -import org.apache.nifi.search.SearchContext; -import org.apache.nifi.search.SearchResult; -import org.apache.nifi.search.Searchable; import org.apache.nifi.web.api.dto.search.ComponentSearchResultDTO; -import org.apache.nifi.web.api.dto.search.SearchResultGroupDTO; import org.apache.nifi.web.api.dto.search.SearchResultsDTO; +import org.apache.nifi.web.search.ComponentMatcher; +import org.apache.nifi.web.search.query.SearchQuery; +import org.apache.nifi.web.search.resultenrichment.ComponentSearchResultEnricher; +import org.apache.nifi.web.search.resultenrichment.ComponentSearchResultEnricherFactory; -import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; +import java.util.LinkedList; import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeUnit; +import java.util.Optional; /** * NiFi web controller's helper service that implements component search. */ public class ControllerSearchService { + private final static String FILTER_NAME_GROUP = "group"; + private final static String FILTER_NAME_SCOPE = "scope"; + private final static String FILTER_SCOPE_VALUE_HERE = "here"; + private FlowController flowController; private Authorizer authorizer; - private VariableRegistry variableRegistry; + private ComponentSearchResultEnricherFactory resultEnricherFactory; + + private ComponentMatcher matcherForProcessor; + private ComponentMatcher matcherForProcessGroup; + private ComponentMatcher matcherForConnection; + private ComponentMatcher matcherForRemoteProcessGroup; + private ComponentMatcher matcherForPort; + private ComponentMatcher matcherForFunnel; + private ComponentMatcher matcherForParameterContext; + private ComponentMatcher matcherForParameter; + private ComponentMatcher