package caltool.model.caldb;

import caltool.model.*;
import caltool.model.schedule.*;
import caltool.model.admin.*;
import caltool.model.options.*;
import mvp.*;
import java.util.Collection;

/****
 * 
 * CalendarDB is the top-level model data class for the Calendar Tool.  The
 * first component is the list of UserCalendars for all registered users.  The
 * next three components are the registered UserDB, the user GroupDB, and the
 * LocationDB.  The GlobalOptions component is the set of calendar options
 * common by default for all users, both registered and non-registered.  The
 * UserWorkSpace component is active calendars upon which the current user is
 * working.
 *
 * @author Gene Fisher (gfisher@calpoly.edu)
 * @version 13apr15
 *
 */

public class CalendarDB extends Model {

    public CalendarDB(View view) {
	super(view);
        workspace = new UserWorkSpace();
    }

    /**
     * Get the currently selected date.  If none, return today's date.
     */
    public Date getSelectedDate() {
        return workspace.getCurrent().getSelectedDate();
    }

    /**
     * Set the currently selected date to the given date.
     */
    public void setSelectedDate(Date date) {
        workspace.getCurrent().setSelectedDate(date);
    }

    /**
     * Return the currently active calendar in the workspace.
     */
    public UserCalendar getCurrentCalendar() {
        return workspace.getCurrent();
    }

    /*-*
     * Derived data fields
     */

    /** List of UserCalendars for all registered users */
    protected UserCalendars userCalendars;

    /** Registered user data base */
    protected UserDB userDB;

    /** User group data base */
    protected GroupDB groupDB;

    /** Location data base */
    protected RoomDB roomDB;
    
    /** Set of calendar options commom by default for all users, both
	registered and non-registered */
    protected GlobalOptions global_options;

    /** Active calendars upon which the current user is working. */
    protected UserWorkSpace workspace;

}