Skip to content

Commit

Permalink
similar to Soumayadip's update task details feature, implemented add …
Browse files Browse the repository at this point in the history
…task use case to update the database and create new task entities. HAS NOT IMPLEMENTED HOW TO ADD THE NEWLY CREATED TASK ENTITY TO THE RESPECTIVE COLUMN'S LIST OF TASKS.Implemented delete task use case to update the database. HAS NOT IMPLEMENTED HOW TO DELETE TASK ENTITY FROM COLUMN ENTITY'S LIST OF TASKS.
  • Loading branch information
wennapengooin committed Aug 4, 2023
1 parent 8e413b1 commit f72bda4
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@ default void updateTaskName(UUID taskID, TaskModel updatedTask) {

}


default void addNewTask(TaskModel newTask) {

}

default void updateTaskDetail(UUID taskID, TaskModel updatedTask) {

}

default void deleteTask(UUID taskID, TaskModel deletedTask) {
default void removeTask(UUID taskID, TaskModel deletedTask) {

}

Expand All @@ -30,5 +35,4 @@ default void updateColumnName(UUID columnID, ColumnModel updatedColumn) {
default void deleteColumn(UUID columnID, ColumnModel deletedColumn) {

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package b_application_business_rules.use_cases.project_viewing_and_modification_use_cases;

import a_enterprise_business_rules.entities.Task;
import b_application_business_rules.DataAccessInterface;

import b_application_business_rules.entity_models.TaskModel;
import b_application_business_rules.use_cases.project_selection_gateways.IDBInsert;
import d_frameworks_and_drivers.database_management.DBControllers.DBManagerInsertController;

import java.time.LocalDateTime;
import java.util.UUID;

/**
* A use case class for editing task details (name and description)
*/
public class AddTask implements DataAccessInterface {
TaskModel taskModel;

public AddTask(TaskModel model) {
this.taskModel = model;
}

/**
* This method creates the task and calls the method that will add the task to the database
* NEED TO IMPLEMENT ADDING TASK TO THE LIST OF TASKS IN THE COLUMN ENTITY
*/
public void addTask() {
// Create task entity
String name = taskModel.getName();
UUID taskID = taskModel.getID();
String description = taskModel.getDescription();
boolean isCompleted = taskModel.getCompletionStatus();
LocalDateTime dueDate = taskModel.getDueDateTime();
Task newTask = new Task(name, taskID, description, isCompleted, dueDate);
//Call the method that accesses the database
addNewTask(taskModel);
}

/**
* Adds the newly created task to the database
* @param newTask
*/
@Override
public void addNewTask(TaskModel newTask) {
//Initializing the required controllers
IDBInsert insertTask = new DBManagerInsertController();
insertTask.DBInsert(newTask);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package b_application_business_rules.use_cases.project_viewing_and_modification_use_cases;

import b_application_business_rules.DataAccessInterface;
import b_application_business_rules.entity_models.TaskModel;
import b_application_business_rules.use_cases.project_selection_gateways.IDBRemove;
import d_frameworks_and_drivers.database_management.DBControllers.DBManagerRemoveController;

import java.util.UUID;

/**
* A use case class for deleting a task
*/
public class DeleteTask implements DataAccessInterface{
TaskModel taskModel;
UUID taskID;

public DeleteTask(TaskModel model, UUID id) {
this.taskModel = model;
this.taskID = id;
}

/**
* NEED TO IMPLEMENT REMOVING TASK ENTITY FROM COLUMN ENTITY
*/
public void deleteTask() {

//call the method that accesses the database
removeTask(taskID, taskModel);
}

@Override
public void removeTask(UUID taskID, TaskModel deletedTask) {
//initialize controller
IDBRemove removeTask = new DBManagerRemoveController();
//remove task from database
removeTask.DBRemove(taskModel, taskID);
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
package b_application_business_rules.use_cases.project_viewing_and_modification_use_cases;

import b_application_business_rules.DataAccessInterface;
import b_application_business_rules.boundaries.ProjectViewingAndModificationInputBoundary;
import b_application_business_rules.boundaries.ProjectViewingAndModificationOutputBoundary;

import b_application_business_rules.entity_models.TaskModel;
import b_application_business_rules.factories.TaskFactory;
import b_application_business_rules.use_cases.CurrentProjectRepository;
import b_application_business_rules.factories.TaskModelFactory;
import b_application_business_rules.use_cases.project_selection_gateways.IDBInsert;
import b_application_business_rules.use_cases.project_selection_gateways.IDBRemove;
import b_application_business_rules.use_cases.project_selection_gateways.IDBSearch;
import c_interface_adapters.ProjectViewingAndModificationController;
import c_interface_adapters.ProjectViewingAndModificationPresenter;
import d_frameworks_and_drivers.database_management.DBControllers.DBManagerInsertController;
import d_frameworks_and_drivers.database_management.DBControllers.DBManagerRemoveController;
import d_frameworks_and_drivers.database_management.DBControllers.DBManagerSearchController;
Expand Down Expand Up @@ -67,7 +62,7 @@ public void updateTaskDetail(UUID taskID, TaskModel updatedTask) {
String oldTaskDescription = oldTaskInfo.get(2);
boolean oldTaskStatus = Boolean.parseBoolean(oldTaskInfo.get(3));
LocalDateTime oldTaskDate = LocalDateTime.parse(oldTaskInfo.get(4));
TaskModel oldTask = TaskFactory.create(oldTaskName, taskID,
TaskModel oldTask = TaskModelFactory.create(oldTaskName, taskID,
oldTaskDescription, oldTaskStatus, oldTaskDate );

//Removing the old task
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import b_application_business_rules.entity_models.ColumnModel;
import b_application_business_rules.entity_models.ProjectModel;
import b_application_business_rules.entity_models.TaskModel;
import b_application_business_rules.factories.TaskModelFactory;
import b_application_business_rules.use_cases.CurrentProjectRepository;
import c_interface_adapters.view_models.TaskViewModel;

Expand Down Expand Up @@ -46,7 +47,18 @@ public void removeCurrentProject() {

@Override
public void addNewTask(UUID idOfColumn, String taskName, String taskDescription, LocalDateTime dueDate) {

//Generate random UUID for task
UUID taskID = UUID.randomUUID();
//Create TaskModel with given info
TaskModel newTaskModel = TaskModelFactory.create(taskName, taskID, taskDescription, false, dueDate);
//initialize use case class
AddTask useCase = new AddTask(newTaskModel);
//call use case class to create a new task and save it to the database
useCase.addTask();
//Initialize TaskViewModel
TaskViewModel newTask = new TaskViewModel(newTaskModel);
//calls presenter to display message
presenter.displayNewTask(idOfColumn, newTask);
}

@Override
Expand All @@ -65,7 +77,16 @@ public void renameColumn(UUID columnBoxId) {

@Override
public void deleteTask(TaskModel task, UUID TaskUIid) {

DeleteTask useCase = new DeleteTask(task, TaskUIid);
try {
useCase.deleteTask();
TaskViewModel newTask = new TaskViewModel(task.getName(), TaskUIid, task.getDescription(),
task.getCompletionStatus(), task.getDueDateTime());
presenter.displayRemovedTask(TaskUIid, newTask);
}
catch(Exception e) {
e.printStackTrace();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
import b_application_business_rules.entity_models.ColumnModel;
import b_application_business_rules.entity_models.*;
import b_application_business_rules.entity_models.TaskModel;
import b_application_business_rules.factories.ColumnFactory;
import b_application_business_rules.factories.ProjectFactory;
import b_application_business_rules.factories.TaskFactory;
import b_application_business_rules.use_cases.project_selection_gateways.IEntityIDsToList;
import b_application_business_rules.factories.ColumnModelFactory;
import b_application_business_rules.factories.ProjectModelFactory;
import b_application_business_rules.factories.TaskModelFactory;
import d_frameworks_and_drivers.database_management.ProjectUUIDArray;

import c_interface_adapters.DBAdapterInterface;
Expand Down Expand Up @@ -66,20 +65,20 @@ public List<ProjectModel> IDstoProjectModelList() {
LocalDateTime dueDate = LocalDateTime.parse(taskInfo.get(4));

//Creating a TaskModel object
TaskModel newTModel = TaskFactory.create(taskName, taskID, taskDescription,
TaskModel newTModel = TaskModelFactory.create(taskName, taskID, taskDescription,
isCompleted, dueDate);
//Appending it to list of TaskModels
taskModelList.add(newTModel);

}
//Creating a ColumnModel object
ColumnModel newCModel = ColumnFactory.create(columnName, taskModelList, columnID);
ColumnModel newCModel = ColumnModelFactory.create(columnName, taskModelList, columnID);
//Appending to the list of ColumnModels
columnModelList.add(newCModel);

}
//Creating a ProjectModel object
ProjectModel newPModel = ProjectFactory.create(projectName, projectID,
ProjectModel newPModel = ProjectModelFactory.create(projectName, projectID,
projectDescription, columnModelList);
//Appending to the list of ProjectModels
projectModels.add(newPModel);
Expand Down

0 comments on commit f72bda4

Please sign in to comment.