Add an "assignmentId" field in the "Assignment"-class.

This commit is contained in:
Lampros Smyrnaios 2021-06-09 05:45:07 +03:00
parent 82e12655e7
commit 53ccea869a
2 changed files with 22 additions and 4 deletions

View File

@ -10,12 +10,16 @@ import java.util.List;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"assignmentId",
"tasks",
"workerId",
"date"
})
public class Assignment {
@JsonProperty("assignmentId")
private int assignmentId;
@JsonProperty("tasks")
private List<Task> tasks;
@ -27,12 +31,21 @@ public class Assignment {
public Assignment() {}
public Assignment(List<Task> tasks, String workerId, Date date) {
public Assignment(int assignmentId, List<Task> tasks, String workerId, Date date) {
this.assignmentId = assignmentId;
this.tasks = tasks;
this.workerId = workerId;
this.date = date;
}
public int getAssignmentId() {
return assignmentId;
}
public void setAssignmentId(int assignmentId) {
this.assignmentId = assignmentId;
}
public List<Task> getTasks() {
return tasks;
}
@ -60,7 +73,8 @@ public class Assignment {
@Override
public String toString() {
return "Assignment{" +
"tasks=" + tasks +
"assignmentId=" + assignmentId +
", tasks=" + tasks +
", workerId='" + workerId + '\'' +
", date=" + date +
'}';

View File

@ -48,9 +48,13 @@ public class AssignmentHandler {
System.exit(1);
}
logger.debug(assignmentRequest.toString());
//logger.debug(assignmentRequest.toString()); // DEBUG!
return assignmentRequest.getAssignment();
Assignment assignment = assignmentRequest.getAssignment();
logger.info("Assignment with id < " + assignment.getAssignmentId() + " > was received and it's ready to be processed.");
// TODO - Maybe create a HashSet with these IDs. It may be useful for the Worker to know and report which assignments (and how many) it has processed.
return assignment;
}