Search in sources :

Example 6 with Funnel

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

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

the class FunnelAuditor method removeFunnelAdvice.

/**
 * Audits the removal of a funnel.
 *
 * @param proceedingJoinPoint join point
 * @param funnelId funnel id
 * @param funnelDAO funnel dao
 * @throws Throwable ex
 */
@Around("within(org.apache.nifi.web.dao.FunnelDAO+) && " + "execution(void deleteFunnel(java.lang.String)) && " + "args(funnelId) && " + "target(funnelDAO)")
public void removeFunnelAdvice(ProceedingJoinPoint proceedingJoinPoint, String funnelId, FunnelDAO funnelDAO) throws Throwable {
    // get the funnel before removing it
    Funnel funnel = funnelDAO.getFunnel(funnelId);
    // remove the funnel
    proceedingJoinPoint.proceed();
    // if no exceptions were thrown, add removal actions...
    final Action action = generateAuditRecord(funnel, Operation.Remove);
    // save the actions
    if (action != null) {
        saveAction(action, logger);
    }
}
Also used : Funnel(org.apache.nifi.connectable.Funnel) FlowChangeAction(org.apache.nifi.action.FlowChangeAction) Action(org.apache.nifi.action.Action) Around(org.aspectj.lang.annotation.Around)

Example 8 with Funnel

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

the class RelationshipAuditor method determineConnectableType.

/**
 * Determines the type of component the specified connectable is.
 */
private Component determineConnectableType(Connectable connectable) {
    String sourceId = connectable.getIdentifier();
    Component componentType = Component.Controller;
    if (connectable instanceof ProcessorNode) {
        componentType = Component.Processor;
    } else if (connectable instanceof RemoteGroupPort) {
        final RemoteGroupPort remoteGroupPort = (RemoteGroupPort) connectable;
        if (TransferDirection.RECEIVE.equals(remoteGroupPort.getTransferDirection())) {
            if (remoteGroupPort.getRemoteProcessGroup() == null) {
                componentType = Component.InputPort;
            } else {
                componentType = Component.OutputPort;
            }
        } else {
            if (remoteGroupPort.getRemoteProcessGroup() == null) {
                componentType = Component.OutputPort;
            } else {
                componentType = Component.InputPort;
            }
        }
    } else if (connectable instanceof Port) {
        ProcessGroup processGroup = connectable.getProcessGroup();
        if (processGroup.getInputPort(sourceId) != null) {
            componentType = Component.InputPort;
        } else if (processGroup.getOutputPort(sourceId) != null) {
            componentType = Component.OutputPort;
        }
    } else if (connectable instanceof Funnel) {
        componentType = Component.Funnel;
    }
    return componentType;
}
Also used : Funnel(org.apache.nifi.connectable.Funnel) ProcessorNode(org.apache.nifi.controller.ProcessorNode) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) Port(org.apache.nifi.connectable.Port) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) ProcessGroup(org.apache.nifi.groups.ProcessGroup) Component(org.apache.nifi.action.Component)

Example 9 with Funnel

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

the class SnippetAuditor method updateSnippetAdvice.

/**
 * Audits a bulk move.
 *
 * @param proceedingJoinPoint join point
 * @param snippetDTO dto
 * @param snippetDAO dao
 * @return snippet
 * @throws Throwable ex
 */
