@Override protected ProcessGroupFlowDTO getDto(final ProcessGroupFlowEntity entity) { return entity.getProcessGroupFlow(); }
@Override public String getRootGroupId() throws NiFiClientException, IOException { final ProcessGroupFlowEntity entity = getProcessGroup(ROOT); return entity.getProcessGroupFlow().getId(); }
@Override public ProcessGroupBox getSuggestedProcessGroupCoordinates(final String parentId) throws NiFiClientException, IOException { if (StringUtils.isBlank(parentId)) { throw new IllegalArgumentException("Process group id cannot be null"); } final ProcessGroupFlowEntity processGroup = getProcessGroup(parentId); final ProcessGroupFlowDTO processGroupFlowDTO = processGroup.getProcessGroupFlow(); final FlowDTO flowDTO = processGroupFlowDTO.getFlow(); final List<ComponentEntity> pgComponents = new ArrayList<>(); pgComponents.addAll(flowDTO.getProcessGroups()); pgComponents.addAll(flowDTO.getProcessors()); pgComponents.addAll(flowDTO.getRemoteProcessGroups()); pgComponents.addAll(flowDTO.getConnections()); pgComponents.addAll(flowDTO.getFunnels()); pgComponents.addAll(flowDTO.getInputPorts()); pgComponents.addAll(flowDTO.getOutputPorts()); pgComponents.addAll(flowDTO.getLabels()); final Set<PositionDTO> positions = pgComponents.stream() .map(ComponentEntity::getPosition) .collect(Collectors.toSet()); if (positions.isEmpty()) { return ProcessGroupBox.CANVAS_CENTER; } final List<ProcessGroupBox> coords = positions.stream() .filter(Objects::nonNull) .map(p -> new ProcessGroupBox(p.getX().intValue(), p.getY().intValue())) .collect(Collectors.toList()); final ProcessGroupBox freeSpot = coords.get(0).findFreeSpace(coords); return freeSpot; }
populateRemainingFlowContent(entity.getProcessGroupFlow()); return generateOkResponse(entity).build();
@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); }