Search in sources :

Example 6 with ProcessGroupFlowEntity

use of org.apache.nifi.web.api.entity.ProcessGroupFlowEntity in project nifi by apache.

the class ITProcessGroupAccessControl method getRandomProcessGroup.

private ProcessGroupEntity getRandomProcessGroup(final NiFiTestUser user) throws Exception {
    final String url = helper.getBaseUrl() + "/flow/process-groups/root";
    // get the process groups
    final Response response = user.testGet(url);
    // ensure the response was successful
    assertEquals(200, response.getStatus());
    // unmarshal
    final ProcessGroupFlowEntity flowEntity = response.readEntity(ProcessGroupFlowEntity.class);
    final FlowDTO flowDto = flowEntity.getProcessGroupFlow().getFlow();
    final Set<ProcessGroupEntity> processGroups = flowDto.getProcessGroups();
    // ensure the correct number of process groups
    assertFalse(processGroups.isEmpty());
    // use the first process group as the target
    Iterator<ProcessGroupEntity> processGroupIter = processGroups.iterator();
    assertTrue(processGroupIter.hasNext());
    return processGroupIter.next();
}
Also used : Response(javax.ws.rs.core.Response) ProcessGroupEntity(org.apache.nifi.web.api.entity.ProcessGroupEntity) FlowDTO(org.apache.nifi.web.api.dto.flow.FlowDTO) ProcessGroupFlowEntity(org.apache.nifi.web.api.entity.ProcessGroupFlowEntity)

Example 7 with ProcessGroupFlowEntity

use of org.apache.nifi.web.api.entity.ProcessGroupFlowEntity 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 8 with ProcessGroupFlowEntity

use of org.apache.nifi.web.api.entity.ProcessGroupFlowEntity in project nifi by apache.

the class EntityFactory method createProcessGroupFlowEntity.

public ProcessGroupFlowEntity createProcessGroupFlowEntity(final ProcessGroupFlowDTO dto, final PermissionsDTO permissions) {
    final ProcessGroupFlowEntity entity = new ProcessGroupFlowEntity();
    entity.setProcessGroupFlow(dto);
    entity.setPermissions(permissions);
    return entity;
}
Also used : ProcessGroupFlowEntity(org.apache.nifi.web.api.entity.ProcessGroupFlowEntity)

Example 9 with ProcessGroupFlowEntity

use of org.apache.nifi.web.api.entity.ProcessGroupFlowEntity in project nifi by apache.

the class FlowResource method getFlow.

/**
 * Retrieves the contents of the specified group.
 *
 * @param groupId The id of the process group.
 * @return A processGroupEntity.
 * @throws InterruptedException if interrupted
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("process-groups/{id}")
@ApiOperation(value = "Gets a process group", response = ProcessGroupFlowEntity.class, authorizations = { @Authorization(value = "Read - /flow") })
@ApiResponses(value = { @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), @ApiResponse(code = 401, message = "Client could not be authenticated."), @ApiResponse(code = 403, message = "Client is not authorized to make this request."), @ApiResponse(code = 404, message = "The specified resource could not be found."), @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") })
public Response getFlow(@ApiParam(value = "The process group id.", required = false) @PathParam("id") String groupId) throws InterruptedException {
    authorizeFlow();
    if (isReplicateRequest()) {
        return replicate(HttpMethod.GET);
    }
    // get this process group flow
    final ProcessGroupFlowEntity entity = serviceFacade.getProcessGroupFlow(groupId);
    populateRemainingFlowContent(entity.getProcessGroupFlow());
    return generateOkResponse(entity).build();
}
Also used : ProcessGroupFlowEntity(org.apache.nifi.web.api.entity.ProcessGroupFlowEntity) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 10 with ProcessGroupFlowEntity

use of org.apache.nifi.web.api.entity.ProcessGroupFlowEntity in project nifi by apache.

the class ITConnectionAccessControl method getRandomConnection.

private ConnectionEntity getRandomConnection(final NiFiTestUser user) throws Exception {
    final String url = helper.getBaseUrl() + "/flow/process-groups/root";
    // get the connections
    final Response response = user.testGet(url);
    // ensure the response was successful
    assertEquals(200, response.getStatus());
    // unmarshal
    final ProcessGroupFlowEntity flowEntity = response.readEntity(ProcessGroupFlowEntity.class);
    final FlowDTO flowDto = flowEntity.getProcessGroupFlow().getFlow();
    final Set<ConnectionEntity> connections = flowDto.getConnections();
    // ensure the correct number of connection
    assertFalse(connections.isEmpty());
    // use the first connection as the target
    Iterator<ConnectionEntity> connectionIter = connections.iterator();
    assertTrue(connectionIter.hasNext());
    return connectionIter.next();
}
Also used : Response(javax.ws.rs.core.Response) FlowDTO(org.apache.nifi.web.api.dto.flow.FlowDTO) ProcessGroupFlowEntity(org.apache.nifi.web.api.entity.ProcessGroupFlowEntity) ConnectionEntity(org.apache.nifi.web.api.entity.ConnectionEntity)

Aggregations

ProcessGroupFlowEntity (org.apache.nifi.web.api.entity.ProcessGroupFlowEntity)12 FlowDTO (org.apache.nifi.web.api.dto.flow.FlowDTO)10 Response (javax.ws.rs.core.Response)8 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 PortEntity (org.apache.nifi.web.api.entity.PortEntity)3 Collections (java.util.Collections)2 Map (java.util.Map)2 Objects (java.util.Objects)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 StringUtils (org.apache.commons.lang3.StringUtils)2 ProcessGroupDTO (org.apache.nifi.web.api.dto.ProcessGroupDTO)2 FunnelEntity (org.apache.nifi.web.api.entity.FunnelEntity)2 LabelEntity (org.apache.nifi.web.api.entity.LabelEntity)2 ProcessGroupEntity (org.apache.nifi.web.api.entity.ProcessGroupEntity)2 Sets (com.google.common.collect.Sets)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1