/*This code was generated using the UMPLE modeling language!*/

package library;

import java.sql.Time;
import java.sql.Date;
import java.util.ArrayList;
import java.util.Iterator;
import library.json.*;
import library.core.*;

public class LibraryFacade {
  // Singleton instance.
  private static LibraryFacade theInstance;

  //System registry.
  LibraryRegistry registry = LibraryRegistry.getInstance();

  /**
   * Dummy constructor
   */
  private LibraryFacade() {
  }

  /**
   * Returns the only instance of the Facade.
   * 
   * @return
   */
  public static LibraryFacade getInstance() {
    if (theInstance == null)
      theInstance = new LibraryFacade();
    return theInstance;
  }

  public int constructBook(String aName) {
    return registry.add(new Book(aName));
  }

  public JSONObject constructBookJSON(String aName) throws JSONException {
    Book contextObj = new Book(aName);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public void deleteBook(int context) {
    ((Book) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfBook(int context) throws JSONException {
    return ((Book) registry.getValue(context)).getAttributes();
  }

  public int constructIssueOfPeriodical(String aIssueNumber,
    String aPublishedDate, int aPublisher, int aPublication, String aVolume) {
    return registry.add(new IssueOfPeriodical(aIssueNumber, aPublishedDate,
      (Publisher) registry.getValue(aPublisher), (Publication) registry
        .getValue(aPublication), aVolume));
  }

  public JSONObject constructIssueOfPeriodicalJSON(String aIssueNumber,
    String aPublishedDate, int aPublisher, int aPublication, String aVolume)
    throws JSONException {
    IssueOfPeriodical contextObj =
      new IssueOfPeriodical(aIssueNumber, aPublishedDate, (Publisher) registry
        .getValue(aPublisher), (Publication) registry.getValue(aPublication),
        aVolume);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setVolumeInIssueOfPeriodical(int context, String aVolume) {
    return ((IssueOfPeriodical) registry.getValue(context)).setVolume(aVolume);
  }

  public String getVolumeFromIssueOfPeriodical(int context) {
    return ((IssueOfPeriodical) registry.getValue(context)).getVolume();
  }

  public void deleteIssueOfPeriodical(int context) {
    ((IssueOfPeriodical) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfIssueOfPeriodical(int context)
    throws JSONException {
    return ((IssueOfPeriodical) registry.getValue(context)).getAttributes();
  }

  public int constructPublisher(String aName) {
    return registry.add(new Publisher(aName));
  }

  public JSONObject constructPublisherJSON(String aName) throws JSONException {
    Publisher contextObj = new Publisher(aName);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setNameInPublisher(int context, String aName) {
    return ((Publisher) registry.getValue(context)).setName(aName);
  }

  public String getNameFromPublisher(int context) {
    return ((Publisher) registry.getValue(context)).getName();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getEditionOrIssuesFromPublisher(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (EditionOrIssue obj : ((Publisher) registry.getValue(context))
      .getEditionOrIssues()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int addEditionOrIssueToPublisher(int context, String aIssueNumber,
    String aPublishedDate, int aPublisher, int aPublication) throws Exception {
    return registry.getKey(((Publisher) registry.getValue(context))
      .addEditionOrIssue(aIssueNumber, aPublishedDate, (Publisher) registry
        .getValue(aPublisher), (Publication) registry.getValue(aPublication)));
  }

  public JSONObject addEditionOrIssueToPublisherJSON(int context,
    String aIssueNumber, String aPublishedDate, int aPublisher, int aPublication)
    throws JSONException, Exception {
    return ((Publisher) registry.getValue(context)).addEditionOrIssue(
      aIssueNumber, aPublishedDate, (Publisher) registry.getValue(aPublisher),
      (Publication) registry.getValue(aPublication)).getAttributes();
  }

  public int addEditionOrIssueToPublisherOnly(int context, int aEditionOrIssue)
    throws Exception {
    return registry.getKey(((Publisher) registry.getValue(context))
      .addEditionOrIssue((EditionOrIssue) registry.getValue(aEditionOrIssue)));
  }

  public JSONObject addEditionOrIssueToPublisherOnlyJSON(int context,
    int aEditionOrIssue) throws JSONException, Exception {
    return ((Publisher) registry.getValue(context)).addEditionOrIssue(
      (EditionOrIssue) registry.getValue(aEditionOrIssue)).getAttributes();
  }

  public void deletePublisher(int context) {
    ((Publisher) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteEditionOrIssueFromPublisher(int context, int aEditionOrIssue) {
    ((Publisher) registry.getValue(context))
      .deleteEditionOrIssue((EditionOrIssue) registry.getValue(aEditionOrIssue));
  }

  public JSONObject getAttributesOfPublisher(int context) throws JSONException {
    return ((Publisher) registry.getValue(context)).getAttributes();
  }

  public int constructEditionOfBook(String aIssueNumber, String aPublishedDate,
    int aPublisher, int aPublication, String aIsbn, String aLibOfCongress) {
    return registry.add(new EditionOfBook(aIssueNumber, aPublishedDate,
      (Publisher) registry.getValue(aPublisher), (Publication) registry
        .getValue(aPublication), aIsbn, aLibOfCongress));
  }

  public JSONObject constructEditionOfBookJSON(String aIssueNumber,
    String aPublishedDate, int aPublisher, int aPublication, String aIsbn,
    String aLibOfCongress) throws JSONException {
    EditionOfBook contextObj =
      new EditionOfBook(aIssueNumber, aPublishedDate, (Publisher) registry
        .getValue(aPublisher), (Publication) registry.getValue(aPublication),
        aIsbn, aLibOfCongress);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setIsbnInEditionOfBook(int context, String aIsbn) {
    return ((EditionOfBook) registry.getValue(context)).setIsbn(aIsbn);
  }

  public boolean setLibOfCongressInEditionOfBook(int context,
    String aLibOfCongress) {
    return ((EditionOfBook) registry.getValue(context))
      .setLibOfCongress(aLibOfCongress);
  }

  public String getIsbnFromEditionOfBook(int context) {
    return ((EditionOfBook) registry.getValue(context)).getIsbn();
  }

  public String getLibOfCongressFromEditionOfBook(int context) {
    return ((EditionOfBook) registry.getValue(context)).getLibOfCongress();
  }

  public void deleteEditionOfBook(int context) {
    ((EditionOfBook) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfEditionOfBook(int context)
    throws JSONException {
    return ((EditionOfBook) registry.getValue(context)).getAttributes();
  }

  public int constructPartOfPublication(String aTitle, String aPageNumber,
    int aPartOfPublication, int aEditionOrIssue) {
    return registry.add(new PartOfPublication(aTitle, aPageNumber,
      (PartOfPublication) registry.getValue(aPartOfPublication),
      (EditionOrIssue) registry.getValue(aEditionOrIssue)));
  }

  public JSONObject constructPartOfPublicationJSON(String aTitle,
    String aPageNumber, int aPartOfPublication, int aEditionOrIssue)
    throws JSONException {
    PartOfPublication contextObj =
      new PartOfPublication(aTitle, aPageNumber, (PartOfPublication) registry
        .getValue(aPartOfPublication), (EditionOrIssue) registry
        .getValue(aEditionOrIssue));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setTitleInPartOfPublication(int context, String aTitle) {
    return ((PartOfPublication) registry.getValue(context)).setTitle(aTitle);
  }

  public boolean setPageNumberInPartOfPublication(int context,
    String aPageNumber) {
    return ((PartOfPublication) registry.getValue(context))
      .setPageNumber(aPageNumber);
  }

  public String getTitleFromPartOfPublication(int context) {
    return ((PartOfPublication) registry.getValue(context)).getTitle();
  }

  public String getPageNumberFromPartOfPublication(int context) {
    return ((PartOfPublication) registry.getValue(context)).getPageNumber();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getSubpartssFromPartOfPublication(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (PartOfPublication obj : ((PartOfPublication) registry
      .getValue(context)).getSubpartss()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int getPartOfPublicationFromPartOfPublication(int context) {
    return registry.getKey(((PartOfPublication) registry.getValue(context))
      .getPartOfPublication());
  }

  public JSONObject getPartOfPublicationFromPartOfPublicationJSON(int context)
    throws JSONException {
    return ((PartOfPublication) registry.getValue(context))
      .getPartOfPublication().getAttributes();
  }

  public int getEditionOrIssueFromPartOfPublication(int context) {
    return registry.getKey(((PartOfPublication) registry.getValue(context))
      .getEditionOrIssue());
  }

  public JSONObject getEditionOrIssueFromPartOfPublicationJSON(int context)
    throws JSONException {
    return ((PartOfPublication) registry.getValue(context)).getEditionOrIssue()
      .getAttributes();
  }

  public int addSubpartsToPartOfPublication(int context, String aTitle,
    String aPageNumber, int aPartOfPublication, int aEditionOrIssue)
    throws Exception {
    return registry.getKey(((PartOfPublication) registry.getValue(context))
      .addSubparts(aTitle, aPageNumber, (PartOfPublication) registry
        .getValue(aPartOfPublication), (EditionOrIssue) registry
        .getValue(aEditionOrIssue)));
  }

  public JSONObject addSubpartsToPartOfPublicationJSON(int context,
    String aTitle, String aPageNumber, int aPartOfPublication,
    int aEditionOrIssue) throws JSONException, Exception {
    return ((PartOfPublication) registry.getValue(context)).addSubparts(aTitle,
      aPageNumber, (PartOfPublication) registry.getValue(aPartOfPublication),
      (EditionOrIssue) registry.getValue(aEditionOrIssue)).getAttributes();
  }

  public int addSubpartsToPartOfPublicationOnly(int context, int aSubparts)
    throws Exception {
    return registry.getKey(((PartOfPublication) registry.getValue(context))
      .addSubparts((PartOfPublication) registry.getValue(aSubparts)));
  }

  public JSONObject addSubpartsToPartOfPublicationOnlyJSON(int context,
    int aSubparts) throws JSONException, Exception {
    return ((PartOfPublication) registry.getValue(context)).addSubparts(
      (PartOfPublication) registry.getValue(aSubparts)).getAttributes();
  }

  public void setPartOfPublicationInPartOfPublication(int context,
    int aPartOfPublication) throws Exception {
    ((PartOfPublication) registry.getValue(context))
      .setPartOfPublication((PartOfPublication) registry
        .getValue(aPartOfPublication));
  }

  public void setEditionOrIssueInPartOfPublication(int context,
    int aEditionOrIssue) throws Exception {
    ((PartOfPublication) registry.getValue(context))
      .setEditionOrIssue((EditionOrIssue) registry.getValue(aEditionOrIssue));
  }

  public void deletePartOfPublication(int context) {
    ((PartOfPublication) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteSubpartsFromPartOfPublication(int context,
    int aPartOfPublication) {
    ((PartOfPublication) registry.getValue(context))
      .deleteSubparts((PartOfPublication) registry.getValue(aPartOfPublication));
  }

  public JSONObject getAttributesOfPartOfPublication(int context)
    throws JSONException {
    return ((PartOfPublication) registry.getValue(context)).getAttributes();
  }

  public int constructPublication(String aName) {
    return registry.add(new Publication(aName));
  }

  public JSONObject constructPublicationJSON(String aName) throws JSONException {
    Publication contextObj = new Publication(aName);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setNameInPublication(int context, String aName) {
    return ((Publication) registry.getValue(context)).setName(aName);
  }

  public String getNameFromPublication(int context) {
    return ((Publication) registry.getValue(context)).getName();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getEditionOrIssuesFromPublication(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (EditionOrIssue obj : ((Publication) registry.getValue(context))
      .getEditionOrIssues()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int addEditionOrIssueToPublication(int context, String aIssueNumber,
    String aPublishedDate, int aPublisher, int aPublication) throws Exception {
    return registry.getKey(((Publication) registry.getValue(context))
      .addEditionOrIssue(aIssueNumber, aPublishedDate, (Publisher) registry
        .getValue(aPublisher), (Publication) registry.getValue(aPublication)));
  }

  public JSONObject addEditionOrIssueToPublicationJSON(int context,
    String aIssueNumber, String aPublishedDate, int aPublisher, int aPublication)
    throws JSONException, Exception {
    return ((Publication) registry.getValue(context)).addEditionOrIssue(
      aIssueNumber, aPublishedDate, (Publisher) registry.getValue(aPublisher),
      (Publication) registry.getValue(aPublication)).getAttributes();
  }

  public int addEditionOrIssueToPublicationOnly(int context, int aEditionOrIssue)
    throws Exception {
    return registry.getKey(((Publication) registry.getValue(context))
      .addEditionOrIssue((EditionOrIssue) registry.getValue(aEditionOrIssue)));
  }

  public JSONObject addEditionOrIssueToPublicationOnlyJSON(int context,
    int aEditionOrIssue) throws JSONException, Exception {
    return ((Publication) registry.getValue(context)).addEditionOrIssue(
      (EditionOrIssue) registry.getValue(aEditionOrIssue)).getAttributes();
  }

  public void deletePublication(int context) {
    ((Publication) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteEditionOrIssueFromPublication(int context,
    int aEditionOrIssue) {
    ((Publication) registry.getValue(context))
      .deleteEditionOrIssue((EditionOrIssue) registry.getValue(aEditionOrIssue));
  }

  public JSONObject getAttributesOfPublication(int context)
    throws JSONException {
    return ((Publication) registry.getValue(context)).getAttributes();
  }

  public int constructAuthor(String aName) {
    return registry.add(new Author(aName));
  }

  public JSONObject constructAuthorJSON(String aName) throws JSONException {
    Author contextObj = new Author(aName);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setNameInAuthor(int context, String aName) {
    return ((Author) registry.getValue(context)).setName(aName);
  }

  public String getNameFromAuthor(int context) {
    return ((Author) registry.getValue(context)).getName();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getEditionOrIssuesFromAuthor(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (EditionOrIssue obj : ((Author) registry.getValue(context))
      .getEditionOrIssues()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int addEditionOrIssueToAuthor(int context, String aIssueNumber,
    String aPublishedDate, int aPublisher, int aPublication) throws Exception {
    return registry.getKey(((Author) registry.getValue(context))
      .addEditionOrIssue(aIssueNumber, aPublishedDate, (Publisher) registry
        .getValue(aPublisher), (Publication) registry.getValue(aPublication)));
  }

  public JSONObject addEditionOrIssueToAuthorJSON(int context,
    String aIssueNumber, String aPublishedDate, int aPublisher, int aPublication)
    throws JSONException, Exception {
    return ((Author) registry.getValue(context)).addEditionOrIssue(
      aIssueNumber, aPublishedDate, (Publisher) registry.getValue(aPublisher),
      (Publication) registry.getValue(aPublication)).getAttributes();
  }

  public int addEditionOrIssueToAuthorOnly(int context, int aEditionOrIssue)
    throws Exception {
    return registry.getKey(((Author) registry.getValue(context))
      .addEditionOrIssue((EditionOrIssue) registry.getValue(aEditionOrIssue)));
  }

  public JSONObject addEditionOrIssueToAuthorOnlyJSON(int context,
    int aEditionOrIssue) throws JSONException, Exception {
    return ((Author) registry.getValue(context)).addEditionOrIssue(
      (EditionOrIssue) registry.getValue(aEditionOrIssue)).getAttributes();
  }

  public void deleteAuthor(int context) {
    ((Author) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteEditionOrIssueFromAuthor(int context, int aEditionOrIssue) {
    ((Author) registry.getValue(context))
      .deleteEditionOrIssue((EditionOrIssue) registry.getValue(aEditionOrIssue));
  }

  public JSONObject getAttributesOfAuthor(int context) throws JSONException {
    return ((Author) registry.getValue(context)).getAttributes();
  }

  public int constructPeriodical(String aName, String aIssn, String aFrequency) {
    return registry.add(new Periodical(aName, aIssn, aFrequency));
  }

  public JSONObject constructPeriodicalJSON(String aName, String aIssn,
    String aFrequency) throws JSONException {
    Periodical contextObj = new Periodical(aName, aIssn, aFrequency);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setIssnInPeriodical(int context, String aIssn) {
    return ((Periodical) registry.getValue(context)).setIssn(aIssn);
  }

  public boolean setFrequencyInPeriodical(int context, String aFrequency) {
    return ((Periodical) registry.getValue(context)).setFrequency(aFrequency);
  }

  public String getIssnFromPeriodical(int context) {
    return ((Periodical) registry.getValue(context)).getIssn();
  }

  public String getFrequencyFromPeriodical(int context) {
    return ((Periodical) registry.getValue(context)).getFrequency();
  }

  public void deletePeriodical(int context) {
    ((Periodical) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfPeriodical(int context) throws JSONException {
    return ((Periodical) registry.getValue(context)).getAttributes();
  }

  public int constructEditionOrIssue(String aIssueNumber,
    String aPublishedDate, int aPublisher, int aPublication) {
    return registry.add(new EditionOrIssue(aIssueNumber, aPublishedDate,
      (Publisher) registry.getValue(aPublisher), (Publication) registry
        .getValue(aPublication)));
  }

  public JSONObject constructEditionOrIssueJSON(String aIssueNumber,
    String aPublishedDate, int aPublisher, int aPublication)
    throws JSONException {
    EditionOrIssue contextObj =
      new EditionOrIssue(aIssueNumber, aPublishedDate, (Publisher) registry
        .getValue(aPublisher), (Publication) registry.getValue(aPublication));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setIssueNumberInEditionOrIssue(int context, String aIssueNumber) {
    return ((EditionOrIssue) registry.getValue(context))
      .setIssueNumber(aIssueNumber);
  }

  public boolean setPublishedDateInEditionOrIssue(int context,
    String aPublishedDate) {
    return ((EditionOrIssue) registry.getValue(context))
      .setPublishedDate(aPublishedDate);
  }

  public String getIssueNumberFromEditionOrIssue(int context) {
    return ((EditionOrIssue) registry.getValue(context)).getIssueNumber();
  }

  public String getPublishedDateFromEditionOrIssue(int context) {
    return ((EditionOrIssue) registry.getValue(context)).getPublishedDate();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getTableOfContentssFromEditionOrIssue(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (PartOfPublication obj : ((EditionOrIssue) registry.getValue(context))
      .getTableOfContentss()) {
      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 getCopysFromEditionOrIssue(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (Copy obj : ((EditionOrIssue) registry.getValue(context)).getCopys()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int getPublisherFromEditionOrIssue(int context) {
    return registry.getKey(((EditionOrIssue) registry.getValue(context))
      .getPublisher());
  }

  public JSONObject getPublisherFromEditionOrIssueJSON(int context)
    throws JSONException {
    return ((EditionOrIssue) registry.getValue(context)).getPublisher()
      .getAttributes();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getAuthorsFromEditionOrIssue(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (Author obj : ((EditionOrIssue) registry.getValue(context))
      .getAuthors()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int getPublicationFromEditionOrIssue(int context) {
    return registry.getKey(((EditionOrIssue) registry.getValue(context))
      .getPublication());
  }

  public JSONObject getPublicationFromEditionOrIssueJSON(int context)
    throws JSONException {
    return ((EditionOrIssue) registry.getValue(context)).getPublication()
      .getAttributes();
  }

  public int addTableOfContentsToEditionOrIssue(int context, String aTitle,
    String aPageNumber, int aPartOfPublication, int aEditionOrIssue)
    throws Exception {
    return registry.getKey(((EditionOrIssue) registry.getValue(context))
      .addTableOfContents(aTitle, aPageNumber, (PartOfPublication) registry
        .getValue(aPartOfPublication), (EditionOrIssue) registry
        .getValue(aEditionOrIssue)));
  }

  public JSONObject addTableOfContentsToEditionOrIssueJSON(int context,
    String aTitle, String aPageNumber, int aPartOfPublication,
    int aEditionOrIssue) throws JSONException, Exception {
    return ((EditionOrIssue) registry.getValue(context)).addTableOfContents(
      aTitle, aPageNumber,
      (PartOfPublication) registry.getValue(aPartOfPublication),
      (EditionOrIssue) registry.getValue(aEditionOrIssue)).getAttributes();
  }

  public int addTableOfContentsToEditionOrIssueOnly(int context,
    int aTableOfContents) throws Exception {
    return registry.getKey(((EditionOrIssue) registry.getValue(context))
      .addTableOfContents((PartOfPublication) registry
        .getValue(aTableOfContents)));
  }

  public JSONObject addTableOfContentsToEditionOrIssueOnlyJSON(int context,
    int aTableOfContents) throws JSONException, Exception {
    return ((EditionOrIssue) registry.getValue(context)).addTableOfContents(
      (PartOfPublication) registry.getValue(aTableOfContents)).getAttributes();
  }

  public int addCopyToEditionOrIssue(int context, String aBarCodeNumber,
    int aEditionOrIssue) throws Exception {
    return registry.getKey(((EditionOrIssue) registry.getValue(context))
      .addCopy(aBarCodeNumber, (EditionOrIssue) registry
        .getValue(aEditionOrIssue)));
  }

  public JSONObject addCopyToEditionOrIssueJSON(int context,
    String aBarCodeNumber, int aEditionOrIssue) throws JSONException, Exception {
    return ((EditionOrIssue) registry.getValue(context)).addCopy(
      aBarCodeNumber, (EditionOrIssue) registry.getValue(aEditionOrIssue))
      .getAttributes();
  }

  public int addCopyToEditionOrIssueOnly(int context, int aCopy)
    throws Exception {
    return registry.getKey(((EditionOrIssue) registry.getValue(context))
      .addCopy((Copy) registry.getValue(aCopy)));
  }

  public JSONObject addCopyToEditionOrIssueOnlyJSON(int context, int aCopy)
    throws JSONException, Exception {
    return ((EditionOrIssue) registry.getValue(context)).addCopy(
      (Copy) registry.getValue(aCopy)).getAttributes();
  }

  public int addAuthorToEditionOrIssue(int context, String aName)
    throws Exception {
    return registry.getKey(((EditionOrIssue) registry.getValue(context))
      .addAuthor(aName));
  }

  public JSONObject addAuthorToEditionOrIssueJSON(int context, String aName)
    throws JSONException, Exception {
    return ((EditionOrIssue) registry.getValue(context)).addAuthor(aName)
      .getAttributes();
  }

  public int addAuthorToEditionOrIssueOnly(int context, int aAuthor)
    throws Exception {
    return registry.getKey(((EditionOrIssue) registry.getValue(context))
      .addAuthor((Author) registry.getValue(aAuthor)));
  }

  public JSONObject addAuthorToEditionOrIssueOnlyJSON(int context, int aAuthor)
    throws JSONException, Exception {
    return ((EditionOrIssue) registry.getValue(context)).addAuthor(
      (Author) registry.getValue(aAuthor)).getAttributes();
  }

  public void setPublisherInEditionOrIssue(int context, int aPublisher)
    throws Exception {
    ((EditionOrIssue) registry.getValue(context))
      .setPublisher((Publisher) registry.getValue(aPublisher));
  }

  public void setPublicationInEditionOrIssue(int context, int aPublication)
    throws Exception {
    ((EditionOrIssue) registry.getValue(context))
      .setPublication((Publication) registry.getValue(aPublication));
  }

  public void deleteEditionOrIssue(int context) {
    ((EditionOrIssue) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteTableOfContentsFromEditionOrIssue(int context,
    int aPartOfPublication) {
    ((EditionOrIssue) registry.getValue(context))
      .deleteTableOfContents((PartOfPublication) registry
        .getValue(aPartOfPublication));
  }

  public void deleteCopyFromEditionOrIssue(int context, int aCopy) {
    ((EditionOrIssue) registry.getValue(context)).deleteCopy((Copy) registry
      .getValue(aCopy));
  }

  public void deleteAuthorFromEditionOrIssue(int context, int aAuthor) {
    ((EditionOrIssue) registry.getValue(context))
      .deleteAuthor((Author) registry.getValue(aAuthor));
  }

  public JSONObject getAttributesOfEditionOrIssue(int context)
    throws JSONException {
    return ((EditionOrIssue) registry.getValue(context)).getAttributes();
  }

  public int constructCopy(String aBarCodeNumber, int aEditionOrIssue) {
    return registry.add(new Copy(aBarCodeNumber, (EditionOrIssue) registry
      .getValue(aEditionOrIssue)));
  }

  public JSONObject constructCopyJSON(String aBarCodeNumber, int aEditionOrIssue)
    throws JSONException {
    Copy contextObj =
      new Copy(aBarCodeNumber, (EditionOrIssue) registry
        .getValue(aEditionOrIssue));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setBarCodeNumberInCopy(int context, String aBarCodeNumber) {
    return ((Copy) registry.getValue(context)).setBarCodeNumber(aBarCodeNumber);
  }

  public String getBarCodeNumberFromCopy(int context) {
    return ((Copy) registry.getValue(context)).getBarCodeNumber();
  }

  public int getEditionOrIssueFromCopy(int context) {
    return registry.getKey(((Copy) registry.getValue(context))
      .getEditionOrIssue());
  }

  public JSONObject getEditionOrIssueFromCopyJSON(int context)
    throws JSONException {
    return ((Copy) registry.getValue(context)).getEditionOrIssue()
      .getAttributes();
  }

  public void setEditionOrIssueInCopy(int context, int aEditionOrIssue)
    throws Exception {
    ((Copy) registry.getValue(context))
      .setEditionOrIssue((EditionOrIssue) registry.getValue(aEditionOrIssue));
  }

  public void deleteCopy(int context) {
    ((Copy) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfCopy(int context) throws JSONException {
    return ((Copy) registry.getValue(context)).getAttributes();
  }
}