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

The following examples show how to use org.apache.nifi.web.api.dto.ProcessGroupDTO#getParameterContext() . 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: PGGetParamContext.java    From nifi with Apache License 2.0 6 votes vote down vote up
private String getParamContextId(final ProcessGroupDTO processGroup) {
    if (processGroup == null) {
        return "";
    }

    final ParameterContextReferenceEntity parameterContextReference = processGroup.getParameterContext();
    if (parameterContextReference == null) {
        return "";
    }

    final String paramContextId = parameterContextReference.getId();
    if (StringUtils.isBlank(paramContextId)) {
        return "";
    }

    return paramContextId;
}
 
Example 2
Source File: ProcessGroupEntityMerger.java    From nifi with Apache License 2.0 6 votes vote down vote up
private static void mergeDtos(final ProcessGroupDTO clientDto, final Map<NodeIdentifier, ProcessGroupDTO> dtoMap) {
    // if unauthorized for the client dto, simple return
    if (clientDto == null) {
        return;
    }

    // get the parameter context if configured
    final ParameterContextReferenceEntity clientParameterContextEntity = clientDto.getParameterContext();

    // if this process group is bound to a parameter context, merge the permissions from the other nodes
    if (clientParameterContextEntity != null) {
        for (Map.Entry<NodeIdentifier, ProcessGroupDTO> entry : dtoMap.entrySet()) {
            final ProcessGroupDTO dto = entry.getValue();
            final ParameterContextReferenceEntity parameterContextReferenceEntity = dto.getParameterContext();

            PermissionsDtoMerger.mergePermissions(clientParameterContextEntity.getPermissions(), parameterContextReferenceEntity.getPermissions());
        }
    }
}
 
Example 3
Source File: StandardFlowSynchronizer.java    From nifi with Apache License 2.0 6 votes vote down vote up
private static boolean isEmpty(final ProcessGroupDTO dto) {
    if (dto == null) {
        return true;
    }

    final FlowSnippetDTO contents = dto.getContents();
    if (contents == null) {
        return true;
    }

    final String parameterContextId = dto.getParameterContext() == null ? null : dto.getParameterContext().getId();

    return CollectionUtils.isEmpty(contents.getProcessors())
            && CollectionUtils.isEmpty(contents.getConnections())
            && CollectionUtils.isEmpty(contents.getFunnels())
            && CollectionUtils.isEmpty(contents.getLabels())
            && CollectionUtils.isEmpty(contents.getInputPorts())
            && CollectionUtils.isEmpty(contents.getOutputPorts())
            && CollectionUtils.isEmpty(contents.getProcessGroups())
            && CollectionUtils.isEmpty(contents.getRemoteProcessGroups())
            && parameterContextId == null;
}
 
Example 4
Source File: StandardProcessGroupDAO.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public ProcessGroup createProcessGroup(String parentGroupId, ProcessGroupDTO processGroup) {
    final FlowManager flowManager = flowController.getFlowManager();
    if (processGroup.getParentGroupId() != null && !flowManager.areGroupsSame(processGroup.getParentGroupId(), parentGroupId)) {
        throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the Process Group is being added.");
    }

    // get the parent group
    ProcessGroup parentGroup = locateProcessGroup(flowController, parentGroupId);

    // create the process group
    ProcessGroup group = flowManager.createProcessGroup(processGroup.getId());
    if (processGroup.getName() != null) {
        group.setName(processGroup.getName());
    }
    if (processGroup.getPosition() != null) {
        group.setPosition(new Position(processGroup.getPosition().getX(), processGroup.getPosition().getY()));
    }

    final ParameterContextReferenceEntity parameterContextReference = processGroup.getParameterContext();
    if (parameterContextReference != null && parameterContextReference.getId() != null) {
        final ParameterContext parameterContext = flowController.getFlowManager().getParameterContextManager().getParameterContext(parameterContextReference.getId());
        group.setParameterContext(parameterContext);
    }

    // add the process group
    group.setParent(parentGroup);
    parentGroup.addProcessGroup(group);

    return group;
}
 
Example 5
Source File: StandardProcessGroupDAO.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void verifyUpdate(final ProcessGroupDTO processGroup) {
    final ParameterContextReferenceEntity parameterContextReference = processGroup.getParameterContext();
    if (parameterContextReference == null) {
        return;
    }

    final ParameterContext parameterContext = locateParameterContext(parameterContextReference.getId());
    final ProcessGroup group = locateProcessGroup(flowController, processGroup.getId());
    group.verifyCanSetParameterContext(parameterContext);
}
 
