Search in sources :

Example 1 with RuleTemplateDTO

use of org.eclipse.smarthome.automation.dto.RuleTemplateDTO in project smarthome by eclipse.

the class TemplateResource method getAll.

@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get all available templates.", response = Template.class, responseContainer = "Collection")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = Template.class, responseContainer = "Collection") })
public Response getAll(@HeaderParam("Accept-Language") @ApiParam(value = "language") String language) {
    Locale locale = LocaleUtil.getLocale(language);
    Collection<RuleTemplateDTO> result = templateRegistry.getAll(locale).stream().map(template -> RuleTemplateDTOMapper.map(template)).collect(Collectors.toList());
    return Response.ok(result).build();
}
Also used : Locale(java.util.Locale) PathParam(javax.ws.rs.PathParam) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Path(javax.ws.rs.Path) ApiParam(io.swagger.annotations.ApiParam) ApiResponses(io.swagger.annotations.ApiResponses) ApiOperation(io.swagger.annotations.ApiOperation) MediaType(javax.ws.rs.core.MediaType) RuleTemplateDTO(org.eclipse.smarthome.automation.dto.RuleTemplateDTO) Locale(java.util.Locale) RuleTemplateDTOMapper(org.eclipse.smarthome.automation.dto.RuleTemplateDTOMapper) HeaderParam(javax.ws.rs.HeaderParam) Api(io.swagger.annotations.Api) Status(javax.ws.rs.core.Response.Status) RESTResource(org.eclipse.smarthome.io.rest.RESTResource) Context(javax.ws.rs.core.Context) Collection(java.util.Collection) Collectors(java.util.stream.Collectors) RuleTemplate(org.eclipse.smarthome.automation.template.RuleTemplate) Template(org.eclipse.smarthome.automation.template.Template) TemplateRegistry(org.eclipse.smarthome.automation.template.TemplateRegistry) Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.annotations.ApiResponse) UriInfo(javax.ws.rs.core.UriInfo) LocaleUtil(org.eclipse.smarthome.io.rest.LocaleUtil) RuleTemplateDTO(org.eclipse.smarthome.automation.dto.RuleTemplateDTO) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

Api (io.swagger.annotations.Api)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiParam (io.swagger.annotations.ApiParam)1 ApiResponse (io.swagger.annotations.ApiResponse)1 ApiResponses (io.swagger.annotations.ApiResponses)1 Collection (java.util.Collection)1 Locale (java.util.Locale)1 Collectors (java.util.stream.Collectors)1 GET (javax.ws.rs.GET)1 HeaderParam (javax.ws.rs.HeaderParam)1 Path (javax.ws.rs.Path)1 PathParam (javax.ws.rs.PathParam)1 Produces (javax.ws.rs.Produces)1 Context (javax.ws.rs.core.Context)1 MediaType (javax.ws.rs.core.MediaType)1 Response (javax.ws.rs.core.Response)1 Status (javax.ws.rs.core.Response.Status)1 UriInfo (javax.ws.rs.core.UriInfo)1 RuleTemplateDTO (org.eclipse.smarthome.automation.dto.RuleTemplateDTO)1 RuleTemplateDTOMapper (org.eclipse.smarthome.automation.dto.RuleTemplateDTOMapper)1