Java Code Examples for org.apache.nifi.web.api.dto.FunnelDTO#getPosition()

The following examples show how to use org.apache.nifi.web.api.dto.FunnelDTO#getPosition() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StandardFunnelDAO.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Override
public Funnel createFunnel(String groupId, FunnelDTO funnelDTO) {
    if (funnelDTO.getParentGroupId() != null && !flowController.areGroupsSame(groupId, funnelDTO.getParentGroupId())) {
        throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the Funnel is being added.");
    }

    // get the desired group
    ProcessGroup group = locateProcessGroup(flowController, groupId);

    // create the funnel
    Funnel funnel = flowController.createFunnel(funnelDTO.getId());
    if (funnelDTO.getPosition() != null) {
        funnel.setPosition(new Position(funnelDTO.getPosition().getX(), funnelDTO.getPosition().getY()));
    }

    // add the funnel
    group.addFunnel(funnel);
    group.startFunnel(funnel);
    return funnel;
}
 
Example 2
Source File: StandardFunnelDAO.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public Funnel createFunnel(String groupId, FunnelDTO funnelDTO) {
    if (funnelDTO.getParentGroupId() != null && !flowController.getFlowManager().areGroupsSame(groupId, funnelDTO.getParentGroupId())) {
        throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the Funnel is being added.");
    }

    // get the desired group
    ProcessGroup group = locateProcessGroup(flowController, groupId);

    // create the funnel
    Funnel funnel = flowController.getFlowManager().createFunnel(funnelDTO.getId());
    if (funnelDTO.getPosition() != null) {
        funnel.setPosition(new Position(funnelDTO.getPosition().getX(), funnelDTO.getPosition().getY()));
    }

    // add the funnel
    group.addFunnel(funnel);
    group.startFunnel(funnel);
    return funnel;
}
 
Example 3
Source File: StandardFunnelDAO.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public Funnel updateFunnel(FunnelDTO funnelDTO) {
    // get the funnel being updated
    Funnel funnel = locateFunnel(funnelDTO.getId());

    // update the label state
    if (isNotNull(funnelDTO.getPosition())) {
        if (funnelDTO.getPosition() != null) {
            funnel.setPosition(new Position(funnelDTO.getPosition().getX(), funnelDTO.getPosition().getY()));
        }
    }

    funnel.getProcessGroup().onComponentModified();

    return funnel;
}
 
Example 4
Source File: StandardFunnelDAO.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public Funnel updateFunnel(FunnelDTO funnelDTO) {
    // get the funnel being updated
    Funnel funnel = locateFunnel(funnelDTO.getId());

    // update the label state
    if (isNotNull(funnelDTO.getPosition())) {
        if (funnelDTO.getPosition() != null) {
            funnel.setPosition(new Position(funnelDTO.getPosition().getX(), funnelDTO.getPosition().getY()));
        }
    }

    return funnel;
}
 
