115 lines
4.0 KiB
Java
115 lines
4.0 KiB
Java
package hhn.temp.project.provider;
|
|
|
|
import hhn.temp.project.Task;
|
|
import hhn.temp.project.Worker;
|
|
|
|
import java.sql.SQLException;
|
|
import java.util.Collection;
|
|
|
|
/**
|
|
* Simple Database Manager to handle simple command such as insertion, deletion, updating of Task and Worker objects.
|
|
* @author Riley Schneider
|
|
*/
|
|
public interface DatabaseManager extends Database {
|
|
/**
|
|
* Saves a Task object into the database
|
|
* @param task Task to be saved into the database
|
|
* @throws SQLException Thrown if database error occurs
|
|
*/
|
|
void saveTask(Task task) throws SQLException;
|
|
|
|
/**
|
|
* Saves a collection of Task objects into the database
|
|
* @param tasks Tasks to be saved into the database
|
|
* @throws SQLException Thrown if database error occurs
|
|
*/
|
|
void saveTasks(Collection<Task> tasks) throws SQLException;
|
|
|
|
/**
|
|
* Saves a Worker object into the database
|
|
* @param worker Worker to be saved into the database
|
|
* @throws SQLException Thrown if database error occurs
|
|
*/
|
|
void saveWorker(Worker worker) throws SQLException;
|
|
|
|
/**
|
|
* Saves a collection Worker objects into the database
|
|
* @param workers Workers to be saved into the database
|
|
* @throws SQLException Thrown if database error occurs
|
|
*/
|
|
void saveWorkers(Collection<Worker> workers) throws SQLException;
|
|
|
|
/**
|
|
* Updates a Task object that already exists in the database
|
|
* @param taskId The ID of the given task
|
|
* @param newTaskObject The new Task object that will overwrite the existent task on database
|
|
* @throws SQLException Thrown if database error occurs
|
|
*/
|
|
void updateTask(int taskId, Task newTaskObject) throws SQLException;
|
|
|
|
/**
|
|
* Updates a Worker object that already exists in the database
|
|
* @param workerId The ID of the given worker
|
|
* @param newWorkerObject The new Worker object that will overwrite the existent task on database
|
|
* @throws SQLException Thrown if database error occurs
|
|
*/
|
|
void updateWorker(int workerId, Worker newWorkerObject) throws SQLException;
|
|
|
|
/**
|
|
* Deletes a task from the database
|
|
* @param taskId The ID of the given task that needs to be deleted
|
|
* @throws SQLException Thrown if database error occurs
|
|
*/
|
|
void deleteTask(int taskId) throws SQLException;
|
|
|
|
/**
|
|
* Deletes a worker from the database
|
|
* @param workerId The ID of the given worker that needs to be deleted
|
|
* @throws SQLException Thrown if database error occurs
|
|
*/
|
|
void deleteWorker(int workerId) throws SQLException;
|
|
|
|
/**
|
|
* Gets a collection of all tasks available in the database
|
|
* @return A collection of tasks (empty if no task available)
|
|
* @throws SQLException Thrown if database error occurs
|
|
*/
|
|
Collection<Task> getTasks() throws SQLException;
|
|
|
|
/**
|
|
* Gets a collection of all workers available in the database
|
|
* @return A collection of workers (empty if no task available)
|
|
* @throws SQLException Thrown if database error occurs
|
|
*/
|
|
Collection<Worker> getWorkers() throws SQLException;
|
|
|
|
/**
|
|
* Gets a task given by its ID from the database
|
|
* @param taskId The task ID
|
|
* @return A task from the database (NULL if no task found)
|
|
* @throws SQLException Thrown if database error occurs
|
|
*/
|
|
Task getTaskByTaskId(int taskId) throws SQLException;
|
|
|
|
/**
|
|
* Gets a worker given by its ID from the database
|
|
* @param workerId The worker ID
|
|
* @return A worker from the database (NULL if no worker found)
|
|
* @throws SQLException Thrown if database error occurs
|
|
*/
|
|
Worker getWorkerByWorkerId(int workerId) throws SQLException;
|
|
|
|
/**
|
|
* Gets the total number of available tasks in the database.
|
|
* @return The total number of tasks (0 = zero entries; -1 = error)
|
|
* @throws SQLException Thrown if database error occurs
|
|
*/
|
|
int getTotalNumberOfTasks() throws SQLException;
|
|
|
|
/**
|
|
* Gets the total number of available workers in the database.
|
|
* @return The total number of workers (0 = zero entries; -1 = error)
|
|
* @throws SQLException Thrown if database error occurs
|
|
*/
|
|
int getTotalNumberOfWorkers() throws SQLException;
|
|
} |