preparing for task dependency implementation
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -6,7 +6,6 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
|||||||
|
|
||||||
public class Constants {
|
public class Constants {
|
||||||
|
|
||||||
|
|
||||||
private Constants(){}
|
private Constants(){}
|
||||||
|
|
||||||
public static final String ADDRESS = "address";
|
public static final String ADDRESS = "address";
|
||||||
@@ -140,6 +139,7 @@ public class Constants {
|
|||||||
public static final String RECEIVERS = "receivers";
|
public static final String RECEIVERS = "receivers";
|
||||||
public static final String REDIRECT = "redirect";
|
public static final String REDIRECT = "redirect";
|
||||||
public static final String RENDERED = "rendered";
|
public static final String RENDERED = "rendered";
|
||||||
|
public static final String REQUIRED_TASKS_IDS = "required_tasks_ids";
|
||||||
|
|
||||||
public static final String SENDER = "sender";
|
public static final String SENDER = "sender";
|
||||||
public static final String SETTINGS = "settings";
|
public static final String SETTINGS = "settings";
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public class Task implements Mappable {
|
|||||||
private final long id, projectId;
|
private final long id, projectId;
|
||||||
private Long parentTaskId;
|
private Long parentTaskId;
|
||||||
private String description, name;
|
private String description, name;
|
||||||
|
private Set<Long> requiredTasksIds;
|
||||||
private int status;
|
private int status;
|
||||||
private Double estimatedTime;
|
private Double estimatedTime;
|
||||||
private LocalDate dueDate, start;
|
private LocalDate dueDate, start;
|
||||||
@@ -41,6 +42,7 @@ public class Task implements Mappable {
|
|||||||
this.showClosed = showClosed;
|
this.showClosed = showClosed;
|
||||||
this.noIndex = noIndex;
|
this.noIndex = noIndex;
|
||||||
this.members = members;
|
this.members = members;
|
||||||
|
this.requiredTasksIds = new HashSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task clean() {
|
public Task clean() {
|
||||||
@@ -131,8 +133,6 @@ public class Task implements Mappable {
|
|||||||
default -> throw invalidFieldException(json.get(DESCRIPTION).getClass().getSimpleName(),"String or JSON");
|
default -> throw invalidFieldException(json.get(DESCRIPTION).getClass().getSimpleName(),"String or JSON");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var status = Status.OPEN.code();
|
var status = Status.OPEN.code();
|
||||||
if (json.has(STATUS) && json.get(STATUS) instanceof JSONObject state){
|
if (json.has(STATUS) && json.get(STATUS) instanceof JSONObject state){
|
||||||
if (state.get(CODE) instanceof Number code) status = code.intValue();
|
if (state.get(CODE) instanceof Number code) status = code.intValue();
|
||||||
@@ -185,6 +185,10 @@ public class Task implements Mappable {
|
|||||||
return projectId;
|
return projectId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<Long> requiredTasksIds(){
|
||||||
|
return requiredTasksIds;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean showClosed(){
|
public boolean showClosed(){
|
||||||
return showClosed;
|
return showClosed;
|
||||||
}
|
}
|
||||||
@@ -216,6 +220,7 @@ public class Task implements Mappable {
|
|||||||
map.put(SHOW_CLOSED,showClosed);
|
map.put(SHOW_CLOSED,showClosed);
|
||||||
map.put(NO_INDEX,noIndex);
|
map.put(NO_INDEX,noIndex);
|
||||||
map.put(MEMBERS,memberMap);
|
map.put(MEMBERS,memberMap);
|
||||||
|
map.put(REQUIRED_TASKS_IDS,requiredTasksIds);
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,12 @@ public class Constants {
|
|||||||
private Constants(){}
|
private Constants(){}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static final String CONFIG_DATABASE = "umbrella.modules.task.database";
|
public static final String CONFIG_DATABASE = "umbrella.modules.task.database";
|
||||||
public static final String CHILDREN = "children";
|
public static final String CHILDREN = "children";
|
||||||
public static final String ESTIMATED_TIMES = "estimated_times";
|
public static final String ESTIMATED_TIMES = "estimated_times";
|
||||||
|
public static final String REQUIRED_TASK_ID = "required_task_id";
|
||||||
|
public static final String TABLE_TASK_DEPENDENCIES = "task_dependencies";
|
||||||
public static final String TABLE_TASKS = "tasks";
|
public static final String TABLE_TASKS = "tasks";
|
||||||
public static final String TABLE_TASKS_USERS = "tasks_users";
|
public static final String TABLE_TASKS_USERS = "tasks_users";
|
||||||
public static final String TASK = "task";
|
public static final String TASK = "task";
|
||||||
|
|||||||
@@ -35,16 +35,31 @@ public class SqliteDb extends BaseDb implements TaskDb {
|
|||||||
int currentVersion = createSettingsTable();
|
int currentVersion = createSettingsTable();
|
||||||
switch (currentVersion){
|
switch (currentVersion){
|
||||||
case 0:
|
case 0:
|
||||||
createTaskTables();
|
createTaskTable();
|
||||||
createTasksUsersTable();
|
createTasksUsersTable();
|
||||||
case 1:
|
case 1:
|
||||||
swapStates(TABLE_TASKS);
|
swapStates(TABLE_TASKS);
|
||||||
|
case 2:
|
||||||
|
createDependencyTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
return setCurrentVersion(2);
|
return setCurrentVersion(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createTaskTables() {
|
private void createDependencyTable() {
|
||||||
|
var sql = "CREATE TABLE IF NOT EXISTS {0} ({1} INT NOT NULL, {2} INT NOT NULL, PRIMARY KEY({1}, {2}))";
|
||||||
|
sql = format(sql,TABLE_TASK_DEPENDENCIES,TASK_ID,REQUIRED_TASK_ID);
|
||||||
|
try {
|
||||||
|
var stmt = db.prepareStatement(sql);
|
||||||
|
stmt.execute();
|
||||||
|
stmt.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
LOG.log(ERROR, ERROR_FAILED_CREATE_TABLE, TABLE_TASK_DEPENDENCIES, e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createTaskTable() {
|
||||||
var createTable = """
|
var createTable = """
|
||||||
CREATE TABLE IF NOT EXISTS "{0}" (
|
CREATE TABLE IF NOT EXISTS "{0}" (
|
||||||
{1} INTEGER PRIMARY KEY,
|
{1} INTEGER PRIMARY KEY,
|
||||||
|
|||||||
Reference in New Issue
Block a user