use of org.apache.nifi.web.api.entity.ProcessGroupFlowEntity in project nifi by apache.
the class StandardNiFiServiceFacade method getProcessGroupFlow.
@Override
public ProcessGroupFlowEntity getProcessGroupFlow(final String groupId) {
// get all identifiers for every child component
final Set<String> identifiers = new HashSet<>();
final ProcessGroup processGroup = processGroupDAO.getProcessGroup(groupId);
processGroup.getProcessors().stream().map(proc -> proc.getIdentifier()).forEach(id -> identifiers.add(id));
processGroup.getConnections().stream().map(conn -> conn.getIdentifier()).forEach(id -> identifiers.add(id));
processGroup.getInputPorts().stream().map(port -> port.getIdentifier()).forEach(id -> identifiers.add(id));
processGroup.getOutputPorts().stream().map(port -> port.getIdentifier()).forEach(id -> identifiers.add(id));
processGroup.getProcessGroups().stream().map(group -> group.getIdentifier()).forEach(id -> identifiers.add(id));
processGroup.getRemoteProcessGroups().stream().map(remoteGroup -> remoteGroup.getIdentifier()).forEach(id -> identifiers.add(id));
processGroup.getRemoteProcessGroups().stream().flatMap(remoteGroup -> remoteGroup.getInputPorts().stream()).map(remoteInputPort -> remoteInputPort.getIdentifier()).forEach(id -> identifiers.add(id));
processGroup.getRemoteProcessGroups().stream().flatMap(remoteGroup -> remoteGroup.getOutputPorts().stream()).map(remoteOutputPort -> remoteOutputPort.getIdentifier()).forEach(id -> identifiers.add(id));
// read lock on every component being accessed in the dto conversion
final ProcessGroupStatus groupStatus = controllerFacade.getProcessGroupStatus(groupId);
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processGroup);
return entityFactory.createProcessGroupFlowEntity(dtoFactory.createProcessGroupFlowDto(processGroup, groupStatus, revisionManager, this::getProcessGroupBulletins), permissions);
}
use of org.apache.nifi.web.api.entity.ProcessGroupFlowEntity in project nifi by apache.
the class PGList method doExecute.
@Override
public ProcessGroupsResult doExecute(final NiFiClient client, final Properties properties) throws NiFiClientException, IOException {
final FlowClient flowClient = client.getFlowClient();
// get the optional id of the parent PG, otherwise fallback to the root group
String parentPgId = getArg(properties, CommandOption.PG_ID);
if (StringUtils.isBlank(parentPgId)) {
parentPgId = flowClient.getRootGroupId();
}
final ProcessGroupFlowEntity processGroupFlowEntity = flowClient.getProcessGroup(parentPgId);
final ProcessGroupFlowDTO processGroupFlowDTO = processGroupFlowEntity.getProcessGroupFlow();
final FlowDTO flowDTO = processGroupFlowDTO.getFlow();
final List<ProcessGroupDTO> processGroups = new ArrayList<>();
if (flowDTO.getProcessGroups() != null) {
flowDTO.getProcessGroups().stream().map(pge -> pge.getComponent()).forEach(dto -> processGroups.add(dto));
}
return new ProcessGroupsResult(getResultType(properties), processGroups);
}
use of org.apache.nifi.web.api.entity.ProcessGroupFlowEntity in project nifi by apache.
the class ITFunnelAccessControl method getRandomFunnel.
private FunnelEntity getRandomFunnel(final NiFiTestUser user) throws Exception {
final String url = helper.getBaseUrl() + "/flow/process-groups/root";
// get the flow
final Response response = user.testGet(url);
// ensure the response was successful
assertEquals(200, response.getStatus());
// unmarshal
final ProcessGroupFlowEntity flowEntity = response.readEntity(ProcessGroupFlowEntity.class);
final FlowDTO flowDto = flowEntity.getProcessGroupFlow().getFlow();
final Set<FunnelEntity> funnels = flowDto.getFunnels();
// ensure the correct number of funnels
assertFalse(funnels.isEmpty());
// use the first funnel as the target
Iterator<FunnelEntity> funnelIter = funnels.iterator();
assertTrue(funnelIter.hasNext());
return funnelIter.next();
}
use of org.apache.nifi.web.api.entity.ProcessGroupFlowEntity in project nifi by apache.
the class ITLabelAccessControl method getRandomLabel.
private LabelEntity getRandomLabel(final NiFiTestUser user) throws Exception {
final String url = helper.getBaseUrl() + "/flow/process-groups/root";
// get the labels
final Response response = user.testGet(url);
// ensure the response was successful
assertEquals(200, response.getStatus());
// unmarshal
final ProcessGroupFlowEntity flowEntity = response.readEntity(ProcessGroupFlowEntity.class);
final FlowDTO flowDto = flowEntity.getProcessGroupFlow().getFlow();
final Set<LabelEntity> labels = flowDto.getLabels();
// ensure the correct number of labels
assertFalse(labels.isEmpty());
// use the first label as the target
Iterator<LabelEntity> labelIter = labels.iterator();
assertTrue(labelIter.hasNext());
return labelIter.next();
}
use of org.apache.nifi.web.api.entity.ProcessGroupFlowEntity in project nifi by apache.
the class ITOutputPortAccessControl method getRandomOutputPort.
private PortEntity getRandomOutputPort(final NiFiTestUser user) throws Exception {
final String url = helper.getBaseUrl() + "/flow/process-groups/root";
// get the output ports
final Response response = user.testGet(url);
// ensure the response was successful
assertEquals(200, response.getStatus());
// unmarshal
final ProcessGroupFlowEntity flowEntity = response.readEntity(ProcessGroupFlowEntity.class);
final FlowDTO flowDto = flowEntity.getProcessGroupFlow().getFlow();
final Set<PortEntity> outputPorts = flowDto.getOutputPorts();
// ensure the correct number of output ports
assertFalse(outputPorts.isEmpty());
// use the first output port as the target
Iterator<PortEntity> outputPortIter = outputPorts.iterator();
assertTrue(outputPortIter.hasNext());
return outputPortIter.next();
}
Aggregations