use of com.thinkbiganalytics.feedmgr.rest.model.TemplateDtoWrapper in project kylo by Teradata.
the class TemplatesRestController method getUnregisteredTemplates.
/**
* This will populate the select drop down when a user asks to register a new template
*/
@GET
@Path("/unregistered")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Gets the list of unregistered templates.")
@ApiResponses({ @ApiResponse(code = 200, message = "Returns the templates.", response = TemplateDtoWrapper.class, responseContainer = "Set"), @ApiResponse(code = 500, message = "NiFi is unavailable.", response = RestResponseStatus.class) })
public Response getUnregisteredTemplates(@QueryParam("includeDetails") boolean includeDetails) {
Set<TemplateDTO> nifiTemplates = nifiRestClient.getTemplates(includeDetails);
// List<RegisteredTemplate> registeredTemplates = metadataService.getRegisteredTemplates();
Set<TemplateDtoWrapper> dtos = new HashSet<>();
for (final TemplateDTO dto : nifiTemplates) {
RegisteredTemplate match = registeredTemplateService.findRegisteredTemplate(RegisteredTemplateRequest.requestByNiFiTemplateProperties(dto.getId(), dto.getName()));
if (match == null) {
dtos.add(new TemplateDtoWrapper(dto));
}
}
return Response.ok(dtos).build();
}
use of com.thinkbiganalytics.feedmgr.rest.model.TemplateDtoWrapper in project kylo by Teradata.
the class TemplatesRestController method getTemplates.
/**
* This will list all the templates registered in Kylo
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Gets the list of all templates.")
@ApiResponses({ @ApiResponse(code = 200, message = "Returns the templates.", response = TemplateDtoWrapper.class, responseContainer = "Set"), @ApiResponse(code = 500, message = "NiFi is unavailable.", response = RestResponseStatus.class) })
public Response getTemplates(@QueryParam("includeDetails") boolean includeDetails) {
Set<TemplateDTO> nifiTemplates = nifiRestClient.getTemplates(includeDetails);
Set<TemplateDtoWrapper> dtos = new HashSet<>();
List<RegisteredTemplate> registeredTemplates = registeredTemplateService.getRegisteredTemplates();
for (final TemplateDTO dto : nifiTemplates) {
RegisteredTemplate match = registeredTemplates.stream().filter(template -> template.getNifiTemplateId().equalsIgnoreCase(dto.getId()) || template.getTemplateName().equalsIgnoreCase(dto.getName())).findFirst().orElse(null);
TemplateDtoWrapper wrapper = new TemplateDtoWrapper(dto);
if (match != null) {
wrapper.setRegisteredTemplateId(match.getId());
}
dtos.add(wrapper);
}
return Response.ok(dtos).build();
}
Aggregations