Search in sources :

Example 6 with Label

use of org.apache.nifi.controller.label.Label 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 7 with Label

use of org.apache.nifi.controller.label.Label 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)

Example 8 with Label

use of org.apache.nifi.controller.label.Label 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)

Example 9 with Label

use of org.apache.nifi.controller.label.Label in project nifi by apache.

the class StandardProcessGroup method addLabel.

private Label addLabel(final ProcessGroup destination, final VersionedLabel proposed, final String componentIdSeed) {
    final Label label = flowController.createLabel(generateUuid(proposed.getIdentifier(), destination.getIdentifier(), componentIdSeed), proposed.getLabel());
    label.setVersionedComponentId(proposed.getIdentifier());
    destination.addLabel(label);
    updateLabel(label, proposed);
    return label;
}
Also used : VersionedLabel(org.apache.nifi.registry.flow.VersionedLabel) Label(org.apache.nifi.controller.label.Label)

Example 10 with Label

use of org.apache.nifi.controller.label.Label in project nifi by apache.

the class StandardProcessGroup method removeLabel.

@Override
public void removeLabel(final Label label) {
    writeLock.lock();
    try {
        final Label removed = labels.remove(requireNonNull(label).getIdentifier());
        if (removed == null) {
            throw new IllegalStateException(label + " is not a member of this Process Group.");
        }
        onComponentModified();
        LOG.info("Label with ID {} removed from flow", label.getIdentifier());
    } finally {
        writeLock.unlock();
    }
}
Also used : VersionedLabel(org.apache.nifi.registry.flow.VersionedLabel) Label(org.apache.nifi.controller.label.Label)

Aggregations

Label (org.apache.nifi.controller.label.Label)21 Connection (org.apache.nifi.connectable.Connection)11 Port (org.apache.nifi.connectable.Port)11 ProcessGroup (org.apache.nifi.groups.ProcessGroup)11 ControllerServiceNode (org.apache.nifi.controller.service.ControllerServiceNode)10 RemoteGroupPort (org.apache.nifi.remote.RemoteGroupPort)10 RootGroupPort (org.apache.nifi.remote.RootGroupPort)10 ArrayList (java.util.ArrayList)9 HashSet (java.util.HashSet)9 Funnel (org.apache.nifi.connectable.Funnel)9 RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)9 Position (org.apache.nifi.connectable.Position)8 ProcessorNode (org.apache.nifi.controller.ProcessorNode)8 HashMap (java.util.HashMap)7 Map (java.util.Map)7 FlowFilePrioritizer (org.apache.nifi.flowfile.FlowFilePrioritizer)7 Collections (java.util.Collections)6 LinkedHashSet (java.util.LinkedHashSet)6 List (java.util.List)6 Set (java.util.Set)6