use of com.thinkbiganalytics.metadata.rest.model.data.DatasourceDefinition in project kylo by Teradata.
the class TemplatesRestController method getNiFiTemplateFlowInfo.
/**
* Returns data about the NiFiTemplate and its processors related to the input connections, along with the Datasources in the flow
*/
@POST
@Path("/nifi/{templateId}/flow-info")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Gets the flow for the specified template.")
@ApiResponses({ @ApiResponse(code = 200, message = "Returns the flow.", response = NiFiTemplateFlowResponse.class), @ApiResponse(code = 500, message = "NiFi is unavailable.", response = RestResponseStatus.class) })
public Response getNiFiTemplateFlowInfo(@PathParam("templateId") String templateId, NiFiTemplateFlowRequest flowRequest) {
this.accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.ACCESS_TEMPLATES);
List<TemplateProcessorDatasourceDefinition> templateProcessorDatasourceDefinitions = new ArrayList<>();
NiFiTemplateFlowResponse response = new NiFiTemplateFlowResponse();
response.setRequest(flowRequest);
if (StringUtils.isNotBlank(templateId)) {
List<RegisteredTemplate.FlowProcessor> processors = feedManagerTemplateService.getNiFiTemplateFlowProcessors(templateId, flowRequest.getConnectionInfo());
Set<DatasourceDefinition> defs = datasourceService.getDatasourceDefinitions();
Map<String, DatasourceDefinition> datasourceDefinitionMap = new HashMap<>();
if (defs != null) {
defs.stream().forEach(def -> datasourceDefinitionMap.put(def.getProcessorType(), def));
}
templateProcessorDatasourceDefinitions = processors.stream().filter(processor -> datasourceDefinitionMap.containsKey(processor.getType())).map(p -> {
TemplateProcessorDatasourceDefinition definition = new TemplateProcessorDatasourceDefinition();
definition.setProcessorType(p.getType());
definition.setProcessorName(p.getName());
definition.setProcessorId(p.getId());
definition.setDatasourceDefinition(datasourceDefinitionMap.get(p.getType()));
return definition;
}).collect(Collectors.toList());
response.setProcessors(processors);
response.setTemplateProcessorDatasourceDefinitions(templateProcessorDatasourceDefinitions);
}
return Response.ok(response).build();
}
Aggregations