Package cz.muni.fi.pa165.library.web_layer.readerPages

Examples of cz.muni.fi.pa165.library.web_layer.readerPages.MenuReaderPanel


    private static final long serialVersionUID = 60L;
    private BorrowTO borrow;

    public EditBorrow(final PageParameters parameters) {
        super(parameters);
        BorrowService borrowService = (BorrowService) ApplicationContextProvider.getApplicationContext().getBean("borrowService");
        StringValue borrowId = parameters.get("borrowId");
        borrow = borrowService.findBorrowByID(borrowId.toLong());

        Form<?> form = new Form("form") {
            @Override
            protected void onSubmit() {
                BorrowService borrowService = (BorrowService) ApplicationContextProvider.getApplicationContext().getBean("borrowService");
                borrowService.updateExpirationDate(borrow, borrow.getExpirationDate());
                setResponsePage(ShowAllBorrow.class);
            }
        };
        add(form);
View Full Code Here


public class ShowAllBorrow extends Template {
    private static final long serialVersionUID = 30L;
    public ShowAllBorrow(final PageParameters parameters) {
  super(parameters);
       
        BorrowService borrowService = (BorrowService) ApplicationContextProvider.getApplicationContext().getBean("borrowService");
       
        // RETURN BORROW
        StringValue borrowId = parameters.get("borrowId");
        if (!borrowId.isEmpty()) {
            BorrowTO borrow = borrowService.findBorrowByID(borrowId.toLong());
            borrowService.returnBooks(borrow, borrow.getTitlesTO());
            setResponsePage(ShowAllBorrow.class);
        }
       
        // EXTEND BORROW
        StringValue extend = parameters.get("extend");
        if (!extend.isEmpty()) {
            BorrowTO borrow = borrowService.findBorrowByID(extend.toLong());
           
            Calendar cal = Calendar.getInstance()
            cal.setTime(borrow.getExpirationDate())
            cal.add(Calendar.MONTH, 1); // add 1 month 

            borrow.setExpirationDate(cal.getTime());            
            borrowService.updateExpirationDate(borrow, borrow.getExpirationDate());
            setResponsePage(ShowAllBorrow.class);
        }

        RepeatingView repeating = new RepeatingView("repeating");
       
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
       
        for (BorrowTO borrow : borrowService.findAllBorrows()) {
            AbstractItem item = new AbstractItem(repeating.newChildId());
            PageParameters pageParameters = new PageParameters();
            pageParameters.add("borrowId", borrow.getBorrowID());
            PageParameters pageParameters2 = new PageParameters();
            pageParameters2.add("extend", borrow.getBorrowID());
View Full Code Here

        Form<?> form;
        form = new Form("form") {
            @Override
            protected void onSubmit() {
                BorrowService borrowService = (BorrowService) ApplicationContextProvider.getApplicationContext().getBean("borrowService");
                if (borrow.getBorrowID() == null) {
                    borrow.setBorrowDate(new Date(System.currentTimeMillis()));
                    Calendar cal = Calendar.getInstance();
                    cal.setTime(new Date(System.currentTimeMillis()));
                    cal.add(Calendar.MONTH, 1); // add 1 month 
                    borrow.setExpirationDate(cal.getTime());
                    if (selectedBook != null) {
                        listSelectedBook.add(selectedBook);
                    }
                    if (selectedBook2 != null) {
                        listSelectedBook.add(selectedBook2);
                    }
                    if (selectedBook3 != null) {
                        listSelectedBook.add(selectedBook3);
                    }
                    if (selectedBook4 != null) {
                        listSelectedBook.add(selectedBook4);
                    }
                    if (selectedBook5 != null) {
                        listSelectedBook.add(selectedBook5);
                    }
                    if (selectedBook6 != null) {
                        listSelectedBook.add(selectedBook6);
                    }
                    for (int i = 0; i < listSelectedBook.size(); i++) {
                        for (int j = i + 1; j < listSelectedBook.size(); j++) {
                            if (listSelectedBook.get(i).equals(listSelectedBook.get(j))) {
                                listSelectedBook.remove(listSelectedBook.get(j));
                                j--;
                            }
                        }
                    }
                    borrow.setTitlesTO(listSelectedBook);
                    borrowService.createBorrow(borrow);
                }
                setResponsePage(ShowAllBorrow.class);
            }
        };
        add(form);
View Full Code Here

*/
public class ShowBorrowReader extends Template {
    private static final long serialVersionUID = 30L;
    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

        BorrowService borrowService = (BorrowService) ApplicationContextProvider.getApplicationContext().getBean("borrowService");
       
        // RETURN BORROW
        StringValue borrowId = parameters.get("borrowId");
        if (!borrowId.isEmpty()) {
            BorrowTO borrow = borrowService.findBorrowByID(borrowId.toLong());
            borrowService.returnBooks(borrow, borrow.getTitlesTO());
            setResponsePage(ShowAllBorrow.class);
        }
       
        // EXTEND BORROW
        StringValue extend = parameters.get("extend");
        if (!extend.isEmpty()) {
            BorrowTO borrow = borrowService.findBorrowByID(extend.toLong());
           
            Calendar cal = Calendar.getInstance()
            cal.setTime(borrow.getExpirationDate())
            cal.add(Calendar.MONTH, 1); // add 1 month 

            borrow.setExpirationDate(cal.getTime());            
            borrowService.updateExpirationDate(borrow, borrow.getExpirationDate());
            setResponsePage(ShowAllBorrow.class);
        }

        RepeatingView repeating = new RepeatingView("repeating");
       
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
       
        for (BorrowTO borrow : borrowService.findAllBorrows()) {
            AbstractItem item = new AbstractItem(repeating.newChildId());
            PageParameters pageParameters = new PageParameters();
            pageParameters.add("borrowId", borrow.getBorrowID());
            PageParameters pageParameters2 = new PageParameters();
            pageParameters2.add("extend", borrow.getBorrowID());
            item.add(new BookmarkablePageLink<Void>("extend", ShowAllBorrow.class, pageParameters2));
            item.add(new BookmarkablePageLink<Void>("return", ShowAllBorrow.class, pageParameters));
            item.add(new Label("reader", borrow.getReaderTO().toString()));
            if (borrow.getTitlesTO().size() > 0) {
                item.add(new Label("title", borrow.getTitlesTO().toString()));     
            } else {
                item.add(new Label("title", new Model("[RETURNED]")));
            }
            item.add(new Label("borrowdate", dateFormat.format(borrow.getBorrowDate())));
            item.add(new Label("expirationdate", dateFormat.format(borrow.getExpirationDate())));
            repeating.add(item);
       }
       
       add(repeating);
      
View Full Code Here

    public AddBorrow(final PageParameters parameters) {
        super(parameters);
        ReaderService readerService = (ReaderService) ApplicationContextProvider.getApplicationContext().getBean("readerService");
        final BookService bookService = (BookService) ApplicationContextProvider.getApplicationContext().getBean("bookService");

        borrow = new BorrowTO();

        Form<?> form;
        form = new Form("form") {
            @Override
            protected void onSubmit() {
View Full Code Here

        if (borrow.getTitles() != null) {
            for (Book book : borrow.getTitles()) {
                titleTOList.add(DTOConvertor.convertBookEntityToTO(book));
            }
        }
        BorrowTO borrowTO = new BorrowTO(DTOConvertor.convertReaderEntityToTO(borrow.getReader()),
                titleTOList, borrow.getBorrowDate(), borrow.getExpirationDate());
        borrowTO.setBorrowID(borrow.getBorrowID());
        return borrowTO;
    }
View Full Code Here

    private BookTO selectedBook, selectedBook2, selectedBook3, selectedBook4, selectedBook5, selectedBook6;
    private List<BookTO> listSelectedBook = new ArrayList();

    public AddBorrow(final PageParameters parameters) {
        super(parameters);
        ReaderService readerService = (ReaderService) ApplicationContextProvider.getApplicationContext().getBean("readerService");
        final BookService bookService = (BookService) ApplicationContextProvider.getApplicationContext().getBean("bookService");

        borrow = new BorrowTO();

        Form<?> form;
        form = new Form("form") {
            @Override
            protected void onSubmit() {
                BorrowService borrowService = (BorrowService) ApplicationContextProvider.getApplicationContext().getBean("borrowService");
                if (borrow.getBorrowID() == null) {
                    borrow.setBorrowDate(new Date(System.currentTimeMillis()));
                    Calendar cal = Calendar.getInstance();
                    cal.setTime(new Date(System.currentTimeMillis()));
                    cal.add(Calendar.MONTH, 1); // add 1 month 
                    borrow.setExpirationDate(cal.getTime());
                    if (selectedBook != null) {
                        listSelectedBook.add(selectedBook);
                    }
                    if (selectedBook2 != null) {
                        listSelectedBook.add(selectedBook2);
                    }
                    if (selectedBook3 != null) {
                        listSelectedBook.add(selectedBook3);
                    }
                    if (selectedBook4 != null) {
                        listSelectedBook.add(selectedBook4);
                    }
                    if (selectedBook5 != null) {
                        listSelectedBook.add(selectedBook5);
                    }
                    if (selectedBook6 != null) {
                        listSelectedBook.add(selectedBook6);
                    }
                    for (int i = 0; i < listSelectedBook.size(); i++) {
                        for (int j = i + 1; j < listSelectedBook.size(); j++) {
                            if (listSelectedBook.get(i).equals(listSelectedBook.get(j))) {
                                listSelectedBook.remove(listSelectedBook.get(j));
                                j--;
                            }
                        }
                    }
                    borrow.setTitlesTO(listSelectedBook);
                    borrowService.createBorrow(borrow);
                }
                setResponsePage(ShowAllBorrow.class);
            }
        };
        add(form);

        List<ReaderTO> readers = readerService.findAllReaders();
        DropDownChoice choiceReaders = new DropDownChoice("reader", new PropertyModel(borrow, "readerTO"), readers);
        form.add(choiceReaders);

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

        super(parameters);

        RepeatingView repeating = new RepeatingView("repeating");
        add(repeating);

        ReaderService readerService = (ReaderService) ApplicationContextProvider.getApplicationContext().getBean("readerService");
        for (ReaderTO reader : readerService.findAllReaders()) {

            AbstractItem item = new AbstractItem(repeating.newChildId());

            PageParameters pageParameters = new PageParameters();
            pageParameters.add("readerId", reader.getId());
            item.add(new BookmarkablePageLink<Void>("edit", EditReader.class, pageParameters));
            item.add(new BookmarkablePageLink<Void>("delete", ShowAllReader.class, pageParameters));
            item.add(new Label("firstName", reader.getFirstName()));
            item.add(new Label("surname", reader.getSurname()));
            item.add(new Label("birthNumber", reader.getBirthNumber()));
            item.add(new Label("address", reader.getAddress()));
            item.add(new Label("email", reader.getEmail()));
            item.add(new Label("telephoneNumber", reader.getTelephoneNumber()));
           
            item.add(new BookmarkablePageLink<Void>("reserve", EditReservation.class, pageParameters));
            repeating.add(item);
        }
       
        StringValue readerId = parameters.get("readerId");
        if (!readerId.isEmpty()) {
            readerService.deleteReader(readerService.findReaderById(readerId.toLong()));
            setResponsePage(ShowAllReader.class);
        }

        BookmarkablePageLink addReaderLink = new BookmarkablePageLink<>(
                "addReader", EditReader.class);
View Full Code Here

TOP

Related Classes of cz.muni.fi.pa165.library.web_layer.readerPages.MenuReaderPanel

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.