Class PaperDAO

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

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

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

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

    Modifier and Type Method Description
    int deletePaper​(int paperId)
    Delete a paper using paperId from the database (only ADMIN)
    int deleteUserPaper​(int submitterId)
    Delete a user's paper from the database (only ADMIN)
    Paper getPaper​(int paperId)
    Gives a paper's instance for paperId provided
    java.util.ArrayList<Paper> getPapers​(int userId)
    Gives a list of paper instances
    private int nextPaperId​(MySQLDatabase connection)
    Get the new paper id to be inserted
    Paper setPaper​(java.util.HashMap<java.lang.String,​java.lang.Object> paperDetails)
    Creates a new paper or updates an existing paper and sets the information for it

    Methods inherited from class java.lang.Object

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

  • Constructor Details

  • Method Details

    • getPapers

      public java.util.ArrayList<Paper> getPapers​(int userId) throws PubPaperException
      Gives a list of paper instances
      Parameters:
      userId - for which papers are required
      Returns:
      array list of papers for userId provided
      Throws:
      PubPaperException
    • getPaper

      public Paper getPaper​(int paperId) throws PubPaperException
      Gives a paper's instance for paperId provided
      Parameters:
      paperId - - id for which paper information is required
      Returns:
      paper's instance
      Throws:
      PubPaperException
    • nextPaperId

      private int nextPaperId​(MySQLDatabase connection)
      Get the new paper id to be inserted
      Parameters:
      connection - MySQLDatababase connection object
      Returns:
      int new paper id to use
    • setPaper

      public Paper setPaper​(java.util.HashMap<java.lang.String,​java.lang.Object> paperDetails) throws PubPaperException
      Creates a new paper or updates an existing paper and sets the information for it
      Parameters:
      paperDetails - key value pairs containing paper information
      Returns:
      Paper instance for created / updated paper
      Throws:
      PubPaperException
    • deleteUserPaper

      public int deleteUserPaper​(int submitterId) throws PubPaperException
      Delete a user's paper from the database (only ADMIN)
      Parameters:
      submitterId - to be deleted from the database
      Returns:
      int number of rows affected
      Throws:
      PubPaperException
    • deletePaper

      public int deletePaper​(int paperId) throws PubPaperException
      Delete a paper using paperId from the database (only ADMIN)
      Parameters:
      paperId - paperid of the paper to be deleted from the database
      Returns:
      int number of rows affected
      Throws:
      PubPaperException