Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main/java/app/AppBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,14 @@ public AppBuilder addDashboardUseCase() {
DynamoDbClientSingleton.getInstance());
final CommitDataAccessInterface commitDataAccess = new CommitDataAccessObject(
DynamoDbClientSingleton.getInstance());
final ChoreDataAccessInterface choreDataAccess = new ChoreDataAccessObject(
DynamoDbClientSingleton.getInstance());

final DashboardOutputBoundary dashboardOutputBoundary = new DashboardPresenter(
dashboardViewModel, viewManagerModel, choreCreationViewModel);

final DashboardInputBoundary dashboardInteractor = new DashboardInteractor(dashboardOutputBoundary, userService,
roomDataAccess, commitDataAccess);
roomDataAccess, commitDataAccess, choreDataAccess);

final DashboardController dashboardController = new DashboardController(
dashboardInteractor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public void prepareSuccessView(DashboardOutputData dashboardOutputData) {
dashboardState.setRoomCode(dashboardOutputData.getRoomCode());
dashboardState.setRoomName(dashboardOutputData.getRoomName());
dashboardState.setRoomDescription(dashboardOutputData.getRoomDescription());
dashboardState.setChores(dashboardOutputData.getChores());
dashboardViewModel.setState(dashboardState);
dashboardViewModel.firePropertyChange();
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/interface_adapter/dashboard/DashboardState.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
package interface_adapter.dashboard;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import entity.Chore;

public class DashboardState {
private String currentUsername;
private String roomName;
private String roomDescription;
private String roomCode;
private Map<LocalDate, Integer> activityData = new HashMap<>();
private Map<LocalDate, List<String>> commitsMessages = new HashMap<>();
private List<Chore> chores = new ArrayList<>();
private String errorMessage;

public Map<LocalDate, Integer> getActivityData() {
Expand All @@ -38,6 +42,10 @@ public Map<LocalDate, List<String>> getCommitsMessages() {
return commitsMessages;
}

public List<Chore> getChores() {
return chores;
}

public String getErrorMessage() {
return errorMessage;
}
Expand Down Expand Up @@ -66,6 +74,10 @@ public void setCommitsMessages(Map<LocalDate, List<String>> commitsMessages) {
this.commitsMessages = commitsMessages;
}

public void setChores(List<Chore> chores) {
this.chores = chores;
}

public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
Expand Down
19 changes: 17 additions & 2 deletions src/main/java/use_case/dashboard/DashboardInteractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;

import entity.Chore;
import entity.Commit;
import entity.Room;
import entity.User;
import use_case.chore.ChoreDataAccessInterface;
import use_case.commit.CommitDataAccessInterface;
import use_case.logged_in.UserService;
import use_case.room.RoomDataAccessInterface;
Expand All @@ -17,18 +20,21 @@ public class DashboardInteractor implements DashboardInputBoundary {
private final UserService userService;
private final RoomDataAccessInterface roomDataAccessObject;
private final CommitDataAccessInterface commitDataAccessObject;
private final ChoreDataAccessInterface choreDataAccessObject;

public DashboardInteractor(DashboardOutputBoundary dashboardPresenter,
UserService userService,
RoomDataAccessInterface roomDataAccessObject,
CommitDataAccessInterface commitDataAccessObject) {
CommitDataAccessInterface commitDataAccessObject, ChoreDataAccessInterface choreDataAccessObject) {
this.dashboardPresenter = dashboardPresenter;
this.userService = userService;
this.roomDataAccessObject = roomDataAccessObject;
this.commitDataAccessObject = commitDataAccessObject;
this.choreDataAccessObject = choreDataAccessObject;
}

@Override
@SuppressWarnings("checkstyle:IllegalCatch")
public void execute(DashboardInputData dashboardInputData) {
final User user = userService.getUser();
if (user == null) {
Expand Down Expand Up @@ -61,13 +67,22 @@ public void execute(DashboardInputData dashboardInputData) {
messages.computeIfAbsent(date, key -> new ArrayList<>()).add(commit.getMessage());
}

List<Chore> chores;
try {
chores = choreDataAccessObject.getChoresForRoom(roomId);
chores.sort(Comparator.comparing(Chore::getDueDate));
} catch (Exception empty) {
chores = new ArrayList<>();
}

final DashboardOutputData dashboardOutputData = new DashboardOutputData(true,
user.getUsername(),
room.getName(),
room.getDescription(),
room.getInviteCode(),
counts,
messages);
messages,
chores);

dashboardPresenter.prepareSuccessView(dashboardOutputData);
}
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/use_case/dashboard/DashboardOutputData.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.List;
import java.util.Map;

import entity.Chore;

public class DashboardOutputData {
private final boolean success;
private final String currentUsername;
Expand All @@ -12,21 +14,25 @@ public class DashboardOutputData {
private final String roomCode;
private final Map<LocalDate, Integer> activityData;
private final Map<LocalDate, List<String>> commitsMessages;
private final List<Chore> chores;

@SuppressWarnings("checkstyle:ParameterNumber")
public DashboardOutputData(boolean success,
String currentUsername,
String roomName,
String roomDescription,
String roomCode,
Map<LocalDate, Integer> activityData,
Map<LocalDate, List<String>> commitsMessages) {
Map<LocalDate, List<String>> commitsMessages,
List<Chore> chores) {
this.success = success;
this.currentUsername = currentUsername;
this.roomName = roomName;
this.roomDescription = roomDescription;
this.roomCode = roomCode;
this.activityData = activityData;
this.commitsMessages = commitsMessages;
this.chores = chores;
}

public boolean isSuccess() {
Expand Down Expand Up @@ -56,4 +62,8 @@ public Map<LocalDate, Integer> getActivityData() {
public Map<LocalDate, List<String>> getCommitsMessages() {
return commitsMessages;
}

public List<Chore> getChores() {
return chores;
}
}
Loading
Loading