library upgrade
This commit is contained in:
@ -32,6 +32,7 @@ public class ThemeBean implements Serializable
|
||||
list.add("lumen");
|
||||
list.add("other");
|
||||
list.add("paper");
|
||||
list.add("patternfly");
|
||||
list.add("readable");
|
||||
list.add("sandstone");
|
||||
list.add("simplex");
|
||||
|
@ -1,44 +1,43 @@
|
||||
package de.jottyfan.timetrack.modules;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.TableLike;
|
||||
|
||||
import de.jooqFaces.EJooqApplicationScope;
|
||||
import de.jooqFaces.JooqFacesContext;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author henkej
|
||||
*
|
||||
*/
|
||||
public class JooqGateway
|
||||
{
|
||||
private final FacesContext facesContext;
|
||||
public class JooqGateway {
|
||||
private final JooqFacesContext facesContext;
|
||||
|
||||
public JooqGateway(FacesContext facesContext)
|
||||
{
|
||||
public JooqGateway(JooqFacesContext facesContext) {
|
||||
this.facesContext = facesContext;
|
||||
}
|
||||
|
||||
public DSLContext getJooq()
|
||||
{
|
||||
return (DSLContext) facesContext.getExternalContext().getApplicationMap().get(EJooqApplicationScope.JOOQ_FACES_DSLCONTEXT.get());
|
||||
public DSLContext getJooq() throws ClassNotFoundException, SQLException {
|
||||
return (DSLContext) facesContext.getJooq();
|
||||
}
|
||||
|
||||
|
||||
public Integer getFkLogin() {
|
||||
// TODO: make a login, add the profile id to the session and read it here from facesContext
|
||||
// TODO: make a login, add the profile id to the session and read it here from
|
||||
// facesContext
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* return amount of "select count(1) as amount " + subQuery
|
||||
*
|
||||
* @param subQuery
|
||||
* @return number of entries
|
||||
* @throws ClassNotFoundException
|
||||
* @throws SQLException
|
||||
*/
|
||||
public Long getAmount(TableLike<?> table)
|
||||
{
|
||||
public Long getAmount(TableLike<?> table) throws ClassNotFoundException, SQLException {
|
||||
return getJooq().selectCount().from(table).fetchOne(0, long.class);
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import javax.faces.context.FacesContext;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import de.jooqFaces.JooqFacesContext;
|
||||
import de.jottyfan.timetrack.help.Pages;
|
||||
|
||||
/**
|
||||
@ -21,7 +22,7 @@ public class SessionControl {
|
||||
|
||||
public String doLogin() {
|
||||
SessionModel model = new SessionModel();
|
||||
model.doLogin(FacesContext.getCurrentInstance(), sessionBean);
|
||||
model.doLogin((JooqFacesContext) FacesContext.getCurrentInstance(), sessionBean);
|
||||
return Pages.START.get();
|
||||
}
|
||||
|
||||
|
@ -2,14 +2,17 @@ package de.jottyfan.timetrack.modules;
|
||||
|
||||
import static de.jottyfan.timetrack.db.profile.Tables.T_LOGIN;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Record4;
|
||||
import org.jooq.SelectConditionStep;
|
||||
import org.jooq.exception.DataAccessException;
|
||||
|
||||
import de.jooqFaces.JooqFacesContext;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author henkej
|
||||
@ -18,7 +21,7 @@ import org.jooq.exception.DataAccessException;
|
||||
public class SessionGateway extends JooqGateway {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
public SessionGateway(FacesContext facesContext) {
|
||||
public SessionGateway(JooqFacesContext facesContext) {
|
||||
super(facesContext);
|
||||
}
|
||||
|
||||
@ -28,31 +31,36 @@ public class SessionGateway extends JooqGateway {
|
||||
* @param bean
|
||||
* the bean
|
||||
* @return true or false
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
public boolean seekAndSetLogin(SessionBean bean) {
|
||||
SelectConditionStep<Record4<Integer, String, String, String>> sql = getJooq()
|
||||
// @formatter:off
|
||||
.select(T_LOGIN.PK,
|
||||
T_LOGIN.FORENAME,
|
||||
T_LOGIN.SURNAME,
|
||||
T_LOGIN.PASSWORD)
|
||||
.from(T_LOGIN)
|
||||
.where(T_LOGIN.LOGIN.eq(bean.getUsername()));
|
||||
// @formatter:on
|
||||
LOGGER.debug(sql.toString());
|
||||
Record4<Integer, String, String, String> r = sql.fetchOne();
|
||||
if (r != null) {
|
||||
String encrypted = r.get(T_LOGIN.PASSWORD);
|
||||
if (bean.checkSecret(encrypted)) {
|
||||
bean.setLogin(r.get(T_LOGIN.PK));
|
||||
bean.setForename(r.get(T_LOGIN.FORENAME));
|
||||
bean.setSurname(r.get(T_LOGIN.SURNAME));
|
||||
return true;
|
||||
public boolean seekAndSetLogin(SessionBean bean) throws DataAccessException, ClassNotFoundException, SQLException {
|
||||
try (DSLContext jooq = getJooq()) {
|
||||
SelectConditionStep<Record4<Integer, String, String, String>> sql = jooq
|
||||
// @formatter:off
|
||||
.select(T_LOGIN.PK,
|
||||
T_LOGIN.FORENAME,
|
||||
T_LOGIN.SURNAME,
|
||||
T_LOGIN.PASSWORD)
|
||||
.from(T_LOGIN)
|
||||
.where(T_LOGIN.LOGIN.eq(bean.getUsername()));
|
||||
// @formatter:on
|
||||
LOGGER.debug(sql.toString());
|
||||
Record4<Integer, String, String, String> r = sql.fetchOne();
|
||||
if (r != null) {
|
||||
String encrypted = r.get(T_LOGIN.PASSWORD);
|
||||
if (bean.checkSecret(encrypted)) {
|
||||
bean.setLogin(r.get(T_LOGIN.PK));
|
||||
bean.setForename(r.get(T_LOGIN.FORENAME));
|
||||
bean.setSurname(r.get(T_LOGIN.SURNAME));
|
||||
return true;
|
||||
} else {
|
||||
throw new DataAccessException("wrong password");
|
||||
}
|
||||
} else {
|
||||
throw new DataAccessException("wrong password");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,13 @@
|
||||
package de.jottyfan.timetrack.modules;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.jooq.exception.DataAccessException;
|
||||
|
||||
import de.jooqFaces.JooqFacesContext;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author henkej
|
||||
@ -12,10 +15,10 @@ import org.jooq.exception.DataAccessException;
|
||||
*/
|
||||
public class SessionModel {
|
||||
|
||||
public boolean doLogin(FacesContext facesContext, SessionBean bean) {
|
||||
public boolean doLogin(JooqFacesContext facesContext, SessionBean bean) {
|
||||
try {
|
||||
return new SessionGateway(facesContext).seekAndSetLogin(bean);
|
||||
} catch (DataAccessException e) {
|
||||
} catch (DataAccessException | ClassNotFoundException | SQLException e) {
|
||||
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "error on login", e.getMessage());
|
||||
facesContext.addMessage(null, msg);
|
||||
return false;
|
||||
|
@ -7,6 +7,7 @@ import javax.faces.context.FacesContext;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import de.jooqFaces.JooqFacesContext;
|
||||
import de.jottyfan.timetrack.help.Navigation;
|
||||
import de.jottyfan.timetrack.help.Pages;
|
||||
import de.jottyfan.timetrack.modules.ControlInterface;
|
||||
@ -30,7 +31,7 @@ public class ContactControl extends Navigation implements ControlInterface, Seri
|
||||
}
|
||||
|
||||
public String toList() {
|
||||
boolean ready = model.init(FacesContext.getCurrentInstance());
|
||||
boolean ready = model.init((JooqFacesContext) FacesContext.getCurrentInstance());
|
||||
return ready ? navigateTo(Pages.CONTACT_LIST) : toStart();
|
||||
}
|
||||
|
||||
@ -45,21 +46,21 @@ public class ContactControl extends Navigation implements ControlInterface, Seri
|
||||
}
|
||||
|
||||
public String doAdd() {
|
||||
boolean ready = model.add(FacesContext.getCurrentInstance());
|
||||
boolean ready = model.add((JooqFacesContext) FacesContext.getCurrentInstance());
|
||||
return ready ? toList() : navigateTo(Pages.CONTACT_ITEM);
|
||||
}
|
||||
|
||||
public String doUpdate() {
|
||||
boolean ready = model.update(FacesContext.getCurrentInstance());
|
||||
boolean ready = model.update((JooqFacesContext) FacesContext.getCurrentInstance());
|
||||
return ready ? toList() : navigateTo(Pages.CONTACT_ITEM);
|
||||
}
|
||||
|
||||
public String doDelete() {
|
||||
boolean ready = model.delete(FacesContext.getCurrentInstance());
|
||||
boolean ready = model.delete((JooqFacesContext) FacesContext.getCurrentInstance());
|
||||
return ready ? toList() : navigateTo(Pages.CONTACT_ITEM);
|
||||
}
|
||||
|
||||
public Integer getAmount() {
|
||||
return model.getAmount(FacesContext.getCurrentInstance());
|
||||
return model.getAmount((JooqFacesContext) FacesContext.getCurrentInstance());
|
||||
}
|
||||
}
|
||||
|
@ -2,22 +2,24 @@ package de.jottyfan.timetrack.modules.contact;
|
||||
|
||||
import static de.jottyfan.timetrack.db.contact.Tables.T_CONTACT;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.DeleteConditionStep;
|
||||
import org.jooq.InsertValuesStep4;
|
||||
import org.jooq.Record1;
|
||||
import org.jooq.Record5;
|
||||
import org.jooq.SelectJoinStep;
|
||||
import org.jooq.UpdateConditionStep;
|
||||
import org.jooq.exception.DataAccessException;
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
import de.jooqFaces.JooqFacesContext;
|
||||
import de.jottyfan.timetrack.db.contact.enums.EnumContacttype;
|
||||
import de.jottyfan.timetrack.db.contact.tables.records.TContactRecord;
|
||||
import de.jottyfan.timetrack.modules.JooqGateway;
|
||||
@ -30,7 +32,7 @@ import de.jottyfan.timetrack.modules.JooqGateway;
|
||||
public class ContactGateway extends JooqGateway {
|
||||
private static final Logger LOGGER = LogManager.getLogger(ContactGateway.class);
|
||||
|
||||
public ContactGateway(FacesContext facesContext) {
|
||||
public ContactGateway(JooqFacesContext facesContext) {
|
||||
super(facesContext);
|
||||
}
|
||||
|
||||
@ -38,29 +40,34 @@ public class ContactGateway extends JooqGateway {
|
||||
* get sorted list of contacts
|
||||
*
|
||||
* @return a list (an empty one at least)
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
public List<ContactBean> getAll() {
|
||||
SelectJoinStep<Record5<Integer, String, String, String, EnumContacttype>> sql = getJooq()
|
||||
// @formatter:off
|
||||
.select(T_CONTACT.PK,
|
||||
T_CONTACT.FORENAME,
|
||||
T_CONTACT.SURNAME,
|
||||
T_CONTACT.CONTACT,
|
||||
T_CONTACT.TYPE)
|
||||
.from(T_CONTACT);
|
||||
// @formatter:on
|
||||
LOGGER.debug("{}", sql.toString());
|
||||
List<ContactBean> list = new ArrayList<>();
|
||||
for (Record5<Integer, String, String, String, EnumContacttype> r : sql.fetch()) {
|
||||
ContactBean bean = new ContactBean(r.get(T_CONTACT.PK));
|
||||
bean.setForename(r.get(T_CONTACT.FORENAME));
|
||||
bean.setSurname(r.get(T_CONTACT.SURNAME));
|
||||
bean.setContact(r.get(T_CONTACT.CONTACT));
|
||||
bean.setType(r.get(T_CONTACT.TYPE));
|
||||
list.add(bean);
|
||||
public List<ContactBean> getAll() throws DataAccessException, ClassNotFoundException, SQLException {
|
||||
try (DSLContext jooq = getJooq()) {
|
||||
SelectJoinStep<Record5<Integer, String, String, String, EnumContacttype>> sql = jooq
|
||||
// @formatter:off
|
||||
.select(T_CONTACT.PK,
|
||||
T_CONTACT.FORENAME,
|
||||
T_CONTACT.SURNAME,
|
||||
T_CONTACT.CONTACT,
|
||||
T_CONTACT.TYPE)
|
||||
.from(T_CONTACT);
|
||||
// @formatter:on
|
||||
LOGGER.debug("{}", sql.toString());
|
||||
List<ContactBean> list = new ArrayList<>();
|
||||
for (Record5<Integer, String, String, String, EnumContacttype> r : sql.fetch()) {
|
||||
ContactBean bean = new ContactBean(r.get(T_CONTACT.PK));
|
||||
bean.setForename(r.get(T_CONTACT.FORENAME));
|
||||
bean.setSurname(r.get(T_CONTACT.SURNAME));
|
||||
bean.setContact(r.get(T_CONTACT.CONTACT));
|
||||
bean.setType(r.get(T_CONTACT.TYPE));
|
||||
list.add(bean);
|
||||
}
|
||||
list.sort((o1, o2) -> o1 == null ? 0 : o1.compareTo(o2));
|
||||
return list;
|
||||
}
|
||||
list.sort((o1, o2) -> o1 == null ? 0 : o1.compareTo(o2));
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -69,15 +76,20 @@ public class ContactGateway extends JooqGateway {
|
||||
* @param pk
|
||||
* the id of the contact
|
||||
* @return the number of affected database rows, should be 1
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
public Integer delete(Integer pk) {
|
||||
DeleteConditionStep<TContactRecord> sql = getJooq()
|
||||
// @formatter:off
|
||||
.deleteFrom(T_CONTACT)
|
||||
.where(T_CONTACT.PK.eq(pk));
|
||||
// @formatter:on
|
||||
LOGGER.debug("{}", sql.toString());
|
||||
return sql.execute();
|
||||
public Integer delete(Integer pk) throws DataAccessException, ClassNotFoundException, SQLException {
|
||||
try (DSLContext jooq = getJooq()) {
|
||||
DeleteConditionStep<TContactRecord> sql = jooq
|
||||
// @formatter:off
|
||||
.deleteFrom(T_CONTACT)
|
||||
.where(T_CONTACT.PK.eq(pk));
|
||||
// @formatter:on
|
||||
LOGGER.debug("{}", sql.toString());
|
||||
return sql.execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -87,19 +99,24 @@ public class ContactGateway extends JooqGateway {
|
||||
* @param bean
|
||||
* the contact information
|
||||
* @return the number of affected database rows, should be 1
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
public Integer add(ContactBean bean) {
|
||||
InsertValuesStep4<TContactRecord, String, String, String, EnumContacttype> sql = getJooq()
|
||||
// @formatter:off
|
||||
.insertInto(T_CONTACT,
|
||||
T_CONTACT.FORENAME,
|
||||
T_CONTACT.SURNAME,
|
||||
T_CONTACT.CONTACT,
|
||||
T_CONTACT.TYPE)
|
||||
.values(bean.getForename(), bean.getSurname(), bean.getContact(), bean.getType());
|
||||
// @formatter:on
|
||||
LOGGER.debug("{}", sql.toString());
|
||||
return sql.execute();
|
||||
public Integer add(ContactBean bean) throws DataAccessException, ClassNotFoundException, SQLException {
|
||||
try (DSLContext jooq = getJooq()) {
|
||||
InsertValuesStep4<TContactRecord, String, String, String, EnumContacttype> sql = jooq
|
||||
// @formatter:off
|
||||
.insertInto(T_CONTACT,
|
||||
T_CONTACT.FORENAME,
|
||||
T_CONTACT.SURNAME,
|
||||
T_CONTACT.CONTACT,
|
||||
T_CONTACT.TYPE)
|
||||
.values(bean.getForename(), bean.getSurname(), bean.getContact(), bean.getType());
|
||||
// @formatter:on
|
||||
LOGGER.debug("{}", sql.toString());
|
||||
return sql.execute();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,34 +125,44 @@ public class ContactGateway extends JooqGateway {
|
||||
* @param bean
|
||||
* the contact information
|
||||
* @return the number of affected database rows, should be 1
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
public Integer update(ContactBean bean) {
|
||||
UpdateConditionStep<TContactRecord> sql = getJooq()
|
||||
// @formatter:off
|
||||
.update(T_CONTACT)
|
||||
.set(T_CONTACT.FORENAME, bean.getForename())
|
||||
.set(T_CONTACT.SURNAME, bean.getSurname())
|
||||
.set(T_CONTACT.CONTACT, bean.getContact())
|
||||
.set(T_CONTACT.TYPE, bean.getType())
|
||||
.where(T_CONTACT.PK.eq(bean.getPk()));
|
||||
// @formatter:on
|
||||
LOGGER.debug("{}", sql.toString());
|
||||
return sql.execute();
|
||||
public Integer update(ContactBean bean) throws DataAccessException, ClassNotFoundException, SQLException {
|
||||
try (DSLContext jooq = getJooq()) {
|
||||
UpdateConditionStep<TContactRecord> sql = jooq
|
||||
// @formatter:off
|
||||
.update(T_CONTACT)
|
||||
.set(T_CONTACT.FORENAME, bean.getForename())
|
||||
.set(T_CONTACT.SURNAME, bean.getSurname())
|
||||
.set(T_CONTACT.CONTACT, bean.getContact())
|
||||
.set(T_CONTACT.TYPE, bean.getType())
|
||||
.where(T_CONTACT.PK.eq(bean.getPk()));
|
||||
// @formatter:on
|
||||
LOGGER.debug("{}", sql.toString());
|
||||
return sql.execute();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get number of entries in t_contact
|
||||
*
|
||||
* @return number of entries
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
public Integer getAmount() {
|
||||
SelectJoinStep<Record1<Integer>> sql = getJooq()
|
||||
// @formatter:off
|
||||
.selectCount()
|
||||
.from(T_CONTACT);
|
||||
// @formatter:on
|
||||
LOGGER.debug("{}", sql.toString());
|
||||
return sql.fetchOne(DSL.count());
|
||||
public Integer getAmount() throws DataAccessException, ClassNotFoundException, SQLException {
|
||||
try (DSLContext jooq = getJooq()) {
|
||||
SelectJoinStep<Record1<Integer>> sql = jooq
|
||||
// @formatter:off
|
||||
.selectCount()
|
||||
.from(T_CONTACT);
|
||||
// @formatter:on
|
||||
LOGGER.debug("{}", sql.toString());
|
||||
return sql.fetchOne(DSL.count());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,16 +1,17 @@
|
||||
package de.jottyfan.timetrack.modules.contact;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.enterprise.context.SessionScoped;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jooq.exception.DataAccessException;
|
||||
|
||||
import de.jooqFaces.JooqFacesContext;
|
||||
import de.jottyfan.timetrack.db.contact.enums.EnumContacttype;
|
||||
import de.jottyfan.timetrack.modules.Model;
|
||||
|
||||
@ -28,14 +29,14 @@ public class ContactModel implements Model, Serializable {
|
||||
private List<ContactBean> list;
|
||||
private List<EnumContacttype> types;
|
||||
|
||||
public boolean init(FacesContext facesContext) {
|
||||
public boolean init(JooqFacesContext facesContext) {
|
||||
bean = new ContactBean(null);
|
||||
try {
|
||||
ContactGateway gw = new ContactGateway(facesContext);
|
||||
list = gw.getAll();
|
||||
types = gw.getTypes();
|
||||
return true;
|
||||
} catch (DataAccessException e) {
|
||||
} catch (DataAccessException | ClassNotFoundException | SQLException e) {
|
||||
facesContext.addMessage(null,
|
||||
new FacesMessage(FacesMessage.SEVERITY_ERROR, "error on loading data from db", e.getMessage()));
|
||||
list = new ArrayList<>();
|
||||
@ -44,46 +45,46 @@ public class ContactModel implements Model, Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean delete(FacesContext facesContext) {
|
||||
public boolean delete(JooqFacesContext facesContext) {
|
||||
try {
|
||||
Integer affected = new ContactGateway(facesContext).delete(bean.getPk());
|
||||
return affected.equals(1);
|
||||
} catch (DataAccessException e) {
|
||||
} catch (DataAccessException | ClassNotFoundException | SQLException e) {
|
||||
facesContext.addMessage(null,
|
||||
new FacesMessage(FacesMessage.SEVERITY_ERROR, "error on deleting data from db", e.getMessage()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean add(FacesContext facesContext) {
|
||||
public boolean add(JooqFacesContext facesContext) {
|
||||
try {
|
||||
Integer affected = new ContactGateway(facesContext).add(bean);
|
||||
return affected.equals(1);
|
||||
} catch (DataAccessException e) {
|
||||
} catch (DataAccessException | ClassNotFoundException | SQLException e) {
|
||||
facesContext.addMessage(null,
|
||||
new FacesMessage(FacesMessage.SEVERITY_ERROR, "error on adding data to db", e.getMessage()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean update(FacesContext facesContext) {
|
||||
public boolean update(JooqFacesContext facesContext) {
|
||||
try {
|
||||
Integer affected = new ContactGateway(facesContext).update(bean);
|
||||
return affected.equals(1);
|
||||
} catch (DataAccessException e) {
|
||||
} catch (DataAccessException | ClassNotFoundException | SQLException e) {
|
||||
facesContext.addMessage(null,
|
||||
new FacesMessage(FacesMessage.SEVERITY_ERROR, "error on updating data to db", e.getMessage()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getAmount(FacesContext facesContext) {
|
||||
public Integer getAmount(JooqFacesContext facesContext) {
|
||||
try {
|
||||
return new ContactGateway(facesContext).getAmount();
|
||||
} catch (DataAccessException e) {
|
||||
} catch (DataAccessException | ClassNotFoundException | SQLException e) {
|
||||
facesContext.addMessage(null,
|
||||
new FacesMessage(FacesMessage.SEVERITY_ERROR, "error on getting size of contacts", e.getMessage()));
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import javax.faces.context.FacesContext;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import de.jooqFaces.JooqFacesContext;
|
||||
import de.jottyfan.timetrack.help.Navigation;
|
||||
import de.jottyfan.timetrack.help.Pages;
|
||||
import de.jottyfan.timetrack.modules.ControlInterface;
|
||||
@ -33,7 +34,7 @@ public class DoneControl extends Navigation implements ControlInterface, Seriali
|
||||
}
|
||||
|
||||
public String toList() {
|
||||
boolean ready = model.init(FacesContext.getCurrentInstance());
|
||||
boolean ready = model.init((JooqFacesContext) FacesContext.getCurrentInstance());
|
||||
return ready ? navigateTo(Pages.DONE_INIT) : toStart();
|
||||
}
|
||||
|
||||
@ -41,13 +42,13 @@ public class DoneControl extends Navigation implements ControlInterface, Seriali
|
||||
DoneBean bean = new DoneBean();
|
||||
bean.setTimeFrom(getCurrentDate());
|
||||
model.setBean(bean);
|
||||
boolean ready = model.loadDefaults(FacesContext.getCurrentInstance());
|
||||
boolean ready = model.loadDefaults((JooqFacesContext) FacesContext.getCurrentInstance());
|
||||
return ready ? navigateTo(Pages.DONE_ADD) : toList();
|
||||
}
|
||||
|
||||
public String toEdit(DoneBean bean) {
|
||||
model.setBean(bean);
|
||||
boolean ready = model.loadDefaults(FacesContext.getCurrentInstance());
|
||||
boolean ready = model.loadDefaults((JooqFacesContext) FacesContext.getCurrentInstance());
|
||||
return ready ? navigateTo(Pages.DONE_EDIT) : toList();
|
||||
}
|
||||
|
||||
@ -57,17 +58,17 @@ public class DoneControl extends Navigation implements ControlInterface, Seriali
|
||||
}
|
||||
|
||||
public String doUpdate() {
|
||||
boolean ready = model.update(FacesContext.getCurrentInstance());
|
||||
boolean ready = model.update((JooqFacesContext) FacesContext.getCurrentInstance());
|
||||
return ready ? toList() : toEdit(model.getBean());
|
||||
}
|
||||
|
||||
public String doDelete() {
|
||||
boolean ready = model.delete(FacesContext.getCurrentInstance());
|
||||
boolean ready = model.delete((JooqFacesContext) FacesContext.getCurrentInstance());
|
||||
return ready ? toList() : toDelete(model.getBean());
|
||||
}
|
||||
|
||||
public String doAdd() {
|
||||
boolean ready = model.insert(FacesContext.getCurrentInstance());
|
||||
boolean ready = model.insert((JooqFacesContext) FacesContext.getCurrentInstance());
|
||||
return ready ? toList() : toAdd();
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import static de.jottyfan.timetrack.db.done.Tables.T_PROJECT;
|
||||
import static de.jottyfan.timetrack.db.done.Tables.V_TASKLIST;
|
||||
import static de.jottyfan.timetrack.db.done.Tables.V_TOTALOFDAY;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
@ -16,10 +17,9 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.DeleteConditionStep;
|
||||
import org.jooq.InsertValuesStep6;
|
||||
import org.jooq.Record;
|
||||
@ -30,6 +30,7 @@ import org.jooq.SelectWhereStep;
|
||||
import org.jooq.UpdateConditionStep;
|
||||
import org.jooq.exception.DataAccessException;
|
||||
|
||||
import de.jooqFaces.JooqFacesContext;
|
||||
import de.jottyfan.timetrack.db.done.tables.records.TDoneRecord;
|
||||
import de.jottyfan.timetrack.db.done.tables.records.TJobRecord;
|
||||
import de.jottyfan.timetrack.db.done.tables.records.TModuleRecord;
|
||||
@ -46,7 +47,7 @@ import net.bootsfaces.component.fullCalendar.FullCalendarEventList;
|
||||
public class DoneGateway extends JooqGateway {
|
||||
private final static Logger LOGGER = LogManager.getLogger(DoneGateway.class);
|
||||
|
||||
public DoneGateway(FacesContext facesContext) {
|
||||
public DoneGateway(JooqFacesContext facesContext) {
|
||||
super(facesContext);
|
||||
}
|
||||
|
||||
@ -54,51 +55,63 @@ public class DoneGateway extends JooqGateway {
|
||||
* get all modules from db
|
||||
*
|
||||
* @return modules
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public List<TModuleRecord> getAllModules() throws DataAccessException {
|
||||
List<TModuleRecord> list = new ArrayList<>();
|
||||
SelectWhereStep<TModuleRecord> sql = getJooq().selectFrom(T_MODULE);
|
||||
LOGGER.debug(sql.toString());
|
||||
for (TModuleRecord r : sql.fetch()) {
|
||||
list.add(r);
|
||||
public List<TModuleRecord> getAllModules() throws DataAccessException, ClassNotFoundException, SQLException {
|
||||
try (DSLContext jooq = getJooq()) {
|
||||
List<TModuleRecord> list = new ArrayList<>();
|
||||
SelectWhereStep<TModuleRecord> sql = jooq.selectFrom(T_MODULE);
|
||||
LOGGER.debug(sql.toString());
|
||||
for (TModuleRecord r : sql.fetch()) {
|
||||
list.add(r);
|
||||
}
|
||||
list.sort((o1, o2) -> o1 == null || o2 == null || o1.getName() == null || o2.getName() == null ? 0
|
||||
: o1.getName().compareTo(o2.getName()));
|
||||
return list;
|
||||
}
|
||||
list.sort((o1, o2) -> o1 == null || o2 == null || o1.getName() == null || o2.getName() == null ? 0
|
||||
: o1.getName().compareTo(o2.getName()));
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* get all activities from db
|
||||
*
|
||||
* @return activities
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public List<TJobRecord> getAllActivities() throws DataAccessException {
|
||||
List<TJobRecord> list = new ArrayList<>();
|
||||
SelectWhereStep<TJobRecord> sql = getJooq().selectFrom(T_JOB);
|
||||
LOGGER.debug(sql.toString());
|
||||
for (TJobRecord r : sql.fetch()) {
|
||||
list.add(r);
|
||||
public List<TJobRecord> getAllActivities() throws DataAccessException, ClassNotFoundException, SQLException {
|
||||
try (DSLContext jooq = getJooq()) {
|
||||
List<TJobRecord> list = new ArrayList<>();
|
||||
SelectWhereStep<TJobRecord> sql = jooq.selectFrom(T_JOB);
|
||||
LOGGER.debug(sql.toString());
|
||||
for (TJobRecord r : sql.fetch()) {
|
||||
list.add(r);
|
||||
}
|
||||
list.sort((o1, o2) -> o1 == null || o2 == null || o1.getName() == null || o2.getName() == null ? 0
|
||||
: o1.getName().compareTo(o2.getName()));
|
||||
return list;
|
||||
}
|
||||
list.sort((o1, o2) -> o1 == null || o2 == null || o1.getName() == null || o2.getName() == null ? 0
|
||||
: o1.getName().compareTo(o2.getName()));
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* get all projects from db
|
||||
*
|
||||
* @return projects
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public List<TProjectRecord> getAllProjects() throws DataAccessException {
|
||||
List<TProjectRecord> list = new ArrayList<>();
|
||||
SelectWhereStep<TProjectRecord> sql = getJooq().selectFrom(T_PROJECT);
|
||||
LOGGER.debug(sql.toString());
|
||||
for (TProjectRecord r : sql.fetch()) {
|
||||
list.add(r);
|
||||
public List<TProjectRecord> getAllProjects() throws DataAccessException, ClassNotFoundException, SQLException {
|
||||
try (DSLContext jooq = getJooq()) {
|
||||
List<TProjectRecord> list = new ArrayList<>();
|
||||
SelectWhereStep<TProjectRecord> sql = jooq.selectFrom(T_PROJECT);
|
||||
LOGGER.debug(sql.toString());
|
||||
for (TProjectRecord r : sql.fetch()) {
|
||||
list.add(r);
|
||||
}
|
||||
list.sort((o1, o2) -> o1 == null || o2 == null || o1.getName() == null || o2.getName() == null ? 0
|
||||
: o1.getName().compareTo(o2.getName()));
|
||||
return list;
|
||||
}
|
||||
list.sort((o1, o2) -> o1 == null || o2 == null || o1.getName() == null || o2.getName() == null ? 0
|
||||
: o1.getName().compareTo(o2.getName()));
|
||||
return list;
|
||||
}
|
||||
|
||||
private Map<Integer, TProjectRecord> generateProjectMap(List<TProjectRecord> list) {
|
||||
@ -132,8 +145,10 @@ public class DoneGateway extends JooqGateway {
|
||||
* the day; if null, the current date is used
|
||||
*
|
||||
* @return a list of found times, an empty one at least
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public List<DoneBean> getAll(LocalDateTime day) throws DataAccessException {
|
||||
public List<DoneBean> getAll(LocalDateTime day) throws DataAccessException, ClassNotFoundException, SQLException {
|
||||
Map<Integer, TProjectRecord> projectMap = generateProjectMap(getAllProjects());
|
||||
Map<Integer, TModuleRecord> moduleMap = generateModuleMap(getAllModules());
|
||||
Map<Integer, TJobRecord> jobMap = generateJobMap(getAllActivities());
|
||||
@ -145,20 +160,22 @@ public class DoneGateway extends JooqGateway {
|
||||
LocalDateTime tomorrow = day.plusDays(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
|
||||
|
||||
List<DoneBean> list = new ArrayList<>();
|
||||
SelectConditionStep<TDoneRecord> sql = getJooq()
|
||||
// @formatter:off
|
||||
.selectFrom(T_DONE)
|
||||
.where(T_DONE.FK_LOGIN.eq(getFkLogin()))
|
||||
.and(T_DONE.TIME_FROM.isNull()
|
||||
.or(T_DONE.TIME_FROM.greaterThan(Timestamp.valueOf(yesterday))
|
||||
.and(T_DONE.TIME_FROM.lessThan(Timestamp.valueOf(tomorrow)))))
|
||||
.and(T_DONE.TIME_UNTIL.isNull()
|
||||
.or(T_DONE.TIME_UNTIL.lessThan(Timestamp.valueOf(tomorrow))
|
||||
.and(T_DONE.TIME_UNTIL.greaterThan(Timestamp.valueOf(yesterday)))));
|
||||
// @formatter:on
|
||||
LOGGER.debug(sql.toString());
|
||||
for (TDoneRecord r : sql.fetch()) {
|
||||
list.add(new DoneBean(r, projectMap, moduleMap, jobMap));
|
||||
try (DSLContext jooq = getJooq()) {
|
||||
SelectConditionStep<TDoneRecord> sql = getJooq()
|
||||
// @formatter:off
|
||||
.selectFrom(T_DONE)
|
||||
.where(T_DONE.FK_LOGIN.eq(getFkLogin()))
|
||||
.and(T_DONE.TIME_FROM.isNull()
|
||||
.or(T_DONE.TIME_FROM.greaterThan(Timestamp.valueOf(yesterday))
|
||||
.and(T_DONE.TIME_FROM.lessThan(Timestamp.valueOf(tomorrow)))))
|
||||
.and(T_DONE.TIME_UNTIL.isNull()
|
||||
.or(T_DONE.TIME_UNTIL.lessThan(Timestamp.valueOf(tomorrow))
|
||||
.and(T_DONE.TIME_UNTIL.greaterThan(Timestamp.valueOf(yesterday)))));
|
||||
// @formatter:on
|
||||
LOGGER.debug(sql.toString());
|
||||
for (TDoneRecord r : sql.fetch()) {
|
||||
list.add(new DoneBean(r, projectMap, moduleMap, jobMap));
|
||||
}
|
||||
}
|
||||
list.sort((o1, o2) -> o1 == null || o2 == null ? 0 : o1.compareTo(o2));
|
||||
return list;
|
||||
@ -168,57 +185,69 @@ public class DoneGateway extends JooqGateway {
|
||||
* insert data into t_done
|
||||
*
|
||||
* @param bean
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public void insert(DoneBean bean) throws DataAccessException {
|
||||
public void insert(DoneBean bean) throws DataAccessException, ClassNotFoundException, SQLException {
|
||||
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();
|
||||
Integer fkLogin = getFkLogin();
|
||||
|
||||
InsertValuesStep6<TDoneRecord, Timestamp, Timestamp, Integer, Integer, Integer, Integer> sql = getJooq()
|
||||
// @formatter:off
|
||||
.insertInto(T_DONE,
|
||||
T_DONE.TIME_FROM,
|
||||
T_DONE.TIME_UNTIL,
|
||||
T_DONE.FK_PROJECT,
|
||||
T_DONE.FK_MODULE,
|
||||
T_DONE.FK_JOB,
|
||||
T_DONE.FK_LOGIN)
|
||||
.values(bean.getTimeFrom(), bean.getTimeUntil(), fkProject, fkModule, fkJob, fkLogin);
|
||||
// @formatter:on
|
||||
LOGGER.debug(sql.toString());
|
||||
sql.execute();
|
||||
try (DSLContext jooq = getJooq()) {
|
||||
InsertValuesStep6<TDoneRecord, Timestamp, Timestamp, Integer, Integer, Integer, Integer> sql = jooq
|
||||
// @formatter:off
|
||||
.insertInto(T_DONE,
|
||||
T_DONE.TIME_FROM,
|
||||
T_DONE.TIME_UNTIL,
|
||||
T_DONE.FK_PROJECT,
|
||||
T_DONE.FK_MODULE,
|
||||
T_DONE.FK_JOB,
|
||||
T_DONE.FK_LOGIN)
|
||||
.values(bean.getTimeFrom(), bean.getTimeUntil(), fkProject, fkModule, fkJob, fkLogin);
|
||||
// @formatter:on
|
||||
LOGGER.debug(sql.toString());
|
||||
sql.execute();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* update bean in t_done
|
||||
*
|
||||
* @param bean
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public void update(DoneBean bean) throws DataAccessException {
|
||||
UpdateConditionStep<TDoneRecord> sql = getJooq()
|
||||
// @formatter:off
|
||||
.update(T_DONE)
|
||||
.set(T_DONE.TIME_FROM, bean.getTimeFrom())
|
||||
.set(T_DONE.TIME_UNTIL, bean.getTimeUntil())
|
||||
.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())
|
||||
.where(T_DONE.PK.eq(bean.getPk()));
|
||||
// @formatter:on
|
||||
LOGGER.debug(sql.toString());
|
||||
sql.execute();
|
||||
public void update(DoneBean bean) throws DataAccessException, ClassNotFoundException, SQLException {
|
||||
try (DSLContext jooq = getJooq()) {
|
||||
UpdateConditionStep<TDoneRecord> sql = jooq
|
||||
// @formatter:off
|
||||
.update(T_DONE)
|
||||
.set(T_DONE.TIME_FROM, bean.getTimeFrom())
|
||||
.set(T_DONE.TIME_UNTIL, bean.getTimeUntil())
|
||||
.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())
|
||||
.where(T_DONE.PK.eq(bean.getPk()));
|
||||
// @formatter:on
|
||||
LOGGER.debug(sql.toString());
|
||||
sql.execute();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* delete bean from t_done
|
||||
*
|
||||
* @param bean
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public void delete(DoneBean bean) throws DataAccessException {
|
||||
DeleteConditionStep<TDoneRecord> sql = getJooq().deleteFrom(T_DONE).where(T_DONE.PK.eq(bean.getPk()));
|
||||
LOGGER.debug(sql.toString());
|
||||
sql.execute();
|
||||
public void delete(DoneBean bean) throws DataAccessException, ClassNotFoundException, SQLException {
|
||||
try (DSLContext jooq = getJooq()) {
|
||||
DeleteConditionStep<TDoneRecord> sql = jooq.deleteFrom(T_DONE).where(T_DONE.PK.eq(bean.getPk()));
|
||||
LOGGER.debug(sql.toString());
|
||||
sql.execute();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -227,28 +256,33 @@ public class DoneGateway extends JooqGateway {
|
||||
* @param day
|
||||
* the day
|
||||
* @return the day summary if found, an empty map otherwise
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
public WholeDaySummaryBean getDaySummary(Date day) {
|
||||
SelectConditionStep<Record4<String, String, String, String>> sql = getJooq()
|
||||
// @formatter:off
|
||||
.select(V_TOTALOFDAY.STARTTIME,
|
||||
V_TOTALOFDAY.ENDTIME,
|
||||
V_TOTALOFDAY.WORKTIME,
|
||||
V_TOTALOFDAY.BREAKTIME)
|
||||
.from(V_TOTALOFDAY)
|
||||
.where(V_TOTALOFDAY.DAY.eq(new SimpleDateFormat("yyyy-MM-dd").format(day)))
|
||||
.and(V_TOTALOFDAY.FK_LOGIN.eq(getFkLogin()));
|
||||
// @formatter:on
|
||||
LOGGER.debug(sql.toString());
|
||||
Record r = sql.fetchOne();
|
||||
if (r != null) {
|
||||
String startTime = r.get(V_TOTALOFDAY.STARTTIME);
|
||||
String endTime = r.get(V_TOTALOFDAY.ENDTIME);
|
||||
String workTime = r.get(V_TOTALOFDAY.WORKTIME);
|
||||
String breakTime = r.get(V_TOTALOFDAY.BREAKTIME);
|
||||
return new WholeDaySummaryBean(startTime, endTime, workTime, breakTime);
|
||||
public WholeDaySummaryBean getDaySummary(Date day) throws DataAccessException, ClassNotFoundException, SQLException {
|
||||
try (DSLContext jooq = getJooq()) {
|
||||
SelectConditionStep<Record4<String, String, String, String>> sql = jooq
|
||||
// @formatter:off
|
||||
.select(V_TOTALOFDAY.STARTTIME,
|
||||
V_TOTALOFDAY.ENDTIME,
|
||||
V_TOTALOFDAY.WORKTIME,
|
||||
V_TOTALOFDAY.BREAKTIME)
|
||||
.from(V_TOTALOFDAY)
|
||||
.where(V_TOTALOFDAY.DAY.eq(new SimpleDateFormat("yyyy-MM-dd").format(day)))
|
||||
.and(V_TOTALOFDAY.FK_LOGIN.eq(getFkLogin()));
|
||||
// @formatter:on
|
||||
LOGGER.debug(sql.toString());
|
||||
Record r = sql.fetchOne();
|
||||
if (r != null) {
|
||||
String startTime = r.get(V_TOTALOFDAY.STARTTIME);
|
||||
String endTime = r.get(V_TOTALOFDAY.ENDTIME);
|
||||
String workTime = r.get(V_TOTALOFDAY.WORKTIME);
|
||||
String breakTime = r.get(V_TOTALOFDAY.BREAKTIME);
|
||||
return new WholeDaySummaryBean(startTime, endTime, workTime, breakTime);
|
||||
}
|
||||
return new WholeDaySummaryBean("", "", "", "");
|
||||
}
|
||||
return new WholeDaySummaryBean("", "", "", "");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -257,76 +291,86 @@ public class DoneGateway extends JooqGateway {
|
||||
* @param day
|
||||
* the day
|
||||
* @return list of found jobs; an empty list at least
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
public List<DailySummaryBean> getAllJobs(Date day) {
|
||||
SelectConditionStep<Record4<String, String, String, String>> sql = getJooq()
|
||||
// @formatter:off
|
||||
.select(V_TASKLIST.DURATION,
|
||||
V_TASKLIST.PROJECT_NAME,
|
||||
V_TASKLIST.MODULE_NAME,
|
||||
V_TASKLIST.JOB_NAME)
|
||||
.from(V_TASKLIST)
|
||||
.where(V_TASKLIST.DAY.eq(new SimpleDateFormat("yyyy-MM-dd").format(day)))
|
||||
.and(V_TASKLIST.FK_LOGIN.eq(getFkLogin()));
|
||||
// @formatter:on
|
||||
LOGGER.debug(sql.toString());
|
||||
List<DailySummaryBean> list = new ArrayList<>();
|
||||
for (Record4<String, String, String, String> r : sql.fetch()) {
|
||||
String duration = r.get(V_TASKLIST.DURATION);
|
||||
String projectName = r.get(V_TASKLIST.PROJECT_NAME);
|
||||
String moduleName = r.get(V_TASKLIST.MODULE_NAME);
|
||||
String jobName = r.get(V_TASKLIST.JOB_NAME);
|
||||
list.add(new DailySummaryBean(projectName, moduleName, jobName, duration));
|
||||
public List<DailySummaryBean> getAllJobs(Date day) throws DataAccessException, ClassNotFoundException, SQLException {
|
||||
try (DSLContext jooq = getJooq()) {
|
||||
SelectConditionStep<Record4<String, String, String, String>> sql = jooq
|
||||
// @formatter:off
|
||||
.select(V_TASKLIST.DURATION,
|
||||
V_TASKLIST.PROJECT_NAME,
|
||||
V_TASKLIST.MODULE_NAME,
|
||||
V_TASKLIST.JOB_NAME)
|
||||
.from(V_TASKLIST)
|
||||
.where(V_TASKLIST.DAY.eq(new SimpleDateFormat("yyyy-MM-dd").format(day)))
|
||||
.and(V_TASKLIST.FK_LOGIN.eq(getFkLogin()));
|
||||
// @formatter:on
|
||||
LOGGER.debug(sql.toString());
|
||||
List<DailySummaryBean> list = new ArrayList<>();
|
||||
for (Record4<String, String, String, String> r : sql.fetch()) {
|
||||
String duration = r.get(V_TASKLIST.DURATION);
|
||||
String projectName = r.get(V_TASKLIST.PROJECT_NAME);
|
||||
String moduleName = r.get(V_TASKLIST.MODULE_NAME);
|
||||
String jobName = r.get(V_TASKLIST.JOB_NAME);
|
||||
list.add(new DailySummaryBean(projectName, moduleName, jobName, duration));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* get json representation of all calendar events of user
|
||||
*
|
||||
* @return
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
public String getAllCalendarEvents() {
|
||||
SelectConditionStep<Record5<Timestamp, Timestamp, String, String, String>> sql = getJooq()
|
||||
// @formatter:off
|
||||
.select(T_DONE.TIME_FROM,
|
||||
T_DONE.TIME_UNTIL,
|
||||
T_PROJECT.NAME,
|
||||
T_MODULE.NAME,
|
||||
T_JOB.NAME)
|
||||
.from(T_DONE)
|
||||
.leftJoin(T_PROJECT).on(T_PROJECT.PK.eq(T_DONE.FK_PROJECT))
|
||||
.leftJoin(T_MODULE).on(T_MODULE.PK.eq(T_DONE.FK_MODULE))
|
||||
.leftJoin(T_JOB).on(T_JOB.PK.eq(T_DONE.FK_JOB))
|
||||
.where(T_DONE.FK_LOGIN.eq(getFkLogin()));
|
||||
// @formatter:on
|
||||
LOGGER.debug(sql.toString());
|
||||
FullCalendarEventList list = new FullCalendarEventList();
|
||||
for (Record r : sql.fetch()) {
|
||||
String projectName = r.get(T_PROJECT.NAME);
|
||||
String moduleName = r.get(T_MODULE.NAME);
|
||||
String jobName = r.get(T_JOB.NAME);
|
||||
Date timeFrom = r.get(T_DONE.TIME_FROM);
|
||||
Date timeUntil = r.get(T_DONE.TIME_UNTIL);
|
||||
public String getAllCalendarEvents() throws DataAccessException, ClassNotFoundException, SQLException {
|
||||
try (DSLContext jooq = getJooq()) {
|
||||
SelectConditionStep<Record5<Timestamp, Timestamp, String, String, String>> sql = jooq
|
||||
// @formatter:off
|
||||
.select(T_DONE.TIME_FROM,
|
||||
T_DONE.TIME_UNTIL,
|
||||
T_PROJECT.NAME,
|
||||
T_MODULE.NAME,
|
||||
T_JOB.NAME)
|
||||
.from(T_DONE)
|
||||
.leftJoin(T_PROJECT).on(T_PROJECT.PK.eq(T_DONE.FK_PROJECT))
|
||||
.leftJoin(T_MODULE).on(T_MODULE.PK.eq(T_DONE.FK_MODULE))
|
||||
.leftJoin(T_JOB).on(T_JOB.PK.eq(T_DONE.FK_JOB))
|
||||
.where(T_DONE.FK_LOGIN.eq(getFkLogin()));
|
||||
// @formatter:on
|
||||
LOGGER.debug(sql.toString());
|
||||
FullCalendarEventList list = new FullCalendarEventList();
|
||||
for (Record r : sql.fetch()) {
|
||||
String projectName = r.get(T_PROJECT.NAME);
|
||||
String moduleName = r.get(T_MODULE.NAME);
|
||||
String jobName = r.get(T_JOB.NAME);
|
||||
Date timeFrom = r.get(T_DONE.TIME_FROM);
|
||||
Date timeUntil = r.get(T_DONE.TIME_UNTIL);
|
||||
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(projectName);
|
||||
buf.append(", ");
|
||||
buf.append(moduleName);
|
||||
buf.append(": ");
|
||||
buf.append(jobName);
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(projectName);
|
||||
buf.append(", ");
|
||||
buf.append(moduleName);
|
||||
buf.append(": ");
|
||||
buf.append(jobName);
|
||||
|
||||
FullCalendarEventBean bean = new FullCalendarEventBean(buf.toString(), timeFrom) {
|
||||
private static final long serialVersionUID = 1L;
|
||||
FullCalendarEventBean bean = new FullCalendarEventBean(buf.toString(), timeFrom) {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void addExtendedFields(StringBuilder buf) {
|
||||
}
|
||||
};
|
||||
bean.setEnd(timeUntil);
|
||||
bean.setColor(new RgbColor().determineRgbColor(projectName, moduleName, jobName));
|
||||
list.getList().add(bean);
|
||||
@Override
|
||||
public void addExtendedFields(StringBuilder buf) {
|
||||
}
|
||||
};
|
||||
bean.setEnd(timeUntil);
|
||||
bean.setColor(new RgbColor().determineRgbColor(projectName, moduleName, jobName));
|
||||
list.getList().add(bean);
|
||||
}
|
||||
return list.toJson();
|
||||
}
|
||||
return list.toJson();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package de.jottyfan.timetrack.modules.done;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
@ -13,11 +14,11 @@ import java.util.TimeZone;
|
||||
|
||||
import javax.enterprise.context.SessionScoped;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jooq.exception.DataAccessException;
|
||||
|
||||
import de.jooqFaces.JooqFacesContext;
|
||||
import de.jottyfan.timetrack.db.done.tables.records.TJobRecord;
|
||||
import de.jottyfan.timetrack.db.done.tables.records.TModuleRecord;
|
||||
import de.jottyfan.timetrack.db.done.tables.records.TProjectRecord;
|
||||
@ -44,7 +45,7 @@ public class DoneModel implements Model, Serializable {
|
||||
private Date day;
|
||||
private String calendarEvents;
|
||||
|
||||
public boolean init(FacesContext facesContext) {
|
||||
public boolean init(JooqFacesContext facesContext) {
|
||||
try {
|
||||
day = day == null ? new Date() : day;
|
||||
beans = getAllOfDay(facesContext, day);
|
||||
@ -56,13 +57,13 @@ public class DoneModel implements Model, Serializable {
|
||||
allJobs = gw.getAllJobs(day);
|
||||
calendarEvents = gw.getAllCalendarEvents();
|
||||
return true;
|
||||
} catch (DataAccessException e) {
|
||||
} catch (DataAccessException | ClassNotFoundException | SQLException e) {
|
||||
facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "error", e.getMessage()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean loadDefaults(FacesContext facesContext) {
|
||||
public boolean loadDefaults(JooqFacesContext facesContext) {
|
||||
try {
|
||||
defineTimes();
|
||||
return true;
|
||||
@ -126,37 +127,39 @@ public class DoneModel implements Model, Serializable {
|
||||
* @param login
|
||||
* the user to look up for
|
||||
* @return all entries
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
private List<DoneBean> getAllOfDay(FacesContext facesContext, Date day) throws DataAccessException {
|
||||
private List<DoneBean> getAllOfDay(JooqFacesContext facesContext, Date day) throws DataAccessException, ClassNotFoundException, SQLException {
|
||||
LocalDateTime ldt = day.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||
return new DoneGateway(facesContext).getAll(ldt);
|
||||
}
|
||||
|
||||
public boolean insert(FacesContext facesContext) {
|
||||
public boolean insert(JooqFacesContext facesContext) {
|
||||
try {
|
||||
new DoneGateway(facesContext).insert(bean);
|
||||
return true;
|
||||
} catch (DataAccessException e) {
|
||||
} catch (DataAccessException | ClassNotFoundException | SQLException e) {
|
||||
facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "error", e.getMessage()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean update(FacesContext facesContext) {
|
||||
public boolean update(JooqFacesContext facesContext) {
|
||||
try {
|
||||
new DoneGateway(facesContext).update(bean);
|
||||
return true;
|
||||
} catch (DataAccessException e) {
|
||||
} catch (DataAccessException | ClassNotFoundException | SQLException e) {
|
||||
facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "error", e.getMessage()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean delete(FacesContext facesContext) {
|
||||
public boolean delete(JooqFacesContext facesContext) {
|
||||
try {
|
||||
new DoneGateway(facesContext).delete(bean);
|
||||
return true;
|
||||
} catch (DataAccessException e) {
|
||||
} catch (DataAccessException | ClassNotFoundException | SQLException e) {
|
||||
facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "error", e.getMessage()));
|
||||
return false;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import javax.faces.context.FacesContext;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import de.jooqFaces.JooqFacesContext;
|
||||
import de.jottyfan.timetrack.help.Navigation;
|
||||
import de.jottyfan.timetrack.help.Pages;
|
||||
import de.jottyfan.timetrack.modules.ControlInterface;
|
||||
@ -33,7 +34,7 @@ public class NoteControl extends Navigation implements ControlInterface, Seriali
|
||||
|
||||
public String toList()
|
||||
{
|
||||
boolean ready = model.init(FacesContext.getCurrentInstance());
|
||||
boolean ready = model.init((JooqFacesContext) FacesContext.getCurrentInstance());
|
||||
return ready ? navigateTo(Pages.NOTE_LIST) : "";
|
||||
}
|
||||
|
||||
@ -50,19 +51,19 @@ public class NoteControl extends Navigation implements ControlInterface, Seriali
|
||||
|
||||
public String doAdd()
|
||||
{
|
||||
boolean ready = model.add(FacesContext.getCurrentInstance());
|
||||
boolean ready = model.add((JooqFacesContext) FacesContext.getCurrentInstance());
|
||||
return ready ? toList() : toItem(model.getBean());
|
||||
}
|
||||
|
||||
public String doUpdate()
|
||||
{
|
||||
boolean ready = model.update(FacesContext.getCurrentInstance());
|
||||
boolean ready = model.update((JooqFacesContext) FacesContext.getCurrentInstance());
|
||||
return ready ? toList() : toItem(model.getBean());
|
||||
}
|
||||
|
||||
public String doDelete()
|
||||
{
|
||||
boolean ready = model.delete(FacesContext.getCurrentInstance());
|
||||
boolean ready = model.delete((JooqFacesContext) FacesContext.getCurrentInstance());
|
||||
return ready ? toList() : toItem(model.getBean());
|
||||
}
|
||||
|
||||
@ -98,6 +99,6 @@ public class NoteControl extends Navigation implements ControlInterface, Seriali
|
||||
}
|
||||
|
||||
public Long getAmount() {
|
||||
return model.getAmount(FacesContext.getCurrentInstance());
|
||||
return model.getAmount((JooqFacesContext) FacesContext.getCurrentInstance());
|
||||
}
|
||||
}
|
||||
|
@ -2,13 +2,13 @@ package de.jottyfan.timetrack.modules.note;
|
||||
|
||||
import static de.jottyfan.timetrack.db.note.Tables.T_NOTE;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.DeleteConditionStep;
|
||||
import org.jooq.InsertValuesStep4;
|
||||
import org.jooq.Record;
|
||||
@ -16,6 +16,7 @@ import org.jooq.SelectJoinStep;
|
||||
import org.jooq.UpdateConditionStep;
|
||||
import org.jooq.exception.DataAccessException;
|
||||
|
||||
import de.jooqFaces.JooqFacesContext;
|
||||
import de.jottyfan.timetrack.db.note.enums.EnumCategory;
|
||||
import de.jottyfan.timetrack.db.note.enums.EnumNotetype;
|
||||
import de.jottyfan.timetrack.db.note.tables.records.TNoteRecord;
|
||||
@ -26,12 +27,10 @@ import de.jottyfan.timetrack.modules.JooqGateway;
|
||||
* @author henkej
|
||||
*
|
||||
*/
|
||||
public class NoteGateway extends JooqGateway
|
||||
{
|
||||
public class NoteGateway extends JooqGateway {
|
||||
private static final Logger LOGGER = LogManager.getLogger(NoteGateway.class);
|
||||
|
||||
public NoteGateway(FacesContext facesContext)
|
||||
{
|
||||
public NoteGateway(JooqFacesContext facesContext) {
|
||||
super(facesContext);
|
||||
}
|
||||
|
||||
@ -40,14 +39,24 @@ public class NoteGateway extends JooqGateway
|
||||
*
|
||||
* @param noteBean
|
||||
* @throws DataAccessException
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
* @returns amount of affected rows in db
|
||||
*/
|
||||
public void insert(NoteBean bean) throws DataAccessException
|
||||
{
|
||||
InsertValuesStep4<TNoteRecord, String, EnumCategory, EnumNotetype, String> sql = getJooq().insertInto(T_NOTE, T_NOTE.TITLE, T_NOTE.CATEGORY, T_NOTE.NOTETYPE, T_NOTE.CONTENT).values(bean.getTitle(), bean.getCategory(), bean.getType(),
|
||||
bean.getContent());
|
||||
LOGGER.debug(sql.toString());
|
||||
sql.execute();
|
||||
public void insert(NoteBean bean) throws DataAccessException, ClassNotFoundException, SQLException {
|
||||
try (DSLContext jooq = getJooq()) {
|
||||
InsertValuesStep4<TNoteRecord, String, EnumCategory, EnumNotetype, String> sql = jooq
|
||||
// @formatter:off
|
||||
.insertInto(T_NOTE,
|
||||
T_NOTE.TITLE,
|
||||
T_NOTE.CATEGORY,
|
||||
T_NOTE.NOTETYPE,
|
||||
T_NOTE.CONTENT)
|
||||
.values(bean.getTitle(), bean.getCategory(), bean.getType(), bean.getContent());
|
||||
// @formatter:on
|
||||
LOGGER.debug(sql.toString());
|
||||
sql.execute();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,12 +64,21 @@ public class NoteGateway extends JooqGateway
|
||||
*
|
||||
* @param bean
|
||||
* @throws DataAccessException
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public void update(NoteBean bean) throws DataAccessException
|
||||
{
|
||||
UpdateConditionStep<TNoteRecord> sql = getJooq().update(T_NOTE).set(T_NOTE.TITLE, bean.getTitle()).set(T_NOTE.CONTENT, bean.getContent()).where(T_NOTE.PK.eq(bean.getPk()));
|
||||
LOGGER.debug(sql.toString());
|
||||
sql.execute();
|
||||
public void update(NoteBean bean) throws DataAccessException, ClassNotFoundException, SQLException {
|
||||
try (DSLContext jooq = getJooq()) {
|
||||
UpdateConditionStep<TNoteRecord> sql = jooq
|
||||
// @formatter:off
|
||||
.update(T_NOTE)
|
||||
.set(T_NOTE.TITLE, bean.getTitle())
|
||||
.set(T_NOTE.CONTENT, bean.getContent())
|
||||
.where(T_NOTE.PK.eq(bean.getPk()));
|
||||
// @formatter:on
|
||||
LOGGER.debug(sql.toString());
|
||||
sql.execute();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,12 +86,15 @@ public class NoteGateway extends JooqGateway
|
||||
*
|
||||
* @param pk
|
||||
* @throws DataAccessException
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public void delete(Integer pk) throws DataAccessException
|
||||
{
|
||||
DeleteConditionStep<TNoteRecord> sql = getJooq().deleteFrom(T_NOTE).where(T_NOTE.PK.eq(pk));
|
||||
LOGGER.debug(sql.toString());
|
||||
sql.execute();
|
||||
public void delete(Integer pk) throws DataAccessException, ClassNotFoundException, SQLException {
|
||||
try (DSLContext jooq = getJooq()) {
|
||||
DeleteConditionStep<TNoteRecord> sql = jooq.deleteFrom(T_NOTE).where(T_NOTE.PK.eq(pk));
|
||||
LOGGER.debug(sql.toString());
|
||||
sql.execute();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,22 +102,24 @@ public class NoteGateway extends JooqGateway
|
||||
*
|
||||
* @return
|
||||
* @throws DataAccessException
|
||||
* @throws SQLException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public List<NoteBean> getAll() throws DataAccessException
|
||||
{
|
||||
SelectJoinStep<Record> sql = getJooq().select().from(T_NOTE);
|
||||
LOGGER.debug(sql.toString());
|
||||
List<NoteBean> list = new ArrayList<>();
|
||||
for (Record r : sql.fetch())
|
||||
{
|
||||
NoteBean bean = new NoteBean(r.get(T_NOTE.PK));
|
||||
bean.setTitle(r.get(T_NOTE.TITLE));
|
||||
bean.setCategory(r.get(T_NOTE.CATEGORY));
|
||||
bean.setContent(r.get(T_NOTE.CONTENT));
|
||||
bean.setType(r.get(T_NOTE.NOTETYPE));
|
||||
bean.setLastchange(r.get(T_NOTE.LASTCHANGE));
|
||||
list.add(bean);
|
||||
public List<NoteBean> getAll() throws DataAccessException, ClassNotFoundException, SQLException {
|
||||
try (DSLContext jooq = getJooq()) {
|
||||
SelectJoinStep<Record> sql = jooq.select().from(T_NOTE);
|
||||
LOGGER.debug(sql.toString());
|
||||
List<NoteBean> list = new ArrayList<>();
|
||||
for (Record r : sql.fetch()) {
|
||||
NoteBean bean = new NoteBean(r.get(T_NOTE.PK));
|
||||
bean.setTitle(r.get(T_NOTE.TITLE));
|
||||
bean.setCategory(r.get(T_NOTE.CATEGORY));
|
||||
bean.setContent(r.get(T_NOTE.CONTENT));
|
||||
bean.setType(r.get(T_NOTE.NOTETYPE));
|
||||
bean.setLastchange(r.get(T_NOTE.LASTCHANGE));
|
||||
list.add(bean);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,16 @@
|
||||
package de.jottyfan.timetrack.modules.note;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.enterprise.context.SessionScoped;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jooq.exception.DataAccessException;
|
||||
|
||||
import de.jooqFaces.JooqFacesContext;
|
||||
import de.jottyfan.timetrack.db.note.Tables;
|
||||
import de.jottyfan.timetrack.modules.Model;
|
||||
|
||||
@ -27,65 +28,70 @@ public class NoteModel implements Model, Serializable
|
||||
private List<NoteBean> beans;
|
||||
private NoteBean bean;
|
||||
|
||||
public boolean init(FacesContext facesContext)
|
||||
public boolean init(JooqFacesContext facesContext)
|
||||
{
|
||||
try
|
||||
{
|
||||
beans = new NoteGateway(facesContext).getAll();
|
||||
return true;
|
||||
}
|
||||
catch (DataAccessException e)
|
||||
catch (DataAccessException | ClassNotFoundException | SQLException e)
|
||||
{
|
||||
facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "error", e.getMessage()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean add(FacesContext facesContext)
|
||||
public boolean add(JooqFacesContext facesContext)
|
||||
{
|
||||
try
|
||||
{
|
||||
new NoteGateway(facesContext).insert(bean);
|
||||
return true;
|
||||
}
|
||||
catch (DataAccessException e)
|
||||
catch (DataAccessException | ClassNotFoundException | SQLException e)
|
||||
{
|
||||
facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "error", e.getMessage()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean update(FacesContext facesContext)
|
||||
public boolean update(JooqFacesContext facesContext)
|
||||
{
|
||||
try
|
||||
{
|
||||
new NoteGateway(facesContext).update(bean);
|
||||
return true;
|
||||
}
|
||||
catch (DataAccessException e)
|
||||
catch (DataAccessException | ClassNotFoundException | SQLException e)
|
||||
{
|
||||
facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "error", e.getMessage()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean delete(FacesContext facesContext)
|
||||
public boolean delete(JooqFacesContext facesContext)
|
||||
{
|
||||
try
|
||||
{
|
||||
new NoteGateway(facesContext).delete(bean.getPk());
|
||||
return true;
|
||||
}
|
||||
catch (DataAccessException e)
|
||||
catch (DataAccessException | ClassNotFoundException | SQLException e)
|
||||
{
|
||||
facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "error", e.getMessage()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Long getAmount(FacesContext facesContext)
|
||||
public Long getAmount(JooqFacesContext facesContext)
|
||||
{
|
||||
return new NoteGateway(facesContext).getAmount(Tables.T_NOTE);
|
||||
try {
|
||||
return new NoteGateway(facesContext).getAmount(Tables.T_NOTE);
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "error", e.getMessage()));
|
||||
return -1l;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,10 +4,6 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
|
||||
version="2.0">
|
||||
<lifecycle>
|
||||
<phase-listener>de.jooqFaces.JooqFacesRenderResponsePhaseListener</phase-listener>
|
||||
<phase-listener>de.jooqFaces.JooqFacesRestoreViewPhaseListener</phase-listener>
|
||||
</lifecycle>
|
||||
<factory>
|
||||
<faces-context-factory>de.jooqFaces.JooqFacesContextFactory</faces-context-factory>
|
||||
</factory>
|
||||
|
@ -61,7 +61,7 @@
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>jooqFacesProperties</param-name>
|
||||
<param-value>/etc/tomcat8#/timetrack.properties</param-value>
|
||||
<param-value>/etc/timetrack.properties</param-value>
|
||||
</context-param>
|
||||
<listener>
|
||||
<listener-class>de.jooqFaces.PropertiesDeploymentListener</listener-class>
|
||||
|
@ -19,18 +19,17 @@
|
||||
</h:panelGrid>
|
||||
<b:tabView>
|
||||
<b:tab title="Liste">
|
||||
<b:dataTable value="#{doneModel.beans}" var="b" border="false" info="false" paginated="false" searching="false"
|
||||
styleClass="doneoverview">
|
||||
<b:dataTableColumn label="" orderable="false">
|
||||
<b:dataTable value="#{doneModel.beans}" var="b" border="false" info="false" paginated="false" searching="false">
|
||||
<b:dataTableColumn label="" style="width: 100px !important" orderable="false">
|
||||
<b:commandButton action="#{doneControl.toDelete(b)}" value="Entfernen" look="danger" iconAwesome="trash" />
|
||||
</b:dataTableColumn>
|
||||
<b:dataTableColumn label="" value="#{b.timeSummary}" contentStyleClass="doneoverviewtext" style="min-width: 100px !important" orderable="false" />
|
||||
<b:dataTableColumn label="" value="#{b.projectName}" contentStyleClass="doneoverviewtextemph" orderable="false" />
|
||||
<b:dataTableColumn label="" value="#{b.timeDiff}" contentStyleClass="doneoverviewtextemph" orderable="false" />
|
||||
<b:dataTableColumn label="" orderable="false">
|
||||
<b:dataTableColumn label="" value="#{b.timeSummary}" contentStyleClass="doneoverviewtext" style="width: 128px !important" orderable="false" />
|
||||
<b:dataTableColumn label="" value="#{b.projectName}" contentStyleClass="doneoverviewtextemph" style="width: 128px !important" orderable="false" />
|
||||
<b:dataTableColumn label="" value="#{b.timeDiff}" contentStyleClass="doneoverviewtextemph" style="width: 64px !important" orderable="false" />
|
||||
<b:dataTableColumn label="" style="width: 100px !important" orderable="false">
|
||||
<b:commandButton action="#{doneControl.toEdit(b)}" value="Editieren" look="warning" iconAwesome="pencil" />
|
||||
</b:dataTableColumn>
|
||||
<b:dataTableColumn label="" value="#{b.moduleName}" contentStyleClass="doneoverviewtext" orderable="false" />
|
||||
<b:dataTableColumn label="" value="#{b.moduleName}" contentStyleClass="doneoverviewtext" style="width: 128px !important" orderable="false" />
|
||||
<b:dataTableColumn label="" value="#{b.jobName}" contentStyleClass="doneoverviewtext" orderable="false" />
|
||||
</b:dataTable>
|
||||
<b:row rendered="#{doneModel.daySummary != null}">
|
||||
|
@ -6,11 +6,6 @@
|
||||
!important;
|
||||
}
|
||||
|
||||
.doneoverview {
|
||||
max-width: 850px !important;
|
||||
width: 850px !important;
|
||||
}
|
||||
|
||||
.doneoverviewtext {
|
||||
font-size: 120%;
|
||||
}
|
||||
|
Reference in New Issue
Block a user