/*This code was generated using the UMPLE modeling language!*/

package University;

import java.sql.Time;
import java.sql.Date;
import java.util.ArrayList;
import java.util.Iterator;
import University.json.*;
import University.core.*;

public class UniversityFacade {
  // Singleton instance.
  private static UniversityFacade theInstance;

  //System registry.
  UniversityRegistry registry = UniversityRegistry.getInstance();

  /**
   * Dummy constructor
   */
  private UniversityFacade() {
  }

  /**
   * Returns the only instance of the Facade.
   * 
   * @return
   */
  public static UniversityFacade getInstance() {
    if (theInstance == null)
      theInstance = new UniversityFacade();
    return theInstance;
  }

  public int constructTopic() {
    return registry.add(new Topic());
  }

  public JSONObject constructTopicJSON() throws JSONException {
    Topic contextObj = new Topic();
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getPrerequisiteReasonsFromTopic(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (PrerequisiteReason obj : ((Topic) registry.getValue(context))
      .getPrerequisiteReasons()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getMutualExclusionReasonsFromTopic(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (MutualExclusionReason obj : ((Topic) registry.getValue(context))
      .getMutualExclusionReasons()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int addPrerequisiteReasonToTopic(int context, int aSuccessor,
    int aPrerequisite) throws Exception {
    return registry.getKey(((Topic) registry.getValue(context))
      .addPrerequisiteReason((Course) registry.getValue(aSuccessor),
        (Course) registry.getValue(aPrerequisite)));
  }

  public JSONObject addPrerequisiteReasonToTopicJSON(int context,
    int aSuccessor, int aPrerequisite) throws JSONException, Exception {
    return ((Topic) registry.getValue(context)).addPrerequisiteReason(
      (Course) registry.getValue(aSuccessor),
      (Course) registry.getValue(aPrerequisite)).getAttributes();
  }

  public int addPrerequisiteReasonToTopicOnly(int context,
    int aPrerequisiteReason) throws Exception {
    return registry.getKey(((Topic) registry.getValue(context))
      .addPrerequisiteReason((PrerequisiteReason) registry
        .getValue(aPrerequisiteReason)));
  }

  public JSONObject addPrerequisiteReasonToTopicOnlyJSON(int context,
    int aPrerequisiteReason) throws JSONException, Exception {
    return ((Topic) registry.getValue(context)).addPrerequisiteReason(
      (PrerequisiteReason) registry.getValue(aPrerequisiteReason))
      .getAttributes();
  }

  public int addMutualExclusionReasonToTopic(int context, int aCourse,
    int aIsMutualyExclusiveWith) throws Exception {
    return registry.getKey(((Topic) registry.getValue(context))
      .addMutualExclusionReason((Course) registry.getValue(aCourse),
        (Course) registry.getValue(aIsMutualyExclusiveWith)));
  }

  public JSONObject addMutualExclusionReasonToTopicJSON(int context,
    int aCourse, int aIsMutualyExclusiveWith) throws JSONException, Exception {
    return ((Topic) registry.getValue(context)).addMutualExclusionReason(
      (Course) registry.getValue(aCourse),
      (Course) registry.getValue(aIsMutualyExclusiveWith)).getAttributes();
  }

  public int addMutualExclusionReasonToTopicOnly(int context,
    int aMutualExclusionReason) throws Exception {
    return registry.getKey(((Topic) registry.getValue(context))
      .addMutualExclusionReason((MutualExclusionReason) registry
        .getValue(aMutualExclusionReason)));
  }

  public JSONObject addMutualExclusionReasonToTopicOnlyJSON(int context,
    int aMutualExclusionReason) throws JSONException, Exception {
    return ((Topic) registry.getValue(context)).addMutualExclusionReason(
      (MutualExclusionReason) registry.getValue(aMutualExclusionReason))
      .getAttributes();
  }

  public void deleteTopic(int context) {
    ((Topic) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deletePrerequisiteReasonFromTopic(int context,
    int aPrerequisiteReason) {
    ((Topic) registry.getValue(context))
      .deletePrerequisiteReason((PrerequisiteReason) registry
        .getValue(aPrerequisiteReason));
  }

  public void deleteMutualExclusionReasonFromTopic(int context,
    int aMutualExclusionReason) {
    ((Topic) registry.getValue(context))
      .deleteMutualExclusionReason((MutualExclusionReason) registry
        .getValue(aMutualExclusionReason));
  }

  public JSONObject getAttributesOfTopic(int context) throws JSONException {
    return ((Topic) registry.getValue(context)).getAttributes();
  }

  public int constructMutualExclusionReason(int aCourse,
    int aIsMutualyExclusiveWith) {
    return registry.add(new MutualExclusionReason((Course) registry
      .getValue(aCourse), (Course) registry.getValue(aIsMutualyExclusiveWith)));
  }

  public JSONObject constructMutualExclusionReasonJSON(int aCourse,
    int aIsMutualyExclusiveWith) throws JSONException {
    MutualExclusionReason contextObj =
      new MutualExclusionReason((Course) registry.getValue(aCourse),
        (Course) registry.getValue(aIsMutualyExclusiveWith));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getOverlappingMaterialsFromMutualExclusionReason(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (Topic obj : ((MutualExclusionReason) registry.getValue(context))
      .getOverlappingMaterials()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int getCourseFromMutualExclusionReason(int context) {
    return registry.getKey(((MutualExclusionReason) registry.getValue(context))
      .getCourse());
  }

  public JSONObject getCourseFromMutualExclusionReasonJSON(int context)
    throws JSONException {
    return ((MutualExclusionReason) registry.getValue(context)).getCourse()
      .getAttributes();
  }

  public int getIsMutualyExclusiveWithFromMutualExclusionReason(int context) {
    return registry.getKey(((MutualExclusionReason) registry.getValue(context))
      .getIsMutualyExclusiveWith());
  }

  public JSONObject getIsMutualyExclusiveWithFromMutualExclusionReasonJSON(
    int context) throws JSONException {
    return ((MutualExclusionReason) registry.getValue(context))
      .getIsMutualyExclusiveWith().getAttributes();
  }

  public int addOverlappingMaterialToMutualExclusionReason(int context)
    throws Exception {
    return registry.getKey(((MutualExclusionReason) registry.getValue(context))
      .addOverlappingMaterial());
  }

  public JSONObject addOverlappingMaterialToMutualExclusionReasonJSON(
    int context) throws JSONException, Exception {
    return ((MutualExclusionReason) registry.getValue(context))
      .addOverlappingMaterial().getAttributes();
  }

  public int addOverlappingMaterialToMutualExclusionReasonOnly(int context,
    int aOverlappingMaterial) throws Exception {
    return registry.getKey(((MutualExclusionReason) registry.getValue(context))
      .addOverlappingMaterial((Topic) registry.getValue(aOverlappingMaterial)));
  }

  public JSONObject addOverlappingMaterialToMutualExclusionReasonOnlyJSON(
    int context, int aOverlappingMaterial) throws JSONException, Exception {
    return ((MutualExclusionReason) registry.getValue(context))
      .addOverlappingMaterial((Topic) registry.getValue(aOverlappingMaterial))
      .getAttributes();
  }

  public void setCourseInMutualExclusionReason(int context, int aCourse)
    throws Exception {
    ((MutualExclusionReason) registry.getValue(context))
      .setCourse((Course) registry.getValue(aCourse));
  }

  public void setIsMutualyExclusiveWithInMutualExclusionReason(int context,
    int aIsMutualyExclusiveWith) throws Exception {
    ((MutualExclusionReason) registry.getValue(context))
      .setIsMutualyExclusiveWith((Course) registry
        .getValue(aIsMutualyExclusiveWith));
  }

  public void deleteMutualExclusionReason(int context) {
    ((MutualExclusionReason) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteOverlappingMaterialFromMutualExclusionReason(int context,
    int aTopic) {
    ((MutualExclusionReason) registry.getValue(context))
      .deleteOverlappingMaterial((Topic) registry.getValue(aTopic));
  }

  public JSONObject getAttributesOfMutualExclusionReason(int context)
    throws JSONException {
    return ((MutualExclusionReason) registry.getValue(context)).getAttributes();
  }

  public int constructCourse() {
    return registry.add(new Course());
  }

  public JSONObject constructCourseJSON() throws JSONException {
    Course contextObj = new Course();
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getMutualyExclusiveFirstEndsFromCourse(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (MutualExclusionReason obj : ((Course) registry.getValue(context))
      .getMutualyExclusiveFirstEnds()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getMutualyExclusiveSecondEndsFromCourse(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (MutualExclusionReason obj : ((Course) registry.getValue(context))
      .getMutualyExclusiveSecondEnds()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getSuccessorReasonsFromCourse(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (PrerequisiteReason obj : ((Course) registry.getValue(context))
      .getSuccessorReasons()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getPrerequisiteReasonsFromCourse(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (PrerequisiteReason obj : ((Course) registry.getValue(context))
      .getPrerequisiteReasons()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int addMutualyExclusiveFirstEndToCourse(int context) throws Exception {
    return registry.getKey(((Course) registry.getValue(context))
      .addMutualyExclusiveFirstEnd());
  }

  public JSONObject addMutualyExclusiveFirstEndToCourseJSON(int context)
    throws JSONException, Exception {
    return ((Course) registry.getValue(context)).addMutualyExclusiveFirstEnd()
      .getAttributes();
  }

  public int addMutualyExclusiveFirstEndToCourseOnly(int context,
    int aMutualyExclusiveFirstEnd) throws Exception {
    return registry.getKey(((Course) registry.getValue(context))
      .addMutualyExclusiveFirstEnd((MutualExclusionReason) registry
        .getValue(aMutualyExclusiveFirstEnd)));
  }

  public JSONObject addMutualyExclusiveFirstEndToCourseOnlyJSON(int context,
    int aMutualyExclusiveFirstEnd) throws JSONException, Exception {
    return ((Course) registry.getValue(context)).addMutualyExclusiveFirstEnd(
      (MutualExclusionReason) registry.getValue(aMutualyExclusiveFirstEnd))
      .getAttributes();
  }

  public int addMutualyExclusiveSecondEndToCourse(int context) throws Exception {
    return registry.getKey(((Course) registry.getValue(context))
      .addMutualyExclusiveSecondEnd());
  }

  public JSONObject addMutualyExclusiveSecondEndToCourseJSON(int context)
    throws JSONException, Exception {
    return ((Course) registry.getValue(context)).addMutualyExclusiveSecondEnd()
      .getAttributes();
  }

  public int addMutualyExclusiveSecondEndToCourseOnly(int context,
    int aMutualyExclusiveSecondEnd) throws Exception {
    return registry.getKey(((Course) registry.getValue(context))
      .addMutualyExclusiveSecondEnd((MutualExclusionReason) registry
        .getValue(aMutualyExclusiveSecondEnd)));
  }

  public JSONObject addMutualyExclusiveSecondEndToCourseOnlyJSON(int context,
    int aMutualyExclusiveSecondEnd) throws JSONException, Exception {
    return ((Course) registry.getValue(context)).addMutualyExclusiveSecondEnd(
      (MutualExclusionReason) registry.getValue(aMutualyExclusiveSecondEnd))
      .getAttributes();
  }

  public int addSuccessorReasonToCourse(int context) throws Exception {
    return registry.getKey(((Course) registry.getValue(context))
      .addSuccessorReason());
  }

  public JSONObject addSuccessorReasonToCourseJSON(int context)
    throws JSONException, Exception {
    return ((Course) registry.getValue(context)).addSuccessorReason()
      .getAttributes();
  }

  public int addSuccessorReasonToCourseOnly(int context, int aSuccessorReason)
    throws Exception {
    return registry.getKey(((Course) registry.getValue(context))
      .addSuccessorReason((PrerequisiteReason) registry
        .getValue(aSuccessorReason)));
  }

  public JSONObject addSuccessorReasonToCourseOnlyJSON(int context,
    int aSuccessorReason) throws JSONException, Exception {
    return ((Course) registry.getValue(context)).addSuccessorReason(
      (PrerequisiteReason) registry.getValue(aSuccessorReason)).getAttributes();
  }

  public int addPrerequisiteReasonToCourse(int context) throws Exception {
    return registry.getKey(((Course) registry.getValue(context))
      .addPrerequisiteReason());
  }

  public JSONObject addPrerequisiteReasonToCourseJSON(int context)
    throws JSONException, Exception {
    return ((Course) registry.getValue(context)).addPrerequisiteReason()
      .getAttributes();
  }

  public int addPrerequisiteReasonToCourseOnly(int context,
    int aPrerequisiteReason) throws Exception {
    return registry.getKey(((Course) registry.getValue(context))
      .addPrerequisiteReason((PrerequisiteReason) registry
        .getValue(aPrerequisiteReason)));
  }

  public JSONObject addPrerequisiteReasonToCourseOnlyJSON(int context,
    int aPrerequisiteReason) throws JSONException, Exception {
    return ((Course) registry.getValue(context)).addPrerequisiteReason(
      (PrerequisiteReason) registry.getValue(aPrerequisiteReason))
      .getAttributes();
  }

  public void deleteCourse(int context) {
    ((Course) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteMutualyExclusiveFirstEndFromCourse(int context,
    int aMutualExclusionReason) {
    ((Course) registry.getValue(context))
      .deleteMutualyExclusiveFirstEnd((MutualExclusionReason) registry
        .getValue(aMutualExclusionReason));
  }

  public void deleteMutualyExclusiveSecondEndFromCourse(int context,
    int aMutualExclusionReason) {
    ((Course) registry.getValue(context))
      .deleteMutualyExclusiveSecondEnd((MutualExclusionReason) registry
        .getValue(aMutualExclusionReason));
  }

  public void deleteSuccessorReasonFromCourse(int context,
    int aPrerequisiteReason) {
    ((Course) registry.getValue(context))
      .deleteSuccessorReason((PrerequisiteReason) registry
        .getValue(aPrerequisiteReason));
  }

  public void deletePrerequisiteReasonFromCourse(int context,
    int aPrerequisiteReason) {
    ((Course) registry.getValue(context))
      .deletePrerequisiteReason((PrerequisiteReason) registry
        .getValue(aPrerequisiteReason));
  }

  public JSONObject getAttributesOfCourse(int context) throws JSONException {
    return ((Course) registry.getValue(context)).getAttributes();
  }

  public int constructPrerequisiteReason(int aSuccessor, int aPrerequisite) {
    return registry.add(new PrerequisiteReason((Course) registry
      .getValue(aSuccessor), (Course) registry.getValue(aPrerequisite)));
  }

  public JSONObject constructPrerequisiteReasonJSON(int aSuccessor,
    int aPrerequisite) throws JSONException {
    PrerequisiteReason contextObj =
      new PrerequisiteReason((Course) registry.getValue(aSuccessor),
        (Course) registry.getValue(aPrerequisite));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getMaterialNeededBySuccessorsFromPrerequisiteReason(
    int context) {
    ArrayList listOfIDs = new ArrayList();
    for (Topic obj : ((PrerequisiteReason) registry.getValue(context))
      .getMaterialNeededBySuccessors()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int getSuccessorFromPrerequisiteReason(int context) {
    return registry.getKey(((PrerequisiteReason) registry.getValue(context))
      .getSuccessor());
  }

  public JSONObject getSuccessorFromPrerequisiteReasonJSON(int context)
    throws JSONException {
    return ((PrerequisiteReason) registry.getValue(context)).getSuccessor()
      .getAttributes();
  }

  public int getPrerequisiteFromPrerequisiteReason(int context) {
    return registry.getKey(((PrerequisiteReason) registry.getValue(context))
      .getPrerequisite());
  }

  public JSONObject getPrerequisiteFromPrerequisiteReasonJSON(int context)
    throws JSONException {
    return ((PrerequisiteReason) registry.getValue(context)).getPrerequisite()
      .getAttributes();
  }

  public int addMaterialNeededBySuccessorToPrerequisiteReason(int context)
    throws Exception {
    return registry.getKey(((PrerequisiteReason) registry.getValue(context))
      .addMaterialNeededBySuccessor());
  }

  public JSONObject addMaterialNeededBySuccessorToPrerequisiteReasonJSON(
    int context) throws JSONException, Exception {
    return ((PrerequisiteReason) registry.getValue(context))
      .addMaterialNeededBySuccessor().getAttributes();
  }

  public int addMaterialNeededBySuccessorToPrerequisiteReasonOnly(int context,
    int aMaterialNeededBySuccessor) throws Exception {
    return registry.getKey(((PrerequisiteReason) registry.getValue(context))
      .addMaterialNeededBySuccessor((Topic) registry
        .getValue(aMaterialNeededBySuccessor)));
  }

  public JSONObject addMaterialNeededBySuccessorToPrerequisiteReasonOnlyJSON(
    int context, int aMaterialNeededBySuccessor) throws JSONException,
    Exception {
    return ((PrerequisiteReason) registry.getValue(context))
      .addMaterialNeededBySuccessor(
        (Topic) registry.getValue(aMaterialNeededBySuccessor)).getAttributes();
  }

  public void setSuccessorInPrerequisiteReason(int context, int aSuccessor)
    throws Exception {
    ((PrerequisiteReason) registry.getValue(context))
      .setSuccessor((Course) registry.getValue(aSuccessor));
  }

  public void setPrerequisiteInPrerequisiteReason(int context, int aPrerequisite)
    throws Exception {
    ((PrerequisiteReason) registry.getValue(context))
      .setPrerequisite((Course) registry.getValue(aPrerequisite));
  }

  public void deletePrerequisiteReason(int context) {
    ((PrerequisiteReason) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteMaterialNeededBySuccessorFromPrerequisiteReason(
    int context, int aTopic) {
    ((PrerequisiteReason) registry.getValue(context))
      .deleteMaterialNeededBySuccessor((Topic) registry.getValue(aTopic));
  }

  public JSONObject getAttributesOfPrerequisiteReason(int context)
    throws JSONException {
    return ((PrerequisiteReason) registry.getValue(context)).getAttributes();
  }
}