-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from CSC207-2022F-UofT/feature-3-updates-fixes
Calendar Screen Clean Architecture bug fix
- Loading branch information
Showing
20 changed files
with
501 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/main/java/screens/calendar_scheduler/CalendarPresenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package screens.calendar_scheduler; | ||
|
||
import screens.task_management.todolist_screens.ToDoListFail; | ||
import use_cases.task_management.todolist_use_case.*; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class CalendarPresenter implements ToDoListOutputBoundary { | ||
|
||
private ToDoListInputBoundary toDoListInput; | ||
|
||
public void setToDoListInput(ToDoListInputBoundary toDoListInput) { | ||
this.toDoListInput = toDoListInput; | ||
} | ||
|
||
public ArrayList<ArrayList<String>> getToDoList() { | ||
ToDoListResponseModel responseModel = toDoListInput.getToDoList(); | ||
return responseModel.getToDoListView(); | ||
} | ||
|
||
@Override | ||
public ToDoListResponseModel display(ToDoListResponseModel responseModel) { | ||
|
||
// Initialise task list array | ||
ArrayList<ArrayList<String>> taskList = new ArrayList<>(); | ||
|
||
// Iterate through each task in to-do list | ||
for (ToDoListItem item : responseModel.getToDoList()) { | ||
|
||
// Intialise task item array | ||
ArrayList<String> taskItem = new ArrayList<>(); | ||
|
||
// Get title, task type, start time, end time, recurrence and frequency of task item | ||
if (item.getTaskType().equals(TaskType.TEST)) { | ||
taskItem.add(item.getTaskTitle()); | ||
taskItem.add("Test"); | ||
taskItem.add(item.getStartTime().toString()); | ||
taskItem.add(item.getEndTime().toString()); | ||
taskItem.add(null); | ||
taskItem.add(null); | ||
} else if (item.getTaskType().equals(TaskType.EVENT)) { | ||
taskItem.add(item.getTaskTitle()); | ||
taskItem.add("Event"); | ||
taskItem.add(item.getStartTime().toString()); | ||
taskItem.add(item.getEndTime().toString()); | ||
taskItem.add(item.isRecurring()); | ||
taskItem.add(item.getFrequency()); | ||
} else { | ||
taskItem.add(item.getTaskTitle()); | ||
taskItem.add("Assignment"); | ||
taskItem.add(null); | ||
taskItem.add(null); | ||
taskItem.add(null); | ||
taskItem.add(null); | ||
} | ||
|
||
// Add task item to task list array | ||
taskList.add(taskItem); | ||
} | ||
|
||
responseModel.setToDoListView(taskList); | ||
|
||
return responseModel; | ||
|
||
} | ||
|
||
@Override | ||
public ToDoListResponseModel failView(String error) { | ||
throw new ToDoListFail(error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.