@Around("within(org.apache.nifi.web.dao.SnippetDAO+) && " + "execution(org.apache.nifi.controller.Snippet updateSnippetComponents(org.apache.nifi.web.api.dto.SnippetDTO)) && " + "args(snippetDTO) && " + "target(snippetDAO)")
public Snippet updateSnippetAdvice(ProceedingJoinPoint proceedingJoinPoint, SnippetDTO snippetDTO, SnippetDAO snippetDAO) throws Throwable {
    // get the snippet before removing it
    Snippet snippet = snippetDAO.getSnippet(snippetDTO.getId());
    final String previousGroupId = snippet.getParentGroupId();
    // perform the underlying operation
    snippet = (Snippet) proceedingJoinPoint.proceed();
    // if this snippet is linked and its parent group id has changed
    final String groupId = snippetDTO.getParentGroupId();
    if (!previousGroupId.equals(groupId)) {
        // create move audit records for all items in this snippet
        final Collection<Action> actions = new ArrayList<>();
        for (String id : snippet.getProcessors().keySet()) {
            final ProcessorNode processor = processorDAO.getProcessor(id);
            final Action action = processorAuditor.generateAuditRecord(processor, Operation.Move, createMoveDetails(previousGroupId, groupId, logger));
            if (action != null) {
                actions.add(action);
            }
        }
        for (String id : snippet.getFunnels().keySet()) {
            final Funnel funnel = funnelDAO.getFunnel(id);
            final Action action = funnelAuditor.generateAuditRecord(funnel, Operation.Move, createMoveDetails(previousGroupId, groupId, logger));
            if (action != null) {
                actions.add(action);
            }
        }
        for (String id : snippet.getInputPorts().keySet()) {
            final Port port = inputPortDAO.getPort(id);
            final Action action = portAuditor.generateAuditRecord(port, Operation.Move, createMoveDetails(previousGroupId, groupId, logger));
            if (action != null) {
                actions.add(action);
            }
        }
        for (String id : snippet.getOutputPorts().keySet()) {
            final Port port = outputPortDAO.getPort(id);
            final Action action = portAuditor.generateAuditRecord(port, Operation.Move, createMoveDetails(previousGroupId, groupId, logger));
            if (action != null) {
                actions.add(action);
            }
        }
        for (String id : snippet.getRemoteProcessGroups().keySet()) {
            final RemoteProcessGroup remoteProcessGroup = remoteProcessGroupDAO.getRemoteProcessGroup(id);
            final Action action = remoteProcessGroupAuditor.generateAuditRecord(remoteProcessGroup, Operation.Move, createMoveDetails(previousGroupId, groupId, logger));
            if (action != null) {
                actions.add(action);
            }
        }
        for (String id : snippet.getProcessGroups().keySet()) {
            final ProcessGroupDAO processGroupDAO = getProcessGroupDAO();
            final ProcessGroup processGroup = processGroupDAO.getProcessGroup(id);
            final Action action = processGroupAuditor.generateAuditRecord(processGroup, Operation.Move, createMoveDetails(previousGroupId, groupId, logger));
            if (action != null) {
                actions.add(action);
            }
        }
        for (String id : snippet.getConnections().keySet()) {
            final Connection connection = connectionDAO.getConnection(id);
            final Action action = relationshipAuditor.generateAuditRecordForConnection(connection, Operation.Move, createMoveDetails(previousGroupId, groupId, logger));
            if (action != null) {
                actions.add(action);
            }
        }
        // save the actions
        if (CollectionUtils.isNotEmpty(actions)) {
            saveActions(actions, logger);
        }
    }
    return snippet;
}
Also used : Funnel(org.apache.nifi.connectable.Funnel) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) FlowChangeAction(org.apache.nifi.action.FlowChangeAction) Action(org.apache.nifi.action.Action) ProcessorNode(org.apache.nifi.controller.ProcessorNode) ProcessGroupDAO(org.apache.nifi.web.dao.ProcessGroupDAO) RemoteProcessGroupDAO(org.apache.nifi.web.dao.RemoteProcessGroupDAO) Port(org.apache.nifi.connectable.Port) ArrayList(java.util.ArrayList) ProcessGroup(org.apache.nifi.groups.ProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) Connection(org.apache.nifi.connectable.Connection) Snippet(org.apache.nifi.controller.Snippet) Around(org.aspectj.lang.annotation.Around)

Example 10 with Funnel

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

the class StandardProcessGroup method verifyCanDelete.

