/** * Returns a specific model by id. * * @param id the of the matching model * @return the request document as JSON */ @GET @Path("sales/{id}") public Response read(@PathParam("id") final String id, @Context final SecurityContext context) { ResponseBuilder response = null; final SaleData sale = mapper.fromEntity(dao.get(id)); if (sale == null) { response = Response.status(Status.NOT_FOUND); } else { response = Response.ok().entity(sale); } return response.build(); }
/** * Example method to get multiple values. Shows use of a query param. * * @param title the title of models to find * @return a Response containing JSON data. */ @GET @Path("sales") public Response getAllValues( @QueryParam("page") final int page, @QueryParam("pageSize") final int pageSize, @QueryParam("orderby") final String orderby) { LOGGER.info("Count=" + dao.count()); final HouseSaleEntity[] all = dao.get(pageSize, page, orderby); LOGGER.info( "getAllValues(" + page + ", " + pageSize + ", " + orderby + "). Returned " + all.length + " values."); final SaleDataPage salePage = mapper.getPage(pageSize, page, all); return Response.ok().entity(salePage).build(); }