Java Code Examples for org.apache.nifi.web.api.dto.FlowSnippetDTO#getConnections()

The following examples show how to use org.apache.nifi.web.api.dto.FlowSnippetDTO#getConnections() . 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: TemplateUtils.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
private static void scrubSnippet(final FlowSnippetDTO snippet) {
    // ensure that contents have been specified
    if (snippet != null) {
        // go through each processor if specified
        if (snippet.getProcessors() != null) {
            scrubProcessors(snippet.getProcessors());
        }

        // go through each connection if specified
        if (snippet.getConnections() != null) {
            scrubConnections(snippet.getConnections());
        }

        // go through each remote process group if specified
        if (snippet.getRemoteProcessGroups() != null) {
            scrubRemoteProcessGroups(snippet.getRemoteProcessGroups());
        }

        // go through each process group if specified
        if (snippet.getProcessGroups() != null) {
            scrubProcessGroups(snippet.getProcessGroups());
        }

        // go through each controller service if specified
        if (snippet.getControllerServices() != null) {
            scrubControllerServices(snippet.getControllerServices());
        }
    }
}
 
Example 2
Source File: SnippetUtils.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Gets all connections that are part of the specified template.
 *
 * @param contents snippet content
 * @return connection dtos
 */
private static Collection<ConnectionDTO> getConnections(FlowSnippetDTO contents) {
    final Collection<ConnectionDTO> connections = new HashSet<>();
    if (contents.getConnections() != null) {
        connections.addAll(contents.getConnections());
    }
    return connections;
}
 
Example 3
Source File: TemplateUtils.java    From nifi with Apache License 2.0 5 votes vote down vote up
private static void scrubSnippet(final FlowSnippetDTO snippet) {
    // ensure that contents have been specified
    if (snippet != null) {
        // go through each processor if specified
        if (snippet.getProcessors() != null) {
            scrubProcessors(snippet.getProcessors());
        }

        // go through each connection if specified
        if (snippet.getConnections() != null) {
            scrubConnections(snippet.getConnections());
        }

        // go through each remote process group if specified
        if (snippet.getRemoteProcessGroups() != null) {
            scrubRemoteProcessGroups(snippet.getRemoteProcessGroups());
        }

        // go through each process group if specified
        if (snippet.getProcessGroups() != null) {
            scrubProcessGroups(snippet.getProcessGroups());
        }

        // go through each controller service if specified
        if (snippet.getControllerServices() != null) {
            scrubControllerServices(snippet.getControllerServices());
        }
    }
}
 
Example 4
Source File: SnippetUtils.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Gets all connections that are part of the specified template.
 *
 * @param contents snippet content
 * @return connection dtos
 */
private static Collection<ConnectionDTO> getConnections(FlowSnippetDTO contents) {
    final Collection<ConnectionDTO> connections = new HashSet<>();
    if (contents.getConnections() != null) {
        connections.addAll(contents.getConnections());
    }
    return connections;
}
 
Example 5
Source File: StandardFlowServiceTest.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
private void assertEquals(FlowSnippetDTO expected, FlowSnippetDTO actual) {
    if (expected == null && actual == null) {
        return;
    }

    // check connections
    Assert.assertEquals(expected.getConnections().size(), actual.getConnections().size());
    List<ConnectionDTO> expectedConnections = new ArrayList<>(expected.getConnections());
    List<ConnectionDTO> actualConnections = new ArrayList<>(actual.getConnections());
    for (int i = 0; i < expectedConnections.size(); i++) {
        assertEquals(expectedConnections.get(i), actualConnections.get(i));
    }

    // check groups
    Assert.assertEquals(expected.getProcessGroups().size(), actual.getProcessGroups().size());
    List<ProcessGroupDTO> expectedProcessGroups = new ArrayList<>(expected.getProcessGroups());
    List<ProcessGroupDTO> actualProcessGroups = new ArrayList<>(actual.getProcessGroups());
    for (int i = 0; i < expectedProcessGroups.size(); i++) {
        assertEquals(expectedProcessGroups.get(i), actualProcessGroups.get(i));
    }

    // check input ports
    Assert.assertEquals(expected.getInputPorts().size(), actual.getInputPorts().size());
    List<PortDTO> expectedInputPorts = new ArrayList<>(expected.getInputPorts());
    List<PortDTO> actualInputPort = new ArrayList<>(actual.getInputPorts());
    for (int i = 0; i < expectedInputPorts.size(); i++) {
        assertEquals(expectedInputPorts.get(i), actualInputPort.get(i));
    }

    // check labels
    Assert.assertEquals(expected.getLabels().size(), actual.getLabels().size());
    List<LabelDTO> expectedLabels = new ArrayList<>(expected.getLabels());
    List<LabelDTO> actualLabels = new ArrayList<>(actual.getLabels());
    for (int i = 0; i < expectedLabels.size(); i++) {
        assertEquals(expectedLabels.get(i), actualLabels.get(i));
    }

    // check output ports
    Assert.assertEquals(expected.getOutputPorts().size(), actual.getOutputPorts().size());
    List<PortDTO> expectedOutputPorts = new ArrayList<>(expected.getOutputPorts());
    List<PortDTO> actualOutputPort = new ArrayList<>(actual.getOutputPorts());
    for (int i = 0; i < expectedOutputPorts.size(); i++) {
        assertEquals(expectedOutputPorts.get(i), actualOutputPort.get(i));
    }

    // check processors
    Assert.assertEquals(expected.getProcessors().size(), actual.getProcessors().size());
    List<ProcessorDTO> expectedProcessors = new ArrayList<>(expected.getProcessors());
    List<ProcessorDTO> actualProcessors = new ArrayList<>(actual.getProcessors());
    for (int i = 0; i < expectedProcessors.size(); i++) {
        assertEquals(expectedProcessors.get(i), actualProcessors.get(i));
    }
}
 
