Class TypeDAO

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

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

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

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

    Modifier and Type Method Description
    boolean addTypes​(java.lang.String typeName)
    Add a new type to the database (only ADMIN)
    int changeType​(int typeId, java.lang.String newTypeName)
    Update a type in the database (only ADMIN)
    int deleteType​(int typeId)
    Delete a type from the database (only ADMIN)
    Type getType​(int paperId)
    Gives a type's instance
    java.util.ArrayList<Type> getTypes()
    Gives a list of all type instances
    private int nextTypeId​(MySQLDatabase connection)
    Get the new typeId to insert new type

    Methods inherited from class java.lang.Object

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

  • Constructor Details

  • Method Details

    • getType

      public Type getType​(int paperId) throws PubPaperException
      Gives a type's instance
      Parameters:
      paperId - for which type instance is required
      Returns:
      Type instance for paper id provided
      Throws:
      PubPaperException
    • getTypes

      public java.util.ArrayList<Type> getTypes() throws PubPaperException
      Gives a list of all type instances
      Returns:
      ArrayList of type instances
      Throws:
      PubPaperException
    • nextTypeId

      private int nextTypeId​(MySQLDatabase connection)
      Get the new typeId to insert new type
      Parameters:
      connection - MYSQLDatabase connection parameter
      Returns:
      int next type id or -1
    • addTypes

      public boolean addTypes​(java.lang.String typeName) throws PubPaperException
      Add a new type to the database (only ADMIN)
      Parameters:
      typeName - typeName to be added to the database
      Returns:
      boolean success or failure to add a new type
      Throws:
      PubPaperException
    • deleteType

      public int deleteType​(int typeId) throws PubPaperException
      Delete a type from the database (only ADMIN)
      Parameters:
      typeId - typeId to be deleted from the database
      Returns:
      int number of rows affected
      Throws:
      PubPaperException
    • changeType

      public int changeType​(int typeId, java.lang.String newTypeName) throws PubPaperException
      Update a type in the database (only ADMIN)
      Parameters:
      typeId - typeId to be update in the database
      newTypeName - typeName to be to be replaced with in the database
      Returns:
      int number of rows affected
      Throws:
      PubPaperException