implemented function to return estimated times of company.
Therefore task and project module had to be created and partially implemented
This commit is contained in:
@@ -48,12 +48,13 @@ public class Constants {
|
||||
public static final String RENDERED = "rendered";
|
||||
public static final String SENDER = "sender";
|
||||
public static final String SETTINGS = "settings";
|
||||
public static final String SHOW_CLOSED = "show_closed";
|
||||
public static final String SOURCE = "source";
|
||||
public static final String STATE = "state";
|
||||
public static final String STATUS = "status";
|
||||
public static final String STATUS_CODE = "code";
|
||||
public static final String STRING = "string";
|
||||
public static final String SUBJECT = "subject";
|
||||
|
||||
public static final String TABLE_SETTINGS = "settings";
|
||||
|
||||
public static final String TEMPLATE = "template";
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.core.api;
|
||||
|
||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
import de.srsoftware.umbrella.core.model.Project;
|
||||
import java.util.Collection;
|
||||
|
||||
public interface ProjectService {
|
||||
public Collection<Project> listProjects(long companyId,boolean includeClosed) throws UmbrellaException;
|
||||
|
||||
CompanyService companyService();
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.core.model;
|
||||
|
||||
import static de.srsoftware.umbrella.core.Constants.*;
|
||||
|
||||
import de.srsoftware.tools.Mappable;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
|
||||
public record Project(long id, String name, String description, Status status, long companyId, boolean showClosed) implements Mappable {
|
||||
public enum Status{
|
||||
Open(10),
|
||||
Started(20),
|
||||
Pending(40),
|
||||
Complete(60),
|
||||
Cancelled(100);
|
||||
|
||||
private int code;
|
||||
|
||||
Status(int code){
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public int code(){
|
||||
return code;
|
||||
}
|
||||
|
||||
public static Status of(int code){
|
||||
return switch (code){
|
||||
case 10 -> Open;
|
||||
case 20 -> Started;
|
||||
case 40 -> Pending;
|
||||
case 60 -> Complete;
|
||||
case 100 -> Cancelled;
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
@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
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user