package caltool.schedule;

import caltool.caldb.*;
import mvp.*;

/****
 *
 * Class Appointment adds a number of components to a generic ScheduledItem.
 * The StartTime and Duration indicate when the appointment starts and how long
 * it lasts.  The RecurringInfo defines if and how an appointment recurs.  The
 * Location is where it is held.  The Security indicates who can see that the
 * appointment is scheduled.  Priority is how important the appointment is.
 * RemindInfo indicates if and how the user is reminded of the appointment.
 * Details are free form text describing any specific appointment details.
 *
 */

public class Appointment extends ScheduledItem {
    
    /**
     * Construct an empty appointment.
     */
    public Appointment() {
        super();
    }

    /**
     * Construct an appointment with the given field values.  Generate and
     * store the unique key for this appointment.
     */
    public Appointment(String title, Date startOrDueDate, Date endDate,
           Time startTime, Duration duration, RecurringInfo recurringInfo,
           Category category, String location, Security security,
           Priority priority, RemindInfo remindInfo, String details) {

        this.title = title;
        this.startOrDueDate = startOrDueDate;
        this.endDate = endDate;
        this.startTime = startTime;
        this.duration = duration;
        this.recurringInfo = recurringInfo;
        this.category = category;
        this.location = location;
        this.security = security;
        this.priority = priority;
        this.remindInfo = remindInfo;
        this.details = details;

        itemKey = new ItemKey(startOrDueDate, startTime, duration, title, 0);

    }


    /*-*
     * Access methods.
     */

    /**
     * Return the start date.
     */
    public Date getStartDate() {
        return startOrDueDate;
    }

    /**
     * Return the end date.
     */
    public Date getEndDate() {
        return endDate;
    }

    /**
     * Return the start time.
     */
    public Time getStartTime() {
        return startTime;
    }

    /**
     * Return the duration.
     */
    public Duration getDuration() {
        return duration;
    }

    /**
     * Return the recurring info.
     */
    public RecurringInfo getRecurringInfo() {
        return recurringInfo;
    }

    /**
     * Return the location.
     */
    public String getLocation() {
        return location;
    }

    /**
     * Return the security.
     */
    public Security getSecurity() {
        return security;
    }

    /**
     * Return the priority.
     */
    public Priority getPriority() {
        return priority;
    }

    /**
     * Return the remind info.
     */
    public RemindInfo getRemindInfo() {
        return remindInfo;
    }

    /**
     * Return the details.
     */
    public String getDetails() {
        return details;
    }


    /*-*
     * Process methods
     */

    /**
     * Return the unique key for this, consisting of date, time, duration, and
     * title.  Priority is unused at 0.  Note that this method need not be
     * specialized in Meeting, since apppointments and meetings have the same
     * key formats.
     */
    public ItemKey getKey() {
        return itemKey;
    }


    /*-*
     * Derived data fields, in addition to those inherited from ScheduledItem.
     */
    /** Starting time of the appointment */
    protected Time startTime;

    /** How long the appointment lasts */
    protected Duration duration;

    /** Defines if and how an appointment recurs */
    protected RecurringInfo recurringInfo;

    /** Where the appointment is held */
    protected String location;

    /** Indicates who can see that the appointment is scheduled */
    protected Security security;

    /** How important the appointment is */
    protected Priority priority;

    /** Indicates if and how user is reminded */
    protected RemindInfo remindInfo;

    /** Free-form text describing any specific appointment details */
    protected String details;


    /*-*
     * Process data field
     */

    /** The uniqe key for storing this in the UserCalendar items list */
    protected ItemKey itemKey;
}