Search in sources :

Example 6 with ComponentSearchResultDTO

use of org.apache.nifi.web.api.dto.search.ComponentSearchResultDTO in project nifi by apache.

the class ControllerSearchService method search.

private ComponentSearchResultDTO search(final String searchStr, final Funnel funnel) {
    final List<String> matches = new ArrayList<>();
    addIfAppropriate(searchStr, funnel.getIdentifier(), "Id", matches);
    addIfAppropriate(searchStr, funnel.getVersionedComponentId().orElse(null), "Version Control ID", matches);
    if (matches.isEmpty()) {
        return null;
    }
    final ComponentSearchResultDTO dto = new ComponentSearchResultDTO();
    dto.setId(funnel.getIdentifier());
    dto.setName(funnel.getName());
    dto.setMatches(matches);
    return dto;
}
Also used : ArrayList(java.util.ArrayList) ComponentSearchResultDTO(org.apache.nifi.web.api.dto.search.ComponentSearchResultDTO)

Example 7 with ComponentSearchResultDTO

use of org.apache.nifi.web.api.dto.search.ComponentSearchResultDTO in project nifi by apache.

the class ControllerSearchService method search.

private ComponentSearchResultDTO search(final String searchStr, final Port port) {
    final List<String> matches = new ArrayList<>();
    addIfAppropriate(searchStr, port.getIdentifier(), "Id", matches);
    addIfAppropriate(searchStr, port.getVersionedComponentId().orElse(null), "Version Control ID", matches);
    addIfAppropriate(searchStr, port.getName(), "Name", matches);
    addIfAppropriate(searchStr, port.getComments(), "Comments", matches);
    // consider scheduled state
    if (ScheduledState.DISABLED.equals(port.getScheduledState())) {
        if (StringUtils.containsIgnoreCase("disabled", searchStr)) {
            matches.add("Run status: Disabled");
        }
    } else {
        if (StringUtils.containsIgnoreCase("invalid", searchStr) && !port.isValid()) {
            matches.add("Run status: Invalid");
        } else if (ScheduledState.RUNNING.equals(port.getScheduledState()) && StringUtils.containsIgnoreCase("running", searchStr)) {
            matches.add("Run status: Running");
        } else if (ScheduledState.STOPPED.equals(port.getScheduledState()) && StringUtils.containsIgnoreCase("stopped", searchStr)) {
            matches.add("Run status: Stopped");
        }
    }
    if (port instanceof RootGroupPort) {
        final RootGroupPort rootGroupPort = (RootGroupPort) port;
        // user access controls
        for (final String userAccessControl : rootGroupPort.getUserAccessControl()) {
            addIfAppropriate(searchStr, userAccessControl, "User access control", matches);
        }
        // group access controls
        for (final String groupAccessControl : rootGroupPort.getGroupAccessControl()) {
            addIfAppropriate(searchStr, groupAccessControl, "Group access control", matches);
        }
    }
    if (matches.isEmpty()) {
        return null;
    }
    final ComponentSearchResultDTO dto = new ComponentSearchResultDTO();
    dto.setId(port.getIdentifier());
    dto.setName(port.getName());
    dto.setMatches(matches);
    return dto;
}
Also used : RootGroupPort(org.apache.nifi.remote.RootGroupPort) ArrayList(java.util.ArrayList) ComponentSearchResultDTO(org.apache.nifi.web.api.dto.search.ComponentSearchResultDTO)

Example 8 with ComponentSearchResultDTO

use of org.apache.nifi.web.api.dto.search.ComponentSearchResultDTO in project nifi by apache.

the class ControllerSearchService method search.

private ComponentSearchResultDTO search(final String searchStr, final RemoteProcessGroup group) {
    final List<String> matches = new ArrayList<>();
    addIfAppropriate(searchStr, group.getIdentifier(), "Id", matches);
    addIfAppropriate(searchStr, group.getVersionedComponentId().orElse(null), "Version Control ID", matches);
    addIfAppropriate(searchStr, group.getName(), "Name", matches);
    addIfAppropriate(searchStr, group.getComments(), "Comments", matches);
    addIfAppropriate(searchStr, group.getTargetUris(), "URLs", matches);
    // consider the transmission status
    if ((StringUtils.containsIgnoreCase("transmitting", searchStr) || StringUtils.containsIgnoreCase("transmission enabled", searchStr)) && group.isTransmitting()) {
        matches.add("Transmission: On");
    } else if ((StringUtils.containsIgnoreCase("not transmitting", searchStr) || StringUtils.containsIgnoreCase("transmission disabled", searchStr)) && !group.isTransmitting()) {
        matches.add("Transmission: Off");
    }
    if (matches.isEmpty()) {
        return null;
    }
    final ComponentSearchResultDTO result = new ComponentSearchResultDTO();
    result.setId(group.getIdentifier());
    result.setName(group.getName());
    result.setMatches(matches);
    return result;
}
Also used : ArrayList(java.util.ArrayList) ComponentSearchResultDTO(org.apache.nifi.web.api.dto.search.ComponentSearchResultDTO)

Aggregations

ComponentSearchResultDTO (org.apache.nifi.web.api.dto.search.ComponentSearchResultDTO)8 ArrayList (java.util.ArrayList)6 Map (java.util.Map)2 ProcessGroup (org.apache.nifi.groups.ProcessGroup)2 RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)2 Relationship (org.apache.nifi.processor.Relationship)2 RootGroupPort (org.apache.nifi.remote.RootGroupPort)2 List (java.util.List)1 NiFiUser (org.apache.nifi.authorization.user.NiFiUser)1 PropertyDescriptor (org.apache.nifi.components.PropertyDescriptor)1 Connectable (org.apache.nifi.connectable.Connectable)1 Connection (org.apache.nifi.connectable.Connection)1 Funnel (org.apache.nifi.connectable.Funnel)1 Port (org.apache.nifi.connectable.Port)1 ProcessorNode (org.apache.nifi.controller.ProcessorNode)1 FlowFileQueue (org.apache.nifi.controller.queue.FlowFileQueue)1 FlowFilePrioritizer (org.apache.nifi.flowfile.FlowFilePrioritizer)1 NarCloseable (org.apache.nifi.nar.NarCloseable)1 Processor (org.apache.nifi.processor.Processor)1 ComponentVariableRegistry (org.apache.nifi.registry.ComponentVariableRegistry)1