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

The following examples show how to use org.apache.nifi.web.api.dto.FlowSnippetDTO#setProcessGroups() . 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: FlowFromDOMFactory.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
public static ProcessGroupDTO getProcessGroup(final String parentId, final Element element, final StringEncryptor encryptor, final FlowEncodingVersion encodingVersion) {
    final ProcessGroupDTO dto = new ProcessGroupDTO();
    final String groupId = getString(element, "id");
    dto.setId(groupId);
    dto.setParentGroupId(parentId);
    dto.setName(getString(element, "name"));
    dto.setPosition(getPosition(DomUtils.getChild(element, "position")));
    dto.setComments(getString(element, "comment"));

    final Set<ProcessorDTO> processors = new HashSet<>();
    final Set<ConnectionDTO> connections = new HashSet<>();
    final Set<FunnelDTO> funnels = new HashSet<>();
    final Set<PortDTO> inputPorts = new HashSet<>();
    final Set<PortDTO> outputPorts = new HashSet<>();
    final Set<LabelDTO> labels = new HashSet<>();
    final Set<ProcessGroupDTO> processGroups = new HashSet<>();
    final Set<RemoteProcessGroupDTO> remoteProcessGroups = new HashSet<>();

    NodeList nodeList = DomUtils.getChildNodesByTagName(element, "processor");
    for (int i = 0; i < nodeList.getLength(); i++) {
        processors.add(getProcessor((Element) nodeList.item(i), encryptor));
    }

    nodeList = DomUtils.getChildNodesByTagName(element, "funnel");
    for (int i = 0; i < nodeList.getLength(); i++) {
        funnels.add(getFunnel((Element) nodeList.item(i)));
    }

    nodeList = DomUtils.getChildNodesByTagName(element, "inputPort");
    for (int i = 0; i < nodeList.getLength(); i++) {
        inputPorts.add(getPort((Element) nodeList.item(i)));
    }

    nodeList = DomUtils.getChildNodesByTagName(element, "outputPort");
    for (int i = 0; i < nodeList.getLength(); i++) {
        outputPorts.add(getPort((Element) nodeList.item(i)));
    }

    nodeList = DomUtils.getChildNodesByTagName(element, "label");
    for (int i = 0; i < nodeList.getLength(); i++) {
        labels.add(getLabel((Element) nodeList.item(i)));
    }

    nodeList = DomUtils.getChildNodesByTagName(element, "processGroup");
    for (int i = 0; i < nodeList.getLength(); i++) {
        processGroups.add(getProcessGroup(groupId, (Element) nodeList.item(i), encryptor, encodingVersion));
    }

    nodeList = DomUtils.getChildNodesByTagName(element, "remoteProcessGroup");
    for (int i = 0; i < nodeList.getLength(); i++) {
        remoteProcessGroups.add(getRemoteProcessGroup((Element) nodeList.item(i), encryptor));
    }

    nodeList = DomUtils.getChildNodesByTagName(element, "connection");
    for (int i = 0; i < nodeList.getLength(); i++) {
        connections.add(getConnection((Element) nodeList.item(i)));
    }

    final FlowSnippetDTO groupContents = new FlowSnippetDTO();
    groupContents.setConnections(connections);
    groupContents.setFunnels(funnels);
    groupContents.setInputPorts(inputPorts);
    groupContents.setLabels(labels);
    groupContents.setOutputPorts(outputPorts);
    groupContents.setProcessGroups(processGroups);
    groupContents.setProcessors(processors);
    groupContents.setRemoteProcessGroups(remoteProcessGroups);

    dto.setContents(groupContents);
    return dto;
}
 
