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

pvillard pushed a commit to branch support/nifi-1.x
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/support/nifi-1.x by this push:
     new c3386c8659 NIFI-13052 allow CRON driven components to be searchable
c3386c8659 is described below

commit c3386c865950900ce505d8fe002e734e859a4e4b
Author: Mike Moser <[email protected]>
AuthorDate: Tue Apr 16 18:19:59 2024 +0000

    NIFI-13052 allow CRON driven components to be searchable
    
    Signed-off-by: Pierre Villard <[email protected]>
    
    This closes #8659.
---
 nifi-docs/src/main/asciidoc/user-guide.adoc            |  2 ++
 .../search/attributematchers/SchedulingMatcher.java    |  5 +++++
 .../attributematchers/SchedulingMatcherTest.java       | 18 ++++++++++++++++--
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/nifi-docs/src/main/asciidoc/user-guide.adoc 
b/nifi-docs/src/main/asciidoc/user-guide.adoc
index 0a24aaed8d..c64baf43da 100644
--- a/nifi-docs/src/main/asciidoc/user-guide.adoc
+++ b/nifi-docs/src/main/asciidoc/user-guide.adoc
@@ -1968,6 +1968,8 @@ The supported keywords are the following:
 
 ** *timer*: Adds Processors to the result list where the Scheduling Strategy 
is "Timer Driven".
 
+** *cron*: Adds Processors to the result list where the Scheduling Strategy is 
"CRON 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).
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/SchedulingMatcher.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/SchedulingMatcher.java
index 326ae64507..8743a87a73 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/SchedulingMatcher.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/attributematchers/SchedulingMatcher.java
@@ -23,6 +23,7 @@ import org.apache.nifi.web.search.query.SearchQuery;
 
 import java.util.List;
 
+import static org.apache.nifi.scheduling.SchedulingStrategy.CRON_DRIVEN;
 import static org.apache.nifi.scheduling.SchedulingStrategy.EVENT_DRIVEN;
 import static org.apache.nifi.scheduling.SchedulingStrategy.PRIMARY_NODE_ONLY;
 import static org.apache.nifi.scheduling.SchedulingStrategy.TIMER_DRIVEN;
@@ -30,11 +31,13 @@ import static 
org.apache.nifi.scheduling.SchedulingStrategy.TIMER_DRIVEN;
 public class SchedulingMatcher implements AttributeMatcher<ProcessorNode> {
     private static final String SEARCH_TERM_EVENT = "event";
     private static final String SEARCH_TERM_TIMER = "timer";
+    private static final String SEARCH_TERM_CRON = "cron";
     private static final String SEARCH_TERM_PRIMARY = "primary";
 
     private static final String MATCH_PREFIX = "Scheduling strategy: ";
     private static final String MATCH_EVENT = "Event driven";
     private static final String MATCH_TIMER = "Timer driven";
+    private static final String MATCH_CRON = "CRON driven";
     private static final String MATCH_PRIMARY = "On primary node";
 
     @Override
@@ -46,6 +49,8 @@ public class SchedulingMatcher implements 
AttributeMatcher<ProcessorNode> {
             matches.add(MATCH_PREFIX + MATCH_EVENT);
         } else if (TIMER_DRIVEN.equals(schedulingStrategy) && 
StringUtils.containsIgnoreCase(SEARCH_TERM_TIMER, searchTerm)) {
             matches.add(MATCH_PREFIX + MATCH_TIMER);
+        } else if (CRON_DRIVEN.equals(schedulingStrategy) && 
StringUtils.containsIgnoreCase(SEARCH_TERM_CRON, searchTerm)) {
+            matches.add(MATCH_PREFIX + MATCH_CRON);
         } else if (PRIMARY_NODE_ONLY.equals(schedulingStrategy) && 
StringUtils.containsIgnoreCase(SEARCH_TERM_PRIMARY, searchTerm)) {
             // PRIMARY_NODE_ONLY has been deprecated as a SchedulingStrategy 
and replaced by PRIMARY as an ExecutionNode.
             matches.add(MATCH_PREFIX + MATCH_PRIMARY);
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/SchedulingMatcherTest.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/SchedulingMatcherTest.java
index 128d16fd8a..4fcaa5a4dc 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/SchedulingMatcherTest.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/search/attributematchers/SchedulingMatcherTest.java
@@ -59,8 +59,8 @@ public class SchedulingMatcherTest extends 
AbstractAttributeMatcherTest {
     public void testWhenKeywordDoesNotAppearAndEvent() {
         // given
         final SchedulingMatcher testSubject = new SchedulingMatcher();
-        givenSchedulingStrategy(SchedulingStrategy.TIMER_DRIVEN);
-        givenSearchTerm("event");
+        givenSchedulingStrategy(SchedulingStrategy.EVENT_DRIVEN);
+        givenSearchTerm("timer");
 
         // when
         testSubject.match(component, searchQuery, matches);
@@ -97,6 +97,20 @@ public class SchedulingMatcherTest extends 
AbstractAttributeMatcherTest {
         thenMatchConsistsOf("Scheduling strategy: On primary node");
     }
 
+    @Test
+    public void testWhenKeywordAppearsAndCron() {
+        // given
+        final SchedulingMatcher testSubject = new SchedulingMatcher();
+        givenSchedulingStrategy(SchedulingStrategy.CRON_DRIVEN);
+        givenSearchTerm("cron");
+
+        // when
+        testSubject.match(component, searchQuery, matches);
+
+        // then
+        thenMatchConsistsOf("Scheduling strategy: CRON driven");
+    }
+
     private void givenSchedulingStrategy(final SchedulingStrategy 
schedulingStrategy) {
         
Mockito.when(component.getSchedulingStrategy()).thenReturn(schedulingStrategy);
     }

Reply via email to