Class SubjectDAO

java.lang.Object
com.rit.dca.pubpaper.dao.SubjectDAO

public class SubjectDAO
extends java.lang.Object
Database Connectivity and Access
  • Field Summary

    Fields 
    Modifier and Type Field Description
    private UserDAO userAccess  
  • Constructor Summary

    Constructors 
    Constructor Description
    SubjectDAO​(UserDAO userAccess)  
  • Method Summary

    Modifier and Type Method Description
    Subject addSubject​(java.lang.String subjectName)
    Add a new subject to the database (only ADMIN)
    int changeSubject​(int subjectId, java.lang.String newSubjectName)
    Change subject name in the database
    int deleteSubject​(int subjectId)
    Delete a subject from the database (only ADMIN)
    Subject getSubject​(int subjectId)
    Gives a subjects's instance for subjectId provided
    java.util.ArrayList<Subject> getSubjects()
    Gives a list of all subject instances
    private int nextSubjectId​(MySQLDatabase connection)
    Get the new subject id to be inserted

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • getSubject

      public Subject getSubject​(int subjectId) throws PubPaperException
      Gives a subjects's instance for subjectId provided
      Parameters:
      subjectId - - id for which type information is required
      Returns:
      subject's instance
      Throws:
      PubPaperException
    • getSubjects

      public java.util.ArrayList<Subject> getSubjects() throws PubPaperException
      Gives a list of all subject instances
      Returns:
      ArrayList of subject instances
      Throws:
      PubPaperException
    • nextSubjectId

      private int nextSubjectId​(MySQLDatabase connection)
      Get the new subject id to be inserted
      Parameters:
      connection - MySQLDatababase connection object
      Returns:
      int new subject id to use
    • addSubject

      public Subject addSubject​(java.lang.String subjectName) throws PubPaperException
      Add a new subject to the database (only ADMIN)
      Parameters:
      subjectName - to be added to the database
      Returns:
      Subject instance of added subject
      Throws:
      PubPaperException
    • deleteSubject

      public int deleteSubject​(int subjectId) throws PubPaperException
      Delete a subject from the database (only ADMIN)
      Parameters:
      subjectId - to be deleted from the database
      Returns:
      int number of rows affected
      Throws:
      PubPaperException
    • changeSubject

      public int changeSubject​(int subjectId, java.lang.String newSubjectName) throws PubPaperException
      Change subject name in the database
      Parameters:
      subjectId - subject id to be changed
      newSubjectName - subject name to be changed to
      Returns:
      int rows affected on updating subject
      Throws:
      PubPaperException