Search in sources :

Example 11 with ProcessGroupFlowDTO

use of org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO in project nifi by apache.

the class JerseyFlowClient method getSuggestedProcessGroupCoordinates.

@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;
}
Also used : ProcessGroupBox(org.apache.nifi.toolkit.cli.impl.client.nifi.ProcessGroupBox) NiFiClientException(org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException) Set(java.util.Set) IOException(java.io.IOException) StringUtils(org.apache.commons.lang3.StringUtils) Entity(javax.ws.rs.client.Entity) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) PositionDTO(org.apache.nifi.web.api.dto.PositionDTO) Objects(java.util.Objects) ComponentEntity(org.apache.nifi.web.api.entity.ComponentEntity) MediaType(javax.ws.rs.core.MediaType) List(java.util.List) VersionedFlowSnapshotMetadataSetEntity(org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataSetEntity) Map(java.util.Map) FlowClient(org.apache.nifi.toolkit.cli.impl.client.nifi.FlowClient) CurrentUserEntity(org.apache.nifi.web.api.entity.CurrentUserEntity) ProcessGroupFlowEntity(org.apache.nifi.web.api.entity.ProcessGroupFlowEntity) ProcessGroupFlowDTO(org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO) WebTarget(javax.ws.rs.client.WebTarget) FlowDTO(org.apache.nifi.web.api.dto.flow.FlowDTO) Collections(java.util.Collections) ScheduleComponentsEntity(org.apache.nifi.web.api.entity.ScheduleComponentsEntity) 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) ComponentEntity(org.apache.nifi.web.api.entity.ComponentEntity) ArrayList(java.util.ArrayList) ProcessGroupBox(org.apache.nifi.toolkit.cli.impl.client.nifi.ProcessGroupBox) PositionDTO(org.apache.nifi.web.api.dto.PositionDTO) Objects(java.util.Objects)

Example 12 with ProcessGroupFlowDTO

use of org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO in project nifi by apache.

the class FlowResource method populateRemainingFlowContent.

/**
 * Populates the remaining fields in the specified process group.
 *
 * @param flow group
 * @return group dto
 */
private ProcessGroupFlowDTO populateRemainingFlowContent(ProcessGroupFlowDTO flow) {
    FlowDTO flowStructure = flow.getFlow();
    // populate the remaining fields for the processors, connections, process group refs, remote process groups, and labels if appropriate
    if (flowStructure != null) {
        populateRemainingFlowStructure(flowStructure);
    }
    // set the process group uri
    flow.setUri(generateResourceUri("flow", "process-groups", flow.getId()));
    return flow;
}
Also used : ProcessGroupFlowDTO(org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO) FlowDTO(org.apache.nifi.web.api.dto.flow.FlowDTO)

Aggregations

ProcessGroupFlowDTO (org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO)12 List (java.util.List)7 Set (java.util.Set)7 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)6 Map (java.util.Map)6 Collectors (java.util.stream.Collectors)6 StringUtils (org.apache.commons.lang3.StringUtils)6 FlowDTO (org.apache.nifi.web.api.dto.flow.FlowDTO)6 NifiConstants (com.thinkbiganalytics.nifi.rest.support.NifiConstants)5 Collections (java.util.Collections)5 HashMap (java.util.HashMap)5 Inject (javax.inject.Inject)5 ProcessGroupDTO (org.apache.nifi.web.api.dto.ProcessGroupDTO)5 PortDTOWithGroupInfo (com.thinkbiganalytics.feedmgr.rest.model.PortDTOWithGroupInfo)4 TemplateRemoteInputPortConnections (com.thinkbiganalytics.feedmgr.rest.model.TemplateRemoteInputPortConnections)4 LegacyNifiRestClient (com.thinkbiganalytics.nifi.rest.client.LegacyNifiRestClient)4 NifiClientRuntimeException (com.thinkbiganalytics.nifi.rest.client.NifiClientRuntimeException)4 Optional (java.util.Optional)4 ConnectionDTO (org.apache.nifi.web.api.dto.ConnectionDTO)4