From d3eb0aaa9cb0e40ee6bb932465b4dd260a0eb066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Henke?= Date: Fri, 26 Feb 2021 18:59:54 +0100 Subject: [PATCH] fixed functionality --- .../timetrack/modules/done/DoneBean.java | 80 +++++++++++-------- .../timetrack/modules/done/DoneGateway.java | 46 ++++++++--- .../timetrack/modules/done/DoneModel.java | 6 ++ .../timetrack/modules/done/WpBean.java | 34 ++++++++ src/main/webapp/pages/done/add.xhtml | 8 +- src/main/webapp/pages/done/edit.xhtml | 8 +- src/main/webapp/pages/done/init.xhtml | 23 +++++- src/main/webapp/resources/css/style.css | 10 ++- 8 files changed, 158 insertions(+), 57 deletions(-) create mode 100644 src/main/java/de/jottyfan/timetrack/modules/done/WpBean.java diff --git a/src/main/java/de/jottyfan/timetrack/modules/done/DoneBean.java b/src/main/java/de/jottyfan/timetrack/modules/done/DoneBean.java index e00d796..97256b9 100644 --- a/src/main/java/de/jottyfan/timetrack/modules/done/DoneBean.java +++ b/src/main/java/de/jottyfan/timetrack/modules/done/DoneBean.java @@ -7,6 +7,7 @@ import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.Date; +import java.util.List; import java.util.Map; import de.jottyfan.timetrack.db.done.tables.records.TDoneRecord; @@ -31,7 +32,7 @@ public class DoneBean implements Bean, Serializable, Comparable { private TProjectRecord project; private TModuleRecord module; private TJobRecord activity; - private String wp; + private WpBean wp; public DoneBean() { } @@ -44,14 +45,24 @@ public class DoneBean implements Bean, Serializable, Comparable { this.project = projectMap.get(r.getFkProject()); this.module = moduleMap.get(r.getFkModule()); this.activity = jobMap.get(r.getFkJob()); - this.wp = r.getWp(); + List list = DoneGateway.getAllWps(); + String key = r.getWp(); + if (key != null && key.isBlank()) { + key = null; + } + if (key != null) { + for (WpBean bean : list) { + if (bean.getKey().equals(r.getWp())) { + this.wp = bean; + } + } + } } /** * set the day of timeFrom and timeUntil, keeping the times * - * @param day - * the day + * @param day the day */ public void setDay(Date day) { if (timeFrom != null) { @@ -92,18 +103,19 @@ public class DoneBean implements Bean, Serializable, Comparable { return String.format("%02d:%02d", diff.toHours(), diff.toMinutes() % 60); } - /** - * get local date time from s - * - * @param s the HH:mm formatted values - * @param ldt the date as basic for that datetime, for today one can use LocalDateTime.now(); in fact this is set if ldt is null internally - * @return the generated datetime - */ + /** + * get local date time from s + * + * @param s the HH:mm formatted values + * @param ldt the date as basic for that datetime, for today one can use + * LocalDateTime.now(); in fact this is set if ldt is null internally + * @return the generated datetime + */ public LocalDateTime getLocalDateTimeFromHHmm(String s, LocalDateTime ldt) { if (s == null || s.trim().isEmpty()) { return null; } else if (ldt == null) { - ldt = LocalDateTime.now(); + ldt = LocalDateTime.now(); } String[] hm = s.split(":"); Integer hours = 0; @@ -121,14 +133,14 @@ public class DoneBean implements Bean, Serializable, Comparable { return ldt; } - public String getProjectNameWithWP() { - StringBuilder buf = new StringBuilder(); - buf.append(project == null ? "" : project.getName()); - if (wp != null && !wp.isBlank()) { - buf.append(" (").append(wp).append(")"); - } - return buf.toString(); - } + public String getProjectNameWithWP() { + StringBuilder buf = new StringBuilder(); + buf.append(project == null ? "" : project.getName()); + if (wp != null) { + buf.append(" (").append(wp.getKey()).append(")"); + } + return buf.toString(); + } public String getProjectName() { return project == null ? "" : project.getName(); @@ -141,6 +153,10 @@ public class DoneBean implements Bean, Serializable, Comparable { public String getJobName() { return activity == null ? "" : activity.getName(); } + + public String getWpName() { + return wp == null ? "" : wp.getName(); + } public String getTimeFromString() { return timeFrom == null ? "" : timeFrom.format(hhmm); @@ -206,17 +222,17 @@ public class DoneBean implements Bean, Serializable, Comparable { this.activity = activity; } - /** - * @return the wp - */ - public String getWp() { - return wp; - } + /** + * @return the wp + */ + public WpBean getWp() { + return wp; + } - /** - * @param wp the wp to set - */ - public void setWp(String wp) { - this.wp = wp; - } + /** + * @param wp the wp to set + */ + public void setWp(WpBean wp) { + this.wp = wp; + } } diff --git a/src/main/java/de/jottyfan/timetrack/modules/done/DoneGateway.java b/src/main/java/de/jottyfan/timetrack/modules/done/DoneGateway.java index 76765dd..d30b946 100644 --- a/src/main/java/de/jottyfan/timetrack/modules/done/DoneGateway.java +++ b/src/main/java/de/jottyfan/timetrack/modules/done/DoneGateway.java @@ -9,6 +9,8 @@ import static de.jottyfan.timetrack.db.done.Tables.V_TOTALOFDAY; import static de.jottyfan.timetrack.db.done.Tables.V_WORKTIME; import static de.jottyfan.timetrack.db.profile.Tables.T_LOGIN; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.sql.SQLException; import java.text.SimpleDateFormat; import java.time.LocalDate; @@ -151,8 +153,7 @@ public class DoneGateway extends JooqGateway { /** * get all from t_done of the given day * - * @param day - * the day; if null, the current date is used + * @param day the day; if null, the current date is used * * @return a list of found times, an empty one at least * @throws SQLException @@ -202,6 +203,7 @@ public class DoneGateway extends JooqGateway { Integer fkProject = bean.getProject() == null ? null : bean.getProject().getPk(); Integer fkModule = bean.getModule() == null ? null : bean.getModule().getPk(); Integer fkJob = bean.getActivity() == null ? null : bean.getActivity().getPk(); + String wp = bean.getWp() == null ? null : bean.getWp().getKey(); Integer fkLogin = getFkLogin(); try (CloseableDSLContext jooq = getJooq()) { @@ -215,7 +217,7 @@ public class DoneGateway extends JooqGateway { T_DONE.FK_JOB, T_DONE.WP, T_DONE.FK_LOGIN) - .values(bean.getTimeFrom(), bean.getTimeUntil(), fkProject, fkModule, fkJob, bean.getWp(), fkLogin); + .values(bean.getTimeFrom(), bean.getTimeUntil(), fkProject, fkModule, fkJob, wp, fkLogin); // @formatter:on LOGGER.debug(sql.toString()); sql.execute(); @@ -231,6 +233,7 @@ public class DoneGateway extends JooqGateway { */ public void update(DoneBean bean) throws DataAccessException, ClassNotFoundException, SQLException { try (CloseableDSLContext jooq = getJooq()) { + String wp = bean.getWp() == null ? null : bean.getWp().getKey(); UpdateConditionStep sql = jooq // @formatter:off .update(T_DONE) @@ -239,7 +242,7 @@ public class DoneGateway extends JooqGateway { .set(T_DONE.FK_PROJECT, bean.getProject() == null ? null : bean.getProject().getPk()) .set(T_DONE.FK_JOB, bean.getActivity() == null ? null : bean.getActivity().getPk()) .set(T_DONE.FK_MODULE, bean.getModule() == null ? null : bean.getModule().getPk()) - .set(T_DONE.WP, bean.getWp()) + .set(T_DONE.WP, wp) .where(T_DONE.PK.eq(bean.getPk())); // @formatter:on LOGGER.debug(sql.toString()); @@ -265,14 +268,14 @@ public class DoneGateway extends JooqGateway { /** * get day summary * - * @param day - * the day + * @param day the day * @return the day summary if found, an empty map otherwise * @throws SQLException * @throws ClassNotFoundException * @throws DataAccessException */ - public WholeDaySummaryBean getDaySummary(java.util.Date day) throws DataAccessException, ClassNotFoundException, SQLException { + public WholeDaySummaryBean getDaySummary(java.util.Date day) + throws DataAccessException, ClassNotFoundException, SQLException { try (CloseableDSLContext jooq = getJooq()) { SelectConditionStep> sql = jooq // @formatter:off @@ -300,14 +303,14 @@ public class DoneGateway extends JooqGateway { /** * get all jobs of day * - * @param day - * the day + * @param day the day * @return list of found jobs; an empty list at least * @throws SQLException * @throws ClassNotFoundException * @throws DataAccessException */ - public List getAllJobs(java.util.Date day) throws DataAccessException, ClassNotFoundException, SQLException { + public List getAllJobs(java.util.Date day) + throws DataAccessException, ClassNotFoundException, SQLException { try (CloseableDSLContext jooq = getJooq()) { SelectConditionStep> sql = jooq // @formatter:off @@ -330,6 +333,7 @@ public class DoneGateway extends JooqGateway { String moduleName = r.get(V_WORKTIME.MODULE_NAME); String jobName = r.get(V_WORKTIME.JOB_NAME); String wp = r.get(V_WORKTIME.WP); + durationHours = durationHours == null ? null : new BigDecimal(durationHours).setScale(2, RoundingMode.HALF_UP).doubleValue(); list.add(new DailySummaryBean(projectName, moduleName, jobName, duration, wp, durationHours)); } return list; @@ -373,14 +377,15 @@ public class DoneGateway extends JooqGateway { StringBuilder buf = new StringBuilder(); buf.append(projectName); if (wp != null && !wp.isBlank()) { - buf.append(" (").append(wp).append(")"); + buf.append(" (").append(wp).append(")"); } buf.append(", "); buf.append(moduleName); buf.append(": "); buf.append(jobName); - FullCalendarEventBean bean = new FullCalendarEventBean(buf.toString(), java.util.Date.from(timeFrom.atZone(ZoneId.systemDefault()).toInstant())) { + FullCalendarEventBean bean = new FullCalendarEventBean(buf.toString(), + java.util.Date.from(timeFrom.atZone(ZoneId.systemDefault()).toInstant())) { private static final long serialVersionUID = 1L; @Override @@ -434,7 +439,8 @@ public class DoneGateway extends JooqGateway { // @formatter:on LOGGER.debug(sql.toString()); String sep = ";"; - buf.append("day").append(sep).append("duration").append(sep).append("project").append(sep).append("module").append(sep).append("activity\n"); + buf.append("day").append(sep).append("duration").append(sep).append("project").append(sep).append("module") + .append(sep).append("activity\n"); for (Record r : sql.fetch()) { LocalDate workday = r.get(V_HAMSTERSUMMARY.WORKDAY); String date = workday.format(DateTimeFormatter.ofPattern("dd.MM.yyyy")); @@ -447,4 +453,18 @@ public class DoneGateway extends JooqGateway { } return buf.toString(); } + + /** + * dummy method to use until a table has been created + * + * @return all valid wps + */ + public static final List getAllWps() { + List list = new ArrayList<>(); + list.add(new WpBean("WP2", "WP2 (eucs) - Opal/Mica/..., REST")); + list.add(new WpBean("WP4", "WP4 (eucs) - Square²")); + list.add(new WpBean("WP5", "WP5 (eucs) - SHIP-Datenbereitstellung")); + list.add(new WpBean("NFDI TA3", "TA3 (nfdi) - Mica Dev")); + return list; + } } diff --git a/src/main/java/de/jottyfan/timetrack/modules/done/DoneModel.java b/src/main/java/de/jottyfan/timetrack/modules/done/DoneModel.java index e92da9d..ef72e72 100644 --- a/src/main/java/de/jottyfan/timetrack/modules/done/DoneModel.java +++ b/src/main/java/de/jottyfan/timetrack/modules/done/DoneModel.java @@ -41,6 +41,7 @@ public class DoneModel implements Model, Serializable { private List projects; private List modules; private List activities; + private List wps; private List times; private List allJobs; private WholeDaySummaryBean daySummary; @@ -57,6 +58,7 @@ public class DoneModel implements Model, Serializable { modules = gw.getAllModules(); activities = gw.getAllActivities(); projects = gw.getAllProjects(); + wps = DoneGateway.getAllWps(); daySummary = gw.getDaySummary(day); allJobs = gw.getAllJobs(day); calendarEvents = gw.getAllCalendarEvents(); @@ -243,6 +245,10 @@ public class DoneModel implements Model, Serializable { public List getActivities() { return activities; } + + public List getWps() { + return wps; + } public List getAllJobs() { return allJobs; diff --git a/src/main/java/de/jottyfan/timetrack/modules/done/WpBean.java b/src/main/java/de/jottyfan/timetrack/modules/done/WpBean.java new file mode 100644 index 0000000..731138e --- /dev/null +++ b/src/main/java/de/jottyfan/timetrack/modules/done/WpBean.java @@ -0,0 +1,34 @@ +package de.jottyfan.timetrack.modules.done; + +import java.io.Serializable; + +/** + * + * @author jotty + * + */ +public class WpBean implements Serializable { + private static final long serialVersionUID = 1L; + private final String name; + private final String key; + + public WpBean(String key, String name) { + super(); + this.key = key; + this.name = name; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @return the key + */ + public String getKey() { + return key; + } +} diff --git a/src/main/webapp/pages/done/add.xhtml b/src/main/webapp/pages/done/add.xhtml index 708822f..391eec4 100644 --- a/src/main/webapp/pages/done/add.xhtml +++ b/src/main/webapp/pages/done/add.xhtml @@ -45,7 +45,7 @@ - + @@ -59,10 +59,8 @@ - - - - + + diff --git a/src/main/webapp/pages/done/edit.xhtml b/src/main/webapp/pages/done/edit.xhtml index 2de0937..c277465 100644 --- a/src/main/webapp/pages/done/edit.xhtml +++ b/src/main/webapp/pages/done/edit.xhtml @@ -45,7 +45,7 @@ - + @@ -59,10 +59,8 @@ - - - - + + diff --git a/src/main/webapp/pages/done/init.xhtml b/src/main/webapp/pages/done/init.xhtml index 5358c51..7da1bc8 100644 --- a/src/main/webapp/pages/done/init.xhtml +++ b/src/main/webapp/pages/done/init.xhtml @@ -79,7 +79,7 @@ - + @@ -92,6 +92,27 @@ defaultDate="#{doneModel.dayIso8601}" defaultView="agendaDay" hidden="xs" scrollTime="08:00:00" slotDuration="00:15:00" span="half" allDaySlot="false" lang="de" /> + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/resources/css/style.css b/src/main/webapp/resources/css/style.css index 1bd956f..197f13c 100644 --- a/src/main/webapp/resources/css/style.css +++ b/src/main/webapp/resources/css/style.css @@ -7,7 +7,7 @@ .page { height: 100%; width: 100%; - background-image: linear-gradient(to bottom, #fff 0%, #ccc 20%) + background-image: linear-gradient(to bottom, #ffffff 10%, #afffff 40%) !important; } @@ -68,6 +68,14 @@ text-align: right; } +.prompt { + margin: 4px; + padding: 4px !important; + padding-bottom: 2px !important; + font-size: medium !important; + background-color: #005782 !important; +} + .version { font-size: small; color: silver;