NIFI-12987 allow controller service type to be searchable

Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com>

This closes #8593.
This commit is contained in:
Mike Moser 2024-04-01 18:09:16 +00:00 committed by Pierre Villard
parent 322deaa23e
commit b574a7e41a
No known key found for this signature in database
GPG Key ID: F92A93B30C07C6D5
2 changed files with 45 additions and 1 deletions

View File

@ -28,6 +28,7 @@ public class ControllerServiceNodeMatcher implements AttributeMatcher<Controller
private static final String LABEL_VERSION_CONTROL_ID = "Version Control ID";
private static final String LABEL_NAME = "Name";
private static final String LABEL_COMMENTS = "Comments";
private static final String LABEL_TYPE = "Type";
@Override
public void match(final ControllerServiceNode component, final SearchQuery query, final List<String> matches) {
@ -37,5 +38,7 @@ public class ControllerServiceNodeMatcher implements AttributeMatcher<Controller
addIfMatching(searchTerm, component.getVersionedComponentId().orElse(null), LABEL_VERSION_CONTROL_ID, matches);
addIfMatching(searchTerm, component.getName(), LABEL_NAME, matches);
addIfMatching(searchTerm, component.getComments(), LABEL_COMMENTS, matches);
addIfMatching(searchTerm, component.getControllerServiceImplementation().getClass().getSimpleName(), LABEL_TYPE, matches);
addIfMatching(searchTerm, component.getComponentType(), LABEL_TYPE, matches);
}
}

View File

@ -16,11 +16,18 @@
*/
package org.apache.nifi.web.search.attributematchers;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.controller.ControllerService;
import org.apache.nifi.controller.ControllerServiceInitializationContext;
import org.apache.nifi.controller.service.ControllerServiceNode;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
public class ControllerServiceNodeMatcherTest extends AbstractAttributeMatcherTest {
@ -37,6 +44,8 @@ public class ControllerServiceNodeMatcherTest extends AbstractAttributeMatcherTe
Mockito.when(component.getVersionedComponentId()).thenReturn(Optional.of("LoremVersionId"));
Mockito.when(component.getName()).thenReturn("LoremName");
Mockito.when(component.getComments()).thenReturn("LoremComment");
Mockito.when(component.getControllerServiceImplementation()).thenReturn(new LoremControllerService());
Mockito.when(component.getComponentType()).thenReturn("LoremControllerService");
// when
testSubject.match(component, searchQuery, matches);
@ -44,6 +53,38 @@ public class ControllerServiceNodeMatcherTest extends AbstractAttributeMatcherTe
thenMatchConsistsOf("Id: LoremId", //
"Version Control ID: LoremVersionId", //
"Name: LoremName", //
"Comments: LoremComment");
"Comments: LoremComment",
"Type: LoremControllerService");
}
private static class LoremControllerService implements ControllerService {
@Override
public Collection<ValidationResult> validate(ValidationContext context) {
return null;
}
@Override
public PropertyDescriptor getPropertyDescriptor(String name) {
return null;
}
@Override
public void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue) {
}
@Override
public List<PropertyDescriptor> getPropertyDescriptors() {
return null;
}
@Override
public String getIdentifier() {
return null;
}
@Override
public void initialize(ControllerServiceInitializationContext context) {
}
}
}