fixes
This commit is contained in:
@@ -31,7 +31,8 @@ public class NewTaskController {
|
||||
|
||||
logger.info("New task with id:" + task.getTaskID());
|
||||
|
||||
NewTaskCommand command = new NewTaskCommand(task.getTaskID(), task.getTaskType());
|
||||
NewTaskCommand command = new NewTaskCommand(task.getTaskID(), task.getTaskType(),
|
||||
task.getInputData());
|
||||
|
||||
boolean success = newTaskUseCase.addNewTaskToQueue(command);
|
||||
|
||||
|
@@ -25,9 +25,9 @@ public class TaskCompletedController {
|
||||
**/
|
||||
@PostMapping(path = "/task/completed", consumes = {"application/json"})
|
||||
public ResponseEntity<Void> addNewTaskTaskToTaskList(@RequestBody Task task) {
|
||||
|
||||
System.out.println("TEST");
|
||||
TaskCompletedCommand command = new TaskCompletedCommand(task.getTaskID(),
|
||||
task.getStatus(), task.getResult());
|
||||
task.getStatus(), task.getOutputData());
|
||||
|
||||
taskCompletedUseCase.taskCompleted(command);
|
||||
|
||||
|
@@ -32,26 +32,26 @@ public class PublishTaskAssignedEventAdapter implements TaskAssignedEventPort {
|
||||
@Override
|
||||
public void publishTaskAssignedEvent(TaskAssignedEvent event) {
|
||||
|
||||
String body = new JSONObject()
|
||||
.put("taskId", event.taskID)
|
||||
.toString();
|
||||
// String body = new JSONObject()
|
||||
// .put("taskId", event.taskID)
|
||||
// .toString();
|
||||
|
||||
HttpClient client = HttpClient.newHttpClient();
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(URI.create(server + "/tasks/assignTask"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(HttpRequest.BodyPublishers.ofString(body))
|
||||
.build();
|
||||
// HttpClient client = HttpClient.newHttpClient();
|
||||
// HttpRequest request = HttpRequest.newBuilder()
|
||||
// .uri(URI.create(server + "/tasks/assignTask"))
|
||||
// .header("Content-Type", "application/task+json")
|
||||
// .POST(HttpRequest.BodyPublishers.ofString(body))
|
||||
// .build();
|
||||
|
||||
|
||||
try {
|
||||
client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
} catch (InterruptedException e) {
|
||||
logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
|
||||
Thread.currentThread().interrupt();
|
||||
} catch (IOException e) {
|
||||
logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
|
||||
}
|
||||
// try {
|
||||
// client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
// } catch (InterruptedException e) {
|
||||
// logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
|
||||
// Thread.currentThread().interrupt();
|
||||
// } catch (IOException e) {
|
||||
// logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -32,17 +32,22 @@ public class PublishTaskCompletedEventAdapter implements TaskCompletedEventPort
|
||||
@Override
|
||||
public void publishTaskCompleted(TaskCompletedEvent event) {
|
||||
|
||||
System.out.println("PublishTaskCompletedEventAdapter.publishTaskCompleted()");
|
||||
System.out.print(server);
|
||||
|
||||
String body = new JSONObject()
|
||||
.put("taskId", event.taskID)
|
||||
.put("status", event.status)
|
||||
.put("taskResult", event.result)
|
||||
.put("outputData", event.result)
|
||||
.toString();
|
||||
|
||||
System.out.println(event.taskID);
|
||||
|
||||
HttpClient client = HttpClient.newHttpClient();
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(URI.create(server + "/tasks/completeTask"))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(HttpRequest.BodyPublishers.ofString(body))
|
||||
.uri(URI.create(server + "/tasks/completeTask/" + event.taskID))
|
||||
.header("Content-Type", "application/task+json")
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
|
||||
|
@@ -17,9 +17,13 @@ public class NewTaskCommand extends SelfValidating<NewTaskCommand> {
|
||||
@NotNull
|
||||
private final ExecutorType taskType;
|
||||
|
||||
public NewTaskCommand(String taskID, ExecutorType taskType) {
|
||||
@NotNull
|
||||
private final String inputData;
|
||||
|
||||
public NewTaskCommand(String taskID, ExecutorType taskType, String inputData) {
|
||||
this.taskID = taskID;
|
||||
this.taskType = taskType;
|
||||
this.inputData = inputData;
|
||||
this.validateSelf();
|
||||
}
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ public class NewTaskService implements NewTaskUseCase {
|
||||
return false;
|
||||
}
|
||||
|
||||
Task task = new Task(command.getTaskID(), command.getTaskType());
|
||||
Task task = new Task(command.getTaskID(), command.getTaskType(), command.getInputData());
|
||||
|
||||
Roster.getInstance().addTaskToQueue(task);
|
||||
|
||||
|
@@ -14,7 +14,11 @@ public class Task {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String result;
|
||||
private String inputData;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String outputData;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -30,6 +34,12 @@ public class Task {
|
||||
this.taskType = taskType;
|
||||
}
|
||||
|
||||
public Task(String taskID, ExecutorType taskType, String inputData) {
|
||||
this.taskID = taskID;
|
||||
this.taskType = taskType;
|
||||
this.inputData = inputData;
|
||||
}
|
||||
|
||||
public Task() {}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user