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

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


        return new Result<>(productDTOs, count);
    }

    @Override
    public Result<ProductDTO> findByEshop(UriInfo uriInfo, Long eshopId, String order, Integer base, Integer offset) throws NotExistingEntityException {
        Eshop eshop = eshopDAO.findById(Eshop.class, eshopId);
        if (eshop == null) {
            throw new NotExistingEntityException("E-shop with ID " + eshopId + " does not exist.");
        }

        order = order != null ? order : "name";
        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));
        }
View Full Code Here


    @Autowired
    private FeedReader feedReader;

    @Override
    public EshopDTO create(UriInfo uriInfo, EshopDTO eshopDTO) {
        Eshop eshop = new Eshop(eshopDTO.getName(), eshopDTO.getWeb(), eshopDTO.getFeed());

        try {
            if (eshop.getFeed() != null && !eshop.getFeed().trim().isEmpty()) {
                feedReader.parseFeed(eshop);
            }
        } catch (FeedNotFoundException | FeedParsingException ex) {
            Logger.getLogger(EshopServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
View Full Code Here

        return new EshopDTO(eshop, uriInfo);
    }

    @Override
    public void update(Long id, EshopDTO eshopDTO) throws NotExistingEntityException {
        Eshop eshop = eshopDAO.findById(Eshop.class, id);
        if (eshop == null) {
            throw new NotExistingEntityException("E-shop with ID " + id + " does not exist.");
        }
        eshop.setName(eshopDTO.getName());
        eshop.setWeb(eshopDTO.getWeb());
        eshop.setFeed(eshopDTO.getFeed());
        eshopDAO.update(eshop);
    }
View Full Code Here

        eshopDAO.removeById(Eshop.class, id);
    }

    @Override
    public EshopDTO findById(UriInfo uriInfo, Long id) throws NotExistingEntityException {
        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

    @Autowired
    private UserDAO userDAO;

    public void create(String email) {
        GaeUser user = new GaeUser("panekon1@gmail.com");
        userDAO.persist(user);
    }
View Full Code Here

        User user = (User) authentication.getPrincipal();
       // System.out.println("AUTHENTICATING " + user.getUsername());

        CustomAuthentication gaeAuthentication = new CustomAuthentication(user, authentication.getDetails());

        GaeUser googleUser = userService.findByEmail(user.getUsername());
        if (googleUser == null) {
        //    System.out.println("NOT AUTHENTICATED " + user.getUsername());
            gaeAuthentication.setAuthenticated(false);
        }
View Full Code Here

    @Override
    public Product findByComplexId(Class clazz, Long productId, Class parentClazz, Long eshopId) {
        PersistenceManager pm = createPersistenceManager();
        Key key = KeyFactory.createKey(KeyFactory.createKey(parentClazz.getSimpleName(), eshopId), clazz.getSimpleName(), productId);
        Product product = null;
        try {
            product = (Product) pm.getObjectById(clazz, key);

            // must touch lazily-loaded fields because joins aren't supported
            product.getEshop().getName();
            product.getCategory();

            Set<Product> similarProducts = new HashSet<>();
            for (Key similarProductKey : product.getSimilarProductKeys()) {
                similarProducts.add((Product) pm.getObjectById(clazz, similarProductKey));
            }
            product.setSimilarProducts(similarProducts);
        } catch (JDOObjectNotFoundException e) {
            return null;
        } finally {
            pm.close();
        }
View Full Code Here

                if (images.getLength() > 0) {
                    Element imageEl = (Element) images.item(0);
                    imageURL = imageEl.getTextContent();
                }

                eshop.addProduct(new Product(name, description, null, eshop, url, price, priceWithVAT, imageURL));
            }

        } catch (ParserConfigurationException | SAXException ex) {
            throw new FeedParsingException(ex.getMessage());
        } catch (IOException ex) {
View Full Code Here

            if (category == null) {
                throw new NotExistingEntityException("Category with ID " + productDTO.getCategory().getId() + " does not exist.");
            }
        }

        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

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

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

        Category category = null;
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.