Search in sources :

Example 1 with ProcessGroupsResult

use of org.apache.nifi.toolkit.cli.impl.result.ProcessGroupsResult in project nifi by apache.

the class PGList method doExecute.

@Override
public ProcessGroupsResult doExecute(final NiFiClient client, final Properties properties) throws NiFiClientException, IOException {
    final FlowClient flowClient = client.getFlowClient();
    // get the optional id of the parent PG, otherwise fallback to the root group
    String parentPgId = getArg(properties, CommandOption.PG_ID);
    if (StringUtils.isBlank(parentPgId)) {
        parentPgId = flowClient.getRootGroupId();
    }
    final ProcessGroupFlowEntity processGroupFlowEntity = flowClient.getProcessGroup(parentPgId);
    final ProcessGroupFlowDTO processGroupFlowDTO = processGroupFlowEntity.getProcessGroupFlow();
    final FlowDTO flowDTO = processGroupFlowDTO.getFlow();
    final List<ProcessGroupDTO> processGroups = new ArrayList<>();
    if (flowDTO.getProcessGroups() != null) {
        flowDTO.getProcessGroups().stream().map(pge -> pge.getComponent()).forEach(dto -> processGroups.add(dto));
    }
    return new ProcessGroupsResult(getResultType(properties), processGroups);
}
Also used : Properties(java.util.Properties) NiFiClientException(org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException) CommandOption(org.apache.nifi.toolkit.cli.impl.command.CommandOption) AbstractNiFiCommand(org.apache.nifi.toolkit.cli.impl.command.nifi.AbstractNiFiCommand) IOException(java.io.IOException) StringUtils(org.apache.commons.lang3.StringUtils) Context(org.apache.nifi.toolkit.cli.api.Context) ArrayList(java.util.ArrayList) NiFiClient(org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClient) List(java.util.List) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO) ProcessGroupsResult(org.apache.nifi.toolkit.cli.impl.result.ProcessGroupsResult) FlowClient(org.apache.nifi.toolkit.cli.impl.client.nifi.FlowClient) ProcessGroupFlowEntity(org.apache.nifi.web.api.entity.ProcessGroupFlowEntity) ProcessGroupFlowDTO(org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO) FlowDTO(org.apache.nifi.web.api.dto.flow.FlowDTO) ProcessGroupsResult(org.apache.nifi.toolkit.cli.impl.result.ProcessGroupsResult) ProcessGroupFlowDTO(org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO) FlowDTO(org.apache.nifi.web.api.dto.flow.FlowDTO) ProcessGroupFlowDTO(org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO) ProcessGroupFlowEntity(org.apache.nifi.web.api.entity.ProcessGroupFlowEntity) ArrayList(java.util.ArrayList) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO) FlowClient(org.apache.nifi.toolkit.cli.impl.client.nifi.FlowClient)

Aggregations

IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Properties (java.util.Properties)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Context (org.apache.nifi.toolkit.cli.api.Context)1 FlowClient (org.apache.nifi.toolkit.cli.impl.client.nifi.FlowClient)1 NiFiClient (org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClient)1 NiFiClientException (org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException)1 CommandOption (org.apache.nifi.toolkit.cli.impl.command.CommandOption)1 AbstractNiFiCommand (org.apache.nifi.toolkit.cli.impl.command.nifi.AbstractNiFiCommand)1 ProcessGroupsResult (org.apache.nifi.toolkit.cli.impl.result.ProcessGroupsResult)1 ProcessGroupDTO (org.apache.nifi.web.api.dto.ProcessGroupDTO)1 FlowDTO (org.apache.nifi.web.api.dto.flow.FlowDTO)1 ProcessGroupFlowDTO (org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO)1 ProcessGroupFlowEntity (org.apache.nifi.web.api.entity.ProcessGroupFlowEntity)1