/** {@inheritDoc} */ @Override public boolean update() throws DataIntegrityViolationException { boolean result = FamDaoProxy.facilityDao().update(this); Cancelation c = new Cancelation(this.getUserSetThis(), Cancelation.REASON_NOT_AVAILABLE_IN_GENERAL); FamDaoProxy.bookingDao().cancelOverlappingBookings(this.getFacility(), c); return result; }
/** * return the position in the queue of this booking. if this is not a part of the current queue * return queue length. * * @see BookingDao#getCurrentPositionInQueue(de.knurt.fam.core.model.persist.booking.QueueBooking) * @return the position in the queue of this booking. */ public Integer getCurrentQueuePosition() { return FamDaoProxy.bookingDao().getCurrentPositionInQueue(this); }
/** * updateAnswers in db * * @throws DataIntegrityViolationException if it violates db rules */ @Override public boolean update() throws DataIntegrityViolationException { return FamDaoProxy.bookingDao().update(this); }
/** * insert into db * * @throws DataIntegrityViolationException if it violates db rules */ @Override public boolean insert() throws DataIntegrityViolationException { FamDaoProxy.bookingDao().insert(this); this.getQueueBasedBookingRule().incrementQueue(); return OutgoingUserMailBox.insert_BookingMade(this); }
private HtmlElement getSummary(HttpServletRequest request) { HtmlElement result = HtmlFactory.get("ul").addClassName("asList"); HtmlElement warningSpan = HtmlFactory.get("span").addClassName("warning"); // summary availability Integer availability = RequestInterpreter.getAvailability(request); // is valid availability if (availability != null && (availability == COMPLETE_AVAILABLE || availability == GENERAL_NOT_AVAILABLE || availability == BOOKED_NOT_AVAILABLE || availability == MAINTENANCE_NOT_AVAILABLE || availability == BOOKING_MUST_NOT_START_HERE)) { result.add( HtmlFactory.get("li") .add(HtmlFactory.get("strong").add("Availability")) .add(": ") .add(FamText.facilityAvailability(availability))); // INTLANG; } // summary interval Integer interval = RequestInterpreter.getInterval(request); if (interval != null) { result.add( HtmlFactory.get("li") .add(HtmlFactory.get("strong").add("Interval")) .add(": ") .add(FamText.message("calendar.iteration." + interval))); // INTLANG; } // summary notice String notice = RequestInterpreter.getNotice(request); if (notice != null) { result.add( HtmlFactory.get("li") .add(HtmlFactory.get("strong").add("Notice")) .add(": ") .add(notice)); // INTLANG; } if (availability != null && availability.intValue() != FacilityAvailability.COMPLETE_AVAILABLE) { FacilityAvailability da = RequestInterpreter.getCompleteFacilityAvailabilityForInsertion( request, SessionAuth.user(request)); if (da != null) { TimeFrame baseTimeFrame = da.getBasePeriodOfTime(); if (baseTimeFrame != null) { String timeText = interval == FacilityAvailability.ONE_TIME ? "Coming into effect" : "First time coming into effect"; // INTLANG result.add( HtmlFactory.get("li") .add(HtmlFactory.get("strong").add(timeText)) .add(": ") .add(baseTimeFrame)); // summarize bookings being canceled List<Facility> facilities = new ArrayList<Facility>(); facilities.add(da.getFacility()); List<Booking> bookings = FamDaoProxy.bookingDao().getAll(facilities); int negativeAnswers = 0; for (Booking booking : bookings) { if (!booking.isCanceled() && !booking.sessionAlreadyBegun() && booking.getIdBookedInBookingStrategy() != BookingStrategy.QUEUE_BASED && da.applicableTo(booking.getSessionTimeFrame())) { negativeAnswers++; } } result.add( HtmlFactory.get("li") .add( HtmlFactory.get("strong") .add("Number of letters of refusal sent with this input")) .add(": ") .add( negativeAnswers == 0 ? "no letter" : warningSpan .setContent(negativeAnswers + " letter(s)") .toString())); // INTLANG; // warning on nothing set or left long durationOfBaseTime = baseTimeFrame.getDuration(); long durationOfAnHour = 1000l * 60 * 60; boolean willBlockResource = false; boolean nothingSet = durationOfBaseTime <= 0; if (!nothingSet && interval != FacilityAvailability.ONE_TIME && availability != FacilityAvailability.COMPLETE_AVAILABLE) { if ((interval == FacilityAvailability.EACH_YEAR && durationOfBaseTime >= durationOfAnHour * 24 * 365) || (interval == FacilityAvailability.EACH_MONTH && durationOfBaseTime >= durationOfAnHour * 24 * 365 / 12) || (interval == FacilityAvailability.EACH_WEEK && durationOfBaseTime >= durationOfAnHour * 24 * 7) || (interval == FacilityAvailability.EACH_DAY && durationOfBaseTime >= durationOfAnHour * 24) || (interval == FacilityAvailability.EACH_HOUR && durationOfBaseTime >= durationOfAnHour)) { willBlockResource = true; } } if (willBlockResource) { result.add( HtmlFactory.get("li") .add( warningSpan.setContent( "If setting this, the facility will never ever be available!"))); // INTLANG; } if (nothingSet) { result.add( HtmlFactory.get("li") .add(warningSpan.setContent("The duration of your setting is 0!"))); // INTLANG; } } } } return result; }