Class Calendar
java.lang.Object
cz.cuni.kubinja.hospitalsystem.calendar.Calendar
Manager of appointments for hospital system.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intRequirement that all appointments have to start and end at *.30 or *.00 (so at half or whole hours)static final intEvery appointment have to end before this hourstatic final intMinimum length of appointmentstatic final intFirst appointment can start after hour -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidExports calendar in CSV format into provided file.getCalendar(boolean fromToday) Returns list of strings representing graphical version of calendar.getDepartmentCalendar(String department, boolean fromToday) Returns string representing calendar for the provided department.static booleanhaveTime(List<Appointment> appointments, LocalDateTime start, LocalDateTime end) Decides whether the time interval [start, end] is in the conflict (have overlap) with some appointment.static booleanhaveTime(List<Appointment> appointments, LocalDateTime start, LocalDateTime end, Integer excludedId) Decides whether the time interval [start, end] is in the conflict (have overlap) with some appointment.voidimportData(ResultSet resultSet) Imports appointments from SQL resultSet.static booleanChecks whether the date is between 2000-01-01 00:00 and 3000-01-01 00:00static booleanisWithinValidDates(LocalDate date) Checks whether the date is between 1990-01-01 and present.intnumberOfAppearances(Person person) Returns how many appointments does the provided person had or will have in the future.intsize()Returns number of appointments in the calendar.static booleanstartAtHalves(LocalDateTime time) Checks whether the time is in the opening hours and if satisfy alignment (*:30, *:00).static booleantimeIsValid(LocalDateTime start, LocalDateTime end) Decided whether the starting and ending time of appointment satisfy requirements such as: minimal length, opening hours, correct aligning etc.toString()
-
Field Details
-
minimumLengthOfAppointment
public static final int minimumLengthOfAppointmentMinimum length of appointment- See Also:
-
alignmentOfAppointment
public static final int alignmentOfAppointmentRequirement that all appointments have to start and end at *.30 or *.00 (so at half or whole hours)- See Also:
-
minStartingTime
public static final int minStartingTimeFirst appointment can start after hour- See Also:
-
maxEndingTime
public static final int maxEndingTimeEvery appointment have to end before this hour- See Also:
-
-
Constructor Details
-
Calendar
public Calendar()Creates empty calendar.
-
-
Method Details
-
importData
Imports appointments from SQL resultSet.- Parameters:
resultSet- SQL result containing appointment entries.- Throws:
SQLException- Errors occurs while reading SQL results: invalid columns, reading failure.
-
timeIsValid
Decided whether the starting and ending time of appointment satisfy requirements such as: minimal length, opening hours, correct aligning etc.- Parameters:
start- Starting time.end- Ending time.- Returns:
- Whether the interval satisfy requirements for being appointment.
- Throws:
CalendarException- Errors occurs when time interval do not satisfy any of the requirements.
-
startAtHalves
Checks whether the time is in the opening hours and if satisfy alignment (*:30, *:00).- Parameters:
time- Time we want to process.- Returns:
- Whether the time satisfy requirements.
- Throws:
CalendarException- Error occurs when time does not satisfy requirements.
-
isWithinValidDates
Checks whether the date is between 1990-01-01 and present.- Parameters:
date- Date that will be checked.- Returns:
- Whether the date is between 1990-01-01 and present.
-
isAppointmentWithinValidDateTime
Checks whether the date is between 2000-01-01 00:00 and 3000-01-01 00:00- Parameters:
dateTime- Date and time that will be checked.- Returns:
- Whether the date is between 2000-01-01 00:00 and 3000-01-01 00:00
-
getDepartmentCalendar
Returns string representing calendar for the provided department.- Parameters:
department- Name of department.fromToday- Denotes whether calendar will be exported whole or only appointments in the present and future.- Returns:
- String representing calendar for the provided department.
- Throws:
CalendarException- Department with the provided name does not exist.
-
getCalendar
Returns list of strings representing graphical version of calendar.- Parameters:
fromToday- Denotes whether calendar will be exported whole or only appointments in the present and future.- Returns:
- List of strings representing graphical version of calendar.
-
toString
-
export
Exports calendar in CSV format into provided file.- Parameters:
destination- File where the data should be exported.- Throws:
IOException- Errors occurs when occurs problem with opening and writing into files.
-
size
public int size()Returns number of appointments in the calendar.- Returns:
- Number of appointments in the calendar.
-
numberOfAppearances
Returns how many appointments does the provided person had or will have in the future.- Parameters:
person- Person for which we want to know number of appointments.- Returns:
- How many appointments does the provided person had or will have in the future.
-
haveTime
public static boolean haveTime(List<Appointment> appointments, LocalDateTime start, LocalDateTime end) Decides whether the time interval [start, end] is in the conflict (have overlap) with some appointment.- Parameters:
appointments- List of appointments that we want to check.start- Start of the time interval.end- End of the time interval.- Returns:
- Whether the time interval is not in the conflict with the appointments.
-
haveTime
public static boolean haveTime(List<Appointment> appointments, LocalDateTime start, LocalDateTime end, Integer excludedId) Decides whether the time interval [start, end] is in the conflict (have overlap) with some appointment.- Parameters:
appointments- List of appointments that we want to check.start- Start of the time interval.end- End of the time interval.excludedId- Identification number of the appointment that will not be checked against the time intervals.- Returns:
- Whether the time interval is not in the conflict with the appointments.
-