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

The following examples show how to use org.apache.nifi.groups.ProcessGroup#addOutputPort() . 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: StandardOutputPortDAO.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@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 OutputPort 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.createRemoteOutputPort(portDTO.getId(), portDTO.getName());
    } else {
        port = flowController.createLocalOutputPort(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.addOutputPort(port);
    return port;
}
 
Example 2
Source File: StandardOutputPortDAO.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public Port createPort(String groupId, PortDTO portDTO) {
    if (isNotNull(portDTO.getParentGroupId()) && !flowController.getFlowManager().areGroupsSame(groupId, portDTO.getParentGroupId())) {
        throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the OutputPort 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 || Boolean.TRUE.equals(portDTO.getAllowRemoteAccess())) {
        port = flowController.getFlowManager().createPublicOutputPort(portDTO.getId(), portDTO.getName());
    } else {
        port = flowController.getFlowManager().createLocalOutputPort(portDTO.getId(), portDTO.getName());
    }

    // Unique public port check among all groups.
    if (port instanceof PublicPort) {
        verifyPublicPortUniqueness(port.getIdentifier(), port.getName());
    }

    // ensure we can perform the update before we add the port 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.addOutputPort(port);
    return port;
}
 
Example 3
Source File: StandardFlowSynchronizer.java    From nifi with Apache License 2.0 4 votes vote down vote up
private void addOutputPorts(final Element processGroupElement, final ProcessGroup processGroup, final FlowController flowController) {
    final FlowManager flowManager = flowController.getFlowManager();
    final List<Element> outputPortNodeList = getChildrenByTagName(processGroupElement, "outputPort");
    for (final Element outputPortElement : outputPortNodeList) {
        final PortDTO portDTO = FlowFromDOMFactory.getPort(outputPortElement);

        final Port port;
        if (processGroup.isRootGroup() || Boolean.TRUE.equals(portDTO.getAllowRemoteAccess())) {
            port = flowManager.createPublicOutputPort(portDTO.getId(), portDTO.getName());
        } else {
            port = flowManager.createLocalOutputPort(portDTO.getId(), portDTO.getName());
        }

        port.setVersionedComponentId(portDTO.getVersionedComponentId());
        port.setPosition(toPosition(portDTO.getPosition()));
        port.setComments(portDTO.getComments());
        port.setProcessGroup(processGroup);

        final Set<String> userControls = portDTO.getUserAccessControl();
        if (userControls != null && !userControls.isEmpty()) {
            if (!(port instanceof PublicPort)) {
                throw new IllegalStateException("Attempting to add User Access Controls to " + port.getIdentifier() + ", but it is not a RootGroupPort");
            }
            ((PublicPort) port).setUserAccessControl(userControls);
        }
        final Set<String> groupControls = portDTO.getGroupAccessControl();
        if (groupControls != null && !groupControls.isEmpty()) {
            if (!(port instanceof PublicPort)) {
                throw new IllegalStateException("Attempting to add Group Access Controls to " + port.getIdentifier() + ", but it is not a RootGroupPort");
            }
            ((PublicPort) port).setGroupAccessControl(groupControls);
        }

        processGroup.addOutputPort(port);
        if (portDTO.getConcurrentlySchedulableTaskCount() != null) {
            port.setMaxConcurrentTasks(portDTO.getConcurrentlySchedulableTaskCount());
        }

        final ScheduledState scheduledState = ScheduledState.valueOf(portDTO.getState());
        if (ScheduledState.RUNNING.equals(scheduledState)) {
            flowController.startConnectable(port);
        } else if (ScheduledState.DISABLED.equals(scheduledState)) {
            processGroup.disableOutputPort(port);
        }
    }
}