mirror of https://github.com/apache/nifi.git
NIFI-13664 Support Component Search on NAR Bundle ID
This closes #9197 Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
parent
f828907df5
commit
ba13c5d48a
|
@ -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".
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue