/*
 * Licensed Materials - Property of Perforce Software, Inc. 
 * © Copyright Perforce Software, Inc. 2014, 2021 
 * © Copyright IBM Corp. 2009, 2014
 * © Copyright ILOG 1996, 2009
 * All Rights Reserved.
 *
 * Note to U.S. Government Users Restricted Rights:
 * The Software and Documentation were developed at private expense and
 * are "Commercial Items" as that term is defined at 48 CFR 2.101,
 * consisting of "Commercial Computer Software" and
 * "Commercial Computer Software Documentation", as such terms are
 * used in 48 CFR 12.212 or 48 CFR 227.7202-1 through 227.7202-4,
 * as applicable.
 */
package database;

import java.util.Date;

import ilog.views.gantt.IlvConstraintType;

/**
 * <code>GanttDBRO</code> defines a very simple read-only interface to a
 * relational database that contains Gantt scheduling data. Each entity in the
 * database (that is, activities, resources, constraints, and reservations) is
 * assumed to be stored as a record, indexed by a unique lookup key string.
 * Methods are defined to query for the lookup key of an entity and to query for
 * an entity's attributes or properties. Entity properties are returned as
 * <i>Record</i> objects, which are defined as inner interfaces.
 */
public interface GanttDBRO {
  // =========================================
  // Activities
  // =========================================

  /**
   * Returns the lookup key for the root activity or <code>null</code> if there
   * are no activities.
   */
  public String queryRootActivityKey();

  /**
   * Returns the <code>Activity</code> record for the activity specified by its
   * lookup key.
   */
  public ActivityRecord queryActivity(String key);

  /**
   * Returns the lookup key for the parent of the specified parent activity. If
   * the activity is the root activity, then it has no parent and this method
   * will return <code>null</code>.
   */
  public String queryActivityParent(String key);

  /**
   * Returns an array of lookup keys for the children of the specified parent
   * activity.
   */
  public String[] queryActivityChildren(String key);

  /**
   * The <code>ActivityRecord</code> inner interface defines the records
   * returned by the {@link #queryActivity} method.
   */
  public static interface ActivityRecord {
    public String getKey();

    public String getName();

    public String getID();

    public Date getStart();

    public Date getEnd();
  }

  // =========================================
  // Resources
  // =========================================

  /**
   * Returns the lookup key for the root resource or <code>null</code> if there
   * are no resources.
   */
  public String queryRootResourceKey();

  /**
   * Returns the <code>Resource</code> record for the resource specified by its
   * lookup key.
   */
  public ResourceRecord queryResource(String key);

  /**
   * Returns the lookup key for the parent of the specified parent resource. If
   * the resource is the root resource, then it has no parent and this method
   * will return <code>null</code>.
   */
  public String queryResourceParent(String key);

  /**
   * Returns an array of lookup keys for the children of the specified parent
   * resource.
   */
  public String[] queryResourceChildren(String key);

  /**
   * The <code>ResourceRecord</code> inner interface defines the records
   * returned by the {@link #queryResource} method.
   */
  public static interface ResourceRecord {
    public String getKey();

    public String getName();

    public String getID();

    public float getQuantity();
  }

  // =========================================
  // Reservations
  // =========================================

  /**
   * Returns an array of lookup keys for all the reservations.
   */
  public String[] queryReservations();

  /**
   * Returns an array of lookup keys for all the reservations that are
   * associated with an activity, specified by its lookup key.
   */
  public String[] queryReservationsForActivity(String activityKey);

  /**
   * Returns an array of lookup keys for all the reservations that are
   * associated with a resource, specified by its lookup key.
   */
  public String[] queryReservationsForResource(String resourceKey);

  /**
   * Returns an array of lookup keys for all the reservations that are
   * associated with a resource, specified by its lookup key, and that intersect
   * the specified time range.
   */
  public String[] queryReservationsForResource(String resourceKey, Date start, Date end);

  /**
   * Returns the <code>Reservation</code> record for the reservation specified
   * by its lookup key.
   */
  public ReservationRecord queryReservation(String key);

  /**
   * The <code>ReservationRecord</code> inner interface defines the records
   * returned by the {@link #queryReservation} method.
   */
  public static interface ReservationRecord {
    public String getKey();

    public String getActivityKey();

    public String getResourceKey();
  }

  // =========================================
  // Constraints
  // =========================================

  /**
   * Returns an array of lookup keys for all the constraints.
   */
  public String[] queryConstraints();

  /**
   * Returns an array of lookup keys for all the constraints that have the
   * specified activity as their source or <i>from</i> activity, specified by
   * its lookup key.
   */
  public String[] queryConstraintsFromActivity(String activityKey);

  /**
   * Returns an array of lookup keys for all the constraints that have the
   * specified activity as their target or <i>to</i> activity, specified by its
   * lookup key.
   */
  public String[] queryConstraintsToActivity(String activityKey);

  /**
   * Returns the <code>Constraint</code> record for the constraint specified by
   * its lookup key.
   */
  public ConstraintRecord queryConstraint(String key);

  /**
   * The <code>ConstraintRecord</code> inner interface defines the records
   * returned by the {@link #queryConstraint} method.
   */
  public static interface ConstraintRecord {
    public String getKey();

    public String getFromActivityKey();

    public String getToActivityKey();

    public IlvConstraintType getType();
  }

}