/** {@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; }
/** {@inheritDoc} */ @Override public void update(Observable userDao, Object object) { LogbookEntry newEntry = null; if (this.is(object, User.class)) { User user = (User) object; if (user.hasBeenAnonymized()) { newEntry = this.getEntryForUserAnonymized(user.getUsernameBeforeAnonym()); } else if (user.hasJustBeenInserted()) { // a new user was inserted newEntry = this.getEntryForUserNew(user); } else if (user.hasJustBeenDeleted()) { newEntry = this.getEntryForUserDeleted(user); } else { User old = FamDaoProxy.userDao().getUserFromUsername(user.getUsername()); newEntry = this.getEntryForUserUpdate(old, user); } } else if (this.is(object, ContactDetail.class)) { ContactDetail cd = (ContactDetail) object; newEntry = this.getEntryForContactDetails(cd); } if (newEntry != null) { newEntry.insert(); } else { FamLog.error("observed an unknown event: " + object.getClass(), 201403061006l); } }
@SuppressWarnings("deprecation") // TODO #11 kill uses of deprecations @Test public void insertNewForIntern() { SoaActivationDocument internOld = this.insertAndGet("intern"); SoaActivationDocument externOld = this.insertAndGet("extern"); SoaActivationDocument internNew = this.insertAndGet("intern"); new TermsOfUseResolver(TeztBeanSimpleFactory.getAdmin()).deactivateAgreementsFor(internNew); List<SoaActivationDocument> all_sads = FamDaoProxy.soaDao().getAllSoaActivation(); assertTrue(all_sads.size() >= 3); boolean[] foundAll = {false, false, false}; for (SoaActivationDocument sad : all_sads) { if (sad.getId().equals(internOld.getId())) { // intern is still active foundAll[0] = true; assertFalse(sad.isActive()); assertTrue(sad.getDeactivatedOn() > sad.getActivatedOn()); } if (sad.getId().equals(externOld.getId())) { // extern is not active anymore foundAll[1] = true; assertTrue(sad.isActive()); } if (sad.getId().equals(internNew.getId())) { // new one is active foundAll[2] = true; assertTrue(sad.isActive()); } } // found everything assertTrue(foundAll[0]); assertTrue(foundAll[1]); assertTrue(foundAll[2]); }
private String getOverviewHtml( TemplateResource templateResource, Calendar cal, String facilityKey) { List<FacilityAvailability> das = FamDaoProxy.facilityDao().getFacilityAvailabilitiesFollowingParents(facilityKey); if (this.suddenFailureIsActive(das)) { return ""; } else { ComparableCollectionsAdapter.getInstance() .setModusToAll(das, FacilityAvailability.COMPARE_BY_DATE_SET); Collections.sort(das); return new AvailabilityOverviewHtml(cal, facilityKey, das, templateResource.getAuthUser()) .toString(); } }
/** * 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); }
/** @return the userSetThis */ public User getUserSetThis() { return FamDaoProxy.userDao().getUserFromUsername(this.usernameSetThis); }
private boolean suddenFailureIsActive(String facilityKey) { List<FacilityAvailability> das = FamDaoProxy.facilityDao().getFacilityAvailabilitiesFollowingParents(facilityKey); return this.suddenFailureIsActive(das); }
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; }
public List<LogbookEntry> getAllEntries() { LogbookEntry le = new LogbookEntry(); le.setLogbookId(this.getKey()); return FamDaoProxy.logbookEntryDao().getObjectsLike(le); }