Java Code Examples for org.apache.nifi.web.api.dto.ProcessGroupDTO#setParameterContext()

The following examples show how to use org.apache.nifi.web.api.dto.ProcessGroupDTO#setParameterContext() . 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: PGSetParamContext.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public VoidResult doExecute(final NiFiClient client, final Properties properties)
        throws NiFiClientException, IOException, MissingOptionException, CommandException {

    final String pgId = getRequiredArg(properties, CommandOption.PG_ID);
    final String paramContextId = getRequiredArg(properties, CommandOption.PARAM_CONTEXT_ID);

    final ProcessGroupClient pgClient = client.getProcessGroupClient();
    final ProcessGroupEntity pgEntity = pgClient.getProcessGroup(pgId);

    final ParameterContextReferenceEntity parameterContextReference = new ParameterContextReferenceEntity();
    parameterContextReference.setId(paramContextId);

    final ProcessGroupDTO updatedDTO = new ProcessGroupDTO();
    updatedDTO.setId(pgId);
    updatedDTO.setParameterContext(parameterContextReference);

    final ProcessGroupEntity updatedEntity = new ProcessGroupEntity();
    updatedEntity.setId(pgId);
    updatedEntity.setComponent(updatedDTO);
    updatedEntity.setRevision(pgEntity.getRevision());

    pgClient.updateProcessGroup(updatedEntity);
    return VoidResult.getInstance();
}
 
Example 2
Source File: TemplateUtils.java    From nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Scrubs process groups prior to saving.
 *
 * @param processGroups groups
 */
private static void scrubProcessGroups(final Set<ProcessGroupDTO> processGroups) {
    // go through each process group
    for (final ProcessGroupDTO processGroupDTO : processGroups) {
        processGroupDTO.setActiveRemotePortCount(null);
        processGroupDTO.setDisabledCount(null);
        processGroupDTO.setInactiveRemotePortCount(null);
        processGroupDTO.setLocalInputPortCount(null);
        processGroupDTO.setPublicInputPortCount(null);
        processGroupDTO.setInvalidCount(null);
        processGroupDTO.setLocalOutputPortCount(null);
        processGroupDTO.setPublicOutputPortCount(null);
        processGroupDTO.setRunningCount(null);
        processGroupDTO.setStoppedCount(null);
        processGroupDTO.setUpToDateCount(null);
        processGroupDTO.setLocallyModifiedCount(null);
        processGroupDTO.setStaleCount(null);
        processGroupDTO.setLocallyModifiedAndStaleCount(null);
        processGroupDTO.setSyncFailureCount(null);
        processGroupDTO.setVersionControlInformation(null);
        processGroupDTO.setParameterContext(null);

        scrubSnippet(processGroupDTO.getContents());
    }
}
 
Example 3
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;
}