public abstract class Calendar
extends java.lang.Object
The data component of a Calendar is a collection of scheduled items. The operations are those that schedule each of the four types of scheduled item. In the case of meetings, there are two operations involved -- one to compute a list of possible times, and another to confirm a specific selected meeting time.
| Modifier and Type | Field and Description |
|---|---|
(package private) CalendarDB |
calDB |
(package private) java.util.Collection<ScheduledItem> |
data |
(package private) boolean |
requiresSaving |
| Constructor and Description |
|---|
Calendar() |
| Modifier and Type | Method and Description |
|---|---|
(package private) abstract void |
confirmMeeting(MeetingRequest request,
schedule.PossibleMeetingTimes times,
int selectedTime)
ConfirmMeeting takes a MeetingRequest, list of PossibleMeetingTimes, and
a Selected time from the list.
|
(package private) abstract boolean |
InRange(Time time,
Time startTime,
Time endTime)
A given time is between a given start time and end time.
|
(package private) abstract boolean |
isEarliest(Time time,
Time startTime,
Time endTime,
Room room)
For a given time, no other in-range, non-booked time is earlier.
|
(package private) abstract boolean |
roomAvailable(Room room,
Time time) |
(package private) abstract void |
scheduleAppointment(Appointment appointment)
ScheduleAppointment adds the given Appointment to this.data, if an
appointment of the same time, duration, and title is not already
scheduled.
|
(package private) abstract boolean |
scheduledAtBestTime(Meeting meeting,
Time startTime,
Time endTime,
Room room)
A given meeting item is scheduled at the best time.
|
(package private) abstract void |
scheduleEvent(Event event)
ScheduleEvent adds the given Event to this.data, if an event of the same
time, duration, and title is not already scheduled.
|
(package private) abstract schedule.PossibleMeetingTimes |
scheduleMeeting(MeetingRequest meetingRequest)
ScheduleMeeting uses the given MeetingRequest to determine possible
times that the requested meeting might be held, within the existing set
of scheduled items in the this.data.
|
(package private) abstract void |
scheduleTask(Task task)
ScheduleTask adds the given Task to this.data, if a task of the same
time, duration, and title is not already scheduled.
|
java.util.Collection<ScheduledItem> data
CalendarDB calDB
boolean requiresSaving
abstract void scheduleAppointment(Appointment appointment)
abstract schedule.PossibleMeetingTimes scheduleMeeting(MeetingRequest meetingRequest)
pre:
// There is at least one time that is between the given start time and
// end time at which the room is available.
exists (Time time ;
inRange(time, starttime, endtime)
&&
roomAvailable(room, time)
post:
//
// An item is properly added to the output db at the "best" time,
// where best means the earliest possible time between the given start
// time and end time at which the given room is available.
//
// Also, the room in which the item is scheduled is booked for the
// item's time.
//
exists (ScheudledItem item; data'.contains(item) ;
//
// The item is scheduled at the best time.
//
scheduledAtBestTime(item, starttime, endtime, room)
&&
//
// The item's room is booked for the item's time.
//
!roomAvailable(meetingRequest.room', item.time)
&&
//
// The item info is that given in the input.
//
(item.info = info)
and
(*
Only the new item and original items are in the output item
db (this is standard logic for properly adding to a collection).
)
forall (item':ScheduledItem) (
(item' in sidb') iff ((item' in sidb) or (item' = item))
)
);abstract boolean scheduledAtBestTime(Meeting meeting, Time startTime, Time endTime, Room room)
abstract boolean isEarliest(Time time, Time startTime, Time endTime, Room room)
abstract boolean InRange(Time time, Time startTime, Time endTime)
abstract void confirmMeeting(MeetingRequest request, schedule.PossibleMeetingTimes times, int selectedTime)
abstract void scheduleTask(Task task)
abstract void scheduleEvent(Event event)
pre:
//
// The Title field is not empty.
//
(event.title != null && event.title.length() >= 1)
&&
//
// The startOrDueDate field is a valid date value.
//
(event.startOrDueDate != null) && event.startOrDueDate.isValid()
&&
//
// If non-empty, the EndDate field is a valid date value.
//
(event.endDate != null) ==> event.endDate.isValid()
&&
//
// The current workspace is not null.
//
(calDB.getCurrentCalendar() != null)
&&
//
// No event of same startDate and title is in the current workspace
// calendar.
//
// No event of same startDate and title is in the current calendar.
//
! exists (ScheduledItem item ;
calDB.getCurrentCalendar().items.contains(item) ;
(item.startOrDueDate.equals(event.startOrDueDate)) &&
item.duration.equals(event.duration) &&
(item.title.equals(event.title)));
post:
//
// If preconds met, a scheduled item is in the output calendar if
// and only if it is the new appt to be added or it is in the
// input calendar.
//
forall (ScheduledItem item;
calDB'.getCurrentCalendar().items.contains(item) iff
(item == event ||
calDB.getCurrentCalendar().items.contains(item)))
&&
//
// Also, requiresSaving is true in the output calendar.
//
calDB.getCurrentCalendar().requiresSaving;