116 lines
2.4 KiB
Java
116 lines
2.4 KiB
Java
package new_build.models.taskboard;
|
|
|
|
import java.io.Serializable;
|
|
import java.sql.Date;
|
|
import java.time.LocalDate;
|
|
|
|
import new_build.models.common.data.Sendable;
|
|
import new_build.models.network_organisation.Group;
|
|
import new_build.models.network_organisation.User;
|
|
|
|
public class Task implements Serializable, Sendable {
|
|
|
|
/**
|
|
*
|
|
*/
|
|
private static final long serialVersionUID = -6667163577248501284L;
|
|
private int taskID;
|
|
private Group group;
|
|
private String title, content;
|
|
private Date date, finishingDate;
|
|
private User user;
|
|
private State state;
|
|
|
|
/**
|
|
* Constructor to create a new Task
|
|
* @param title
|
|
* @param content
|
|
* @param group
|
|
*/
|
|
|
|
public Task (String title, String content, Group group){
|
|
this.group = group;
|
|
this.title = title;
|
|
this.content = content;
|
|
this.date = Date.valueOf(LocalDate.now());
|
|
this.state = State.CREATED;
|
|
}
|
|
|
|
public Task(int taskID, User user,Group group, String title, String content, Date date, Date finishingDate, State state){
|
|
this.taskID = taskID;
|
|
this.group = group;
|
|
this.title = title;
|
|
this.content = content;
|
|
this.date = date;
|
|
if (user != null) this.user = user;
|
|
if (finishingDate != null) this.finishingDate = finishingDate;
|
|
this.state = state;
|
|
}
|
|
|
|
public int getTaskID() {
|
|
return taskID;
|
|
}
|
|
|
|
public void setTaskID(int taskID) {
|
|
this.taskID = taskID;
|
|
}
|
|
|
|
public Date getFinishingDate() {
|
|
return finishingDate;
|
|
}
|
|
|
|
private void setFinishingDate(Date finishingDate) {
|
|
this.finishingDate = finishingDate;
|
|
}
|
|
|
|
public User getUser() {
|
|
return user;
|
|
}
|
|
|
|
public void setUser(User user) {
|
|
this.user = user;
|
|
this.setState(State.PLANNED);
|
|
}
|
|
|
|
public State getState() {
|
|
return state;
|
|
}
|
|
|
|
public void setState(State state) {
|
|
if (state != State.FINISHED){
|
|
this.setFinishingDate(null);
|
|
this.state = state;
|
|
} else {
|
|
this.setFinishingDate(Date.valueOf(LocalDate.now()));
|
|
this.state = state;
|
|
}
|
|
}
|
|
|
|
public Group getGroup() {
|
|
return group;
|
|
}
|
|
|
|
public String getTitle() {
|
|
return title;
|
|
}
|
|
|
|
public String getContent() {
|
|
return content;
|
|
}
|
|
|
|
public Date getDate() {
|
|
return date;
|
|
}
|
|
|
|
@Override
|
|
public Class getType() {
|
|
return Task.class;
|
|
}
|
|
|
|
@Override
|
|
public String toString(){
|
|
return "Task " + this.taskID + ": " + this.title + " for group " + this.group.getName();
|
|
}
|
|
|
|
}
|