// for use by the UI to get events for a single day public ArrayList<Event> getEventsForDay(int y, int d, int m) throws SQLException { db.createTable(eventTable); int year = y; int day = d; int month = m; Date target = new Date(year, month, day); ArrayList<Event> result = new ArrayList<Event>(db.getEventsForDay(eventTable, target)); return result; }
// returns true if there's conflict protected boolean checkForConflict(Event e) throws SQLException { Date dateBeingAddedStart = e.startTime; Date dateBeingAddedStop = e.stopTime; ArrayList<Event> currentEvents = db.getEventsForDay(eventTable, dateBeingAddedStart); for (int i = 0; i < currentEvents.size(); i++) { Date dateStarted = currentEvents.get(i).startTime; Date dateEnding = currentEvents.get(i).stopTime; // if the events are on the same day, check the times if (isDayEqualToExistingEventDay(dateBeingAddedStart, dateStarted)) { // if there's a conflict, return true if (compareTimes(dateBeingAddedStart, dateBeingAddedStop, dateStarted, dateEnding)) return true; } // end if } // end for // if no conflicts, return false return false; } // end checkForConflict