List of usage examples for org.joda.time LocalDate LocalDate
public LocalDate(Object instant)
From source file:dao.EmprestimoDAOBD.java
@Override public Emprestimo procurarPorISBNLivro(String ISBN) { try {/* w w w . ja va 2 s. co m*/ ItemLivroDAOBD l = new ItemLivroDAOBD(); ItemLivro itemLivro = l.procurarPorISBN(ISBN); if (itemLivro != null) { String sql = "SELECT * FROM emprestimo WHERE codItemLivro=?"; conectar(sql); comando.setInt(1, itemLivro.getId()); ResultSet r = comando.executeQuery(); if (r.next()) { ClienteDAOBD cliente = new ClienteDAOBD(); Cliente c = cliente.procurarPorId(r.getInt("codCliente")); LocalDate dataEmprestimo = new LocalDate(r.getDate("dataEmprestimo")); LocalDate dataDevolucao = new LocalDate(r.getDate("dataDevolucao")); LocalDate devolucaoEfetiva = new LocalDate(r.getDate("devolucaoEfetiva")); int diasAtraso = r.getInt("diasAtraso"); boolean ativo = r.getBoolean("ativo"); return new Emprestimo(r.getInt("id"), c, itemLivro, dataEmprestimo, dataDevolucao, devolucaoEfetiva, diasAtraso, ativo); } } } catch (SQLException ex) { Logger.getLogger(LivroDAOBD.class.getName()).log(Level.SEVERE, null, ex); } finally { fecharConexao(); } return null; }
From source file:dao.EmprestimoDAOBD.java
@Override public List<Emprestimo> procurarPorNomeCliente(String nome) { List<Emprestimo> array = new ArrayList<>(); try {/*from w ww . j ava 2 s . c o m*/ ItemLivroDAOBD l = new ItemLivroDAOBD(); List<ItemLivro> listaLivro = l.procurarPorNome(nome); if (listaLivro.size() > 0) { for (ItemLivro itemLivro : listaLivro) { String sql = "SELECT * FROM emprestimo WHERE codItemLivro=?"; conectar(sql); comando.setInt(1, itemLivro.getId()); ResultSet r = comando.executeQuery(); while (r.next()) { ClienteDAOBD cliente = new ClienteDAOBD(); Cliente c = cliente.procurarPorId(r.getInt("codCliente")); LocalDate dataEmprestimo = new LocalDate(r.getDate("dataEmprestimo")); LocalDate dataDevolucao = new LocalDate(r.getDate("dataDevolucao")); LocalDate devolucaoEfetiva = new LocalDate(r.getDate("devolucaoEfetiva")); int diasAtraso = r.getInt("diasAtraso"); boolean ativo = r.getBoolean("ativo"); array.add(new Emprestimo(r.getInt("id"), c, itemLivro, dataEmprestimo, dataDevolucao, devolucaoEfetiva, diasAtraso, ativo)); } } } } catch (SQLException ex) { Logger.getLogger(LivroDAOBD.class.getName()).log(Level.SEVERE, null, ex); } finally { fecharConexao(); } return (array); }
From source file:dao.EmprestimoDAOBD.java
public Emprestimo getEmprestimoClienteISBNLivro(Cliente cliente, String ISBN) { try {/* w w w .j a va2 s . c o m*/ ItemLivro i = new ItemLivroDAOBD().procurarPorISBN(ISBN); String sql = "SELECT * FROM emprestimo WHERE codCliente=? AND codItemLivro=? AND ativo=true"; conectar(sql); comando.setInt(1, cliente.getId()); comando.setInt(2, i.getId()); ResultSet r = comando.executeQuery(); if (r.next()) { LocalDate dataEmprestimo = new LocalDate(r.getDate("dataEmprestimo")); LocalDate dataDevolucao = new LocalDate(r.getDate("dataDevolucao")); LocalDate devolucaoEfetiva = new LocalDate(r.getDate("devolucaoEfetiva")); int diasAtraso = r.getInt("diasAtraso"); boolean ativo = r.getBoolean("ativo"); return new Emprestimo(r.getInt("id"), cliente, i, dataEmprestimo, dataDevolucao, devolucaoEfetiva, diasAtraso, ativo); } } catch (SQLException ex) { Logger.getLogger(EmprestimoDAOBD.class.getName()).log(Level.SEVERE, null, ex); } finally { fecharConexao(); } return null; }
From source file:de.appsolve.padelcampus.admin.controller.bookings.AdminBookingsReservationsController.java
@RequestMapping("print/{start}/{end}") public ModelAndView getPrintInvoices(@PathVariable("start") String start, @PathVariable("end") String end) { MasterData masterData = masterDataDAO.findFirst(); if (masterData == null) { return new ModelAndView("invoices/masterdata_missing"); }/*from w w w. j a v a2s .co m*/ LocalDate startDate = new LocalDate(start); LocalDate endDate = new LocalDate(end); DateRange dateRange = new DateRange(); dateRange.setStartDate(startDate); dateRange.setEndDate(endDate); List<Booking> bookings = bookingDAO.findActiveBookingsBetween(dateRange.getStartDate(), dateRange.getEndDate()); ModelAndView mav = new ModelAndView("admin/bookings/reservations/printinvoices"); mav.addObject("MasterData", masterData); mav.addObject("Bookings", bookings); return mav; }
From source file:de.appsolve.padelcampus.admin.controller.bookings.AdminBookingsSettingsController.java
private CalendarConfig getDefaultCalendarConfig() { CalendarConfig calendarConfig = new CalendarConfig(); LocalDate now = new LocalDate(Constants.DEFAULT_TIMEZONE); calendarConfig.setStartDate(now);/*from w w w. j ava2 s .c om*/ calendarConfig.setEndDate(now.plusMonths(1)); calendarConfig.setHolidayKey(Constants.DEFAULT_HOLIDAY_KEY); calendarConfig.setStartTimeHour(Constants.BOOKING_DEFAULT_VALID_FROM_HOUR); calendarConfig.setStartTimeMinute(Constants.BOOKING_DEFAULT_VALID_FROM_MINUTE); calendarConfig.setEndTimeHour(Constants.BOOKING_DEFAULT_VALID_UNTIL_HOUR); calendarConfig.setEndTimeMinute(Constants.BOOKING_DEFAULT_VALID_UNTIL_MINUTE); calendarConfig.setMinDuration(Constants.BOOKING_DEFAULT_DURATION); calendarConfig.setMinInterval(Constants.BOOKING_DEFAULT_MIN_INTERVAL); return calendarConfig; }
From source file:de.appsolve.padelcampus.admin.controller.bookings.AdminBookingsVoucherController.java
@Override protected Voucher createNewInstance() { Voucher voucher = new Voucher(); voucher.setDuration(60L);// w w w.ja va 2s . c om voucher.setValidUntil(new LocalDate(DEFAULT_TIMEZONE).plusDays(VOUCHER_DEFAULT_VALIDITY_IN_DAYS)); voucher.setValidFromHour(BOOKING_DEFAULT_VALID_FROM_HOUR); voucher.setValidFromMinute(BOOKING_DEFAULT_VALID_FROM_MINUTE); voucher.setValidUntilHour(BOOKING_DEFAULT_VALID_UNTIL_HOUR); voucher.setValidUntilMinute(BOOKING_DEFAULT_VALID_UNTIL_MINUTE); voucher.setCalendarWeekDays(new HashSet<>(Arrays.asList(CalendarWeekDay.values()))); return voucher; }
From source file:de.appsolve.padelcampus.admin.controller.events.AdminEventsController.java
@RequestMapping(method = GET, value = "/{status}") public ModelAndView showEvents(HttpServletRequest request, Pageable pageable, @RequestParam(required = false, name = "search") String search, @PathVariable("status") String status) { Set<Criterion> criterions = new HashSet<>(); LocalDate today = new LocalDate(Constants.DEFAULT_TIMEZONE); if (status.equals("current")) { criterions.add(Restrictions.ge("endDate", today)); } else {/*from w w w . j a v a 2 s .c o m*/ criterions.add(Restrictions.lt("endDate", today)); } Page<Event> page; if (!StringUtils.isEmpty(search)) { page = eventDAO.findAllByFuzzySearch(search, criterions, "participants", "participants.players"); } else { page = eventDAO.findAllFetchWithParticipantsAndPlayers(pageable, criterions); } ModelAndView mav = new ModelAndView(getModuleName() + "/events"); mav.addObject("Page", page); mav.addObject("Models", page.getContent()); mav.addObject("moduleName", getModuleName()); mav.addObject("status", status); return mav; }
From source file:de.appsolve.padelcampus.controller.events.EventsController.java
@RequestMapping("{moduleTitle}") public ModelAndView getEvent(@PathVariable("moduleTitle") String moduleTitle) { Module module = moduleDAO.findByUrlTitle(moduleTitle); if (module == null) { throw new ResourceNotFoundException(); }//from ww w . ja v a 2 s . c o m List<Event> events = eventDAO.findAllActive(); List<Event> currentEvents = new ArrayList<>(); List<Event> pastEvents = new ArrayList<>(); Iterator<Event> iterator = events.iterator(); while (iterator.hasNext()) { Event event = iterator.next(); if (event.getEventGroup() == null || !module.getEventGroups().contains(event.getEventGroup())) { iterator.remove(); } else if (new LocalDate(Constants.DEFAULT_TIMEZONE).compareTo(event.getEndDate()) <= 0) { currentEvents.add(event); } else { pastEvents.add(event); } } Collections.sort(currentEvents, new EventByStartDateComparator()); Collections.sort(pastEvents, new EventByStartDateComparator(true)); ModelAndView mav = new ModelAndView("events/index"); mav.addObject("CurrentEvents", currentEvents); mav.addObject("PastEvents", pastEvents); mav.addObject("Module", module); return mav; }
From source file:de.appsolve.padelcampus.data.DateRange.java
public LocalDate getStartDate() { return startDate == null ? new LocalDate(DEFAULT_TIMEZONE) : startDate; }
From source file:de.appsolve.padelcampus.data.DateRange.java
public LocalDate getEndDate() { return endDate == null ? new LocalDate(DEFAULT_TIMEZONE) : endDate; }