Package cz.cvut.fel.wa2.interior.entity

Examples of cz.cvut.fel.wa2.interior.entity.Category


    @POST
    @Path("/")
    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response createCategory(@Context UriInfo uriInfo, CategoryDTO categoryDTO) {
        CategoryDTO category = categoryService.create(uriInfo, categoryDTO);
        return Response.status(Response.Status.CREATED)
                .header("Location", category.getUri()).build();
    }
View Full Code Here


    @GET
    @Path("/{id:\\d+}")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response findCategory(@Context UriInfo uriInfo, @PathParam("id") Long id) {
        try {
            CategoryDTO category = categoryService.findById(uriInfo, id);
            return Response.status(Response.Status.OK).entity(category).build();
        } catch (NotExistingEntityException ex) {
            throw new NotFoundException(ex.getMessage());
        }
    }
View Full Code Here

    @Override
    public CategoryDTO create(UriInfo uriInfo, CategoryDTO categoryDTO) {
        Category category = new Category(categoryDTO.getName());
        categoryDAO.persist(category);
        return new CategoryDTO(category, uriInfo);
    }
View Full Code Here

        Category category = categoryDAO.findById(Category.class, id);
        if (category == null) {
            throw new NotExistingEntityException("Category with ID " + id + " does not exist.");
        }
       
        return new CategoryDTO(category, uriInfo);
    }
View Full Code Here

    public List<CategoryDTO> findAll(UriInfo uriInfo) {
        List<Category> categories = categoryDAO.findAll(Category.class, "name", true);

        List<CategoryDTO> categoryDTOs = new ArrayList<>();
        for (Category category : categories) {
            categoryDTOs.add(new CategoryDTO(category, uriInfo));
        }
        return categoryDTOs;
    }
View Full Code Here

    @POST
    @Path("/")
    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response createEshop(@Context UriInfo uriInfo, EshopDTO eshopDTO) {
        EshopDTO eshop = eshopService.create(uriInfo, eshopDTO);
        return Response.status(Response.Status.CREATED)
                .header("Location", eshop.getUri()).build();
    }
View Full Code Here

    @GET
    @Path("/{id:\\d+}")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response findEshop(@Context UriInfo uriInfo, @PathParam("id") Long id) {
        try {
            EshopDTO eshop = eshopService.findById(uriInfo, id);
            return Response.status(Response.Status.OK).entity(eshop).build();
        } catch (NotExistingEntityException ex) {
            throw new NotFoundException(ex.getMessage());
        }
    }
View Full Code Here

            Logger.getLogger(EshopServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            eshopDAO.persist(eshop);
        }

        return new EshopDTO(eshop, uriInfo);
    }
View Full Code Here

        Eshop eshop = eshopDAO.findById(Eshop.class, id);
        if (eshop == null) {
            throw new NotExistingEntityException("E-shop with ID " + id + " does not exist.");
        }

        return new EshopDTO(eshop, uriInfo);
    }
View Full Code Here

    public List<EshopDTO> findAll(UriInfo uriInfo) {
        List<Eshop> categories = eshopDAO.findAll(Eshop.class, "name", true);

        List<EshopDTO> eshopDTOs = new ArrayList<>();
        for (Eshop eshop : categories) {
            eshopDTOs.add(new EshopDTO(eshop, uriInfo));
        }
        return eshopDTOs;
    }
View Full Code Here

TOP

Related Classes of cz.cvut.fel.wa2.interior.entity.Category

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.