use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class StandardProcessGroupDAO method updateProcessGroup.
@Override
public ProcessGroup updateProcessGroup(ProcessGroupDTO processGroupDTO) {
final ProcessGroup group = locateProcessGroup(flowController, processGroupDTO.getId());
final String name = processGroupDTO.getName();
final String comments = processGroupDTO.getComments();
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);
}
group.onComponentModified();
return group;
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class StandardProcessorDAO method createProcessor.
@Override
public ProcessorNode createProcessor(final String groupId, ProcessorDTO processorDTO) {
if (processorDTO.getParentGroupId() != null && !flowController.areGroupsSame(groupId, processorDTO.getParentGroupId())) {
throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the Processor is being added.");
}
// ensure the type is specified
if (processorDTO.getType() == null) {
throw new IllegalArgumentException("The processor type must be specified.");
}
// get the group to add the processor to
ProcessGroup group = locateProcessGroup(flowController, groupId);
try {
// attempt to create the processor
ProcessorNode processor = flowController.createProcessor(processorDTO.getType(), processorDTO.getId(), BundleUtils.getBundle(processorDTO.getType(), processorDTO.getBundle()));
// ensure we can perform the update before we add the processor to the flow
verifyUpdate(processor, processorDTO);
// add the processor to the group
group.addProcessor(processor);
// configure the processor
configureProcessor(processor, processorDTO);
return processor;
} catch (ProcessorInstantiationException pse) {
throw new NiFiCoreException(String.format("Unable to create processor of type %s due to: %s", processorDTO.getType(), pse.getMessage()), pse);
} catch (IllegalStateException | ComponentLifeCycleException ise) {
throw new NiFiCoreException(ise.getMessage(), ise);
}
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class StandardProcessorDAO method locateProcessor.
private ProcessorNode locateProcessor(final String processorId) {
final ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId());
final ProcessorNode processor = rootGroup.findProcessor(processorId);
if (processor == null) {
throw new ResourceNotFoundException(String.format("Unable to find processor with id '%s'.", processorId));
} else {
return processor;
}
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class StandardRemoteProcessGroupDAO method locateRemoteProcessGroup.
private RemoteProcessGroup locateRemoteProcessGroup(final String remoteProcessGroupId) {
final ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId());
final RemoteProcessGroup remoteProcessGroup = rootGroup.findRemoteProcessGroup(remoteProcessGroupId);
if (remoteProcessGroup == null) {
throw new ResourceNotFoundException(String.format("Unable to find remote process group with id '%s'.", remoteProcessGroupId));
} else {
return remoteProcessGroup;
}
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class StandardSnippetDAO method updateSnippetComponents.
@Override
public Snippet updateSnippetComponents(final SnippetDTO snippetDTO) {
// verify the action
verifyUpdateSnippetComponent(snippetDTO);
// find the snippet in question
final StandardSnippet snippet = locateSnippet(snippetDTO.getId());
// if the group is changing move it
if (snippetDTO.getParentGroupId() != null && !snippet.getParentGroupId().equals(snippetDTO.getParentGroupId())) {
final ProcessGroup currentProcessGroup = flowController.getGroup(snippet.getParentGroupId());
if (currentProcessGroup == null) {
throw new IllegalArgumentException("The current process group could not be found.");
}
final ProcessGroup newProcessGroup = flowController.getGroup(snippetDTO.getParentGroupId());
if (newProcessGroup == null) {
throw new IllegalArgumentException("The new process group could not be found.");
}
// move the snippet
currentProcessGroup.move(snippet, newProcessGroup);
// update its parent group id
snippet.setParentGroupId(snippetDTO.getParentGroupId());
}
return snippet;
}
Aggregations