Package org.agoncal.application.petstore.exception

Examples of org.agoncal.application.petstore.exception.ValidationException


    public Order createOrder(final Customer customer, final CreditCard creditCard, final List<CartItem> cartItems) {

        // OMake sure the object is valid
        if (cartItems == null || cartItems.size() == 0)
            throw new ValidationException("Shopping cart is empty"); // TODO exception bean validation

        // Creating the order
        Order order = new Order(em.merge(customer), creditCard, customer.getHomeAddress());

        // From the shopping cart we create the order lines
View Full Code Here


        return order;
    }

    public Order findOrder(Long orderId) {
        if (orderId == null)
            throw new ValidationException("Invalid order id");

        return em.find(Order.class, orderId);
    }
View Full Code Here

        return typedQuery.getResultList();
    }

    public void removeOrder(Order order) {
        if (order == null)
            throw new ValidationException("Order object is null");

        em.remove(em.merge(order));
    }
View Full Code Here

    // ======================================

    public boolean doesLoginAlreadyExist(final String login) {

        if (login == null)
            throw new ValidationException("Login cannot be null");

        // Login has to be unique
        TypedQuery<Customer> typedQuery = em.createNamedQuery(Customer.FIND_BY_LOGIN, Customer.class);
        typedQuery.setParameter("login", login);
        try {
View Full Code Here

    }

    public Customer createCustomer(final Customer customer) {

        if (customer == null)
            throw new ValidationException("Customer object is null");

        em.persist(customer);

        return customer;
    }
View Full Code Here

    }

    public Customer findCustomer(final String login) {

        if (login == null)
            throw new ValidationException("Invalid login");

        TypedQuery<Customer> typedQuery = em.createNamedQuery(Customer.FIND_BY_LOGIN, Customer.class);
        typedQuery.setParameter("login", login);

        try {
View Full Code Here

    }

    public Customer findCustomer(final String login, final String password) {

        if (login == null)
            throw new ValidationException("Invalid login");
        if (password == null)
            throw new ValidationException("Invalid password");

        TypedQuery<Customer> typedQuery = em.createNamedQuery(Customer.FIND_BY_LOGIN_PASSWORD, Customer.class);
        typedQuery.setParameter("login", login);
        typedQuery.setParameter("password", password);
View Full Code Here

    public Customer updateCustomer(final Customer customer) {

        // Make sure the object is valid
        if (customer == null)
            throw new ValidationException("Customer object is null");

        // Update the object in the database
        em.merge(customer);

        return customer;
View Full Code Here

        return customer;
    }

    public void removeCustomer(final Customer customer) {
        if (customer == null)
            throw new ValidationException("Customer object is null");

        em.remove(em.merge(customer));
    }
View Full Code Here

    // =              Public Methods        =
    // ======================================

    public Category findCategory(Long categoryId) {
        if (categoryId == null)
            throw new ValidationException("Invalid category id");

        return em.find(Category.class, categoryId);
    }
View Full Code Here

TOP

Related Classes of org.agoncal.application.petstore.exception.ValidationException

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.