|
|
|
@ -4,6 +4,7 @@ package de.srsoftware.umbrella.core.model; |
|
|
|
import static de.srsoftware.tools.Optionals.nullable; |
|
|
|
import static de.srsoftware.tools.Optionals.nullable; |
|
|
|
import static de.srsoftware.umbrella.core.Constants.*; |
|
|
|
import static de.srsoftware.umbrella.core.Constants.*; |
|
|
|
import static de.srsoftware.umbrella.core.Util.mapMarkdown; |
|
|
|
import static de.srsoftware.umbrella.core.Util.mapMarkdown; |
|
|
|
|
|
|
|
import static de.srsoftware.umbrella.core.model.Status.PREDEFINED; |
|
|
|
|
|
|
|
|
|
|
|
import de.srsoftware.tools.Mappable; |
|
|
|
import de.srsoftware.tools.Mappable; |
|
|
|
import java.sql.ResultSet; |
|
|
|
import java.sql.ResultSet; |
|
|
|
@ -13,6 +14,7 @@ import org.json.JSONObject; |
|
|
|
|
|
|
|
|
|
|
|
public class Project implements Mappable { |
|
|
|
public class Project implements Mappable { |
|
|
|
private final Map<Long,Member> members; |
|
|
|
private final Map<Long,Member> members; |
|
|
|
|
|
|
|
private final Collection<Status> allowedStates; |
|
|
|
private boolean showClosed; |
|
|
|
private boolean showClosed; |
|
|
|
private final Long companyId; |
|
|
|
private final Long companyId; |
|
|
|
private int status; |
|
|
|
private int status; |
|
|
|
@ -21,7 +23,7 @@ public class Project implements Mappable { |
|
|
|
private String description; |
|
|
|
private String description; |
|
|
|
private final Set<String> dirtyFields = new HashSet<>(); |
|
|
|
private final Set<String> dirtyFields = new HashSet<>(); |
|
|
|
|
|
|
|
|
|
|
|
public Project(long id, String name, String description, int status, Long companyId, boolean showClosed, Map<Long,Member> members) { |
|
|
|
public Project(long id, String name, String description, int status, Long companyId, boolean showClosed, Map<Long,Member> members, Collection<Status> allowedStates) { |
|
|
|
this.id = id; |
|
|
|
this.id = id; |
|
|
|
this.name = name; |
|
|
|
this.name = name; |
|
|
|
this.description = description; |
|
|
|
this.description = description; |
|
|
|
@ -29,6 +31,11 @@ public class Project implements Mappable { |
|
|
|
this.companyId = companyId; |
|
|
|
this.companyId = companyId; |
|
|
|
this.showClosed = showClosed; |
|
|
|
this.showClosed = showClosed; |
|
|
|
this.members = members; |
|
|
|
this.members = members; |
|
|
|
|
|
|
|
this.allowedStates = allowedStates; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Collection<Status> allowedStates(){ |
|
|
|
|
|
|
|
return allowedStates; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Project clean() { |
|
|
|
public Project clean() { |
|
|
|
@ -81,7 +88,7 @@ public class Project implements Mappable { |
|
|
|
|
|
|
|
|
|
|
|
public static Project of(ResultSet rs) throws SQLException { |
|
|
|
public static Project of(ResultSet rs) throws SQLException { |
|
|
|
var companyId = rs.getLong(COMPANY_ID); |
|
|
|
var companyId = rs.getLong(COMPANY_ID); |
|
|
|
return new Project(rs.getLong(ID),rs.getString(NAME),rs.getString(DESCRIPTION),rs.getInt(STATUS),companyId == 0 ? null : companyId,rs.getBoolean(SHOW_CLOSED),new HashMap<>()); |
|
|
|
return new Project(rs.getLong(ID),rs.getString(NAME),rs.getString(DESCRIPTION),rs.getInt(STATUS),companyId == 0 ? null : companyId,rs.getBoolean(SHOW_CLOSED),new HashMap<>(),PREDEFINED); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Project patch(JSONObject json) { |
|
|
|
public Project patch(JSONObject json) { |
|
|
|
@ -120,6 +127,9 @@ public class Project implements Mappable { |
|
|
|
map.put(COMPANY_ID,companyId); |
|
|
|
map.put(COMPANY_ID,companyId); |
|
|
|
map.put(SHOW_CLOSED,showClosed); |
|
|
|
map.put(SHOW_CLOSED,showClosed); |
|
|
|
map.put(MEMBERS,memberMap); |
|
|
|
map.put(MEMBERS,memberMap); |
|
|
|
|
|
|
|
var stateMap = new HashMap<Integer,String>(); |
|
|
|
|
|
|
|
for (var state : allowedStates) stateMap.put(state.code(),state.name()); |
|
|
|
|
|
|
|
map.put(ALLOWED_STATES,stateMap); |
|
|
|
return map; |
|
|
|
return map; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|