started to implement project tagging, was interrupted.

next on: saving tags for user = null
This commit is contained in:
2025-07-28 08:49:44 +02:00
parent 0aa7aa67dc
commit 382eae000c
7 changed files with 74 additions and 22 deletions

View File

@@ -20,11 +20,14 @@ import de.srsoftware.tools.SessionToken;
import de.srsoftware.umbrella.core.BaseHandler;
import de.srsoftware.umbrella.core.api.CompanyService;
import de.srsoftware.umbrella.core.api.ProjectService;
import de.srsoftware.umbrella.core.api.TagService;
import de.srsoftware.umbrella.core.api.UserService;
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
import de.srsoftware.umbrella.core.model.*;
import java.io.IOException;
import java.util.*;
import org.json.JSONArray;
import org.json.JSONObject;
public class ProjectModule extends BaseHandler implements ProjectService {
@@ -32,12 +35,14 @@ public class ProjectModule extends BaseHandler implements ProjectService {
private final ProjectDb projects;
private final CompanyService companies;
private final UserService users;
private final TagService tags;
public ProjectModule(Configuration config, CompanyService companyService) throws UmbrellaException {
public ProjectModule(Configuration config, CompanyService companyService, TagService tagService) throws UmbrellaException {
var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE));
projects = new SqliteDb(connect(dbFile));
companies = companyService;
users = companies.userService();
projects = new SqliteDb(connect(dbFile));
companies = companyService;
tags = tagService;
users = companies.userService();
}
private void addMember(Project project, long userId) {
@@ -245,6 +250,12 @@ public class ProjectModule extends BaseHandler implements ProjectService {
var owner = Map.of(user.id(),new Member(user,OWNER));
var prj = new Project(0,name,description, OPEN,companyId,showClosed, owner);
prj = projects.save(prj);
if (json.has(TAGS) && json.get(TAGS) instanceof JSONArray arr){
var tagList = arr.toList().stream().filter(elem -> elem instanceof String).map(String.class::cast).toList();
tags.save(PROJECT,prj.id(),null,tagList);
}
return sendContent(ex,prj);
}