List of usage examples for org.joda.time MutableDateTime toDateTime
DateTime toDateTime();
From source file:com.soen.hasslefree.beans.PhysicianAvailabilityBean.java
public String addAvailability() { String[] startSplit = startTimeHolder.split(":"); String[] endSplit = endTimeHolder.split(":"); MutableDateTime startDateTime = new MutableDateTime(dateHolder); MutableDateTime endDateTime = new MutableDateTime(dateHolder); String patientEmail = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap() .get("patientEmail"); // Setting start time value from string input startDateTime.setHourOfDay(Integer.parseInt(startSplit[0])); startDateTime.setMinuteOfHour(Integer.parseInt(startSplit[1])); // Setting end time value from string input endDateTime.setHourOfDay(Integer.parseInt(endSplit[0])); endDateTime.setMinuteOfHour(Integer.parseInt(endSplit[1])); PhysicianAvailability pa = new PhysicianAvailability(); pa.setStartTime(startDateTime.toDateTime()); pa.setEndTime(endDateTime.toDateTime()); pa.setRelatedPhysician(Physician.getPhysicianByEmail(patientEmail)); pa.savePhysicianAvailability();// w w w . j a v a 2s . com return "myAvailabilities"; }
From source file:com.soen.hasslefree.beans.RegistrationBean.java
public String registerPatient() { Address patientAddress = new Address(); MutableDateTime dateOfBirthMod = new MutableDateTime(dateOfBirth); patientAddress.setApartmentNumber(aptNumber); patientAddress.setCity(city);/* ww w . j a va2 s .c o m*/ patientAddress.setCountry(country); patientAddress.setPostalCode(postalCode); patientAddress.setProvince(province); patientAddress.setStreetName(streetName); patientAddress.setStreetNumber(streetNumber); patientAddress.saveAddress(); Patient patient = new Patient(); patient.setFirstName(firstName); patient.setLastName(lastName); patient.setGender(gender); patient.setPassword(encryptPassword(password)); patient.setPhoneNumber(phoneNumber); patient.setDateOfBirth(dateOfBirthMod.toDateTime()); patient.setEmail(emailAddress); patient.setHealthCardNumber(healthCardNumber); patient.setHomeAddress(patientAddress); patient.savePatient(); User.setUserRole(emailAddress, "patient"); return "index"; }
From source file:com.soen.hasslefree.models.PhysicianAvailability.java
public boolean generateTimeSlots(DateTime startTime, DateTime endTime, int dropInDurationInMinutes) { MutableDateTime slotStatTime = new MutableDateTime(); MutableDateTime slotEndTime = new MutableDateTime(); long availabilityStartTimeInMillis = startTime.getMillis(); long availabilityEndTimeInMillis = startTime.getMillis(); long availableDuration = availabilityEndTimeInMillis - availabilityStartTimeInMillis; long slotDuration = dropInDurationInMinutes * 60 * 1000; // 20 min * 60 sec * 1000 millisecond ArrayList<RoomTimeSlot> roomSlots = RoomTimeSlot.getFilteredAvailableRoomSlotsForDate(startTime, endTime); if (availableDuration > 0) { long currentSlotStartTime = availabilityStartTimeInMillis; boolean stopSlicing = false; while (!stopSlicing) { //<editor-fold defaultstate="collapsed" desc="new PhysicianTimeSlot "> int roomSlotIndex = hasFoundFreeRoomSlot(currentSlotStartTime, roomSlots); if (roomSlotIndex < 0) { return false; } else { PhysicianTimeSlot newTimeSlot = new PhysicianTimeSlot(); slotStatTime.setMillis(currentSlotStartTime); slotEndTime.setMillis(currentSlotStartTime + slotDuration); newTimeSlot.setStartTime(slotStatTime.toDateTime()); newTimeSlot.setEndTime(slotEndTime.toDateTime()); newTimeSlot.setIsAvailable(true); newTimeSlot.setPhysicianAvailability(this); newTimeSlot.setRelatedPhysician(this.relatedPhysician); RoomTimeSlot roomTime = roomSlots.get(roomSlotIndex); newTimeSlot.setRelatedRoomTimeSlot(roomTime); roomTime.setPhysicianTimeSlot(newTimeSlot); roomTime.setIsAvailable(false); //</editor-fold> this.physicianTimeSlots.add(newTimeSlot); availableDuration = availableDuration - slotDuration; currentSlotStartTime = currentSlotStartTime + slotDuration; if (availableDuration < slotDuration) { // I removed = because I want to add the last slot to the time slots. stopSlicing = true;//from w ww.java 2 s.c o m } } } } ObjectDao physicianAvailabilityDao = new ObjectDao(); reserveRoomSlot(roomSlots); physicianAvailabilityDao.addOrUpdateObject(this); return true; }
From source file:com.soen.hasslefree.models.Room.java
public void generateTimeSlots(DateTime clinicStartTime, DateTime clinicEndTime, int dropInDurationInMinutes) { MutableDateTime slotStatTime = new MutableDateTime(); MutableDateTime slotEndTime = new MutableDateTime(); //ArrayList<ClinicHours> clinicHoursList = ClinicHours.getAllClinicHours(); // ClinicHours clinicHours = clinicHoursList.get(0); long availabilityStartTime = clinicStartTime.getMillis(); long availabilityEndTime = clinicEndTime.getMillis(); long availableDuration = availabilityEndTime - availabilityStartTime; long slotDuration = dropInDurationInMinutes * 60 * 1000; // dropIn Duration min * 60 sec * 1000 millisecond if (availableDuration > 0) { long currentSlotStartTime = availabilityStartTime; boolean stopSlicing = false; while (!stopSlicing) { //<editor-fold defaultstate="collapsed" desc="new RoomTimeSlot "> RoomTimeSlot newTimeSlot = new RoomTimeSlot(); slotStatTime.setMillis(currentSlotStartTime); slotEndTime.setMillis(currentSlotStartTime + slotDuration); newTimeSlot.setStartTime(slotStatTime.toDateTime()); newTimeSlot.setEndTime(slotEndTime.toDateTime()); newTimeSlot.setIsAvailable(true); newTimeSlot.setRelatedRoom(this); //</editor-fold> this.roomTimeSlots.add(newTimeSlot); availableDuration = availableDuration - slotDuration; currentSlotStartTime = currentSlotStartTime + slotDuration; if (availableDuration < slotDuration) { // I ti should be smaller than only to add the last slot to the time slots. stopSlicing = true;/*from w ww. jav a2 s .c o m*/ } } } }
From source file:com.tmathmeyer.sentinel.models.data.Commitment.java
License:Open Source License
/** * this is primarily used for multiday events * //from www. j a v a 2 s . c om * @param givenDay gets the time that this event starts on a given day * @return when this event starts */ public DateTime getStartTimeOnDay(DateTime givenDay) { MutableDateTime mDisplayedDay = new MutableDateTime(givenDay); mDisplayedDay.setMillisOfDay(1); // if it starts before the beginning of the day then its a multi day // event, or all day event if (this.getStart().isBefore(mDisplayedDay)) { mDisplayedDay.setMillisOfDay(0); return (mDisplayedDay.toDateTime()); } else return this.getStart(); }
From source file:com.tmathmeyer.sentinel.models.data.Commitment.java
License:Open Source License
/** * this is primarily used for multiday events * //from ww w. j a v a 2 s .c om * @param givenDay gets the time that this event ends on a given day * @return when this event ends */ public DateTime getEndTimeOnDay(DateTime givenDay) { MutableDateTime mDisplayedDay = new MutableDateTime(givenDay); ; mDisplayedDay.setMillisOfDay(86400000 - 2); if (this.getStart().plusMinutes(30).isAfter(mDisplayedDay)) { return mDisplayedDay.toDateTime(); } else return this.getStart().plusMinutes(30); }
From source file:com.tmathmeyer.sentinel.models.data.Event.java
License:Open Source License
/** * this is primarily used for multiday events * //from w w w . j av a2 s.co m * @param givenDay gets the time that this event ends on a given day * @return when this event ends */ public DateTime getEndTimeOnDay(DateTime givenDay) { MutableDateTime mDisplayedDay = new MutableDateTime(givenDay); ; mDisplayedDay.setMillisOfDay(86400000 - 2); if (this.getEnd().isAfter(mDisplayedDay)) { return mDisplayedDay.toDateTime(); } else return this.getEnd(); }
From source file:com.tmathmeyer.sentinel.ui.navigation.CalendarNavigationModule.java
License:Open Source License
public CalendarNavigationModule getPrevious() { MutableDateTime next = new MutableDateTime(time); next.addMonths(-1);/* www. j a v a 2 s . c o m*/ return new CalendarNavigationModule(next.toDateTime(), mc, monthOnly); }
From source file:com.tmathmeyer.sentinel.ui.navigation.CalendarNavigationModule.java
License:Open Source License
public CalendarNavigationModule getFollowing() { MutableDateTime next = new MutableDateTime(time); next.addMonths(1);/* www . j a va 2s. c o m*/ return new CalendarNavigationModule(next.toDateTime(), mc, monthOnly); }
From source file:com.tmathmeyer.sentinel.ui.navigation.GoToPanel.java
License:Open Source License
/** * Parses the input to the goTo field to ensure proper formatting and handle * syntax errors// w ww. j av a 2 s . c o m * * @param text string to parse */ public void parseGoto(String text) { DateTime dt; boolean isValidYear = true; try { dt = gotoField.parseDateTime(text); if (dt.getYear() < 1900 || dt.getYear() > 2100) { isValidYear = false; dt = null; } } catch (IllegalArgumentException illArg) { try { MutableDateTime mdt = gotoFieldShort.parseMutableDateTime(text); mdt.setYear(currentDate.getYear()); // this format does not // provide years. add it dt = mdt.toDateTime(); } catch (IllegalArgumentException varArg) { dt = null; } } if (dt != null) { MainPanel.getInstance().display(dt); MainPanel.getInstance().refreshView(); gotoErrorText.setText(" "); } else { if (isValidYear) gotoErrorText.setText("* Use format: mm/dd/yyyy"); else gotoErrorText.setText("* Year out of range (1900-2100)"); } }