This is an automated email from the ASF dual-hosted git repository.

exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new ba13c5d48a NIFI-13664 Support Component Search on NAR Bundle ID
ba13c5d48a is described below

commit ba13c5d48ae4bd71660730b7f0d8de739fba47bb
Author: Mike Moser <[email protected]>
AuthorDate: Fri Aug 23 16:34:49 2024 +0000

    NIFI-13664 Support Component Search on NAR Bundle ID
    
    This closes #9197
    
    Signed-off-by: David Handermann <[email protected]>
---
 nifi-docs/src/main/asciidoc/user-guide.adoc        |  2 +-
 .../web/configuration/WebSearchConfiguration.java  |  3 ++
 .../search/attributematchers/BundleMatcher.java    | 32 ++++++++++++
 .../attributematchers/BundleMatcherTest.java       | 57 ++++++++++++++++++++++
 4 files changed, 93 insertions(+), 1 deletion(-)

diff --git a/nifi-docs/src/main/asciidoc/user-guide.adoc 
b/nifi-docs/src/main/asciidoc/user-guide.adoc
index 0631146166..6a6ac8ffae 100644
--- a/nifi-docs/src/main/asciidoc/user-guide.adoc
+++ b/nifi-docs/src/main/asciidoc/user-guide.adoc
@@ -2069,7 +2069,7 @@ 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.
+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, bundle, configuration properties, and configuration 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".
diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/configuration/WebSearchConfiguration.java
 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/configuration/WebSearchConfiguration.java
index 2f0feb4d3d..f01bfec5d3 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/configuration/WebSearchConfiguration.java
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/configuration/WebSearchConfiguration.java
@@ -22,6 +22,7 @@ import org.apache.nifi.web.controller.ControllerSearchService;
 import org.apache.nifi.web.search.ComponentMatcherFactory;
 import org.apache.nifi.web.search.attributematchers.BackPressureMatcher;
 import org.apache.nifi.web.search.attributematchers.BasicMatcher;
+import org.apache.nifi.web.search.attributematchers.BundleMatcher;
 import org.apache.nifi.web.search.attributematchers.ConnectionMatcher;
 import 
org.apache.nifi.web.search.attributematchers.ConnectionRelationshipMatcher;
 import org.apache.nifi.web.search.attributematchers.ConnectivityMatcher;
@@ -95,6 +96,7 @@ public class WebSearchConfiguration {
         
controllerSearchService.setMatcherForControllerServiceNode(factory.getInstanceForControllerServiceNode(
                 List.of(
                         new ControllerServiceNodeMatcher(),
+                        new BundleMatcher<>(),
                         new PropertyMatcher<>()
                 )
         ));
@@ -153,6 +155,7 @@ public class WebSearchConfiguration {
                         new ScheduledStateMatcher(),
                         new RelationshipMatcher<>(),
                         new ProcessorMetadataMatcher(),
+                        new BundleMatcher<>(),
                         new PropertyMatcher<>(),
                         searchableMatcher
                 )
diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/BundleMatcher.java
 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/BundleMatcher.java
new file mode 100644
index 0000000000..8caa59f566
--- /dev/null
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/BundleMatcher.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.web.search.attributematchers;
+
+import org.apache.nifi.controller.ComponentNode;
+import org.apache.nifi.web.search.query.SearchQuery;
+
+import java.util.List;
+
+public class BundleMatcher <T extends ComponentNode> implements 
AttributeMatcher<T> {
+    private static final String BUNDLE = "Bundle";
+
+    @Override
+    public void match(T component, SearchQuery query, List<String> matches) {
+        final String searchTerm = query.getTerm();
+        AttributeMatcher.addIfMatching(searchTerm, 
component.getBundleCoordinate().getId(), BUNDLE, matches);
+    }
+}
diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/BundleMatcherTest.java
 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/BundleMatcherTest.java
new file mode 100644
index 0000000000..4337085950
--- /dev/null
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/BundleMatcherTest.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.web.search.attributematchers;
+
+import org.apache.nifi.bundle.BundleCoordinate;
+import org.apache.nifi.controller.ComponentNode;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mock;
+
+import static org.mockito.Mockito.when;
+
+class BundleMatcherTest extends AbstractAttributeMatcherTest {
+
+    @Mock
+    private ComponentNode component;
+
+    @Test
+    void testMatch() {
+        givenBundleId("nifi-lorem-nar");
+        givenDefaultSearchTerm();
+
+        BundleMatcher<ComponentNode> testSubject = new BundleMatcher<>();
+        testSubject.match(component, searchQuery, matches);
+
+        thenMatchConsistsOf("Bundle: nifi-lorem-nar");
+    }
+
+    @Test
+    void testNoMatches() {
+        givenBundleId("nifi-standard-nar");
+        givenDefaultSearchTerm();
+
+        BundleMatcher<ComponentNode> testSubject = new BundleMatcher<>();
+        testSubject.match(component, searchQuery, matches);
+
+        thenNoMatches();
+    }
+
+    private void givenBundleId(String id) {
+        BundleCoordinate coordinate = new BundleCoordinate(null, id, null);
+        when(component.getBundleCoordinate()).thenReturn(coordinate);
+    }
+}

Reply via email to