Package com.rit.dca.pubpaper.dao
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 databaseint
deleteSubject(int subjectId)
Delete a subject from the database (only ADMIN)Subject
getSubject(int subjectId)
Gives a subjects's instance for subjectId providedjava.util.ArrayList<Subject>
getSubjects()
Gives a list of all subject instancesprivate int
nextSubjectId(MySQLDatabase connection)
Get the new subject id to be inserted
-
Field Details
-
Constructor Details
-
Method Details
-
getSubject
Gives a subjects's instance for subjectId provided- Parameters:
subjectId
- - id for which type information is required- Returns:
- subject's instance
- Throws:
PubPaperException
-
getSubjects
Gives a list of all subject instances- Returns:
- ArrayList of subject instances
- Throws:
PubPaperException
-
nextSubjectId
Get the new subject id to be inserted- Parameters:
connection
- MySQLDatababase connection object- Returns:
- int new subject id to use
-
addSubject
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
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
Change subject name in the database- Parameters:
subjectId
- subject id to be changednewSubjectName
- subject name to be changed to- Returns:
- int rows affected on updating subject
- Throws:
PubPaperException
-