Java Code Examples for org.apache.nifi.groups.ProcessGroup#setComments()

The following examples show how to use org.apache.nifi.groups.ProcessGroup#setComments() . 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 updateProcessGroup(ProcessGroupDTO processGroupDTO) {
    final ProcessGroup group = locateProcessGroup(flowController, processGroupDTO.getId());

    final String name = processGroupDTO.getName();
    final String comments = processGroupDTO.getComments();

    if (isNotNull(name)) {
        group.setName(name);
    }
    if (isNotNull(processGroupDTO.getPosition())) {
        group.setPosition(new Position(processGroupDTO.getPosition().getX(), processGroupDTO.getPosition().getY()));
    }
    if (isNotNull(comments)) {
        group.setComments(comments);
    }

    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: 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 4
Source File: StandardProcessGroupDAO.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public ProcessGroup updateProcessGroup(ProcessGroupDTO processGroupDTO) {
    final ProcessGroup group = locateProcessGroup(flowController, processGroupDTO.getId());

    final String name = processGroupDTO.getName();
    final String comments = processGroupDTO.getComments();
    final String concurrencyName = processGroupDTO.getFlowfileConcurrency();
    final FlowFileConcurrency flowFileConcurrency = concurrencyName == null ? null : FlowFileConcurrency.valueOf(concurrencyName);

    final String outboundPolicyName = processGroupDTO.getFlowfileOutboundPolicy();
    final FlowFileOutboundPolicy flowFileOutboundPolicy = outboundPolicyName == null ? null : FlowFileOutboundPolicy.valueOf(outboundPolicyName);

    final ParameterContextReferenceEntity parameterContextReference = processGroupDTO.getParameterContext();
    if (parameterContextReference != null) {
        final String parameterContextId = parameterContextReference.getId();
        if (parameterContextId == null) {
            group.setParameterContext(null);
        } else {
            final ParameterContext parameterContext = flowController.getFlowManager().getParameterContextManager().getParameterContext(parameterContextId);
            if (parameterContext == null) {
                throw new IllegalStateException("Cannot set Process Group's Parameter Context because no Parameter Context exists with ID " + parameterContextId);
            }

            group.setParameterContext(parameterContext);
        }
    }

    if (isNotNull(name)) {
        group.setName(name);
    }
    if (isNotNull(processGroupDTO.getPosition())) {
        group.setPosition(new Position(processGroupDTO.getPosition().getX(), processGroupDTO.getPosition().getY()));
        final ProcessGroup parent = group.getParent();
        if (parent != null) {
            parent.onComponentModified();
        }
    }
    if (isNotNull(comments)) {
        group.setComments(comments);
    }
    if (flowFileConcurrency != null) {
        group.setFlowFileConcurrency(flowFileConcurrency);
    }
    if (flowFileOutboundPolicy != null) {
        group.setFlowFileOutboundPolicy(flowFileOutboundPolicy);
    }
    group.onComponentModified();
    return group;
}
 
Example 5
Source File: StandardFlowSynchronizer.java    From nifi with Apache License 2.0 4 votes vote down vote up
private ProcessGroup addProcessGroup(final FlowController controller, final ProcessGroup parentGroup, final Element processGroupElement,
        final StringEncryptor encryptor, final FlowEncodingVersion encodingVersion) {

    // get the parent group ID
    final String parentId = (parentGroup == null) ? null : parentGroup.getIdentifier();
    final FlowManager flowManager = controller.getFlowManager();

    // add the process group
    final ProcessGroupDTO processGroupDTO = FlowFromDOMFactory.getProcessGroup(parentId, processGroupElement, encryptor, encodingVersion);
    final ProcessGroup processGroup = flowManager.createProcessGroup(processGroupDTO.getId());
    processGroup.setComments(processGroupDTO.getComments());
    processGroup.setVersionedComponentId(processGroupDTO.getVersionedComponentId());
    processGroup.setPosition(toPosition(processGroupDTO.getPosition()));
    processGroup.setName(processGroupDTO.getName());
    processGroup.setParent(parentGroup);
    if (parentGroup == null) {
        controller.setRootGroup(processGroup);
    } else {
        parentGroup.addProcessGroup(processGroup);
    }

    final String flowfileConcurrencyName = processGroupDTO.getFlowfileConcurrency();
    final String flowfileOutboundPolicyName = processGroupDTO.getFlowfileOutboundPolicy();
    if (flowfileConcurrencyName == null) {
        processGroup.setFlowFileConcurrency(FlowFileConcurrency.UNBOUNDED);
    } else {
        processGroup.setFlowFileConcurrency(FlowFileConcurrency.valueOf(flowfileConcurrencyName));
    }

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


    final String parameterContextId = getString(processGroupElement, "parameterContextId");
    if (parameterContextId != null) {
        final ParameterContext parameterContext = controller.getFlowManager().getParameterContextManager().getParameterContext(parameterContextId);
        processGroup.setParameterContext(parameterContext);
    }

    addVariables(processGroupElement, processGroup);
    addVersionControlInfo(processGroup, processGroupDTO, controller);
    addControllerServices(processGroupElement, processGroup, controller, encodingVersion);
    addProcessors(processGroupElement, processGroup, controller, encodingVersion);
    addInputPorts(processGroupElement, processGroup, controller);
    addOutputPorts(processGroupElement, processGroup, controller);
    addFunnels(processGroupElement, processGroup, controller);
    addLabels(processGroupElement, processGroup, controller);
    addNestedProcessGroups(processGroupElement, processGroup, controller, encodingVersion);
    addRemoteProcessGroups(processGroupElement, processGroup, controller);
    addConnections(processGroupElement, processGroup, controller);
    addTemplates(processGroupElement, processGroup);

    return processGroup;
}