fixed functionality

This commit is contained in:
Jörg Henke
2021-02-26 18:59:54 +01:00
parent a2d01b41e3
commit d3eb0aaa9c
8 changed files with 158 additions and 57 deletions

View File

@ -7,6 +7,7 @@ import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Map; import java.util.Map;
import de.jottyfan.timetrack.db.done.tables.records.TDoneRecord; import de.jottyfan.timetrack.db.done.tables.records.TDoneRecord;
@ -31,7 +32,7 @@ public class DoneBean implements Bean, Serializable, Comparable<DoneBean> {
private TProjectRecord project; private TProjectRecord project;
private TModuleRecord module; private TModuleRecord module;
private TJobRecord activity; private TJobRecord activity;
private String wp; private WpBean wp;
public DoneBean() { public DoneBean() {
} }
@ -44,14 +45,24 @@ public class DoneBean implements Bean, Serializable, Comparable<DoneBean> {
this.project = projectMap.get(r.getFkProject()); this.project = projectMap.get(r.getFkProject());
this.module = moduleMap.get(r.getFkModule()); this.module = moduleMap.get(r.getFkModule());
this.activity = jobMap.get(r.getFkJob()); this.activity = jobMap.get(r.getFkJob());
this.wp = r.getWp(); List<WpBean> 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 * set the day of timeFrom and timeUntil, keeping the times
* *
* @param day * @param day the day
* the day
*/ */
public void setDay(Date day) { public void setDay(Date day) {
if (timeFrom != null) { if (timeFrom != null) {
@ -92,18 +103,19 @@ public class DoneBean implements Bean, Serializable, Comparable<DoneBean> {
return String.format("%02d:%02d", diff.toHours(), diff.toMinutes() % 60); return String.format("%02d:%02d", diff.toHours(), diff.toMinutes() % 60);
} }
/** /**
* get local date time from s * get local date time from s
* *
* @param s the HH:mm formatted values * @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 * @param ldt the date as basic for that datetime, for today one can use
* @return the generated datetime * LocalDateTime.now(); in fact this is set if ldt is null internally
*/ * @return the generated datetime
*/
public LocalDateTime getLocalDateTimeFromHHmm(String s, LocalDateTime ldt) { public LocalDateTime getLocalDateTimeFromHHmm(String s, LocalDateTime ldt) {
if (s == null || s.trim().isEmpty()) { if (s == null || s.trim().isEmpty()) {
return null; return null;
} else if (ldt == null) { } else if (ldt == null) {
ldt = LocalDateTime.now(); ldt = LocalDateTime.now();
} }
String[] hm = s.split(":"); String[] hm = s.split(":");
Integer hours = 0; Integer hours = 0;
@ -121,14 +133,14 @@ public class DoneBean implements Bean, Serializable, Comparable<DoneBean> {
return ldt; return ldt;
} }
public String getProjectNameWithWP() { public String getProjectNameWithWP() {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
buf.append(project == null ? "" : project.getName()); buf.append(project == null ? "" : project.getName());
if (wp != null && !wp.isBlank()) { if (wp != null) {
buf.append(" (").append(wp).append(")"); buf.append(" (").append(wp.getKey()).append(")");
} }
return buf.toString(); return buf.toString();
} }
public String getProjectName() { public String getProjectName() {
return project == null ? "" : project.getName(); return project == null ? "" : project.getName();
@ -142,6 +154,10 @@ public class DoneBean implements Bean, Serializable, Comparable<DoneBean> {
return activity == null ? "" : activity.getName(); return activity == null ? "" : activity.getName();
} }
public String getWpName() {
return wp == null ? "" : wp.getName();
}
public String getTimeFromString() { public String getTimeFromString() {
return timeFrom == null ? "" : timeFrom.format(hhmm); return timeFrom == null ? "" : timeFrom.format(hhmm);
} }
@ -206,17 +222,17 @@ public class DoneBean implements Bean, Serializable, Comparable<DoneBean> {
this.activity = activity; this.activity = activity;
} }
/** /**
* @return the wp * @return the wp
*/ */
public String getWp() { public WpBean getWp() {
return wp; return wp;
} }
/** /**
* @param wp the wp to set * @param wp the wp to set
*/ */
public void setWp(String wp) { public void setWp(WpBean wp) {
this.wp = wp; this.wp = wp;
} }
} }

View File

@ -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.done.Tables.V_WORKTIME;
import static de.jottyfan.timetrack.db.profile.Tables.T_LOGIN; import static de.jottyfan.timetrack.db.profile.Tables.T_LOGIN;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.SQLException; import java.sql.SQLException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
@ -151,8 +153,7 @@ public class DoneGateway extends JooqGateway {
/** /**
* get all from t_done of the given day * get all from t_done of the given day
* *
* @param day * @param day the day; if null, the current date is used
* the day; if null, the current date is used
* *
* @return a list of found times, an empty one at least * @return a list of found times, an empty one at least
* @throws SQLException * @throws SQLException
@ -202,6 +203,7 @@ public class DoneGateway extends JooqGateway {
Integer fkProject = bean.getProject() == null ? null : bean.getProject().getPk(); Integer fkProject = bean.getProject() == null ? null : bean.getProject().getPk();
Integer fkModule = bean.getModule() == null ? null : bean.getModule().getPk(); Integer fkModule = bean.getModule() == null ? null : bean.getModule().getPk();
Integer fkJob = bean.getActivity() == null ? null : bean.getActivity().getPk(); Integer fkJob = bean.getActivity() == null ? null : bean.getActivity().getPk();
String wp = bean.getWp() == null ? null : bean.getWp().getKey();
Integer fkLogin = getFkLogin(); Integer fkLogin = getFkLogin();
try (CloseableDSLContext jooq = getJooq()) { try (CloseableDSLContext jooq = getJooq()) {
@ -215,7 +217,7 @@ public class DoneGateway extends JooqGateway {
T_DONE.FK_JOB, T_DONE.FK_JOB,
T_DONE.WP, T_DONE.WP,
T_DONE.FK_LOGIN) 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 // @formatter:on
LOGGER.debug(sql.toString()); LOGGER.debug(sql.toString());
sql.execute(); sql.execute();
@ -231,6 +233,7 @@ public class DoneGateway extends JooqGateway {
*/ */
public void update(DoneBean bean) throws DataAccessException, ClassNotFoundException, SQLException { public void update(DoneBean bean) throws DataAccessException, ClassNotFoundException, SQLException {
try (CloseableDSLContext jooq = getJooq()) { try (CloseableDSLContext jooq = getJooq()) {
String wp = bean.getWp() == null ? null : bean.getWp().getKey();
UpdateConditionStep<TDoneRecord> sql = jooq UpdateConditionStep<TDoneRecord> sql = jooq
// @formatter:off // @formatter:off
.update(T_DONE) .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_PROJECT, bean.getProject() == null ? null : bean.getProject().getPk())
.set(T_DONE.FK_JOB, bean.getActivity() == null ? null : bean.getActivity().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.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())); .where(T_DONE.PK.eq(bean.getPk()));
// @formatter:on // @formatter:on
LOGGER.debug(sql.toString()); LOGGER.debug(sql.toString());
@ -265,14 +268,14 @@ public class DoneGateway extends JooqGateway {
/** /**
* get day summary * get day summary
* *
* @param day * @param day the day
* the day
* @return the day summary if found, an empty map otherwise * @return the day summary if found, an empty map otherwise
* @throws SQLException * @throws SQLException
* @throws ClassNotFoundException * @throws ClassNotFoundException
* @throws DataAccessException * @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()) { try (CloseableDSLContext jooq = getJooq()) {
SelectConditionStep<Record4<String, String, String, String>> sql = jooq SelectConditionStep<Record4<String, String, String, String>> sql = jooq
// @formatter:off // @formatter:off
@ -300,14 +303,14 @@ public class DoneGateway extends JooqGateway {
/** /**
* get all jobs of day * get all jobs of day
* *
* @param day * @param day the day
* the day
* @return list of found jobs; an empty list at least * @return list of found jobs; an empty list at least
* @throws SQLException * @throws SQLException
* @throws ClassNotFoundException * @throws ClassNotFoundException
* @throws DataAccessException * @throws DataAccessException
*/ */
public List<DailySummaryBean> getAllJobs(java.util.Date day) throws DataAccessException, ClassNotFoundException, SQLException { public List<DailySummaryBean> getAllJobs(java.util.Date day)
throws DataAccessException, ClassNotFoundException, SQLException {
try (CloseableDSLContext jooq = getJooq()) { try (CloseableDSLContext jooq = getJooq()) {
SelectConditionStep<Record6<String, Double, String, String, String, String>> sql = jooq SelectConditionStep<Record6<String, Double, String, String, String, String>> sql = jooq
// @formatter:off // @formatter:off
@ -330,6 +333,7 @@ public class DoneGateway extends JooqGateway {
String moduleName = r.get(V_WORKTIME.MODULE_NAME); String moduleName = r.get(V_WORKTIME.MODULE_NAME);
String jobName = r.get(V_WORKTIME.JOB_NAME); String jobName = r.get(V_WORKTIME.JOB_NAME);
String wp = r.get(V_WORKTIME.WP); 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)); list.add(new DailySummaryBean(projectName, moduleName, jobName, duration, wp, durationHours));
} }
return list; return list;
@ -373,14 +377,15 @@ public class DoneGateway extends JooqGateway {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
buf.append(projectName); buf.append(projectName);
if (wp != null && !wp.isBlank()) { if (wp != null && !wp.isBlank()) {
buf.append(" (").append(wp).append(")"); buf.append(" (").append(wp).append(")");
} }
buf.append(", "); buf.append(", ");
buf.append(moduleName); buf.append(moduleName);
buf.append(": "); buf.append(": ");
buf.append(jobName); 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; private static final long serialVersionUID = 1L;
@Override @Override
@ -434,7 +439,8 @@ public class DoneGateway extends JooqGateway {
// @formatter:on // @formatter:on
LOGGER.debug(sql.toString()); LOGGER.debug(sql.toString());
String sep = ";"; 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()) { for (Record r : sql.fetch()) {
LocalDate workday = r.get(V_HAMSTERSUMMARY.WORKDAY); LocalDate workday = r.get(V_HAMSTERSUMMARY.WORKDAY);
String date = workday.format(DateTimeFormatter.ofPattern("dd.MM.yyyy")); String date = workday.format(DateTimeFormatter.ofPattern("dd.MM.yyyy"));
@ -447,4 +453,18 @@ public class DoneGateway extends JooqGateway {
} }
return buf.toString(); return buf.toString();
} }
/**
* dummy method to use until a table has been created
*
* @return all valid wps
*/
public static final List<WpBean> getAllWps() {
List<WpBean> 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;
}
} }

View File

@ -41,6 +41,7 @@ public class DoneModel implements Model, Serializable {
private List<TProjectRecord> projects; private List<TProjectRecord> projects;
private List<TModuleRecord> modules; private List<TModuleRecord> modules;
private List<TJobRecord> activities; private List<TJobRecord> activities;
private List<WpBean> wps;
private List<TimeBean> times; private List<TimeBean> times;
private List<DailySummaryBean> allJobs; private List<DailySummaryBean> allJobs;
private WholeDaySummaryBean daySummary; private WholeDaySummaryBean daySummary;
@ -57,6 +58,7 @@ public class DoneModel implements Model, Serializable {
modules = gw.getAllModules(); modules = gw.getAllModules();
activities = gw.getAllActivities(); activities = gw.getAllActivities();
projects = gw.getAllProjects(); projects = gw.getAllProjects();
wps = DoneGateway.getAllWps();
daySummary = gw.getDaySummary(day); daySummary = gw.getDaySummary(day);
allJobs = gw.getAllJobs(day); allJobs = gw.getAllJobs(day);
calendarEvents = gw.getAllCalendarEvents(); calendarEvents = gw.getAllCalendarEvents();
@ -244,6 +246,10 @@ public class DoneModel implements Model, Serializable {
return activities; return activities;
} }
public List<WpBean> getWps() {
return wps;
}
public List<DailySummaryBean> getAllJobs() { public List<DailySummaryBean> getAllJobs() {
return allJobs; return allJobs;
} }

View File

@ -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;
}
}

View File

@ -45,7 +45,7 @@
<h:outputText value="Projekt" /> <h:outputText value="Projekt" />
<h:outputText value="Modul" /> <h:outputText value="Modul" />
<h:outputText value="Tätigkeit" /> <h:outputText value="Tätigkeit" />
<h:outputText value="euCanShare WP" /> <h:outputText value="Abrechnung" />
<b:selectOneMenu id="project" value="#{doneModel.bean.project}"> <b:selectOneMenu id="project" value="#{doneModel.bean.project}">
<f:selectItem itemValue="" itemLabel="--- bitte wählen ---" /> <f:selectItem itemValue="" itemLabel="--- bitte wählen ---" />
<f:selectItems value="#{doneModel.projects}" var="i" itemValue="#{i}" itemLabel="#{i.name}" /> <f:selectItems value="#{doneModel.projects}" var="i" itemValue="#{i}" itemLabel="#{i.name}" />
@ -59,10 +59,8 @@
<f:selectItems value="#{doneModel.activities}" var="i" itemValue="#{i}" itemLabel="#{i.name}" /> <f:selectItems value="#{doneModel.activities}" var="i" itemValue="#{i}" itemLabel="#{i.name}" />
</b:selectOneMenu> </b:selectOneMenu>
<b:selectOneMenu id="wp" value="#{doneModel.bean.wp}"> <b:selectOneMenu id="wp" value="#{doneModel.bean.wp}">
<f:selectItem itemValue="" itemLabel="---" /> <f:selectItem itemValue="" itemLabel="--- bitte wählen ---" />
<f:selectItem itemValue="WP2" itemLabel="WP2 - Opal/Mica/..., REST" /> <f:selectItems value="#{doneModel.wps}" var="i" itemValue="#{i}" itemLabel="#{i.name}" />
<f:selectItem itemValue="WP4" itemLabel="WP4 - Square²" />
<f:selectItem itemValue="WP5" itemLabel="WP5 - SHIP-Datenbereitstellung" />
</b:selectOneMenu> </b:selectOneMenu>
</b:panelGrid> </b:panelGrid>
<b:buttonGroup> <b:buttonGroup>

View File

@ -45,7 +45,7 @@
<h:outputText value="Projekt (#{doneModel.bean.projectName})" /> <h:outputText value="Projekt (#{doneModel.bean.projectName})" />
<h:outputText value="Modul (#{doneModel.bean.moduleName})" /> <h:outputText value="Modul (#{doneModel.bean.moduleName})" />
<h:outputText value="Tätigkeit (#{doneModel.bean.jobName})" /> <h:outputText value="Tätigkeit (#{doneModel.bean.jobName})" />
<h:outputText value="euCanSHare WP" /> <h:outputText value="Abrechnung (#{doneModel.bean.wpName})" />
<b:selectOneMenu id="project" value="#{doneModel.bean.project}"> <b:selectOneMenu id="project" value="#{doneModel.bean.project}">
<f:selectItem itemValue="" itemLabel="--- bitte wählen ---" /> <f:selectItem itemValue="" itemLabel="--- bitte wählen ---" />
<f:selectItems value="#{doneModel.projects}" var="i" itemValue="#{i}" itemLabel="#{i.name}" /> <f:selectItems value="#{doneModel.projects}" var="i" itemValue="#{i}" itemLabel="#{i.name}" />
@ -59,10 +59,8 @@
<f:selectItems value="#{doneModel.activities}" var="i" itemValue="#{i}" itemLabel="#{i.name}" /> <f:selectItems value="#{doneModel.activities}" var="i" itemValue="#{i}" itemLabel="#{i.name}" />
</b:selectOneMenu> </b:selectOneMenu>
<b:selectOneMenu id="wp" value="#{doneModel.bean.wp}"> <b:selectOneMenu id="wp" value="#{doneModel.bean.wp}">
<f:selectItem itemValue="" itemLabel="---" /> <f:selectItem itemValue="" itemLabel="--- bitte wählen ---" />
<f:selectItem itemValue="WP2" itemLabel="WP2 - Opal/Mica/..., REST" /> <f:selectItems value="#{doneModel.wps}" var="i" itemValue="#{i}" itemLabel="#{i.name}" />
<f:selectItem itemValue="WP4" itemLabel="WP4 - Square²" />
<f:selectItem itemValue="WP5" itemLabel="WP5 - SHIP-Datenbereitstellung" />
</b:selectOneMenu> </b:selectOneMenu>
</b:panelGrid> </b:panelGrid>
<b:buttonGroup> <b:buttonGroup>

View File

@ -79,7 +79,7 @@
</b:dataTableColumn> </b:dataTableColumn>
<b:dataTableColumn label="" value="#{col.moduleName}" contentStyle="font-size: 120%" orderable="false" /> <b:dataTableColumn label="" value="#{col.moduleName}" contentStyle="font-size: 120%" orderable="false" />
<b:dataTableColumn label="" value="#{col.jobName}" contentStyle="font-size: 120%" orderable="false" /> <b:dataTableColumn label="" value="#{col.jobName}" contentStyle="font-size: 120%" orderable="false" />
<b:dataTableColumn label="" value="#{col.duration} = #{col.durationHours} h" contentStyle="font-size: 120%" orderable="false" /> <b:dataTableColumn label="" value="#{col.durationHours} h" contentStyle="font-size: 120%" orderable="false" />
</b:dataTable> </b:dataTable>
</b:tab> </b:tab>
<b:tab title="Anhang"> <b:tab title="Anhang">
@ -92,6 +92,27 @@
defaultDate="#{doneModel.dayIso8601}" defaultView="agendaDay" hidden="xs" scrollTime="08:00:00" defaultDate="#{doneModel.dayIso8601}" defaultView="agendaDay" hidden="xs" scrollTime="08:00:00"
slotDuration="00:15:00" span="half" allDaySlot="false" lang="de" /> slotDuration="00:15:00" span="half" allDaySlot="false" lang="de" />
</b:tab> </b:tab>
<b:tab title="Projekt">
<ui:repeat value="#{doneModel.projects}" var="col">
<b:badge value="#{col.name}" class="prompt" />
</ui:repeat>
</b:tab>
<b:tab title="Modul">
<ui:repeat value="#{doneModel.modules}" var="col">
<b:badge value="#{col.name}" class="prompt" />
</ui:repeat>
</b:tab>
<b:tab title="Tätigkeit">
<ui:repeat value="#{doneModel.activities}" var="col">
<b:badge value="#{col.name}" class="prompt" />
</ui:repeat>
</b:tab>
<b:tab title="Abrechnung">
<b:dataTable value="#{doneModel.wps}" var="col" border="false" info="false">
<b:dataTableColumn label="Schlüssel" value="#{col.key}" />
<b:dataTableColumn label="Name" value="#{col.name}" />
</b:dataTable>
</b:tab>
</b:tabView> </b:tabView>
</b:form> </b:form>
</b:panel> </b:panel>

View File

@ -7,7 +7,7 @@
.page { .page {
height: 100%; height: 100%;
width: 100%; width: 100%;
background-image: linear-gradient(to bottom, #fff 0%, #ccc 20%) background-image: linear-gradient(to bottom, #ffffff 10%, #afffff 40%)
!important; !important;
} }
@ -68,6 +68,14 @@
text-align: right; text-align: right;
} }
.prompt {
margin: 4px;
padding: 4px !important;
padding-bottom: 2px !important;
font-size: medium !important;
background-color: #005782 !important;
}
.version { .version {
font-size: small; font-size: small;
color: silver; color: silver;