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

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


    @Path("/{eshopId:\\d+}/product/")
    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response createProduct(@Context UriInfo uriInfo, @PathParam("eshopId") Long eshopId, ProductDTO productDTO) {
        try {
            ProductDTO product = productService.create(uriInfo, eshopId, productDTO);
            return Response.status(Response.Status.CREATED)
                    .header("Location", product.getUri()).build();
        } catch (NotExistingEntityException ex) {
            throw new NotFoundException(ex.getMessage());
        }
    }
View Full Code Here


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

        Product product = new Product(productDTO.getName(), productDTO.getDescription(), category, eshop, productDTO.getUrl(), productDTO.getPrice(), productDTO.getPriceWithVAT(), productDTO.getImageURL());
        eshop.addProduct(product);

        eshopDAO.persist(eshop);
        return new ProductDTO(product, uriInfo);
    }
View Full Code Here

        Product product = productDAO.findByComplexId(Product.class, productId, Eshop.class, eshopId);
        if (product == null) {
            throw new NotExistingEntityException("Product with ID " + productId + " does not exist.");
        }

        return new ProductDTO(product, uriInfo, true);
    }
View Full Code Here

        List<Product> products = productDAO.findBy(Product.class, searchString, category, priceFrom, priceTo, order, true, base, offset);
        long count = productDAO.findByCount(Product.class, searchString, category, priceFrom, priceTo);

        List<ProductDTO> productDTOs = new ArrayList<>();
        for (Product product : products) {
            productDTOs.add(new ProductDTO(product, uriInfo));
        }

        return new Result<>(productDTOs, count);
    }
View Full Code Here

        List<Product> products = productDAO.findAll(Product.class, order, true, base, offset);
        long count = productDAO.findAllCount(Product.class);

        List<ProductDTO> productDTOs = new ArrayList<>();
        for (Product product : products) {
            productDTOs.add(new ProductDTO(product, uriInfo));
        }

        return new Result<>(productDTOs, count);
    }
View Full Code Here

        List<Product> products = productDAO.findByProperty(Product.class, "eshop", Key.class, eshop.getKey(), order, true, base, offset);
        long count = productDAO.findByPropertyCount(Product.class, "eshop", Key.class, eshop.getKey());

        List<ProductDTO> productDTOs = new ArrayList<>();
        for (Product product : products) {
            productDTOs.add(new ProductDTO(product, uriInfo));
        }

        return new Result<>(productDTOs, count);
    }
View Full Code Here

        List<Product> products = productDAO.findByProperty(Product.class, "category", Key.class, category.getKey(), order, true, base, offset);
        long count = productDAO.findByPropertyCount(Product.class, "category", Key.class, category.getKey());

        List<ProductDTO> productDTOs = new ArrayList<>();
        for (Product product : products) {
            productDTOs.add(new ProductDTO(product, uriInfo));
        }

        return new Result<>(productDTOs, count);
    }
View Full Code Here

    @Autowired
    private CategoryDAO categoryDAO;

    @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

        return new CategoryDTO(category, uriInfo);
    }

    @Override
    public void update(Long id, CategoryDTO categoryDTO) throws NotExistingEntityException {
        Category category = categoryDAO.findById(Category.class, id);
        if (category == null) {
            throw new NotExistingEntityException("Category with ID " + id + " does not exist.");
        }
        category.setName(categoryDTO.getName());
        categoryDAO.update(category);
    }
View Full Code Here

TOP

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

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.