Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.telerikacademy.oop.teamproject.commands.show;
- import com.telerikacademy.oop.teamproject.commands.contracts.Command;
- import com.telerikacademy.oop.teamproject.core.contracts.TaskManagementSystemRepository;
- import com.telerikacademy.oop.teamproject.models.contracts.Board;
- import com.telerikacademy.oop.teamproject.models.contracts.Task;
- import com.telerikacademy.oop.teamproject.models.contracts.Team;
- import com.telerikacademy.oop.teamproject.utils.ParsingHelpers;
- import com.telerikacademy.oop.teamproject.utils.ValidationHelpers;
- import java.util.List;
- public class ShowCommentsCommand implements Command {
- private static final int EXPECTED_NUMBER_OF_ARGUMENTS = 3;
- private TaskManagementSystemRepository taskManagementSystemRepository;
- String teamName;
- String boardName;
- int taskId;
- public ShowCommentsCommand(TaskManagementSystemRepository taskManagementSystemRepository) {
- this.taskManagementSystemRepository = taskManagementSystemRepository;
- }
- @Override
- public String execute(List<String> parameters) {
- ValidationHelpers.validateArgumentsCount(parameters, EXPECTED_NUMBER_OF_ARGUMENTS);
- teamName = parameters.get(0);
- boardName = parameters.get(1);
- taskId = ParsingHelpers.tryParseInt(parameters.get(2), "id");
- Team team = taskManagementSystemRepository.findTeamByTeamName(teamName);
- Board board = team.findBoardByName(boardName);
- Task task = board.findTaskById(board.getAllTasks(), taskId);
- return task.getComments();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment