working on task index

This commit is contained in:
2025-08-04 08:50:40 +02:00
parent 8eef37eb1a
commit 983f1bac49
5 changed files with 105 additions and 30 deletions

View File

@@ -6,6 +6,7 @@ import static de.srsoftware.tools.jdbc.Condition.*;
import static de.srsoftware.tools.jdbc.Query.*;
import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL;
import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.databaseException;
import static de.srsoftware.umbrella.core.model.Status.OPEN;
import static de.srsoftware.umbrella.project.Constants.*;
import static de.srsoftware.umbrella.task.Constants.*;
@@ -210,6 +211,22 @@ CREATE TABLE IF NOT EXISTS {0} (
}
}
@Override
public HashMap<Long, Task> listUserTasks(long userId) {
try {
var rs = select(ALL).from(TABLE_TASKS).leftJoin(ID,TABLE_TASKS_USERS,TASK_ID).where(USER_ID,equal(userId)).exec(db);
var map = new HashMap<Long,Task>();
while (rs.next()) {
var task = Task.of(rs);
map.put(task.id(),task);
}
rs.close();
return map;
} catch (SQLException e) {
throw databaseException("Failed to load tasks of user {0}",userId);
}
}
@Override
public Task load(long taskId) throws UmbrellaException {
try {

View File

@@ -18,8 +18,8 @@ public interface TaskDb {
HashMap<Long, Task> listChildrenOf(Long parentTaskId, UmbrellaUser user, boolean showClosed);
HashMap<Long, Task> listProjectTasks(Long projectId, Long parentTaskId, boolean noIndex) throws UmbrellaException;
HashMap<Long, Task> listRootTasks(Long projectId, UmbrellaUser user, boolean showClosed);
HashMap<Long, Task> listTasks(Collection<Long> projectIds) throws UmbrellaException;
HashMap<Long, Task> listUserTasks(long userId);
Task load(long taskId) throws UmbrellaException;

View File

@@ -103,7 +103,7 @@ public class TaskModule extends BaseHandler implements TaskService {
var head = path.pop();
return switch (head) {
case PERMISSIONS -> getPermissionList(ex);
case null -> super.doGet(path,ex);
case null -> getUserTasks(user.get(),ex);
default -> {
var taskId = Long.parseLong(head);
head = path.pop();
@@ -201,6 +201,11 @@ public class TaskModule extends BaseHandler implements TaskService {
return sendContent(ex,task);
}
private boolean getUserTasks(UmbrellaUser user, HttpExchange ex) throws IOException {
var list = taskDb.listUserTasks(user.id());
return sendContent(ex,mapValues(list));
}
@Override
public HashMap<Long, Task> listCompanyTasks(long companyId) throws UmbrellaException {
var projectList = projects.listCompanyProjects(companyId,false);