Example 2
Source File: FlowFromDOMFactory.java    From nifi with Apache License 2.0 4 votes vote down vote up
public static ProcessGroupDTO getProcessGroup(final String parentId, final Element element, final StringEncryptor encryptor, final FlowEncodingVersion encodingVersion) {
    final ProcessGroupDTO dto = new ProcessGroupDTO();
    final String groupId = getString(element, "id");
    dto.setId(groupId);
    dto.setVersionedComponentId(getString(element, "versionedComponentId"));
    dto.setParentGroupId(parentId);
    dto.setName(getString(element, "name"));
    dto.setPosition(getPosition(DomUtils.getChild(element, "position")));
    dto.setComments(getString(element, "comment"));
    dto.setFlowfileConcurrency(getString(element, "flowfileConcurrency"));
    dto.setFlowfileOutboundPolicy(getString(element, "flowfileOutboundPolicy"));

    final Map<String, String> variables = new HashMap<>();
    final NodeList variableList = DomUtils.getChildNodesByTagName(element, "variable");
    for (int i = 0; i < variableList.getLength(); i++) {
        final Element variableElement = (Element) variableList.item(i);
        final String name = variableElement.getAttribute("name");
        final String value = variableElement.getAttribute("value");
        variables.put(name, value);
    }
    dto.setVariables(variables);

    final Element versionControlInfoElement = DomUtils.getChild(element, "versionControlInformation");
    dto.setVersionControlInformation(getVersionControlInformation(versionControlInfoElement));

    final String parameterContextId = getString(element, "parameterContextId");
    final ParameterContextReferenceEntity parameterContextReference = new ParameterContextReferenceEntity();
    parameterContextReference.setId(parameterContextId);
    dto.setParameterContext(parameterContextReference);

    final Set<ProcessorDTO> processors = new HashSet<>();
    final Set<ConnectionDTO> connections = new HashSet<>();
    final Set<FunnelDTO> funnels = new HashSet<>();
    final Set<PortDTO> inputPorts = new HashSet<>();
    final Set<PortDTO> outputPorts = new HashSet<>();
    final Set<LabelDTO> labels = new HashSet<>();
    final Set<ProcessGroupDTO> processGroups = new HashSet<>();
    final Set<RemoteProcessGroupDTO> remoteProcessGroups = new HashSet<>();

    NodeList nodeList = DomUtils.getChildNodesByTagName(element, "processor");
    for (int i = 0; i < nodeList.getLength(); i++) {
        processors.add(getProcessor((Element) nodeList.item(i), encryptor, encodingVersion));
    }

    nodeList = DomUtils.getChildNodesByTagName(element, "funnel");
    for (int i = 0; i < nodeList.getLength(); i++) {
        funnels.add(getFunnel((Element) nodeList.item(i)));
    }

    nodeList = DomUtils.getChildNodesByTagName(element, "inputPort");
    for (int i = 0; i < nodeList.getLength(); i++) {
        inputPorts.add(getPort((Element) nodeList.item(i)));
    }

    nodeList = DomUtils.getChildNodesByTagName(element, "outputPort");
    for (int i = 0; i < nodeList.getLength(); i++) {
        outputPorts.add(getPort((Element) nodeList.item(i)));
    }

    nodeList = DomUtils.getChildNodesByTagName(element, "label");
    for (int i = 0; i < nodeList.getLength(); i++) {
        labels.add(getLabel((Element) nodeList.item(i)));
    }

    nodeList = DomUtils.getChildNodesByTagName(element, "processGroup");
    for (int i = 0; i < nodeList.getLength(); i++) {
        processGroups.add(getProcessGroup(groupId, (Element) nodeList.item(i), encryptor, encodingVersion));
    }

    nodeList = DomUtils.getChildNodesByTagName(element, "remoteProcessGroup");
    for (int i = 0; i < nodeList.getLength(); i++) {
        remoteProcessGroups.add(getRemoteProcessGroup((Element) nodeList.item(i), encryptor));
    }

    nodeList = DomUtils.getChildNodesByTagName(element, "connection");
    for (int i = 0; i < nodeList.getLength(); i++) {
        connections.add(getConnection((Element) nodeList.item(i)));
    }

    final FlowSnippetDTO groupContents = new FlowSnippetDTO();
    groupContents.setConnections(connections);
    groupContents.setFunnels(funnels);
    groupContents.setInputPorts(inputPorts);
    groupContents.setLabels(labels);
    groupContents.setOutputPorts(outputPorts);
    groupContents.setProcessGroups(processGroups);
    groupContents.setProcessors(processors);
    groupContents.setRemoteProcessGroups(remoteProcessGroups);

    dto.setContents(groupContents);
    return dto;
}