@Override
public void verifyCanDelete(final Snippet snippet) throws IllegalStateException {
    readLock.lock();
    try {
        if (!id.equals(snippet.getParentGroupId())) {
            throw new IllegalStateException("Snippet belongs to ProcessGroup with ID " + snippet.getParentGroupId() + " but this ProcessGroup has id " + id);
        }
        if (!isDisconnected(snippet)) {
            throw new IllegalStateException("One or more components within the snippet is connected to a component outside of the snippet. Only a disconnected snippet may be moved.");
        }
        for (final String id : snippet.getConnections().keySet()) {
            final Connection connection = getConnection(id);
            if (connection == null) {
                throw new IllegalStateException("Snippet references Connection with ID " + id + ", which does not exist in this ProcessGroup");
            }
            connection.verifyCanDelete();
        }
        for (final String id : snippet.getFunnels().keySet()) {
            final Funnel funnel = getFunnel(id);
            if (funnel == null) {
                throw new IllegalStateException("Snippet references Funnel with ID " + id + ", which does not exist in this ProcessGroup");
            }
            funnel.verifyCanDelete(true);
        }
        for (final String id : snippet.getInputPorts().keySet()) {
            final Port port = getInputPort(id);
            if (port == null) {
                throw new IllegalStateException("Snippet references Input Port with ID " + id + ", which does not exist in this ProcessGroup");
            }
            port.verifyCanDelete(true);
        }
        for (final String id : snippet.getLabels().keySet()) {
            final Label label = getLabel(id);
            if (label == null) {
                throw new IllegalStateException("Snippet references Label with ID " + id + ", which does not exist in this ProcessGroup");
            }
        }
        for (final String id : snippet.getOutputPorts().keySet()) {
            final Port port = getOutputPort(id);
            if (port == null) {
                throw new IllegalStateException("Snippet references Output Port with ID " + id + ", which does not exist in this ProcessGroup");
            }
            port.verifyCanDelete(true);
        }
        for (final String id : snippet.getProcessGroups().keySet()) {
            final ProcessGroup group = getProcessGroup(id);
            if (group == null) {
                throw new IllegalStateException("Snippet references Process Group with ID " + id + ", which does not exist in this ProcessGroup");
            }
            group.verifyCanDelete(true);
        }
        for (final String id : snippet.getProcessors().keySet()) {
            final ProcessorNode processor = getProcessor(id);
            if (processor == null) {
                throw new IllegalStateException("Snippet references Processor with ID " + id + ", which does not exist in this ProcessGroup");
            }
            processor.verifyCanDelete(true);
        }
        for (final String id : snippet.getRemoteProcessGroups().keySet()) {
            final RemoteProcessGroup group = getRemoteProcessGroup(id);
            if (group == null) {
                throw new IllegalStateException("Snippet references Remote Process Group with ID " + id + ", which does not exist in this ProcessGroup");
            }
            group.verifyCanDelete(true);
        }
    } finally {
        readLock.unlock();
    }
}
Also used : VersionedFunnel(org.apache.nifi.registry.flow.VersionedFunnel) Funnel(org.apache.nifi.connectable.Funnel) VersionedRemoteProcessGroup(org.apache.nifi.registry.flow.VersionedRemoteProcessGroup) ProcessorNode(org.apache.nifi.controller.ProcessorNode) RootGroupPort(org.apache.nifi.remote.RootGroupPort) VersionedRemoteGroupPort(org.apache.nifi.registry.flow.VersionedRemoteGroupPort) Port(org.apache.nifi.connectable.Port) VersionedPort(org.apache.nifi.registry.flow.VersionedPort) LocalPort(org.apache.nifi.connectable.LocalPort) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) Connection(org.apache.nifi.connectable.Connection) VersionedConnection(org.apache.nifi.registry.flow.VersionedConnection) VersionedLabel(org.apache.nifi.registry.flow.VersionedLabel) Label(org.apache.nifi.controller.label.Label) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) VersionedRemoteProcessGroup(org.apache.nifi.registry.flow.VersionedRemoteProcessGroup)

Aggregations

Funnel (org.apache.nifi.connectable.Funnel)29 Port (org.apache.nifi.connectable.Port)15 Connection (org.apache.nifi.connectable.Connection)13 ProcessGroup (org.apache.nifi.groups.ProcessGroup)13 ProcessorNode (org.apache.nifi.controller.ProcessorNode)12 RemoteGroupPort (org.apache.nifi.remote.RemoteGroupPort)12 RootGroupPort (org.apache.nifi.remote.RootGroupPort)11 RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)10 ArrayList (java.util.ArrayList)9 HashSet (java.util.HashSet)8 Connectable (org.apache.nifi.connectable.Connectable)8 Label (org.apache.nifi.controller.label.Label)8 ControllerServiceNode (org.apache.nifi.controller.service.ControllerServiceNode)7 LinkedHashSet (java.util.LinkedHashSet)6 Action (org.apache.nifi.action.Action)6 LocalPort (org.apache.nifi.connectable.LocalPort)6 Position (org.apache.nifi.connectable.Position)6 Snippet (org.apache.nifi.controller.Snippet)6 VersionControlInformation (org.apache.nifi.registry.flow.VersionControlInformation)6 VersionedFunnel (org.apache.nifi.registry.flow.VersionedFunnel)6