implemented project creation
This commit is contained in:
@@ -42,6 +42,7 @@ public class Constants {
|
||||
public static final String KEY = "key";
|
||||
public static final String LANGUAGE = "language";
|
||||
public static final String LOGIN = "login";
|
||||
public static final String MEMBERS = "members";
|
||||
public static final String MESSAGES = "messages";
|
||||
public static final String NAME = "name";
|
||||
public static final String MIME = "mime";
|
||||
|
||||
@@ -6,7 +6,7 @@ import de.srsoftware.umbrella.core.model.Project;
|
||||
import java.util.Collection;
|
||||
|
||||
public interface ProjectService {
|
||||
public Collection<Project> listProjects(long companyId,boolean includeClosed) throws UmbrellaException;
|
||||
public Collection<Project> listProjectsOfCompany(long companyId, boolean includeClosed) throws UmbrellaException;
|
||||
|
||||
CompanyService companyService();
|
||||
}
|
||||
|
||||
@@ -5,9 +5,12 @@ import com.sun.net.httpserver.HttpExchange;
|
||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
import de.srsoftware.umbrella.core.model.Token;
|
||||
import de.srsoftware.umbrella.core.model.UmbrellaUser;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface UserService {
|
||||
Map<Long, UmbrellaUser> list(Collection<Long> ids) throws UmbrellaException;
|
||||
UmbrellaUser loadUser(long userId) throws UmbrellaException;
|
||||
Optional<UmbrellaUser> loadUser(Optional<Token> sessionToken) throws UmbrellaException;
|
||||
Optional<UmbrellaUser> loadUser(HttpExchange ex) throws UmbrellaException;
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.core.model;
|
||||
|
||||
|
||||
public record Member(UmbrellaUser user, Permission permission){ }
|
||||
@@ -0,0 +1,30 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.core.model;
|
||||
|
||||
import static java.text.MessageFormat.format;
|
||||
|
||||
import java.security.InvalidParameterException;
|
||||
|
||||
public enum Permission {
|
||||
OWNER(1),
|
||||
EDIT(2),
|
||||
ASSIGNEE(3),
|
||||
READ_ONLY(4);
|
||||
|
||||
private final int code;
|
||||
|
||||
Permission(int code){
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public int code(){
|
||||
return code;
|
||||
}
|
||||
|
||||
public static Permission of(int code){
|
||||
for (var p : Permission.values()){
|
||||
if (p.code == code) return p;
|
||||
}
|
||||
throw new InvalidParameterException(format("{0} is not a valid permission code"));
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,9 @@ import static de.srsoftware.umbrella.core.Constants.*;
|
||||
import de.srsoftware.tools.Mappable;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
public record Project(long id, String name, String description, Status status, Long companyId, boolean showClosed) implements Mappable {
|
||||
public record Project(long id, String name, String description, Status status, Long companyId, boolean showClosed, Collection<Member> members) implements Mappable {
|
||||
public enum Status{
|
||||
Open(10),
|
||||
Started(20),
|
||||
@@ -39,18 +39,19 @@ public record Project(long id, String name, String description, Status status, L
|
||||
}
|
||||
|
||||
public static Project of(ResultSet rs) throws SQLException {
|
||||
return new Project(rs.getLong(ID),rs.getString(NAME),rs.getString(DESCRIPTION),Status.of(rs.getInt(STATUS)),rs.getLong(COMPANY_ID),rs.getBoolean(SHOW_CLOSED));
|
||||
return new Project(rs.getLong(ID),rs.getString(NAME),rs.getString(DESCRIPTION),Status.of(rs.getInt(STATUS)),rs.getLong(COMPANY_ID),rs.getBoolean(SHOW_CLOSED),new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap() {
|
||||
return Map.of(
|
||||
ID,id,
|
||||
NAME,name,
|
||||
DESCRIPTION,description,
|
||||
STATUS,Map.of(STATUS_CODE,status.code(), NAME,status.name()),
|
||||
COMPANY_ID,companyId,
|
||||
SHOW_CLOSED,showClosed
|
||||
);
|
||||
var map = new HashMap<String, Object>();
|
||||
map.put(ID,id);
|
||||
map.put(NAME,name);
|
||||
map.put(DESCRIPTION,description);
|
||||
map.put(STATUS,Map.of(STATUS_CODE,status.code(), NAME,status.name()));
|
||||
map.put(COMPANY_ID,companyId);
|
||||
map.put(SHOW_CLOSED,showClosed);
|
||||
map.put(MEMBERS,members == null ? List.of() : members);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user