Package com.rit.dca.pubpaper.dao
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
-
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 instancejava.util.ArrayList<Type>
getTypes()
Gives a list of all type instancesprivate int
nextTypeId(MySQLDatabase connection)
Get the new typeId to insert new type
-
Field Details
-
Constructor Details
-
Method Details
-
getType
Gives a type's instance- Parameters:
paperId
- for which type instance is required- Returns:
- Type instance for paper id provided
- Throws:
PubPaperException
-
getTypes
Gives a list of all type instances- Returns:
- ArrayList of type instances
- Throws:
PubPaperException
-
nextTypeId
Get the new typeId to insert new type- Parameters:
connection
- MYSQLDatabase connection parameter- Returns:
- int next type id or -1
-
addTypes
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
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
Update a type in the database (only ADMIN)- Parameters:
typeId
- typeId to be update in the databasenewTypeName
- typeName to be to be replaced with in the database- Returns:
- int number of rows affected
- Throws:
PubPaperException
-