preparing for task priorities
This commit is contained in:
@@ -135,6 +135,7 @@ public class Constants {
|
||||
public static final String PASSWORD = "password";
|
||||
public static final String PERMISSION = "permission";
|
||||
public static final String POST = "POST";
|
||||
public static final String PRIORITY = "priority";
|
||||
public static final String PROJECT = "project";
|
||||
public static final String PROJECT_ID = "project_id";
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ package de.srsoftware.umbrella.core.model;
|
||||
import static de.srsoftware.umbrella.core.Constants.*;
|
||||
|
||||
import de.srsoftware.tools.Mappable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ public class Task implements Mappable {
|
||||
private final long id, projectId;
|
||||
private Long parentTaskId;
|
||||
private String description, name;
|
||||
private Set<Long> requiredTasksIds;
|
||||
private int status;
|
||||
private final Set<Long> requiredTasksIds;
|
||||
private int status, priority;
|
||||
private Double estimatedTime;
|
||||
private LocalDate dueDate, start;
|
||||
private boolean noIndex, showClosed;
|
||||
@@ -29,7 +29,7 @@ public class Task implements Mappable {
|
||||
private final Set<String> dirtyFields = new HashSet<>();
|
||||
|
||||
|
||||
public Task (long id, long projectId, Long parentTaskId, String name, String description, int status, Double estimatedTime, LocalDate start, LocalDate dueDate, boolean showClosed, boolean noIndex, Map<Long,Member> members){
|
||||
public Task (long id, long projectId, Long parentTaskId, String name, String description, int status, Double estimatedTime, LocalDate start, LocalDate dueDate, boolean showClosed, boolean noIndex, Map<Long,Member> members, int priority){
|
||||
this.id = id;
|
||||
this.projectId = projectId;
|
||||
this.parentTaskId = parentTaskId;
|
||||
@@ -43,6 +43,7 @@ public class Task implements Mappable {
|
||||
this.noIndex = noIndex;
|
||||
this.members = members;
|
||||
this.requiredTasksIds = new HashSet<>();
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
public Task clean() {
|
||||
@@ -105,6 +106,7 @@ public class Task implements Mappable {
|
||||
var parentTaskId = rs.getLong(PARENT_TASK_ID);
|
||||
var startDate = nullIfEmpty(rs.getString(START_DATE));
|
||||
var dueDate = nullIfEmpty(rs.getString(DUE_DATE));
|
||||
|
||||
return new Task(
|
||||
rs.getLong(ID),
|
||||
rs.getLong(PROJECT_ID),
|
||||
@@ -117,7 +119,8 @@ public class Task implements Mappable {
|
||||
dueDate != null ? LocalDate.parse(dueDate) : null,
|
||||
rs.getBoolean(SHOW_CLOSED),
|
||||
rs.getBoolean(NO_INDEX),
|
||||
new HashMap<>()
|
||||
new HashMap<>(),
|
||||
rs.getInt(PRIORITY)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -149,9 +152,9 @@ public class Task implements Mappable {
|
||||
LocalDate dueDate = json.has(DUE_DATE) && json.get(DUE_DATE) instanceof String d ? LocalDate.parse(d) : null;
|
||||
var showClosed = json.has(SHOW_CLOSED) && json.get(SHOW_CLOSED) instanceof Boolean sc ? sc : false;
|
||||
var noIndex = json.has(NO_INDEX) && json.get(NO_INDEX) instanceof Boolean ni ? ni : false;
|
||||
|
||||
var priority = json.has(PRIORITY) && json.get(PRIORITY) instanceof Number pr ? prjId.intValue() : 0;
|
||||
if (!(json.has(MEMBERS) && json.get(MEMBERS) instanceof JSONObject)) throw missingFieldException(MEMBERS);
|
||||
return new Task(0,prjId.longValue(),parentTaskId,name,description,status,estimatedTime,startDate,dueDate,showClosed,noIndex,new HashMap<>());
|
||||
return new Task(0,prjId.longValue(),parentTaskId,name,description,status,estimatedTime,startDate,dueDate,showClosed,noIndex,new HashMap<>(),priority);
|
||||
}
|
||||
|
||||
public Task patch(JSONObject json) {
|
||||
@@ -164,6 +167,7 @@ public class Task implements Mappable {
|
||||
case NAME: name = json.getString(key); break;
|
||||
case NO_INDEX: noIndex = json.getBoolean(NO_INDEX); break;
|
||||
case PARENT_TASK_ID: parentTaskId = json.getLong(PARENT_TASK_ID); break;
|
||||
case PRIORITY: priority = json.getInt(PRIORITY); break;
|
||||
case REQUIRED_TASKS_IDS:
|
||||
requiredTasksIds.clear();
|
||||
requiredTasksIds.addAll(json.getJSONArray(REQUIRED_TASKS_IDS).toList().stream().map(entry -> Long.parseLong(entry.toString())).toList());
|
||||
@@ -185,6 +189,10 @@ public class Task implements Mappable {
|
||||
return parentTaskId;
|
||||
}
|
||||
|
||||
public int priority(){
|
||||
return priority;
|
||||
}
|
||||
|
||||
public long projectId(){
|
||||
return projectId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user