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

The following examples show how to use org.apache.nifi.web.api.dto.ProcessGroupDTO#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: StandardProcessGroupDAO.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Override
public ProcessGroup createProcessGroup(String parentGroupId, ProcessGroupDTO processGroup) {
    if (processGroup.getParentGroupId() != null && !flowController.areGroupsSame(processGroup.getParentGroupId(), parentGroupId)) {
        throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the Process Group is being added.");
    }

    // get the parent group
    ProcessGroup parentGroup = locateProcessGroup(flowController, parentGroupId);

    // create the process group
    ProcessGroup group = flowController.createProcessGroup(processGroup.getId());
    group.setName(processGroup.getName());
    if (processGroup.getPosition() != null) {
        group.setPosition(new Position(processGroup.getPosition().getX(), processGroup.getPosition().getY()));
    }

    // add the process group
    group.setParent(parentGroup);
    parentGroup.addProcessGroup(group);

    return group;
}
 
Example 2
Source File: FlowController.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Updates the process group corresponding to the specified DTO. Any field
 * in DTO that is <code>null</code> (with the exception of the required ID)
 * will be ignored.
 *
 * @param dto group
 * @throws ProcessorInstantiationException
 *
 * @throws IllegalStateException if no process group can be found with the
 * ID of DTO or with the ID of the DTO's parentGroupId, if the template ID
 * specified is invalid, or if the DTO's Parent Group ID changes but the
 * parent group has incoming or outgoing connections
 *
 * @throws NullPointerException if the DTO or its ID is null
 */
public void updateProcessGroup(final ProcessGroupDTO dto) throws ProcessorInstantiationException {
    final ProcessGroup group = lookupGroup(requireNonNull(dto).getId());

    final String name = dto.getName();
    final PositionDTO position = dto.getPosition();
    final String comments = dto.getComments();

    if (name != null) {
        group.setName(name);
    }
    if (position != null) {
        group.setPosition(toPosition(position));
    }
    if (comments != null) {
        group.setComments(comments);
    }
}
 
Example 3
Source File: StandardProcessGroupDAO.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public ProcessGroup createProcessGroup(String parentGroupId, ProcessGroupDTO processGroup) {
    final FlowManager flowManager = flowController.getFlowManager();
    if (processGroup.getParentGroupId() != null && !flowManager.areGroupsSame(processGroup.getParentGroupId(), parentGroupId)) {
        throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the Process Group is being added.");
    }

    // get the parent group
    ProcessGroup parentGroup = locateProcessGroup(flowController, parentGroupId);

    // create the process group
    ProcessGroup group = flowManager.createProcessGroup(processGroup.getId());
    if (processGroup.getName() != null) {
        group.setName(processGroup.getName());
    }
    if (processGroup.getPosition() != null) {
        group.setPosition(new Position(processGroup.getPosition().getX(), processGroup.getPosition().getY()));
    }

    final ParameterContextReferenceEntity parameterContextReference = processGroup.getParameterContext();
    if (parameterContextReference != null && parameterContextReference.getId() != null) {
        final ParameterContext parameterContext = flowController.getFlowManager().getParameterContextManager().getParameterContext(parameterContextReference.getId());
        group.setParameterContext(parameterContext);
    }

    // add the process group
    group.setParent(parentGroup);
    parentGroup.addProcessGroup(group);

    return group;
}
 
Example 4
Source File: StandardFlowSynchronizer.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the process group corresponding to the specified DTO. Any field
 * in DTO that is <code>null</code> (with the exception of the required ID)
 * will be ignored.
 *
 * @throws IllegalStateException if no process group can be found with the
 * ID of DTO or with the ID of the DTO's parentGroupId, if the template ID
 * specified is invalid, or if the DTO's Parent Group ID changes but the
 * parent group has incoming or outgoing connections
 *
 * @throws NullPointerException if the DTO or its ID is null
 */
private void updateProcessGroup(final ProcessGroup group, final ProcessGroupDTO dto, final ParameterContextManager parameterContextManager) {
    final String name = dto.getName();
    final PositionDTO position = dto.getPosition();
    final String comments = dto.getComments();
    final String flowfileConcurrencyName = dto.getFlowfileConcurrency();
    final String flowfileOutboundPolicyName = dto.getFlowfileOutboundPolicy();

    if (name != null) {
        group.setName(name);
    }
    if (position != null) {
        group.setPosition(toPosition(position));
    }
    if (comments != null) {
        group.setComments(comments);
    }

    if (flowfileConcurrencyName == null) {
        group.setFlowFileConcurrency(FlowFileConcurrency.UNBOUNDED);
    } else {
        group.setFlowFileConcurrency(FlowFileConcurrency.valueOf(flowfileConcurrencyName));
    }

    if (flowfileOutboundPolicyName == null) {
        group.setFlowFileOutboundPolicy(FlowFileOutboundPolicy.STREAM_WHEN_AVAILABLE);
    } else {
        group.setFlowFileOutboundPolicy(FlowFileOutboundPolicy.valueOf(flowfileOutboundPolicyName));
    }

    final ParameterContextReferenceEntity parameterContextReference = dto.getParameterContext();
    if (parameterContextReference != null && parameterContextReference.getId() != null) {
        final String parameterContextId = parameterContextReference.getId();
        final ParameterContext parameterContext = parameterContextManager.getParameterContext(parameterContextId);
        if (!Objects.equals(parameterContext, group.getParameterContext())) {
            group.setParameterContext(parameterContext);
        }
    }

}
 
Example 5
Source File: ProcessGroupResource.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
/**
 * Updates the specified process group.
 *
 * @param httpServletRequest request
 * @param id                 The id of the process group.
 * @param requestProcessGroupEntity A processGroupEntity.
 * @return A processGroupEntity.
 */
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}")
@ApiOperation(
        value = "Updates a process group",
        response = ProcessGroupEntity.class,
        authorizations = {
                @Authorization(value = "Write - /process-groups/{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 updateProcessGroup(
        @Context final HttpServletRequest httpServletRequest,
        @ApiParam(
                value = "The process group id.",
                required = true
        )
        @PathParam("id") final String id,
        @ApiParam(
                value = "The process group configuration details.",
                required = true
        ) final ProcessGroupEntity requestProcessGroupEntity) {

    if (requestProcessGroupEntity == null || requestProcessGroupEntity.getComponent() == null) {
        throw new IllegalArgumentException("Process group details must be specified.");
    }

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

    // ensure the same id is being used
    final ProcessGroupDTO requestProcessGroupDTO = requestProcessGroupEntity.getComponent();
    if (!id.equals(requestProcessGroupDTO.getId())) {
        throw new IllegalArgumentException(String.format("The process group id (%s) in the request body does "
                + "not equal the process group id of the requested resource (%s).", requestProcessGroupDTO.getId(), id));
    }

    final PositionDTO proposedPosition = requestProcessGroupDTO.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, requestProcessGroupEntity);
    }

    // handle expects request (usually from the cluster manager)
    final Revision requestRevision = getRevision(requestProcessGroupEntity, id);
    return withWriteLock(
            serviceFacade,
            requestProcessGroupEntity,
            requestRevision,
            lookup -> {
                Authorizable authorizable = lookup.getProcessGroup(id).getAuthorizable();
                authorizable.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
            },
            null,
            (revision, processGroupEntity) -> {
                // update the process group
                final ProcessGroupEntity entity = serviceFacade.updateProcessGroup(revision, processGroupEntity.getComponent());
                populateRemainingProcessGroupEntityContent(entity);

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