#38 use java.net.uri for all ur is in the executor pool #55

Merged
reynisson merged 2 commits from #38_Use_java.net.URI_for_all_URIs_in_the_ExecutorPool into dev 2021-11-10 10:44:56 +00:00
6 changed files with 28 additions and 28 deletions
Showing only changes of commit 8cfdd5ff09 - Show all commits

View File

@ -1,7 +1,7 @@
package ch.unisg.executorpool.adapter.in.web; package ch.unisg.executorpool.adapter.in.web;
import ch.unisg.executorpool.application.port.in.GetAllExecutorInExecutorPoolByTypeQuery; import ch.unisg.executorpool.application.port.in.GetAllExecutorsInExecutorPoolByTypeQuery;
import ch.unisg.executorpool.application.port.in.GetAllExecutorInExecutorPoolByTypeUseCase; import ch.unisg.executorpool.application.port.in.GetAllExecutorsInExecutorPoolByTypeUseCase;
import ch.unisg.executorpool.domain.ExecutorClass; import ch.unisg.executorpool.domain.ExecutorClass;
import ch.unisg.executorpool.domain.ExecutorClass.ExecutorTaskType; import ch.unisg.executorpool.domain.ExecutorClass.ExecutorTaskType;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
@ -14,17 +14,17 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
@RestController @RestController
public class GetAllExecutorInExecutorPoolByTypeWebController { public class GetAllExecutorsInExecutorPoolByTypeWebController {
private final GetAllExecutorInExecutorPoolByTypeUseCase getAllExecutorInExecutorPoolByTypeUseCase; private final GetAllExecutorsInExecutorPoolByTypeUseCase getAllExecutorsInExecutorPoolByTypeUseCase;
public GetAllExecutorInExecutorPoolByTypeWebController(GetAllExecutorInExecutorPoolByTypeUseCase getAllExecutorInExecutorPoolByTypeUseCase){ public GetAllExecutorsInExecutorPoolByTypeWebController(GetAllExecutorsInExecutorPoolByTypeUseCase getAllExecutorInExecutorPoolByTypeUseCase){
this.getAllExecutorInExecutorPoolByTypeUseCase = getAllExecutorInExecutorPoolByTypeUseCase; this.getAllExecutorsInExecutorPoolByTypeUseCase = getAllExecutorInExecutorPoolByTypeUseCase;
} }
@GetMapping(path = "/executor-pool/GetAllExecutorInExecutorPoolByType/{taskType}") @GetMapping(path = "/executor-pool/GetAllExecutorsInExecutorPoolByType/{taskType}")
public ResponseEntity<String> getAllExecutorInExecutorPoolByType(@PathVariable("taskType") String taskType){ public ResponseEntity<String> getAllExecutorInExecutorPoolByType(@PathVariable("taskType") String taskType){
GetAllExecutorInExecutorPoolByTypeQuery query = new GetAllExecutorInExecutorPoolByTypeQuery(new ExecutorTaskType(taskType)); GetAllExecutorsInExecutorPoolByTypeQuery query = new GetAllExecutorsInExecutorPoolByTypeQuery(new ExecutorTaskType(taskType));
List<ExecutorClass> matchedExecutors = getAllExecutorInExecutorPoolByTypeUseCase.getAllExecutorInExecutorPoolByType(query); List<ExecutorClass> matchedExecutors = getAllExecutorsInExecutorPoolByTypeUseCase.getAllExecutorsInExecutorPoolByType(query);
// Add the content type as a response header // Add the content type as a response header
HttpHeaders responseHeaders = new HttpHeaders(); HttpHeaders responseHeaders = new HttpHeaders();

View File

@ -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);
}

View File

@ -7,11 +7,11 @@ import lombok.Value;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@Value @Value
public class GetAllExecutorInExecutorPoolByTypeQuery extends SelfValidating<GetAllExecutorInExecutorPoolByTypeQuery> { public class GetAllExecutorsInExecutorPoolByTypeQuery extends SelfValidating<GetAllExecutorsInExecutorPoolByTypeQuery> {
@NotNull @NotNull
private final ExecutorTaskType executorTaskType; private final ExecutorTaskType executorTaskType;
public GetAllExecutorInExecutorPoolByTypeQuery(ExecutorTaskType executorTaskType){ public GetAllExecutorsInExecutorPoolByTypeQuery(ExecutorTaskType executorTaskType){
this.executorTaskType = executorTaskType; this.executorTaskType = executorTaskType;
this.validateSelf(); this.validateSelf();
} }

View File

@ -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);
}

View File

@ -1,7 +1,7 @@
package ch.unisg.executorpool.application.service; package ch.unisg.executorpool.application.service;
import ch.unisg.executorpool.application.port.in.GetAllExecutorInExecutorPoolByTypeQuery; import ch.unisg.executorpool.application.port.in.GetAllExecutorsInExecutorPoolByTypeQuery;
import ch.unisg.executorpool.application.port.in.GetAllExecutorInExecutorPoolByTypeUseCase; import ch.unisg.executorpool.application.port.in.GetAllExecutorsInExecutorPoolByTypeUseCase;
import ch.unisg.executorpool.domain.ExecutorClass; import ch.unisg.executorpool.domain.ExecutorClass;
import ch.unisg.executorpool.domain.ExecutorPool; import ch.unisg.executorpool.domain.ExecutorPool;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -13,10 +13,10 @@ import java.util.List;
@RequiredArgsConstructor @RequiredArgsConstructor
@Component @Component
@Transactional @Transactional
public class GetAllExecutorInExecutorPoolByTypeService implements GetAllExecutorInExecutorPoolByTypeUseCase { public class GetAllExecutorsInExecutorPoolByTypeService implements GetAllExecutorsInExecutorPoolByTypeUseCase {
@Override @Override
public List<ExecutorClass> getAllExecutorInExecutorPoolByType(GetAllExecutorInExecutorPoolByTypeQuery query){ public List<ExecutorClass> getAllExecutorsInExecutorPoolByType(GetAllExecutorsInExecutorPoolByTypeQuery query){
ExecutorPool executorPool = ExecutorPool.getExecutorPool(); ExecutorPool executorPool = ExecutorPool.getExecutorPool();
return executorPool.getAllExecutorsByType(query.getExecutorTaskType()); return executorPool.getAllExecutorsByType(query.getExecutorTaskType());
} }

View File

@ -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.application.port.in.DeleteTaskUseCase;
import ch.unisg.tapastasks.tasks.domain.Task; import ch.unisg.tapastasks.tasks.domain.Task;
import ch.unisg.tapastasks.tasks.domain.TaskList; import ch.unisg.tapastasks.tasks.domain.TaskList;
import jdk.jshell.spi.ExecutionControl;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -23,11 +24,10 @@ public class DeleteTaskService implements DeleteTaskUseCase {
Optional<Task> updatedTask = taskList.retrieveTaskById(command.getTaskId()); Optional<Task> updatedTask = taskList.retrieveTaskById(command.getTaskId());
Task newTask = updatedTask.get(); Task newTask = updatedTask.get();
// TODO: Fill in the right condition into the if-statement and the else-statement // 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()); 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();
} }
} }