Search in sources :

Example 51 with ProcessGroup

use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.

the class StandardProcessGroupDAO method updateProcessGroup.

@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()));
        final ProcessGroup parent = group.getParent();
        if (parent != null) {
            parent.onComponentModified();
        }
    }
    if (isNotNull(comments)) {
        group.setComments(comments);
    }
    group.onComponentModified();
    return group;
}
Also used : Position(org.apache.nifi.connectable.Position) ProcessGroup(org.apache.nifi.groups.ProcessGroup) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup)

Example 52 with ProcessGroup

use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.

the class StandardProcessorDAO method createProcessor.

@Override
public ProcessorNode createProcessor(final String groupId, ProcessorDTO processorDTO) {
    if (processorDTO.getParentGroupId() != null && !flowController.areGroupsSame(groupId, processorDTO.getParentGroupId())) {
        throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the Processor is being added.");
    }
    // ensure the type is specified
    if (processorDTO.getType() == null) {
        throw new IllegalArgumentException("The processor type must be specified.");
    }
    // get the group to add the processor to
    ProcessGroup group = locateProcessGroup(flowController, groupId);
    try {
        // attempt to create the processor
        ProcessorNode processor = flowController.createProcessor(processorDTO.getType(), processorDTO.getId(), BundleUtils.getBundle(processorDTO.getType(), processorDTO.getBundle()));
        // ensure we can perform the update before we add the processor to the flow
        verifyUpdate(processor, processorDTO);
        // add the processor to the group
        group.addProcessor(processor);
        // configure the processor
        configureProcessor(processor, processorDTO);
        return processor;
    } catch (ProcessorInstantiationException pse) {
        throw new NiFiCoreException(String.format("Unable to create processor of type %s due to: %s", processorDTO.getType(), pse.getMessage()), pse);
    } catch (IllegalStateException | ComponentLifeCycleException ise) {
        throw new NiFiCoreException(ise.getMessage(), ise);
    }
}
Also used : NiFiCoreException(org.apache.nifi.web.NiFiCoreException) ProcessorNode(org.apache.nifi.controller.ProcessorNode) ProcessGroup(org.apache.nifi.groups.ProcessGroup) ProcessorInstantiationException(org.apache.nifi.controller.exception.ProcessorInstantiationException) ComponentLifeCycleException(org.apache.nifi.controller.exception.ComponentLifeCycleException)

Example 53 with ProcessGroup

use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.

the class StandardProcessorDAO method locateProcessor.

private ProcessorNode locateProcessor(final String processorId) {
    final ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId());
    final ProcessorNode processor = rootGroup.findProcessor(processorId);
    if (processor == null) {
        throw new ResourceNotFoundException(String.format("Unable to find processor with id '%s'.", processorId));
    } else {
        return processor;
    }
}
Also used : ProcessorNode(org.apache.nifi.controller.ProcessorNode) ProcessGroup(org.apache.nifi.groups.ProcessGroup) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException)

Example 54 with ProcessGroup

use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.

the class StandardRemoteProcessGroupDAO method locateRemoteProcessGroup.

private RemoteProcessGroup locateRemoteProcessGroup(final String remoteProcessGroupId) {
    final ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId());
    final RemoteProcessGroup remoteProcessGroup = rootGroup.findRemoteProcessGroup(remoteProcessGroupId);
    if (remoteProcessGroup == null) {
        throw new ResourceNotFoundException(String.format("Unable to find remote process group with id '%s'.", remoteProcessGroupId));
    } else {
        return remoteProcessGroup;
    }
}
Also used : RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException)

Example 55 with ProcessGroup

use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.

the class StandardSnippetDAO method updateSnippetComponents.

@Override
public Snippet updateSnippetComponents(final SnippetDTO snippetDTO) {
    // verify the action
    verifyUpdateSnippetComponent(snippetDTO);
    // find the snippet in question
    final StandardSnippet snippet = locateSnippet(snippetDTO.getId());
    // if the group is changing move it
    if (snippetDTO.getParentGroupId() != null && !snippet.getParentGroupId().equals(snippetDTO.getParentGroupId())) {
        final ProcessGroup currentProcessGroup = flowController.getGroup(snippet.getParentGroupId());
        if (currentProcessGroup == null) {
            throw new IllegalArgumentException("The current process group could not be found.");
        }
        final ProcessGroup newProcessGroup = flowController.getGroup(snippetDTO.getParentGroupId());
        if (newProcessGroup == null) {
            throw new IllegalArgumentException("The new process group could not be found.");
        }
        // move the snippet
        currentProcessGroup.move(snippet, newProcessGroup);
        // update its parent group id
        snippet.setParentGroupId(snippetDTO.getParentGroupId());
    }
    return snippet;
}
Also used : ProcessGroup(org.apache.nifi.groups.ProcessGroup) StandardSnippet(org.apache.nifi.controller.StandardSnippet)

Aggregations

ProcessGroup (org.apache.nifi.groups.ProcessGroup)185 RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)97 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)68 ProcessorNode (org.apache.nifi.controller.ProcessorNode)50 Port (org.apache.nifi.connectable.Port)40 RootGroupPort (org.apache.nifi.remote.RootGroupPort)37 Connection (org.apache.nifi.connectable.Connection)36 ArrayList (java.util.ArrayList)35 InstantiatedVersionedProcessGroup (org.apache.nifi.registry.flow.mapping.InstantiatedVersionedProcessGroup)35 Test (org.junit.Test)35 RemoteGroupPort (org.apache.nifi.remote.RemoteGroupPort)34 HashSet (java.util.HashSet)32 ControllerServiceNode (org.apache.nifi.controller.service.ControllerServiceNode)32 ResourceNotFoundException (org.apache.nifi.web.ResourceNotFoundException)29 FlowController (org.apache.nifi.controller.FlowController)27 Connectable (org.apache.nifi.connectable.Connectable)26 VersionControlInformation (org.apache.nifi.registry.flow.VersionControlInformation)25 Funnel (org.apache.nifi.connectable.Funnel)24 List (java.util.List)22 Label (org.apache.nifi.controller.label.Label)22