This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package hhn.temp.project;
|
||||
|
||||
import hhn.temp.project.expections.TaskHasNoWorkerException;
|
||||
import hhn.temp.project.provider.MySql;
|
||||
|
||||
public class Task {
|
||||
|
||||
@@ -8,17 +9,17 @@ public class Task {
|
||||
private String description;
|
||||
private TaskStatus taskStatus;
|
||||
private int taskID;
|
||||
private static int idCounter = 0;
|
||||
private String workername;
|
||||
private MySql mySql;
|
||||
|
||||
public Task(String name, String description) {
|
||||
|
||||
public Task(int id, String name, String description, String workername, TaskStatus status, MySql mySql) {
|
||||
|
||||
this.taskID = id;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.taskStatus = TaskStatus.OPEN;
|
||||
//TODO when DB then auto IDs
|
||||
this.taskID = idCounter++;
|
||||
this.taskStatus = status;
|
||||
this.workername = workername;
|
||||
this.mySql = mySql;
|
||||
}
|
||||
|
||||
public int getTaskID() {
|
||||
@@ -43,6 +44,7 @@ public class Task {
|
||||
throw new IllegalArgumentException("Description is null!");
|
||||
}
|
||||
|
||||
this.mySql.updateDescription(taskID, description);
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@@ -52,6 +54,7 @@ public class Task {
|
||||
throw new IllegalArgumentException("TaskStatus is null!");
|
||||
}
|
||||
|
||||
this.mySql.updateStatus(taskID, taskStatus);
|
||||
this.taskStatus = taskStatus;
|
||||
}
|
||||
|
||||
@@ -62,6 +65,9 @@ public class Task {
|
||||
if(!checkOnlyLetter(workerName)){
|
||||
throw new IllegalArgumentException("Only Lettery as Worker Name!");
|
||||
}
|
||||
|
||||
this.mySql.updateStatus(taskID, TaskStatus.INPROCESS);
|
||||
this.mySql.updateWorker(taskID, workerName);
|
||||
this.workername = workerName;
|
||||
this.setStatus(TaskStatus.INPROCESS);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user