Example 6
Source File: StandardFlowSynchronizer.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the process group corresponding to the specified DTO. Any field
 * in DTO that is <code>null</code> (with the exception of the required ID)
 * will be ignored.
 *
 * @throws IllegalStateException if no process group can be found with the
 * ID of DTO or with the ID of the DTO's parentGroupId, if the template ID
 * specified is invalid, or if the DTO's Parent Group ID changes but the
 * parent group has incoming or outgoing connections
 *
 * @throws NullPointerException if the DTO or its ID is null
 */
private void updateProcessGroup(final ProcessGroup group, final ProcessGroupDTO dto, final ParameterContextManager parameterContextManager) {
    final String name = dto.getName();
    final PositionDTO position = dto.getPosition();
    final String comments = dto.getComments();
    final String flowfileConcurrencyName = dto.getFlowfileConcurrency();
    final String flowfileOutboundPolicyName = dto.getFlowfileOutboundPolicy();

    if (name != null) {
        group.setName(name);
    }
    if (position != null) {
        group.setPosition(toPosition(position));
    }
    if (comments != null) {
        group.setComments(comments);
    }

    if (flowfileConcurrencyName == null) {
        group.setFlowFileConcurrency(FlowFileConcurrency.UNBOUNDED);
    } else {
        group.setFlowFileConcurrency(FlowFileConcurrency.valueOf(flowfileConcurrencyName));
    }

    if (flowfileOutboundPolicyName == null) {
        group.setFlowFileOutboundPolicy(FlowFileOutboundPolicy.STREAM_WHEN_AVAILABLE);
    } else {
        group.setFlowFileOutboundPolicy(FlowFileOutboundPolicy.valueOf(flowfileOutboundPolicyName));
    }

    final ParameterContextReferenceEntity parameterContextReference = dto.getParameterContext();
    if (parameterContextReference != null && parameterContextReference.getId() != null) {
        final String parameterContextId = parameterContextReference.getId();
        final ParameterContext parameterContext = parameterContextManager.getParameterContext(parameterContextId);
        if (!Objects.equals(parameterContext, group.getParameterContext())) {
            group.setParameterContext(parameterContext);
        }
    }

}
 
Example 7
Source File: StandardProcessGroupDAO.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public ProcessGroup updateProcessGroup(ProcessGroupDTO processGroupDTO) {
    final ProcessGroup group = locateProcessGroup(flowController, processGroupDTO.getId());

    final String name = processGroupDTO.getName();
    final String comments = processGroupDTO.getComments();
    final String concurrencyName = processGroupDTO.getFlowfileConcurrency();
    final FlowFileConcurrency flowFileConcurrency = concurrencyName == null ? null : FlowFileConcurrency.valueOf(concurrencyName);

    final String outboundPolicyName = processGroupDTO.getFlowfileOutboundPolicy();
    final FlowFileOutboundPolicy flowFileOutboundPolicy = outboundPolicyName == null ? null : FlowFileOutboundPolicy.valueOf(outboundPolicyName);

    final ParameterContextReferenceEntity parameterContextReference = processGroupDTO.getParameterContext();
    if (parameterContextReference != null) {
        final String parameterContextId = parameterContextReference.getId();
        if (parameterContextId == null) {
            group.setParameterContext(null);
        } else {
            final ParameterContext parameterContext = flowController.getFlowManager().getParameterContextManager().getParameterContext(parameterContextId);
            if (parameterContext == null) {
                throw new IllegalStateException("Cannot set Process Group's Parameter Context because no Parameter Context exists with ID " + parameterContextId);
            }

            group.setParameterContext(parameterContext);
        }
    }

    if (isNotNull(name)) {
        group.setName(name);
    }
    if (isNotNull(processGroupDTO.getPosition())) {
        group.setPosition(new Position(processGroupDTO.getPosition().getX(), processGroupDTO.getPosition().getY()));
        final ProcessGroup parent = group.getParent();
        if (parent != null) {
            parent.onComponentModified();
        }
    }
    if (isNotNull(comments)) {
        group.setComments(comments);
    }
    if (flowFileConcurrency != null) {
        group.setFlowFileConcurrency(flowFileConcurrency);
    }
    if (flowFileOutboundPolicy != null) {
        group.setFlowFileOutboundPolicy(flowFileOutboundPolicy);
    }
    group.onComponentModified();
    return group;
}