Small refactoring and fixes #54
|
@ -1,7 +1,7 @@
|
|||
package ch.unisg.executorpool.adapter.in.web;
|
||||
|
||||
import ch.unisg.executorpool.application.port.in.GetAllExecutorInExecutorPoolByTypeQuery;
|
||||
import ch.unisg.executorpool.application.port.in.GetAllExecutorInExecutorPoolByTypeUseCase;
|
||||
import ch.unisg.executorpool.application.port.in.GetAllExecutorsInExecutorPoolByTypeQuery;
|
||||
import ch.unisg.executorpool.application.port.in.GetAllExecutorsInExecutorPoolByTypeUseCase;
|
||||
import ch.unisg.executorpool.domain.ExecutorClass;
|
||||
import ch.unisg.executorpool.domain.ExecutorClass.ExecutorTaskType;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
@ -14,17 +14,17 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
public class GetAllExecutorInExecutorPoolByTypeWebController {
|
||||
private final GetAllExecutorInExecutorPoolByTypeUseCase getAllExecutorInExecutorPoolByTypeUseCase;
|
||||
public class GetAllExecutorsInExecutorPoolByTypeWebController {
|
||||
private final GetAllExecutorsInExecutorPoolByTypeUseCase getAllExecutorsInExecutorPoolByTypeUseCase;
|
||||
|
||||
public GetAllExecutorInExecutorPoolByTypeWebController(GetAllExecutorInExecutorPoolByTypeUseCase getAllExecutorInExecutorPoolByTypeUseCase){
|
||||
this.getAllExecutorInExecutorPoolByTypeUseCase = getAllExecutorInExecutorPoolByTypeUseCase;
|
||||
public GetAllExecutorsInExecutorPoolByTypeWebController(GetAllExecutorsInExecutorPoolByTypeUseCase getAllExecutorInExecutorPoolByTypeUseCase){
|
||||
this.getAllExecutorsInExecutorPoolByTypeUseCase = getAllExecutorInExecutorPoolByTypeUseCase;
|
||||
}
|
||||
|
||||
@GetMapping(path = "/executor-pool/GetAllExecutorInExecutorPoolByType/{taskType}")
|
||||
@GetMapping(path = "/executor-pool/GetAllExecutorsInExecutorPoolByType/{taskType}")
|
||||
public ResponseEntity<String> getAllExecutorInExecutorPoolByType(@PathVariable("taskType") String taskType){
|
||||
GetAllExecutorInExecutorPoolByTypeQuery query = new GetAllExecutorInExecutorPoolByTypeQuery(new ExecutorTaskType(taskType));
|
||||
List<ExecutorClass> matchedExecutors = getAllExecutorInExecutorPoolByTypeUseCase.getAllExecutorInExecutorPoolByType(query);
|
||||
GetAllExecutorsInExecutorPoolByTypeQuery query = new GetAllExecutorsInExecutorPoolByTypeQuery(new ExecutorTaskType(taskType));
|
||||
List<ExecutorClass> matchedExecutors = getAllExecutorsInExecutorPoolByTypeUseCase.getAllExecutorsInExecutorPoolByType(query);
|
||||
|
||||
// Add the content type as a response header
|
||||
HttpHeaders responseHeaders = new HttpHeaders();
|
|
@ -1,9 +0,0 @@
|
|||
package ch.unisg.executorpool.application.port.in;
|
||||
|
||||
import ch.unisg.executorpool.domain.ExecutorClass;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface GetAllExecutorInExecutorPoolByTypeUseCase {
|
||||
List<ExecutorClass> getAllExecutorInExecutorPoolByType(GetAllExecutorInExecutorPoolByTypeQuery query);
|
||||
}
|
|
@ -7,11 +7,11 @@ import lombok.Value;
|
|||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Value
|
||||
public class GetAllExecutorInExecutorPoolByTypeQuery extends SelfValidating<GetAllExecutorInExecutorPoolByTypeQuery> {
|
||||
public class GetAllExecutorsInExecutorPoolByTypeQuery extends SelfValidating<GetAllExecutorsInExecutorPoolByTypeQuery> {
|
||||
@NotNull
|
||||
private final ExecutorTaskType executorTaskType;
|
||||
|
||||
public GetAllExecutorInExecutorPoolByTypeQuery(ExecutorTaskType executorTaskType){
|
||||
public GetAllExecutorsInExecutorPoolByTypeQuery(ExecutorTaskType executorTaskType){
|
||||
this.executorTaskType = executorTaskType;
|
||||
this.validateSelf();
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package ch.unisg.executorpool.application.port.in;
|
||||
|
||||
import ch.unisg.executorpool.domain.ExecutorClass;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface GetAllExecutorsInExecutorPoolByTypeUseCase {
|
||||
List<ExecutorClass> getAllExecutorsInExecutorPoolByType(GetAllExecutorsInExecutorPoolByTypeQuery query);
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package ch.unisg.executorpool.application.service;
|
||||
|
||||
import ch.unisg.executorpool.application.port.in.GetAllExecutorInExecutorPoolByTypeQuery;
|
||||
import ch.unisg.executorpool.application.port.in.GetAllExecutorInExecutorPoolByTypeUseCase;
|
||||
import ch.unisg.executorpool.application.port.in.GetAllExecutorsInExecutorPoolByTypeQuery;
|
||||
import ch.unisg.executorpool.application.port.in.GetAllExecutorsInExecutorPoolByTypeUseCase;
|
||||
import ch.unisg.executorpool.domain.ExecutorClass;
|
||||
import ch.unisg.executorpool.domain.ExecutorPool;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
@ -13,10 +13,10 @@ import java.util.List;
|
|||
@RequiredArgsConstructor
|
||||
@Component
|
||||
@Transactional
|
||||
public class GetAllExecutorInExecutorPoolByTypeService implements GetAllExecutorInExecutorPoolByTypeUseCase {
|
||||
public class GetAllExecutorsInExecutorPoolByTypeService implements GetAllExecutorsInExecutorPoolByTypeUseCase {
|
||||
|
||||
@Override
|
||||
public List<ExecutorClass> getAllExecutorInExecutorPoolByType(GetAllExecutorInExecutorPoolByTypeQuery query){
|
||||
public List<ExecutorClass> getAllExecutorsInExecutorPoolByType(GetAllExecutorsInExecutorPoolByTypeQuery query){
|
||||
ExecutorPool executorPool = ExecutorPool.getExecutorPool();
|
||||
return executorPool.getAllExecutorsByType(query.getExecutorTaskType());
|
||||
}
|
|
@ -5,6 +5,7 @@ import ch.unisg.tapastasks.tasks.application.port.in.DeleteTaskCommand;
|
|||
import ch.unisg.tapastasks.tasks.application.port.in.DeleteTaskUseCase;
|
||||
import ch.unisg.tapastasks.tasks.domain.Task;
|
||||
import ch.unisg.tapastasks.tasks.domain.TaskList;
|
||||
import jdk.jshell.spi.ExecutionControl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -23,11 +24,10 @@ public class DeleteTaskService implements DeleteTaskUseCase {
|
|||
Optional<Task> updatedTask = taskList.retrieveTaskById(command.getTaskId());
|
||||
Task newTask = updatedTask.get();
|
||||
// TODO: Fill in the right condition into the if-statement and the else-statement
|
||||
if (/*the task can be deleted*/){
|
||||
if (true){
|
||||
return taskList.deleteTaskById(command.getTaskId());
|
||||
} else {
|
||||
/*send message back to TaskList that the task cannot be deleted*/
|
||||
}
|
||||
|
||||
// TODO Handle with a return message
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user