Package cz.muni.fi.pa165.stis.entity

Examples of cz.muni.fi.pa165.stis.entity.Order


    public ShowBorrowReader(final PageParameters parameters) {
  super(parameters);
        BorrowService borrowService = (BorrowService) ApplicationContextProvider.getApplicationContext().getBean("borrowService");
        RepeatingView repeating = new RepeatingView("repeating");
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
        AuthenticatedSession session = ((AuthenticatedSession)Session.get());
        for (BorrowTO borrow : borrowService.findBorrowsByReader(session.getReader())) {
            for (BookTO book: borrow.getTitlesTO()){
                AbstractItem item = new AbstractItem(repeating.newChildId());
                item.add(new Label("title", book.getTitle()));     
                item.add(new Label("author", book.getAuthor()));
                item.add(new Label("borrowdate", dateFormat.format(borrow.getBorrowDate())));
View Full Code Here


            if (list.contains(book)){
                Link link = new Link("edit"){
                      @Override
                      public void onClick() {
                          ReservationService reservationService = (ReservationService) ApplicationContextProvider.getApplicationContext().getBean("reservationService");
                          AuthenticatedSession session = ((AuthenticatedSession)Session.get());
                          ReaderTO reader = session.getReader();
                          BookTO book2 = bookService.findBookById(book.getId());
                          java.util.Date date = new java.util.Date();
                          if (reader != null && book != null){
                              ReservationTO reservation = new ReservationTO(reader, book2,new Timestamp(date.getTime()));
                              reservationService.insertReservation(reservation);
View Full Code Here

       
        RepeatingView repeating = new RepeatingView("repeating");
        add(repeating);
        ReservationService reservationService = (ReservationService) ApplicationContextProvider.getApplicationContext().getBean("reservationService");
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
        AuthenticatedSession session = ((AuthenticatedSession)Session.get());
        List<ReservationTO> list = reservationService.findReservationsByReader(session.getReader());
        if(list != null){
            for (ReservationTO reservation : list) {
                AbstractItem item = new AbstractItem(repeating.newChildId());
                PageParameters pageParameters = new PageParameters();
                item.add(new BookmarkablePageLink<Void>("delete", ShowAllReservation.class, pageParameters));
View Full Code Here

        if (session.getUser()!=null){
            add(new Label("user",session.getUser()));
            add(new Label("login",new Model("")));
           add(new BookmarkablePageLink<>("logout", Logout.class));
           if (session.getCheckAdmin()){
                add(new MenuAdminPanel("menuPanel"));
            }else {
                add(new MenuReaderPanel("menuPanel"));
            }
        }else {
            add(new Label("user",""));
View Full Code Here

            add(new Label("login",new Model("")));
           add(new BookmarkablePageLink<>("logout", Logout.class));
           if (session.getCheckAdmin()){
                add(new MenuAdminPanel("menuPanel"));
            }else {
                add(new MenuReaderPanel("menuPanel"));
            }
        }else {
            add(new Label("user",""));
            add(new BookmarkablePageLink<>("login", Login.class));
            add(new Label("logout",new Model("")));
View Full Code Here

    }
   
    @Test
    public void testCreate() {
        orderService.create(orderTO);
        final Order o = order;
        verify(dao).create(argThat(new BaseMatcher<Order>() {

            @Override
            public boolean matches(Object item) {
                if (!(item instanceof Order)) {
                    return false;
                }
               
                Order no = (Order) item;
                if (!Objects.equals(no.getCarType(), o.getCarType())) {
                    return false;
                }
                if (!Objects.equals(no.getCustomer(), o.getCustomer())) {
                    return false;
                }
                if (!Objects.equals(no.getOrderNewDate(), o.getOrderNewDate())) {
                    return false;
                }
                if (!Objects.equals(no.getOrderPaidDate(), o.getOrderPaidDate())) {
                    return false;
                }
                if (!Objects.equals(no.getOrderServicedDate(), o.getOrderServicedDate())) {
                    return false;
                }
                if (!Objects.equals(no.getTotalPrice(), o.getTotalPrice())) {
                    return false;
                }
                if (!(no.getExtraServices().containsAll(o.getExtraServices()) && o.getExtraServices().containsAll(no.getExtraServices()))) {
                    return false;
                }
                if (no.getTyres() == null || o.getTyres() == null) {
                    if (no.getTyres() != null || o.getTyres() != null) {
                        return false;
                    }
                }
                if (no.getTyres().size() != o.getTyres().size()) {
                    return false;
                }
                for (Map.Entry<TyrePosition, Tyre> me : no.getTyres().entrySet()) {
                    Tyre t = o.getTyres().get(me.getKey());
                    if (!Objects.equals(t, me.getValue())) {
                        return false;
                    }
                }
View Full Code Here

   
    @Test
    public void testFindAll() {
        Customer c = newCustomer("Istvan", "Lelkes", "Hajovna 12", "54544");
        c.setId(22L);
        Order o = newOrder(c, null, null, null, extraServices, tyres, BigDecimal.ZERO);
        order.setId(1L);
        orderTO.setId(1L);
       
        List<Order> orders = Arrays.asList(new Order[] {order, o});
        List<OrderTO> ctos = Arrays.asList(new OrderTO[] {orderTO, mapper.map(o, OrderTO.class)});
View Full Code Here

        assertTrue(res.containsAll(ctos) && ctos.containsAll(res));
    }
   
    @Test
    public void testFindByCustomer() {
        Order o = newOrder(customer, null, null, null, extraServices, tyres, BigDecimal.valueOf(223));
        order.setId(1L);
        orderTO.setId(1L);
       
        List<Order> orders = Arrays.asList(new Order[] {o});
        List<OrderTO> otos = Arrays.asList(new OrderTO[] {mapper.map(o, OrderTO.class)});
View Full Code Here

        return c;
    }
   
    private static Order newOrder(Customer c, Date orderNewDate, Date orderServicedDate,
            Date orderPaidDate, Set<ExtraService> extraServices, Map<TyrePosition, Tyre> tyres, BigDecimal totalPrice) {
        Order o = new Order();
        o.setCustomer(c);
        o.setOrderNewDate(orderNewDate);
        o.setOrderServicedDate(orderServicedDate);
        o.setOrderPaidDate(orderPaidDate);
        o.setTyres(tyres);
        o.setExtraServices(extraServices);
        o.setTotalPrice(totalPrice);
       
        return o;
    }
View Full Code Here

    /**
     * Test of create method, of class OrderDAO.
     */
    @Test
    public void testCreate() {
        Order order = null;
        try {
            dao.create(order);
            fail("Order null and didn't throw exception");
        } catch (DataAccessException ex) {
            //ok
        } catch (Exception ex) {
            fail("Order null and didn't throw appropriate exception");
        }
        order = newOrder(customer, newDate("22.9.2012 12:13:15"), null, null, extraServices, tyres, BigDecimal.valueOf(15.23));
        order.setId(22L);
        try {
            dao.create(order);
            fail("ID not null and didn't throw exception");
        } catch (DataAccessException ex) {
            //ok
        } catch (Exception ex) {
            fail("ID not null and didn't throw appropriate exception");
        }
        order.setId(null);
        dao.create(order);
        assertNotNull("ID is null", order.getId());
    }
View Full Code Here

TOP

Related Classes of cz.muni.fi.pa165.stis.entity.Order

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.