finished implementation of tag loading when loading project tasks
This commit is contained in:
@@ -15,7 +15,6 @@ import static de.srsoftware.umbrella.project.Constants.PERMISSIONS;
|
||||
import static de.srsoftware.umbrella.task.Constants.*;
|
||||
import static java.lang.System.Logger.Level.DEBUG;
|
||||
import static java.lang.System.Logger.Level.WARNING;
|
||||
import static java.net.HttpURLConnection.HTTP_BAD_REQUEST;
|
||||
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
import de.srsoftware.configuration.Configuration;
|
||||
@@ -398,10 +397,8 @@ public class TaskModule extends BaseHandler implements TaskService {
|
||||
var projectTasks = taskDb.listProjectTasks(projectId, parentTaskId, noIndex);
|
||||
loadMembers(projectTasks.values());
|
||||
var tags = tagService().getTags(TASK,projectTasks.keySet(),user);
|
||||
LOG.log(DEBUG,"tags: {0}",tags);
|
||||
|
||||
// TODO: add tags to result map
|
||||
|
||||
projectTasks = addTags(projectTasks, tags);
|
||||
return sendContent(ex, mapValues(projectTasks));
|
||||
}
|
||||
if (isSet(parentTaskId)) return sendContent(ex, mapValues(taskDb.listChildrenOf(parentTaskId, user, showClosed)));
|
||||
@@ -409,4 +406,25 @@ public class TaskModule extends BaseHandler implements TaskService {
|
||||
if (isSet(taskIds)) return sendContent(ex, mapValues(taskDb.load(taskIds)));
|
||||
return sendEmptyResponse(HTTP_NOT_IMPLEMENTED, ex);
|
||||
}
|
||||
|
||||
private static class TaggedTask extends Task{
|
||||
|
||||
private final Collection<String> tags;
|
||||
|
||||
public TaggedTask(Task task, Collection<String> tags) {
|
||||
super(task.id(), task.projectId(), task.parentTaskId(), task.name(), task.description(), task.status(), task.estimatedTime(), task.start(), task.dueDate(), task.showClosed(), task.noIndex(), task.members(), task.priority());
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap() {
|
||||
var map = super.toMap();
|
||||
map.put(TAGS,tags);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
private Map<Long, Task> addTags(Map<Long, Task> taskList, Map<Long, ? extends Collection<String>> tags) {
|
||||
return taskList.values().stream().map(task -> new TaggedTask(task, tags.get(task.id()))).collect(Collectors.toMap(Task::id, t -> t));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user