Search in sources :

Example 1 with Position

use of org.apache.nifi.connectable.Position in project nifi by apache.

the class StandardFunnelDAO method updateFunnel.

@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;
}
Also used : Funnel(org.apache.nifi.connectable.Funnel) Position(org.apache.nifi.connectable.Position)

Example 2 with Position

use of org.apache.nifi.connectable.Position 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 3 with Position

use of org.apache.nifi.connectable.Position 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 4 with Position

use of org.apache.nifi.connectable.Position in project nifi by apache.

the class StandardLabelDAO method updateLabel.

@Override
public Label updateLabel(LabelDTO labelDTO) {
    // get the label being updated
    Label label = locateLabel(labelDTO.getId());
    // update the label state
    if (labelDTO.getPosition() != null) {
        label.setPosition(new Position(labelDTO.getPosition().getX(), labelDTO.getPosition().getY()));
    }
    if (labelDTO.getStyle() != null) {
        label.setStyle(labelDTO.getStyle());
    }
    if (labelDTO.getLabel() != null) {
        label.setValue(labelDTO.getLabel());
    }
    if (labelDTO.getWidth() != null && labelDTO.getHeight() != null) {
        label.setSize(new Size(labelDTO.getWidth(), labelDTO.getHeight()));
    }
    label.getProcessGroup().onComponentModified();
    return label;
}
Also used : Position(org.apache.nifi.connectable.Position) Size(org.apache.nifi.connectable.Size) Label(org.apache.nifi.controller.label.Label)

Example 5 with Position

use of org.apache.nifi.connectable.Position in project nifi by apache.

the class StandardProcessGroupDAO method createProcessGroup.

@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());
    if (processGroup.getName() != null) {
        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;
}
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)

Aggregations

Position (org.apache.nifi.connectable.Position)28 Port (org.apache.nifi.connectable.Port)10 ProcessGroup (org.apache.nifi.groups.ProcessGroup)10 RootGroupPort (org.apache.nifi.remote.RootGroupPort)10 ArrayList (java.util.ArrayList)9 Size (org.apache.nifi.connectable.Size)9 FlowFilePrioritizer (org.apache.nifi.flowfile.FlowFilePrioritizer)9 RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)9 HashSet (java.util.HashSet)7 Funnel (org.apache.nifi.connectable.Funnel)7 Label (org.apache.nifi.controller.label.Label)7 Relationship (org.apache.nifi.processor.Relationship)7 RemoteGroupPort (org.apache.nifi.remote.RemoteGroupPort)7 BundleCoordinate (org.apache.nifi.bundle.BundleCoordinate)6 Connection (org.apache.nifi.connectable.Connection)5 ProcessorInstantiationException (org.apache.nifi.controller.exception.ProcessorInstantiationException)5 ControllerServiceNode (org.apache.nifi.controller.service.ControllerServiceNode)5 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)5 Element (org.w3c.dom.Element)5 URL (java.net.URL)4