Refactoring RetrieveTaskFromTaskListCommand to *Query
This commit is contained in:
parent
5b835bc6bc
commit
ebb91a6010
|
@ -1,6 +1,6 @@
|
|||
package ch.unisg.tapastasks.tasks.adapter.in.web;
|
||||
|
||||
import ch.unisg.tapastasks.tasks.application.port.in.RetrieveTaskFromTaskListCommand;
|
||||
import ch.unisg.tapastasks.tasks.application.port.in.RetrieveTaskFromTaskListQuery;
|
||||
import ch.unisg.tapastasks.tasks.application.port.in.RetrieveTaskFromTaskListUseCase;
|
||||
import ch.unisg.tapastasks.tasks.domain.Task;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
@ -21,7 +21,7 @@ public class RetrieveTaskFromTaskListWebController {
|
|||
|
||||
@GetMapping(path = "/tasks/{taskId}")
|
||||
public ResponseEntity<String> retrieveTaskFromTaskList(@PathVariable("taskId") String taskId) {
|
||||
RetrieveTaskFromTaskListCommand command = new RetrieveTaskFromTaskListCommand(new Task.TaskId(taskId));
|
||||
RetrieveTaskFromTaskListQuery command = new RetrieveTaskFromTaskListQuery(new Task.TaskId(taskId));
|
||||
Optional<Task> updatedTaskOpt = retrieveTaskFromTaskListUseCase.retrieveTaskFromTaskList(command);
|
||||
|
||||
// Check if the task with the given identifier exists
|
||||
|
|
|
@ -7,11 +7,11 @@ import lombok.Value;
|
|||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Value
|
||||
public class RetrieveTaskFromTaskListCommand extends SelfValidating<RetrieveTaskFromTaskListCommand> {
|
||||
public class RetrieveTaskFromTaskListQuery extends SelfValidating<RetrieveTaskFromTaskListQuery> {
|
||||
@NotNull
|
||||
private final TaskId taskId;
|
||||
|
||||
public RetrieveTaskFromTaskListCommand(TaskId taskId) {
|
||||
public RetrieveTaskFromTaskListQuery(TaskId taskId) {
|
||||
this.taskId = taskId;
|
||||
this.validateSelf();
|
||||
}
|
|
@ -5,5 +5,5 @@ import ch.unisg.tapastasks.tasks.domain.Task;
|
|||
import java.util.Optional;
|
||||
|
||||
public interface RetrieveTaskFromTaskListUseCase {
|
||||
Optional<Task> retrieveTaskFromTaskList(RetrieveTaskFromTaskListCommand command);
|
||||
Optional<Task> retrieveTaskFromTaskList(RetrieveTaskFromTaskListQuery command);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ch.unisg.tapastasks.tasks.application.service;
|
||||
|
||||
import ch.unisg.tapastasks.tasks.application.port.in.RetrieveTaskFromTaskListCommand;
|
||||
import ch.unisg.tapastasks.tasks.application.port.in.RetrieveTaskFromTaskListQuery;
|
||||
import ch.unisg.tapastasks.tasks.application.port.in.RetrieveTaskFromTaskListUseCase;
|
||||
import ch.unisg.tapastasks.tasks.domain.Task;
|
||||
import ch.unisg.tapastasks.tasks.domain.TaskList;
|
||||
|
@ -15,7 +15,7 @@ import java.util.Optional;
|
|||
@Transactional
|
||||
public class RetrieveTaskFromTaskListService implements RetrieveTaskFromTaskListUseCase {
|
||||
@Override
|
||||
public Optional<Task> retrieveTaskFromTaskList(RetrieveTaskFromTaskListCommand command) {
|
||||
public Optional<Task> retrieveTaskFromTaskList(RetrieveTaskFromTaskListQuery command) {
|
||||
TaskList taskList = TaskList.getTapasTaskList();
|
||||
return taskList.retrieveTaskById(command.getTaskId());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user