001: /*--------------------------------------------------------------------------*
002: | Copyright (C) 2006 Gereon Fassbender, Christopher Kohlhaas |
003: | |
004: | This program is free software; you can redistribute it and/or modify |
005: | it under the terms of the GNU General Public License as published by the |
006: | Free Software Foundation. A copy of the license has been included with |
007: | these distribution in the COPYING file, if not go to www.fsf.org |
008: | |
009: | As a special exception, you are granted the permissions to link this |
010: | program with every library, which license fulfills the Open Source |
011: | Definition as published by the Open Source Initiative (OSI). |
012: *--------------------------------------------------------------------------*/
013: package org.rapla.entities.domain;
014:
015: import java.util.Date;
016:
017: import org.rapla.entities.Entity;
018: import org.rapla.entities.Ownable;
019: import org.rapla.entities.RaplaObject;
020: import org.rapla.entities.RaplaType;
021:
022: /** The basic building blocks of reservations.
023: @see Reservation
024: @see Repeating*/
025: public interface Appointment extends RaplaObject, Entity, Comparable,
026: Ownable {
027: final RaplaType TYPE = new RaplaType(Appointment.class,
028: "appointment");
029:
030: Date getStart();
031:
032: Date getEnd();
033:
034: /** <p>
035: If no repeating is set this method will return the same
036: as <code>getEnd()</code>.
037: </p>
038: <p>
039: If the repeating has no end the method will return <strong>Null</strong>.
040: Oterwise the maximum of getEnd() and repeating.getEnd() will be returned.
041: </p>
042: @see #getEnd
043: @see Repeating
044: */
045: Date getMaxEnd();
046:
047: /** returns the reservation that owns the appointment.
048: @return the reservation that owns the appointment or null if
049: the appointment does not belong to a reservation.
050: */
051: Reservation getReservation();
052:
053: /** @return null if the appointment has no repeating
054: */
055: Repeating getRepeating();
056:
057: /** Enables repeating for this appointment.
058: Use getRepeating() to manipulate the repeating. */
059: void setRepeatingEnabled(boolean enableRepeating);
060:
061: /** returns if the appointment has a repeating */
062: boolean isRepeatingEnabled();
063:
064: /** Changes the start- and end-time of the appointment.
065: */
066: void move(Date start, Date end);
067:
068: /** Moves the start-time of the appointment.
069: The end-time will be adjusted accordingly to the duration of the appointment.
070: */
071: void move(Date newStart);
072:
073: /** Tests two appointments for overlap.
074: Important: Times like 13:00-14:00 and 14:00-15:00 do not overlap
075: The overlap-relation must be symmetric <code>a1.overlaps(a2) == a2.overlaps(a1)</code>
076: @return true if the appointment overlaps the given appointment.
077: */
078: boolean overlaps(Appointment appointment);
079:
080: /** Test for overlap with a period.
081: * same as overlaps( start, end, true)
082: * @return true if the overlaps with the given period.
083: */
084: boolean overlaps(Date start, Date end);
085:
086: /** Test for overlap with a period. You can specify if exceptions should be considered in the overlapping algorithm.
087: @return true if the overlaps with the given period.
088: */
089: boolean overlaps(Date start, Date end, boolean considerExceptions);
090:
091: /** Returns if the exceptions, repeatings, start and end dates of the Appoinemnts are the same.*/
092: boolean matches(Appointment appointment);
093:
094: /** @param maxDate must not be null, specifies the last date that should be searched
095:
096: returns the first date at which the two appointments differ (dates after maxDate will not be calculated)
097: */
098: Date getFirstDifference(Appointment a2, Date maxDate);
099:
100: /** @param maxDate must not be null, specifies the last date that should be searched
101:
102: returns the last date at which the two appointments differ. (dates after maxDate will not be calculated)*/
103: Date getLastDifference(Appointment a2, Date maxDate);
104:
105: /** this method will be used for future enhancements */
106: boolean isWholeDaysSet();
107:
108: /** this method will be used for future enhancements */
109: void setWholeDays(boolean enable);
110:
111: /** adds all Appointment-blocks in the given period to the appointmentBlockArray.
112: A block is in the period if its starttime<end or its endtime>start. Exceptions are excluded, i.e. there is no block on an exception date.
113: */
114: void createBlocks(Date start, Date end, AppointmentBlockArray blocks);
115:
116: /** adds all Appointment-blocks in the given period to the appointmentBlockArray.
117: A block is in the period if its starttime<end or its endtime>start. You can specify if exceptions should be excluded.
118: */
119: void createBlocks(Date start, Date end,
120: AppointmentBlockArray blocks, boolean excludeExceptions);
121:
122: final Appointment[] EMPTY_ARRAY = new Appointment[0];
123: }
|