Search in sources :

Example 41 with ProcessGroup

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

the class StandardControllerServiceDAO method createControllerService.

@Override
public ControllerServiceNode createControllerService(final ControllerServiceDTO controllerServiceDTO) {
    // ensure the type is specified
    if (controllerServiceDTO.getType() == null) {
        throw new IllegalArgumentException("The controller service type must be specified.");
    }
    try {
        // create the controller service
        final ControllerServiceNode controllerService = serviceProvider.createControllerService(controllerServiceDTO.getType(), controllerServiceDTO.getId(), BundleUtils.getBundle(controllerServiceDTO.getType(), controllerServiceDTO.getBundle()), Collections.emptySet(), true);
        // ensure we can perform the update
        verifyUpdate(controllerService, controllerServiceDTO);
        // perform the update
        configureControllerService(controllerService, controllerServiceDTO);
        final String groupId = controllerServiceDTO.getParentGroupId();
        if (groupId == null) {
            flowController.addRootControllerService(controllerService);
        } else {
            final ProcessGroup group;
            if (groupId.equals(ROOT_GROUP_ID_ALIAS)) {
                group = flowController.getGroup(flowController.getRootGroupId());
            } else {
                group = flowController.getGroup(flowController.getRootGroupId()).findProcessGroup(groupId);
            }
            if (group == null) {
                throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId));
            }
            group.addControllerService(controllerService);
        }
        return controllerService;
    } catch (final ControllerServiceInstantiationException csie) {
        throw new NiFiCoreException(csie.getMessage(), csie);
    }
}
Also used : NiFiCoreException(org.apache.nifi.web.NiFiCoreException) ControllerServiceNode(org.apache.nifi.controller.service.ControllerServiceNode) ProcessGroup(org.apache.nifi.groups.ProcessGroup) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException) ControllerServiceInstantiationException(org.apache.nifi.controller.exception.ControllerServiceInstantiationException)

Example 42 with ProcessGroup

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

the class StandardFunnelDAO method locateFunnel.

private Funnel locateFunnel(final String funnelId) {
    final ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId());
    final Funnel funnel = rootGroup.findFunnel(funnelId);
    if (funnel == null) {
        throw new ResourceNotFoundException(String.format("Unable to find funnel with id '%s'.", funnelId));
    } else {
        return funnel;
    }
}
Also used : Funnel(org.apache.nifi.connectable.Funnel) ProcessGroup(org.apache.nifi.groups.ProcessGroup) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException)

Example 43 with ProcessGroup

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

the class StandardInputPortDAO method createPort.

@Override
public Port createPort(String groupId, PortDTO portDTO) {
    if (isNotNull(portDTO.getParentGroupId()) && !flowController.areGroupsSame(groupId, portDTO.getParentGroupId())) {
        throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the InputPort is being added.");
    }
    // ensure the name has been specified
    if (portDTO.getName() == null) {
        throw new IllegalArgumentException("Port name must be specified.");
    }
    // get the desired group
    ProcessGroup group = locateProcessGroup(flowController, groupId);
    // determine if this is the root group
    Port port;
    if (group.getParent() == null) {
        port = flowController.createRemoteInputPort(portDTO.getId(), portDTO.getName());
    } else {
        port = flowController.createLocalInputPort(portDTO.getId(), portDTO.getName());
    }
    // ensure we can perform the update before we add the processor to the flow
    verifyUpdate(port, portDTO);
    // configure
    if (portDTO.getPosition() != null) {
        port.setPosition(new Position(portDTO.getPosition().getX(), portDTO.getPosition().getY()));
    }
    port.setComments(portDTO.getComments());
    // add the port
    group.addInputPort(port);
    return port;
}
Also used : Position(org.apache.nifi.connectable.Position) Port(org.apache.nifi.connectable.Port) RootGroupPort(org.apache.nifi.remote.RootGroupPort) ProcessGroup(org.apache.nifi.groups.ProcessGroup)

Example 44 with ProcessGroup

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

the class StandardLabelDAO method createLabel.

@Override
public Label createLabel(String groupId, LabelDTO labelDTO) {
    if (labelDTO.getParentGroupId() != null && !flowController.areGroupsSame(groupId, labelDTO.getParentGroupId())) {
        throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the Label is being added.");
    }
    // get the desired group
    ProcessGroup group = locateProcessGroup(flowController, groupId);
    // create the label
    Label label = flowController.createLabel(labelDTO.getId(), labelDTO.getLabel());
    if (labelDTO.getPosition() != null) {
        label.setPosition(new Position(labelDTO.getPosition().getX(), labelDTO.getPosition().getY()));
    }
    if (labelDTO.getWidth() != null && labelDTO.getHeight() != null) {
        label.setSize(new Size(labelDTO.getWidth(), labelDTO.getHeight()));
    }
    label.setStyle(labelDTO.getStyle());
    // add the label
    group.addLabel(label);
    return label;
}
Also used : Position(org.apache.nifi.connectable.Position) Size(org.apache.nifi.connectable.Size) ProcessGroup(org.apache.nifi.groups.ProcessGroup) Label(org.apache.nifi.controller.label.Label)

Example 45 with ProcessGroup

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

the class StandardLabelDAO method locateLabel.

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

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