Search in sources :

Example 1 with TemplateDtoWrapper

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();
}
Also used : TemplateDTO(org.apache.nifi.web.api.dto.TemplateDTO) RegisteredTemplate(com.thinkbiganalytics.feedmgr.rest.model.RegisteredTemplate) TemplateDtoWrapper(com.thinkbiganalytics.feedmgr.rest.model.TemplateDtoWrapper) HashSet(java.util.HashSet) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 2 with TemplateDtoWrapper

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();
}
Also used : TemplateDTO(org.apache.nifi.web.api.dto.TemplateDTO) RegisteredTemplate(com.thinkbiganalytics.feedmgr.rest.model.RegisteredTemplate) TemplateDtoWrapper(com.thinkbiganalytics.feedmgr.rest.model.TemplateDtoWrapper) HashSet(java.util.HashSet) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

RegisteredTemplate (com.thinkbiganalytics.feedmgr.rest.model.RegisteredTemplate)2 TemplateDtoWrapper (com.thinkbiganalytics.feedmgr.rest.model.TemplateDtoWrapper)2 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 HashSet (java.util.HashSet)2 GET (javax.ws.rs.GET)2 Produces (javax.ws.rs.Produces)2 TemplateDTO (org.apache.nifi.web.api.dto.TemplateDTO)2 Path (javax.ws.rs.Path)1