Package cz.muni.fi.pa165.library.web_layer.adminPages.Book

Examples of cz.muni.fi.pa165.library.web_layer.adminPages.Book.EditBook


    public BookReservation(final PageParameters parameters) {
  super(parameters);
       
        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));
                pageParameters.add("reservationid", reservation.getReservationID());
                item.add(new Label("author", reservation.getBookTO().getAuthor()));
                item.add(new Label("title", reservation.getBookTO().getTitle()));
                item.add(new Label("reservationDate", dateFormat.format(reservation.getReservationDate())));
                repeating.add(item);
            }
        }
       
        //delete reservation
        StringValue reservationId = parameters.get("reservationid");
        if (!reservationId.isEmpty()) {
            reservationService.deleteReservation(reservationService.findReservationByID(reservationId.toLong()));
            setResponsePage(BookReservation.class);
        }
    }
View Full Code Here


                + readerService.findReaderById(readerId.toLong()).getFirstName())));

        Form<?> form = new Form("form") {
            @Override
            protected void onSubmit() {
                ReservationService reservationService = (ReservationService) ApplicationContextProvider.getApplicationContext().getBean("reservationService");
                ReaderService readerService = (ReaderService) ApplicationContextProvider.getApplicationContext().getBean("readerService");
                java.util.Date date = new java.util.Date();
                reservation.setReservationDate(new Timestamp(date.getTime()));
                reservation.setReaderTO(readerService.findReaderById(readerId.toLong()));
                reservationService.insertReservation(reservation);
                setResponsePage(ShowAllReservation.class);
            }
        };
        add(form);
        List<BookTO> books = bookService.findAllAvailableBooks();
View Full Code Here

    public ShowAllReservation(final PageParameters parameters) {
        super(parameters);

        RepeatingView repeating = new RepeatingView("repeating");
        add(repeating);
        ReservationService reservationService = (ReservationService) ApplicationContextProvider.getApplicationContext().getBean("reservationService");
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
        for (ReservationTO reservation : reservationService.findAllReservations()) {
            AbstractItem item = new AbstractItem(repeating.newChildId());
            PageParameters pageParameters = new PageParameters();
            item.add(new BookmarkablePageLink<Void>("delete", ShowAllReservation.class, pageParameters));
            pageParameters.add("reservationid", reservation.getReservationID());
            item.add(new Label("readerTO", reservation.getReaderTO().toString()));
            item.add(new Label("bookTO", reservation.getBookTO().toString()));
            item.add(new Label("reservationDate", dateFormat.format(reservation.getReservationDate())));
            repeating.add(item);
        }

        //delete reservation
        StringValue reservationId = parameters.get("reservationid");
        if (!reservationId.isEmpty()) {
            reservationService.deleteReservation(reservationService.findReservationByID(reservationId.toLong()));
            setResponsePage(ShowAllReservation.class);
        }

        BookmarkablePageLink createLink = new BookmarkablePageLink<>(
                "create", ShowAllReader.class);
View Full Code Here

    public static ReservationTO convertReservationEntityToTO(Reservation reservation) {
        if (reservation == null) {
            return null;
        }
        ReservationTO reservationTO = new ReservationTO(DTOConvertor.convertReaderEntityToTO(reservation.getReader()),
                DTOConvertor.convertBookEntityToTO(reservation.getBook()), reservation.getReservationDate());
        reservationTO.setReservationID(reservation.getReservationID());
        return reservationTO;
    }
View Full Code Here

                          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);
                              setResponsePage(ShowAllBookReader.class);
                          }
                         
                    } 
View Full Code Here

    public EditReservation(final PageParameters parameters) {
        super(parameters);
        ReaderService readerService = (ReaderService) ApplicationContextProvider.getApplicationContext().getBean("readerService");
        BookService bookService = (BookService) ApplicationContextProvider.getApplicationContext().getBean("bookService");
        readerId = parameters.get("readerId");
        reservation = new ReservationTO();
        add(new Label("title", new Model("Create reservation for "
                + readerService.findReaderById(readerId.toLong()).getSurname() + " "
                + readerService.findReaderById(readerId.toLong()).getFirstName())));

        Form<?> form = new Form("form") {
View Full Code Here

    private ReaderTO reader;

    
    @Override
    public boolean authenticate(String email, String password) {
        UserService userService = (UserService) ApplicationContextProvider.getApplicationContext().getBean("userService");
        ReaderService readerService = (ReaderService) ApplicationContextProvider.getApplicationContext().getBean("readerService");
       
        UserTO user = userService.findUserByEmail(email);
        ReaderTO reader =readerService.findReaderByEmail(email);
        if (user != null) {
            if ((user.getEmail().equals(email)) && (user.getPassword().equals(password))){
                this.checkAdmin = true;
                this.user = "Admin: " + user.getFirstName() + " " + user.getLastName();
View Full Code Here

   
    public static UserTO convertUserEntityToTO(User user) {
        if (user == null) {
            return null;
        }
        UserTO userTO = new UserTO(user.getEmail(), user.getPassword(), user.getFirstName(), user.getLastName());
        userTO.setUserID(user.getUserID());
        return userTO;
    }
View Full Code Here

    @Override
    public boolean authenticate(String email, String password) {
        UserService userService = (UserService) ApplicationContextProvider.getApplicationContext().getBean("userService");
        ReaderService readerService = (ReaderService) ApplicationContextProvider.getApplicationContext().getBean("readerService");
       
        UserTO user = userService.findUserByEmail(email);
        ReaderTO reader =readerService.findReaderByEmail(email);
        if (user != null) {
            if ((user.getEmail().equals(email)) && (user.getPassword().equals(password))){
                this.checkAdmin = true;
                this.user = "Admin: " + user.getFirstName() + " " + user.getLastName();
                return true;
            }               
        }else if (reader!=null){
            if ((reader.getEmail().equals(email)) && (reader.getPassword().equals(password))){
                this.checkAdmin = false;
View Full Code Here

public class RegistrationLibrarianForm extends Template {
    private UserTO user;
   
    public RegistrationLibrarianForm(final PageParameters parameters){
        super(parameters);
        user = new UserTO();
       
        Form<?> form = new Form("form") {
            UserService userService = (UserService)ApplicationContextProvider.getApplicationContext().getBean("userService");
            @Override
            protected void onSubmit() {
View Full Code Here

TOP

Related Classes of cz.muni.fi.pa165.library.web_layer.adminPages.Book.EditBook

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.