use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class StandardControllerServiceDAO method createControllerService.
@Override
public ControllerServiceNode createControllerService(final ControllerServiceDTO controllerServiceDTO) {
// ensure the type is specified
if (controllerServiceDTO.getType() == null) {
throw new IllegalArgumentException("The controller service type must be specified.");
}
try {
// create the controller service
final ControllerServiceNode controllerService = serviceProvider.createControllerService(controllerServiceDTO.getType(), controllerServiceDTO.getId(), BundleUtils.getBundle(controllerServiceDTO.getType(), controllerServiceDTO.getBundle()), Collections.emptySet(), true);
// ensure we can perform the update
verifyUpdate(controllerService, controllerServiceDTO);
// perform the update
configureControllerService(controllerService, controllerServiceDTO);
final String groupId = controllerServiceDTO.getParentGroupId();
if (groupId == null) {
flowController.addRootControllerService(controllerService);
} else {
final ProcessGroup group;
if (groupId.equals(ROOT_GROUP_ID_ALIAS)) {
group = flowController.getGroup(flowController.getRootGroupId());
} else {
group = flowController.getGroup(flowController.getRootGroupId()).findProcessGroup(groupId);
}
if (group == null) {
throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId));
}
group.addControllerService(controllerService);
}
return controllerService;
} catch (final ControllerServiceInstantiationException csie) {
throw new NiFiCoreException(csie.getMessage(), csie);
}
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class StandardFunnelDAO method locateFunnel.
private Funnel locateFunnel(final String funnelId) {
final ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId());
final Funnel funnel = rootGroup.findFunnel(funnelId);
if (funnel == null) {
throw new ResourceNotFoundException(String.format("Unable to find funnel with id '%s'.", funnelId));
} else {
return funnel;
}
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class StandardInputPortDAO method createPort.
@Override
public Port createPort(String groupId, PortDTO portDTO) {
if (isNotNull(portDTO.getParentGroupId()) && !flowController.areGroupsSame(groupId, portDTO.getParentGroupId())) {
throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the InputPort is being added.");
}
// ensure the name has been specified
if (portDTO.getName() == null) {
throw new IllegalArgumentException("Port name must be specified.");
}
// get the desired group
ProcessGroup group = locateProcessGroup(flowController, groupId);
// determine if this is the root group
Port port;
if (group.getParent() == null) {
port = flowController.createRemoteInputPort(portDTO.getId(), portDTO.getName());
} else {
port = flowController.createLocalInputPort(portDTO.getId(), portDTO.getName());
}
// ensure we can perform the update before we add the processor to the flow
verifyUpdate(port, portDTO);
// configure
if (portDTO.getPosition() != null) {
port.setPosition(new Position(portDTO.getPosition().getX(), portDTO.getPosition().getY()));
}
port.setComments(portDTO.getComments());
// add the port
group.addInputPort(port);
return port;
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class StandardLabelDAO method createLabel.
@Override
public Label createLabel(String groupId, LabelDTO labelDTO) {
if (labelDTO.getParentGroupId() != null && !flowController.areGroupsSame(groupId, labelDTO.getParentGroupId())) {
throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the Label is being added.");
}
// get the desired group
ProcessGroup group = locateProcessGroup(flowController, groupId);
// create the label
Label label = flowController.createLabel(labelDTO.getId(), labelDTO.getLabel());
if (labelDTO.getPosition() != null) {
label.setPosition(new Position(labelDTO.getPosition().getX(), labelDTO.getPosition().getY()));
}
if (labelDTO.getWidth() != null && labelDTO.getHeight() != null) {
label.setSize(new Size(labelDTO.getWidth(), labelDTO.getHeight()));
}
label.setStyle(labelDTO.getStyle());
// add the label
group.addLabel(label);
return label;
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class StandardLabelDAO method locateLabel.
private Label locateLabel(final String labelId) {
final ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId());
final Label label = rootGroup.findLabel(labelId);
if (label == null) {
throw new ResourceNotFoundException(String.format("Unable to find label with id '%s'.", labelId));
} else {
return label;
}
}
Aggregations