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

Examples of cz.muni.fi.pa165.library.web_layer.adminPages.Borrow.ShowAllBorrow


   
    private ReaderTO reader;

    public EditReader(final PageParameters parameters) {
        super(parameters);
        ReaderService readerService = (ReaderService) ApplicationContextProvider.getApplicationContext().getBean("readerService");
        StringValue readerId = parameters.get("readerId");
        if (readerId.isEmpty()) {
            reader = new ReaderTO();
            add(new Label("title", new Model("Create reader")));
        } else {
            reader = readerService.findReaderById(readerId.toLong());
            add(new Label("title", new Model("Edit reader")));
        }

        Form<?> form = new Form("form") {
            @Override
            protected void onSubmit() {
                ReaderService readerService = (ReaderService) ApplicationContextProvider.getApplicationContext().getBean("readerService");
                if (reader.getId() == null) {
                    readerService.createReader(reader);
                } else {
                    readerService.updateReader(reader);
                }
                setResponsePage(ShowAllReader.class);
            }
        };
        add(form);
View Full Code Here


    private ReservationTO reservation;
    private StringValue readerId;

    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") {
            @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);
View Full Code Here

    public static ReaderTO convertReaderEntityToTO(Reader reader) {
        if (reader == null) {
            return null;
        }
        ReaderTO readerTO = new ReaderTO(reader.getFirstName(), reader.getSurname(), reader.getBirthNumber(),
                reader.getAddress(), reader.getEmail(), reader.getTelephoneNumber(), reader.getPassword());
        readerTO.setId(reader.getId());
        return readerTO;
    }
View Full Code Here

    }

    private void parseReader(List<ReaderTO> list) {
        Iterator it = list.listIterator();
        while (it.hasNext()) {
            ReaderTO readerTO = (ReaderTO) it.next();
            Object[] readerRow = {
                readerTO.getId(), readerTO.getFirstName(), readerTO.getSurname(),
                readerTO.getBirthNumber(), readerTO.getAddress(), readerTO.getEmail(), readerTO.getTelephoneNumber()
            };
            model.addRow(readerRow);
        }
    }
View Full Code Here

    }

    private JPanel updateReader() {
        createPanel = new JPanel();
        Long id = (Long) model.getValueAt(table.getSelectedRow(), 0);
        reader = new ReaderTO();
        try {
            reader = readerWebService.findReaderById(id);
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(readerPanel, "Cannot update reader.\nServer connection problem",
                    "Oops!", JOptionPane.ERROR_MESSAGE);
View Full Code Here

                if (phoneField.getText().equals("")) {
                    phoneField.setBackground(Color.getHSBColor(243, 102, 78));
                    check = false;
                }
                if (check) {
                    ReaderTO reader = new ReaderTO();
                    reader.setFirstName(firstNameField.getText());
                    reader.setSurname(lastNameField.getText());
                    reader.setBirthNumber(birthNumberField.getText());
                    reader.setEmail(emailField.getText());
                    reader.setAddress(addressField.getText());
                    reader.setTelephoneNumber(phoneField.getText());
                    try {
                        reader = readerWebService.createReader(reader);
                        Object[] arr = {
                            reader.getId(), reader.getFirstName(), reader.getSurname(), reader.getBirthNumber(), reader.getEmail(), reader.getAddress(), reader.getTelephoneNumber()
                        };
                        model.addRow(arr);
                    } catch (Exception ex) {
                        JOptionPane.showMessageDialog(readerPanel, "Cannot create reader.\nServer connection problem",
                                "Oops!", JOptionPane.ERROR_MESSAGE);
View Full Code Here

    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;
                this.user= "Reader: " + reader.getFirstName() + " " + reader.getSurname();
                this.reader = readerService.findReaderByEmail(email);
                return true;
            }
        }
        this.user=null;
View Full Code Here

                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

    public EditReader(final PageParameters parameters) {
        super(parameters);
        ReaderService readerService = (ReaderService) ApplicationContextProvider.getApplicationContext().getBean("readerService");
        StringValue readerId = parameters.get("readerId");
        if (readerId.isEmpty()) {
            reader = new ReaderTO();
            add(new Label("title", new Model("Create reader")));
        } else {
            reader = readerService.findReaderById(readerId.toLong());
            add(new Label("title", new Model("Edit reader")));
        }
View Full Code Here

            pageParameters.add("bookId", book.getId());
            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);
                              setResponsePage(ShowAllBookReader.class);
                          }
                         
                    } 
                };
View Full Code Here

TOP

Related Classes of cz.muni.fi.pa165.library.web_layer.adminPages.Borrow.ShowAllBorrow

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.