Example 5
Source File: FunnelResource.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new Funnel.
 *
 * @param httpServletRequest request
 * @param id                 The id of the funnel to update.
 * @param requestFunnelEntity       A funnelEntity.
 * @return A funnelEntity.
 */
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}")
@ApiOperation(
        value = "Updates a funnel",
        response = FunnelEntity.class,
        authorizations = {
                @Authorization(value = "Write - /funnels/{uuid}", type = "")
        }
)
@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 updateFunnel(
        @Context final HttpServletRequest httpServletRequest,
        @ApiParam(
                value = "The funnel id.",
                required = true
        )
        @PathParam("id") final String id,
        @ApiParam(
                value = "The funnel configuration details.",
                required = true
        ) final FunnelEntity requestFunnelEntity) {

    if (requestFunnelEntity == null || requestFunnelEntity.getComponent() == null) {
        throw new IllegalArgumentException("Funnel details must be specified.");
    }

    if (requestFunnelEntity.getRevision() == null) {
        throw new IllegalArgumentException("Revision must be specified.");
    }

    // ensure the ids are the same
    final FunnelDTO requestFunnelDTO = requestFunnelEntity.getComponent();
    if (!id.equals(requestFunnelDTO.getId())) {
        throw new IllegalArgumentException(String.format("The funnel id (%s) in the request body does not equal the "
                + "funnel id of the requested resource (%s).", requestFunnelDTO.getId(), id));
    }

    final PositionDTO proposedPosition = requestFunnelDTO.getPosition();
    if (proposedPosition != null) {
        if (proposedPosition.getX() == null || proposedPosition.getY() == null) {
            throw new IllegalArgumentException("The x and y coordinate of the proposed position must be specified.");
        }
    }

    if (isReplicateRequest()) {
        return replicate(HttpMethod.PUT, requestFunnelEntity);
    }

    // Extract the revision
    final Revision requestRevision = getRevision(requestFunnelEntity, id);
    return withWriteLock(
            serviceFacade,
            requestFunnelEntity,
            requestRevision,
            lookup -> {
                Authorizable authorizable = lookup.getFunnel(id);
                authorizable.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
            },
            null,
            (revision, funnelEntity) -> {
                // update the funnel
                final FunnelEntity entity = serviceFacade.updateFunnel(revision, funnelEntity.getComponent());
                populateRemainingFunnelEntityContent(entity);

                return clusterContext(generateOkResponse(entity)).build();
            }
    );
}
 
Example 6
Source File: FunnelResource.java    From nifi with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new Funnel.
 *
 * @param httpServletRequest request
 * @param id                 The id of the funnel to update.
 * @param requestFunnelEntity       A funnelEntity.
 * @return A funnelEntity.
 */
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}")
@ApiOperation(
        value = "Updates a funnel",
        response = FunnelEntity.class,
        authorizations = {
                @Authorization(value = "Write - /funnels/{uuid}")
        }
)
@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 updateFunnel(
        @Context final HttpServletRequest httpServletRequest,
        @ApiParam(
                value = "The funnel id.",
                required = true
        )
        @PathParam("id") final String id,
        @ApiParam(
                value = "The funnel configuration details.",
                required = true
        ) final FunnelEntity requestFunnelEntity) {

    if (requestFunnelEntity == null || requestFunnelEntity.getComponent() == null) {
        throw new IllegalArgumentException("Funnel details must be specified.");
    }

    if (requestFunnelEntity.getRevision() == null) {
        throw new IllegalArgumentException("Revision must be specified.");
    }

    // ensure the ids are the same
    final FunnelDTO requestFunnelDTO = requestFunnelEntity.getComponent();
    if (!id.equals(requestFunnelDTO.getId())) {
        throw new IllegalArgumentException(String.format("The funnel id (%s) in the request body does not equal the "
                + "funnel id of the requested resource (%s).", requestFunnelDTO.getId(), id));
    }

    final PositionDTO proposedPosition = requestFunnelDTO.getPosition();
    if (proposedPosition != null) {
        if (proposedPosition.getX() == null || proposedPosition.getY() == null) {
            throw new IllegalArgumentException("The x and y coordinate of the proposed position must be specified.");
        }
    }

    if (isReplicateRequest()) {
        return replicate(HttpMethod.PUT, requestFunnelEntity);
    } else if (isDisconnectedFromCluster()) {
        verifyDisconnectedNodeModification(requestFunnelEntity.isDisconnectedNodeAcknowledged());
    }

    // Extract the revision
    final Revision requestRevision = getRevision(requestFunnelEntity, id);
    return withWriteLock(
            serviceFacade,
            requestFunnelEntity,
            requestRevision,
            lookup -> {
                Authorizable authorizable = lookup.getFunnel(id);
                authorizable.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
            },
            null,
            (revision, funnelEntity) -> {
                // update the funnel
                final FunnelEntity entity = serviceFacade.updateFunnel(revision, funnelEntity.getComponent());
                populateRemainingFunnelEntityContent(entity);

                return generateOkResponse(entity).build();
            }
    );
}