Example 6
Source File: StandardFlowServiceTest.java    From nifi with Apache License 2.0 4 votes vote down vote up
private void assertEquals(FlowSnippetDTO expected, FlowSnippetDTO actual) {
    if (expected == null && actual == null) {
        return;
    }

    // check connections
    Assert.assertEquals(expected.getConnections().size(), actual.getConnections().size());
    List<ConnectionDTO> expectedConnections = new ArrayList<>(expected.getConnections());
    List<ConnectionDTO> actualConnections = new ArrayList<>(actual.getConnections());
    for (int i = 0; i < expectedConnections.size(); i++) {
        assertEquals(expectedConnections.get(i), actualConnections.get(i));
    }

    // check groups
    Assert.assertEquals(expected.getProcessGroups().size(), actual.getProcessGroups().size());
    List<ProcessGroupDTO> expectedProcessGroups = new ArrayList<>(expected.getProcessGroups());
    List<ProcessGroupDTO> actualProcessGroups = new ArrayList<>(actual.getProcessGroups());
    for (int i = 0; i < expectedProcessGroups.size(); i++) {
        assertEquals(expectedProcessGroups.get(i), actualProcessGroups.get(i));
    }

    // check input ports
    Assert.assertEquals(expected.getInputPorts().size(), actual.getInputPorts().size());
    List<PortDTO> expectedInputPorts = new ArrayList<>(expected.getInputPorts());
    List<PortDTO> actualInputPort = new ArrayList<>(actual.getInputPorts());
    for (int i = 0; i < expectedInputPorts.size(); i++) {
        assertEquals(expectedInputPorts.get(i), actualInputPort.get(i));
    }

    // check labels
    Assert.assertEquals(expected.getLabels().size(), actual.getLabels().size());
    List<LabelDTO> expectedLabels = new ArrayList<>(expected.getLabels());
    List<LabelDTO> actualLabels = new ArrayList<>(actual.getLabels());
    for (int i = 0; i < expectedLabels.size(); i++) {
        assertEquals(expectedLabels.get(i), actualLabels.get(i));
    }

    // check output ports
    Assert.assertEquals(expected.getOutputPorts().size(), actual.getOutputPorts().size());
    List<PortDTO> expectedOutputPorts = new ArrayList<>(expected.getOutputPorts());
    List<PortDTO> actualOutputPort = new ArrayList<>(actual.getOutputPorts());
    for (int i = 0; i < expectedOutputPorts.size(); i++) {
        assertEquals(expectedOutputPorts.get(i), actualOutputPort.get(i));
    }

    // check processors
    Assert.assertEquals(expected.getProcessors().size(), actual.getProcessors().size());
    List<ProcessorDTO> expectedProcessors = new ArrayList<>(expected.getProcessors());
    List<ProcessorDTO> actualProcessors = new ArrayList<>(actual.getProcessors());
    for (int i = 0; i < expectedProcessors.size(); i++) {
        assertEquals(expectedProcessors.get(i), actualProcessors.get(i));
    }
}