Implementovano prepinani ciselnych rad podle obdobi.

closes #262
master
Josef Rokos 9 years ago
parent d2aa1cbd9a
commit 012ad06358

@ -6,6 +6,7 @@ import info.bukova.isspst.data.NumberSeries;
import info.bukova.isspst.data.Permission;
import info.bukova.isspst.data.RequirementType;
import info.bukova.isspst.data.Role;
import info.bukova.isspst.data.Season;
import info.bukova.isspst.data.SettingsData;
import info.bukova.isspst.data.User;
import info.bukova.isspst.reporting.Report;
@ -17,6 +18,7 @@ import info.bukova.isspst.services.munits.MUnitService;
import info.bukova.isspst.services.numberseries.NumberSeriesService;
import info.bukova.isspst.services.requirement.RequirementTypeService;
import info.bukova.isspst.services.settings.GlobalSettingsService;
import info.bukova.isspst.services.settings.SeasonService;
import info.bukova.isspst.services.users.PermissionService;
import info.bukova.isspst.services.users.RoleService;
import info.bukova.isspst.services.users.UserService;
@ -29,6 +31,7 @@ import org.springframework.web.context.support.WebApplicationContextUtils;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.List;
public class AppInitListener implements ServletContextListener {
@ -43,6 +46,7 @@ public class AppInitListener implements ServletContextListener {
private RequirementTypeService reqTypeService;
private GlobalSettingsService gSettingsService;
private FullTextService ftService;
private SeasonService seasonService;
@Override
public void contextDestroyed(ServletContextEvent arg0) {
@ -64,6 +68,7 @@ public class AppInitListener implements ServletContextListener {
gSettingsService = ctx.getBean(GlobalSettingsService.class);
reqTypeService = ctx.getBean(RequirementTypeService.class);
ftService = ctx.getBean(FullTextService.class);
seasonService = ctx.getBean(SeasonService.class);
userService.grantAdmin();
this.checkDbInfo();
@ -286,28 +291,35 @@ public class AppInitListener implements ServletContextListener {
}
}
private void checkNumberSeries()
{
NumberSeries ns = nsService.getNumberSerie(Constants.MOD_REQUIREMENTS);
if (ns == null)
{
private void checkNumberSeriesForSeason(Season season) {
for (String modId : Constants.NUM_SERIES_PREFIX.keySet()) {
NumberSeries ns = nsService.getNumberSerieForSeason(modId, season);
if (ns == null) {
ns = new NumberSeries();
ns.setModule(Constants.MOD_REQUIREMENTS);
ns.setPrefix("");
ns.setModule(modId);
ns.setPrefix(Constants.NUM_SERIES_PREFIX.get(modId));
ns.setNumber(1);
ns.setSeason(season);
nsService.add(ns);
}
}
}
ns = nsService.getNumberSerie(Constants.MOD_ORDER);
if (ns == null)
private void checkNumberSeries()
{
ns = new NumberSeries();
ns.setModule(Constants.MOD_ORDER);
ns.setPrefix("");
ns.setNumber(1);
nsService.add(ns);
Season season = seasonService.getActive();
if (season == null) {
season = new Season();
Calendar cal = Calendar.getInstance();
season.setDescription(String.valueOf(cal.get(Calendar.YEAR)));
season.setValidFrom(cal.getTime());
season.setActive(true);
seasonService.add(season);
}
for (Season s : seasonService.getAllSeasons()) {
checkNumberSeriesForSeason(s);
}
}

@ -35,7 +35,7 @@ import java.util.Map;
public class Constants {
public final static long DB_VERSION = 5;
public final static long DB_VERSION = 6;
public final static String DEF_ADMIN = "admin";
public final static String DEF_ADMIN_PASSWD = "admin";
@ -151,11 +151,18 @@ public class Constants {
new ReportMapping(MOD_REQUIREMENTS, new Report(8, true, "Protokol o kontrole", "orderRequirement", false, true))
};
// pokud je v agnde vic nez jedena podepisovaci sestava, musi se definovat ktera sestava nalezi jake entite
public final static Map<Class<?>, Integer> SIGN_REPORT_MAP = Collections.unmodifiableMap(new HashMap<Class<?>, Integer>() {{
put(TripBillApproval.class, 4);
put(TripRequirement.class, 7);
}});
// vychozi prefixy ciselnych rad. Pokud se prida agenda s vlastni ciselnou radou, je potreba zadefinovat vychozi prefix
public final static Map<String, String> NUM_SERIES_PREFIX = Collections.unmodifiableMap(new HashMap<String, String>() {{
put(MOD_REQUIREMENTS, "P");
put(MOD_ORDER, "O");
}});
public final static String REQTYPE_ORDER = "ORDER";
public final static String REQTYPE_BUSINESSTRIP = "BUSINESSTRIP";
public final static RequirementType REQTYPES[] = {

@ -0,0 +1,10 @@
package info.bukova.isspst.dao;
import info.bukova.isspst.data.Season;
/**
* @author Pepa Rokos
*/
public interface SeasonDao extends BaseDao<Season> {
}

@ -0,0 +1,11 @@
package info.bukova.isspst.dao.jpa;
import info.bukova.isspst.dao.SeasonDao;
import info.bukova.isspst.data.Season;
/**
* @author Pepa Rokos
*/
public class SeasonDaoJPA extends BaseDaoJPA<Season> implements SeasonDao {
}

@ -2,6 +2,8 @@ package info.bukova.isspst.data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@Entity
@ -17,6 +19,10 @@ public class NumberSeries extends BaseSimpleData
@Column(name = "NUMBER")
private int number;
@OneToOne
@JoinColumn(name = "SEASON_ID")
private Season season;
public String getCurrentNumber()
{
return String.format("%s%06d", this.getPrefix(), this.getNumber());
@ -51,4 +57,12 @@ public class NumberSeries extends BaseSimpleData
{
this.number = number;
}
public Season getSeason() {
return season;
}
public void setSeason(Season season) {
this.season = season;
}
}

@ -1,11 +1,13 @@
package info.bukova.isspst.data;
import info.bukova.isspst.Constants;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
@ -13,21 +15,20 @@ import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Entity
@Table(name = "ORDERS")
@Indexed
public class Order extends BaseData implements Cloneable
public class Order extends BaseData implements Cloneable, SeasonsAware
{
@Column(name = "NUMSER")
@ -121,6 +122,10 @@ public class Order extends BaseData implements Cloneable
@Column(name = "DELIVERED")
private boolean delivered;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "SEASON_ID")
private Season season;
public Order()
{
this.items = new ArrayList<OrderItem>();
@ -288,4 +293,12 @@ public class Order extends BaseData implements Cloneable
cloned.setTotal(new BigDecimal(this.getTotal().toString()));
return cloned;
}
public Season getSeason() {
return season;
}
public void setSeason(Season season) {
this.season = season;
}
}

@ -1,10 +1,12 @@
package info.bukova.isspst.data;
import info.bukova.isspst.Constants;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import javax.persistence.CascadeType;
import javax.persistence.Column;
@ -16,17 +18,13 @@ import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@MappedSuperclass
@Indexed
public class RequirementBase extends BaseData implements FilterableRequirement {
public class RequirementBase extends BaseData implements FilterableRequirement, SeasonsAware {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "TYPE_ID")
@ -56,6 +54,9 @@ public class RequirementBase extends BaseData implements FilterableRequirement {
@Column(name = "STATE")
@Enumerated(EnumType.ORDINAL)
private RequirementState state;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "SEASON_ID")
private Season season;
public RequirementBase() {
authorization = new ArrayList<AuthItem>();
@ -152,4 +153,11 @@ public class RequirementBase extends BaseData implements FilterableRequirement {
return authorization.get(authorization.size() - 1).getAuthDate();
}
public Season getSeason() {
return season;
}
public void setSeason(Season season) {
this.season = season;
}
}

@ -0,0 +1,79 @@
package info.bukova.isspst.data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
* @author Pepa Rokos
*/
@Entity
@Table(name = "SEASON")
public class Season extends BaseData {
@Column(name = "DESCRIPTION")
private String description;
@Column(name = "VALID_FROM")
private Date validFrom;
@Column(name = "VALID_TO")
private Date validTo;
@Column(name = "ACTIVE")
private boolean active;
public String getDescription() {
return description;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Season)) return false;
Season season = (Season) o;
if (getId() != season.getId()) return false;
if (active != season.active) return false;
if (description != null ? !description.equals(season.description) : season.description != null) return false;
if (validFrom != null ? !validFrom.equals(season.validFrom) : season.validFrom != null) return false;
if (validTo != null ? !validTo.equals(season.validTo) : season.validTo != null) return false;
return true;
}
@Override
public int hashCode() {
int result = description != null ? description.hashCode() : 0;
result = 31 * result + (validFrom != null ? validFrom.hashCode() : 0);
result = 31 * result + (validTo != null ? validTo.hashCode() : 0);
result = 31 * result + (active ? 1 : 0);
return result;
}
public void setDescription(String description) {
this.description = description;
}
public Date getValidFrom() {
return validFrom;
}
public void setValidFrom(Date validFrom) {
this.validFrom = validFrom;
}
public Date getValidTo() {
return validTo;
}
public void setValidTo(Date validTo) {
this.validTo = validTo;
}
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
}

@ -0,0 +1,8 @@
package info.bukova.isspst.data;
/**
* @author Pepa Rokos
*/
public interface SeasonsAware {
public Season getSeason();
}

@ -15,6 +15,7 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@ -26,7 +27,7 @@ import java.util.List;
@Entity
@Table(name = "TRIP_BILL")
@Indexed
public class TripBill extends BaseData implements EntityWithAttachment {
public class TripBill extends BaseData implements EntityWithAttachment, SeasonsAware {
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "REQUIREMENT_ID")
@ -69,6 +70,9 @@ public class TripBill extends BaseData implements EntityWithAttachment {
private Boolean paid;
@Column(name = "PAID_DATE")
private Date paidDate;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "SEASON_ID")
private Season season;
public TripBill() {
billItems = new ArrayList<TripBillItem>();
@ -206,4 +210,13 @@ public class TripBill extends BaseData implements EntityWithAttachment {
public void setPaidDate(Date paidDate) {
this.paidDate = paidDate;
}
@Override
public Season getSeason() {
return season;
}
public void setSeason(Season season) {
this.season = season;
}
}

@ -38,6 +38,8 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
@Autowired
protected SessionData sessionData;
@Autowired
protected HqlDataFilter hqlFilter;
@Autowired
protected QueryDao queryDao;
private DocumentFileStorage documentFileStorage;
@ -88,6 +90,50 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
}
}
protected Query filterQuery(Query q) {
return filterQuery(q, null);
}
protected Query filterQuery(Query q, HqlDataFilter aditFilter) {
HqlDataFilter f = hqlFilter;
try {
if (((f.getWhere() == null || f.getWhere().isEmpty())
&& (f.getOrderBy() == null || f.getOrderBy().isEmpty()))
&& ((aditFilter.getWhere() == null || aditFilter.getWhere().isEmpty())
&& (aditFilter.getOrderBy() == null || aditFilter.getOrderBy().isEmpty()))) {
return q;
}
} catch (Exception e) {
f = new HqlDataFilter(); // pri volani mimo web request filtr z requestu neresime
}
boolean isAplicable = false;
if (f.getDataClass() != null) {
for (Class<?> clazz : getEntityClasses()) {
if (f.getDataClass().isAssignableFrom(clazz)) {
isAplicable = true;
}
}
}
String hql;
if (isAplicable) {
hql = HqlUtils.buildHql(q.getQueryString(), f);
} else {
hql = q.getQueryString();
}
hql = HqlUtils.addOrderBy(HqlUtils.addAndWhere(hql, aditFilter), aditFilter);
Query newQuery = dao.getQuery(hql);
if (isAplicable) {
HqlUtils.addParameters(newQuery, f);
}
HqlUtils.addParameters(newQuery, aditFilter);
return newQuery;
}
@Override
@PreAuthorize("hasPermission(this, 'PERM_ADD')")
public final T create() {
@ -200,7 +246,9 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
throw new ModuleNotActiveException();
}
return dao.getAll();
Query q = dao.getQuery("from " + dao.getEntityName());
return filterQuery(q).list();
}
@Override

@ -0,0 +1,87 @@
package info.bukova.isspst.services;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* @author Pepa Rokos
*/
public class HqlDataFilter {
private String where;
private String orderBy;
private Map<String, Object> params;
private Class<?> dataClass;
public HqlDataFilter() {
params = new HashMap<String, Object>();
}
public HqlDataFilter(String where) {
this();
this.where = where;
}
public HqlDataFilter(String where, String orderBy) {
this(where);
this.orderBy = orderBy;
}
public String getWhere() {
return where;
}
public void setWhere(String where) {
this.where = where;
}
public String getOrderBy() {
return orderBy;
}
public void setOrderBy(String orderBy) {
this.orderBy = orderBy;
}
public void setParam(String key, Object value) {
params.put(key, value);
}
public Object getParam(String key) {
return params.get(key);
}
public Set<String> getParamKeys() {
return params.keySet();
}
public void andFilter(String filter) {
if (where == null || where.isEmpty()) {
where = filter;
} else {
where += " and (" + filter + ")";
}
}
public void orFilter(String filter) {
if (where == null ||where.isEmpty()) {
where = filter;
} else {
where += " or (" + filter + ")";
}
}
public void reset() {
where = "";
orderBy = "";
params.clear();
}
public Class<?> getDataClass() {
return dataClass;
}
public void setDataClass(Class<?> dataClass) {
this.dataClass = dataClass;
}
}

@ -0,0 +1,90 @@
package info.bukova.isspst.services;
import org.hibernate.Query;
import java.util.Collection;
/**
* @author Pepa Rokos
*/
public class HqlUtils {
public static String buildHql(String select, HqlDataFilter filter) {
if (select.toLowerCase().contains("where")
|| select.toLowerCase().contains("order by")) {
throw new IsspstException("Use add*() methods instead.");
}
String hql = addWhere(select, filter, "");
return addOrderBy(hql, filter);
}
public static String addAndWhere(String hql, HqlDataFilter filter) {
if (!checkWhere(filter)) {
return hql;
}
return addWhere(hql, filter, "and");
}
public static String addOrWhere(String hql, HqlDataFilter filter) {
if (!checkWhere(filter)) {
return hql;
}
return addWhere(hql, filter, "or");
}
public static String addOrderBy(String hql, HqlDataFilter filter) {
if (filter == null || filter.getOrderBy() == null || filter.getOrderBy().isEmpty()) {
return hql;
}
if (!hql.contains("order by")) {
hql += " order by ";
}
hql += filter.getOrderBy();
return hql;
}
public static void addParameters(Query query, HqlDataFilter filter) {
if (filter == null) {
return;
}
for (String key : filter.getParamKeys()) {
if (filter.getParam(key) instanceof Collection<?>) {
query.setParameterList(key, (Collection) filter.getParam(key));
} else {
query.setParameter(key, filter.getParam(key));
}
}
}
private static boolean checkWhere(HqlDataFilter filter) {
return filter != null && filter.getWhere() != null && !filter.getWhere().isEmpty();
}
private static String addWhere(String hql, HqlDataFilter filter, String operator) {
if (hql.toLowerCase().contains("where") && hql.toLowerCase().contains("order by")) {
String[] split = hql.split("order by");
hql = split[0] + " " + operator + " (" + filter.getWhere() + ") order by " + split[1];
return hql;
}
if (hql.toLowerCase().contains("where")) {
hql += " " + operator + " (" + filter.getWhere() + ")";
return hql;
}
if (hql.toLowerCase().contains("order by")) {
String[] split = hql.split("order by");
hql = split[0] + " where (" + filter.getWhere() + ") order by " + split[1];
return hql;
}
hql += " where (" + filter.getWhere() + ")";
return hql;
}
}

@ -3,13 +3,12 @@ package info.bukova.isspst.services.dbinfo;
import info.bukova.isspst.Constants;
import info.bukova.isspst.data.DbInfo;
import info.bukova.isspst.services.AbstractService;
import org.hibernate.SQLQuery;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.SQLQuery;
import org.springframework.transaction.annotation.Transactional;
public class DbInfoServiceImpl extends AbstractService<DbInfo> implements DbInfoService
{
private DbInfo getDbInfo()
@ -142,6 +141,76 @@ public class DbInfoServiceImpl extends AbstractService<DbInfo> implements DbInfo
sq.executeUpdate();
}
if (dbVersion > 0 && dbVersion < 6) {
sql = "INSERT INTO SEASON(DESCRIPTION, VALID_FROM, VALID_TO, ACTIVE) " +
"VALUES ('2015', '2015-01-01', '2015-12-31', 0)";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "INSERT INTO SEASON(DESCRIPTION, VALID_FROM, VALID_TO, ACTIVE) " +
"VALUES ('2016', '2016-01-01', NULL, 1)";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "UPDATE NUMBERSERIES SET SEASON_ID = 2";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "INSERT INTO NUMBERSERIES(MODULE, PREFIX, NUMBER, SEASON_ID) " +
"VALUES ('REQUIREMENTS', 'P', 2528, 1)";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "INSERT INTO NUMBERSERIES(MODULE, PREFIX, NUMBER, SEASON_ID) " +
"VALUES ('ORDER', 'OBJ', 55, 1)";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
// rozdeleni dat do sezon
sql = "UPDATE REQUIREMENT SET SEASON_ID = 2 WHERE NUMSER LIKE 'P16%'";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "UPDATE REQUIREMENT SET SEASON_ID = 1 WHERE NUMSER LIKE 'P0%'";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "UPDATE TRIPREQUIREMENT SET SEASON_ID = 2 WHERE NUMSER LIKE 'P16%'";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "UPDATE TRIPREQUIREMENT SET SEASON_ID = 1 WHERE NUMSER LIKE 'P0%'";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "UPDATE ORDERS SET SEASON_ID = 2 WHERE NUMSER LIKE 'OBJ16%'";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "UPDATE ORDERS SET SEASON_ID = 1 WHERE NUMSER LIKE 'OBJ0%'";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "UPDATE TRIP_BILL_APPROVAL SET SEASON_ID = 2 " +
" WHERE TRIPBILL_ID in " +
" (SELECT tb.ID FROM TRIP_BILL AS tb " +
" JOIN TRIPREQUIREMENT ON TRIPREQUIREMENT.ID = tb.REQUIREMENT_ID WHERE NUMSER LIKE 'P16%')";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "UPDATE TRIP_BILL_APPROVAL SET SEASON_ID = 1 " +
"WHERE TRIPBILL_ID in " +
"(SELECT tb.ID FROM TRIP_BILL AS tb " +
"JOIN TRIPREQUIREMENT ON TRIPREQUIREMENT.ID = tb.REQUIREMENT_ID WHERE NUMSER LIKE 'P0%')";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "UPDATE TRIP_BILL tb JOIN TRIPREQUIREMENT ON TRIPREQUIREMENT.ID = tb.REQUIREMENT_ID " +
"SET tb.SEASON_ID = 2 WHERE NUMSER LIKE 'P16%'";
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
sql = "UPDATE TRIP_BILL tb JOIN TRIPREQUIREMENT ON TRIPREQUIREMENT.ID = tb.REQUIREMENT_ID " +
"SET tb.SEASON_ID = 1 WHERE NUMSER LIKE 'P0%'";;
sq = dao.getSession().createSQLQuery(sql);
sq.executeUpdate();
}
this.updateDatabaseVersion();
}
}

@ -1,11 +1,18 @@
package info.bukova.isspst.services.numberseries;
import info.bukova.isspst.data.NumberSeries;
import info.bukova.isspst.data.Season;
import info.bukova.isspst.services.Service;
import java.util.List;
public interface NumberSeriesService extends Service<NumberSeries>
{
public NumberSeries getNumberSerie(String module);
public NumberSeries getNumberSerieForSeason(String module, Season season);
public void increase(NumberSeries ns);
public List<NumberSeries> getSeriesForSeason(Season season);
}

@ -1,24 +1,48 @@
package info.bukova.isspst.services.numberseries;
import info.bukova.isspst.data.NumberSeries;
import info.bukova.isspst.data.Season;
import info.bukova.isspst.services.AbstractService;
import info.bukova.isspst.services.settings.SeasonService;
import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
public class NumberSeriesServiceImpl extends AbstractService<NumberSeries> implements NumberSeriesService
{
@Autowired
private SeasonService seasonService;
@Transactional
@Override
public NumberSeries getNumberSerie(String module)
{
return this.selectSingle("from NumberSeries where MODULE = '" + module + "'");
public NumberSeries getNumberSerie(String module) {
return getNumberSerieForSeason(module, seasonService.getActive());
}
@Transactional
@Override
public void increase(NumberSeries ns)
{
public NumberSeries getNumberSerieForSeason(String module, Season season) {
Query q = dao.getQuery("from NumberSeries where module = :m and season = :s");
q.setParameter("m", module);
q.setParameter("s", season);
return (NumberSeries) q.uniqueResult();
}
@Transactional
@Override
public void increase(NumberSeries ns) {
ns.setNumber(ns.getNumber() + 1);
this.update(ns);
}
@Transactional
@Override
public List<NumberSeries> getSeriesForSeason(Season season) {
Query q = dao.getQuery("from NumberSeries where season = :s");
q.setParameter("s", season);
return q.list();
}
}

@ -10,16 +10,15 @@ import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.AbstractOwnedService;
import info.bukova.isspst.services.LazyLoader;
import info.bukova.isspst.services.settings.GlobalSettingsService;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
public class OrderServiceImpl extends AbstractOwnedService<Order> implements
OrderService {
@ -76,7 +75,7 @@ public class OrderServiceImpl extends AbstractOwnedService<Order> implements
public List<Order> getAll()
{
Query q = dao.getQuery("select o from Order o join fetch o.ownedBy");
return q.list();
return filterQuery(q).list();
}
@LazyLoader("form")

@ -3,17 +3,14 @@ package info.bukova.isspst.services.requirement;
import info.bukova.isspst.Constants;
import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.data.RequirementState;
import info.bukova.isspst.data.Workgroup;
import java.util.Date;
import java.util.List;
import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
public class ReqMaterialServiceImpl extends RequirementServiceImpl implements RequirementService, RequirementBaseService<Requirement>
{
@Autowired
@ -38,10 +35,10 @@ public class ReqMaterialServiceImpl extends RequirementServiceImpl implements Re
@PreAuthorize("hasPermission(this, 'PERM_READ')")
public List<Requirement> getMy()
{
Query q = dao.getQuery("from " + dao.getEntityName() + " where ownedBy = :owner and kind = :kind");
q.setParameter("owner", getLoggedInUser());
q.setParameter("kind", Constants.REQ_TYPE_MATERIAL);
return q.list();
hqlFilter.setDataClass(Requirement.class);
hqlFilter.andFilter("kind = :kind");
hqlFilter.setParam("kind", Constants.REQ_TYPE_MATERIAL);
return super.getMy();
}
@SuppressWarnings("unchecked")
@ -51,11 +48,10 @@ public class ReqMaterialServiceImpl extends RequirementServiceImpl implements Re
@PostFilter("hasPermission(filterObject, 'PERM_SHOW_CENTRE_REQ')")
public List<Requirement> getCentreReq()
{
List<Workgroup> wgList = workgroupService.getUserCentres(getLoggedInUser());
Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.centre c where c in (:wgList) and kind = :kind order by tr.numser");
q.setParameterList("wgList", wgList);
q.setParameter("kind", Constants.REQ_TYPE_MATERIAL);
return q.list();
hqlFilter.setDataClass(Requirement.class);
hqlFilter.andFilter("kind = :kind");
hqlFilter.setParam("kind", Constants.REQ_TYPE_MATERIAL);
return super.getCentreReq();
}
@SuppressWarnings("unchecked")
@ -65,13 +61,10 @@ public class ReqMaterialServiceImpl extends RequirementServiceImpl implements Re
@PostFilter("hasPermission(filterObject, 'PERM_SHOW_WORKGROUP_REQ')")
public List<Requirement> getWorkgroupReq()
{
List<Workgroup> wgList = workgroupService.getUserWorkgroups(getLoggedInUser());
Query q = dao.getQuery("select tr from "
+ dao.getEntityName()
+ " tr join fetch tr.ownedBy join tr.workgroup w where w in (:wgList) and kind = :kind order by tr.numser");
q.setParameterList("wgList", wgList);
q.setParameter("kind", Constants.REQ_TYPE_MATERIAL);
return q.list();
hqlFilter.setDataClass(Requirement.class);
hqlFilter.andFilter("kind = :kind");
hqlFilter.setParam("kind", Constants.REQ_TYPE_MATERIAL);
return super.getWorkgroupReq();
}
@SuppressWarnings("unchecked")
@ -80,8 +73,9 @@ public class ReqMaterialServiceImpl extends RequirementServiceImpl implements Re
@PreAuthorize("hasPermission(this, 'PERM_SHOW_ALL_REQ')")
public List<Requirement> getAll()
{
Query q = dao.getQuery("from " + dao.getEntityName() + " as tr join fetch tr.ownedBy where kind = :kind order by tr.numser");
q.setParameter("kind", Constants.REQ_TYPE_MATERIAL);
return q.list();
hqlFilter.setDataClass(Requirement.class);
hqlFilter.andFilter("kind = :kind");
hqlFilter.setParam("kind", Constants.REQ_TYPE_MATERIAL);
return super.getAll();
}
}

@ -3,17 +3,14 @@ package info.bukova.isspst.services.requirement;
import info.bukova.isspst.Constants;
import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.data.RequirementState;
import info.bukova.isspst.data.Workgroup;
import java.util.Date;
import java.util.List;
import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
public class ReqServicesServiceImpl extends RequirementServiceImpl implements RequirementService, RequirementBaseService<Requirement>
{
@Autowired
@ -38,10 +35,10 @@ public class ReqServicesServiceImpl extends RequirementServiceImpl implements Re
@PreAuthorize("hasPermission(this, 'PERM_READ')")
public List<Requirement> getMy()
{
Query q = dao.getQuery("from " + dao.getEntityName() + " where ownedBy = :owner and kind = :kind");
q.setParameter("owner", getLoggedInUser());
q.setParameter("kind", Constants.REQ_TYPE_SERVICES);
return q.list();
hqlFilter.setDataClass(Requirement.class);
hqlFilter.andFilter("kind = :kind");
hqlFilter.setParam("kind", Constants.REQ_TYPE_SERVICES);
return super.getMy();
}
@SuppressWarnings("unchecked")
@ -51,11 +48,10 @@ public class ReqServicesServiceImpl extends RequirementServiceImpl implements Re
@PostFilter("hasPermission(filterObject, 'PERM_SHOW_CENTRE_REQ')")
public List<Requirement> getCentreReq()
{
List<Workgroup> wgList = workgroupService.getUserCentres(getLoggedInUser());
Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.centre c where c in (:wgList) and kind = :kind order by tr.numser");
q.setParameterList("wgList", wgList);
q.setParameter("kind", Constants.REQ_TYPE_SERVICES);
return q.list();
hqlFilter.setDataClass(Requirement.class);
hqlFilter.andFilter("kind = :kind");
hqlFilter.setParam("kind", Constants.REQ_TYPE_SERVICES);
return super.getCentreReq();
}
@SuppressWarnings("unchecked")
@ -65,13 +61,10 @@ public class ReqServicesServiceImpl extends RequirementServiceImpl implements Re
@PostFilter("hasPermission(filterObject, 'PERM_SHOW_WORKGROUP_REQ')")
public List<Requirement> getWorkgroupReq()
{
List<Workgroup> wgList = workgroupService.getUserWorkgroups(getLoggedInUser());
Query q = dao.getQuery("select tr from "
+ dao.getEntityName()
+ " tr join fetch tr.ownedBy join tr.workgroup w where w in (:wgList) and kind = :kind order by tr.numser");
q.setParameterList("wgList", wgList);
q.setParameter("kind", Constants.REQ_TYPE_SERVICES);
return q.list();
hqlFilter.setDataClass(Requirement.class);
hqlFilter.andFilter("kind = :kind");
hqlFilter.setParam("kind", Constants.REQ_TYPE_SERVICES);
return super.getWorkgroupReq();
}
@SuppressWarnings("unchecked")
@ -80,8 +73,9 @@ public class ReqServicesServiceImpl extends RequirementServiceImpl implements Re
@PreAuthorize("hasPermission(this, 'PERM_SHOW_ALL_REQ')")
public List<Requirement> getAll()
{
Query q = dao.getQuery("from " + dao.getEntityName() + " as tr join fetch tr.ownedBy where kind = :kind order by tr.numser");
q.setParameter("kind", Constants.REQ_TYPE_SERVICES);
return q.list();
hqlFilter.setDataClass(Requirement.class);
hqlFilter.andFilter("kind = :kind");
hqlFilter.setParam("kind", Constants.REQ_TYPE_SERVICES);
return super.getAll();
}
}

@ -24,9 +24,11 @@ import info.bukova.isspst.reporting.ParamFiller;
import info.bukova.isspst.reporting.Report;
import info.bukova.isspst.reporting.ReportDefinition;
import info.bukova.isspst.services.AbstractOwnedService;
import info.bukova.isspst.services.HqlDataFilter;
import info.bukova.isspst.services.LazyLoader;
import info.bukova.isspst.services.Service;
import info.bukova.isspst.services.settings.GlobalSettingsService;
import info.bukova.isspst.services.settings.SeasonService;
import info.bukova.isspst.services.signeddocs.SignedDocumentService;
import info.bukova.isspst.services.users.UserService;
import info.bukova.isspst.services.workgroups.WorkgroupService;
@ -82,6 +84,9 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
@Autowired
private ReportFileStorage signedDocStorage;
@Autowired
private SeasonService seasonService;
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_ADD')")
@ -433,9 +438,10 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
@PreAuthorize("hasPermission(this, 'PERM_READ')")
public List<T> getMy()
{
Query q = dao.getQuery("from " + dao.getEntityName() + " where ownedBy = :owner");
q.setParameter("owner", getLoggedInUser());
return q.list();
Query q = dao.getQuery("from " + dao.getEntityName());
HqlDataFilter f = new HqlDataFilter("ownedBy = :owner");
f.setParam("owner", getLoggedInUser());
return filterQuery(q, f).list();
}
@SuppressWarnings("unchecked")
@ -446,9 +452,10 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
public List<T> getCentreReq()
{
List<Workgroup> wgList = workgroupService.getUserCentres(getLoggedInUser());
Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.centre c where c in (:wgList) order by tr.numser");
q.setParameterList("wgList", wgList);
return q.list();
Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.centre c");
HqlDataFilter f = new HqlDataFilter("c in (:wgList)", "tr.numser desc");
f.setParam("wgList", wgList);
return filterQuery(q, f).list();
}
@SuppressWarnings("unchecked")
@ -459,9 +466,10 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
public List<T> getWorkgroupReq()
{
List<Workgroup> wgList = workgroupService.getUserWorkgroups(getLoggedInUser());
Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.workgroup w where w in (:wgList) order by tr.numser");
q.setParameterList("wgList", wgList);
return q.list();
Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.workgroup w");
HqlDataFilter f = new HqlDataFilter("w in (:wgList)", "tr.numser desc");
f.setParam("wgList", wgList);
return filterQuery(q, f).list();
}
@SuppressWarnings("unchecked")
@ -470,8 +478,9 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
@PreAuthorize("hasPermission(this, 'PERM_SHOW_ALL_REQ')")
public List<T> getAll()
{
Query q = dao.getQuery("from " + dao.getEntityName() + " as tr join fetch tr.ownedBy order by tr.numser");
return q.list();
Query q = dao.getQuery("from " + dao.getEntityName() + " as tr join fetch tr.ownedBy");
HqlDataFilter f = new HqlDataFilter("", "tr.numser desc");
return filterQuery(q, f).list();
}
@Override

@ -0,0 +1,18 @@
package info.bukova.isspst.services.settings;
import info.bukova.isspst.services.IsspstException;
/**
* @author Pepa Rokos
*/
public class SeasonException extends IsspstException {
SeasonException() {
super();
}
SeasonException(String msg) {
super(msg);
setReason(msg);
}
}

@ -0,0 +1,16 @@
package info.bukova.isspst.services.settings;
import info.bukova.isspst.data.Season;
import info.bukova.isspst.services.Service;
import java.util.List;
/**
* @author Pepa Rokos
*/
public interface SeasonService extends Service<Season> {
Season addSeason();
Season getActive();
List<Season> getAllSeasons();
void setActive(Season season);
}

@ -0,0 +1,100 @@
package info.bukova.isspst.services.settings;
import info.bukova.isspst.StringUtils;
import info.bukova.isspst.data.NumberSeries;
import info.bukova.isspst.data.Season;
import info.bukova.isspst.services.AbstractOwnedService;
import info.bukova.isspst.services.numberseries.NumberSeriesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
/**
* @author Pepa Rokos
*/
public class SeasonServiceImpl extends AbstractOwnedService<Season> implements SeasonService {
private Season activeSeason;
@Autowired
private NumberSeriesService numberSeriesService;
@Transactional
@Override
public Season addSeason() {
Season season = new Season();
season.setDescription(StringUtils.localize("SeasonsNewSeason"));
season.setValidFrom(new Date());
season.setActive(true);
Season last = selectSingle("from Season where validTo Is Null");
add(season);
last.setValidTo(new Date());
last.setActive(false);
update(last);
activeSeason = null;
List<NumberSeries> numSeries = numberSeriesService.getSeriesForSeason(last);
for (NumberSeries ns: numSeries) {
String txt = ns.getPrefix().replaceAll("[0-9]+", "");
String numTxt = ns.getPrefix().replaceAll("[a-zA-Z]+", "");
int num = 0;
try {
num = Integer.valueOf(numTxt);
} catch (Exception e) {
e.printStackTrace();
}
String newPrefix = txt + String.valueOf(num + 1);
NumberSeries newNumSer = new NumberSeries();
newNumSer.setPrefix(newPrefix);
newNumSer.setModule(ns.getModule());
newNumSer.setNumber(1);
newNumSer.setSeason(season);
numberSeriesService.add(newNumSer);
}
return season;
}
@Transactional
@Override
public Season getActive() {
if (activeSeason == null) {
activeSeason = selectSingle("from Season where active = true");
}
if (activeSeason == null) {
throw new SeasonException("Active_season_not_set");
}
return activeSeason;
}
@Override
@Transactional
public List<Season> getAllSeasons() {
return getAll();
}
@Transactional
@Override
public void setActive(Season season) {
for (Season s: getAll()) {
s.setActive(false);
update(s);
}
Season s = dao.getById(season.getId());
if (s == null) {
throw new SeasonException("Season_not_in_database");
}
s.setActive(true);
activeSeason = s;
}
}

@ -6,6 +6,7 @@ import info.bukova.isspst.data.TripBill;
import info.bukova.isspst.data.TripBillItem;
import info.bukova.isspst.data.TripRequirement;
import info.bukova.isspst.services.AbstractOwnedService;
import info.bukova.isspst.services.HqlDataFilter;
import info.bukova.isspst.services.LazyLoader;
import info.bukova.isspst.services.settings.GlobalSettingsService;
import org.hibernate.Hibernate;
@ -179,9 +180,10 @@ public class TripBillServiceImpl extends AbstractOwnedService<TripBill> implemen
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_READ')")
public List<TripBill> getMy() {
Query q = dao.getQuery("from TripBill where ownedBy = :owner");
q.setParameter("owner", getLoggedInUser());
return q.list();
Query q = dao.getQuery("from TripBill");
HqlDataFilter f = new HqlDataFilter("ownedBy = :owner");
f.setParam("owner", getLoggedInUser());
return filterQuery(q, f).list();
}
@Override

@ -2,9 +2,13 @@ package info.bukova.isspst.ui;
import info.bukova.isspst.StringUtils;
import info.bukova.isspst.data.DataModel;
import info.bukova.isspst.data.Season;
import info.bukova.isspst.data.SeasonsAware;
import info.bukova.isspst.filters.Filter;
import info.bukova.isspst.services.HqlDataFilter;
import info.bukova.isspst.services.IsspstException;
import info.bukova.isspst.services.Service;
import info.bukova.isspst.services.settings.SeasonService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataIntegrityViolationException;
@ -18,6 +22,7 @@ import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Window;
@ -44,6 +49,13 @@ public class ListViewModel<T extends DataModel> extends DocumentViewModel
private boolean newRec = false;
private boolean fullFill = false;
@WireVariable
private SeasonService seasonService;
private List<Season> seasons;
private Season selSeason;
@WireVariable
private HqlDataFilter hqlFilter;
protected Service<T> service;
protected Class<T> dataClass;
protected String formZul;
@ -53,6 +65,13 @@ public class ListViewModel<T extends DataModel> extends DocumentViewModel
public void initListViewModel()
{
super.initDocumentViewModel();
seasons = seasonService.getAllSeasons();
Map<String, String[]> map = Executions.getCurrent().getParameterMap();
if (map.get("select") == null) {
selSeason = seasonService.getActive();
}
setHqlFilter();
}
public List<T> getDataList() {
@ -303,6 +322,9 @@ public class ListViewModel<T extends DataModel> extends DocumentViewModel
}
if (id > 0) {
selSeason = null;
setHqlFilter();
dataList = getListFromService();
for (int i = 0; i < dataList.size(); i++) {
if (dataList.get(i).getId() == id) {
selIndex = i;
@ -397,11 +419,61 @@ public class ListViewModel<T extends DataModel> extends DocumentViewModel
public boolean isAbleToDelete()
{
if (isSeasonFilter()
&&(!seasonService.getActive().equals(selSeason))) {
return false;
}
return this.isRecordSelected();
}
public boolean isAbleToAdd()
{
if (isSeasonFilter()
&&(!seasonService.getActive().equals(selSeason))) {
return false;
}
return true;
}
public List<Season> getSeasons() {
return seasons;
}
public Season getSelSeason() {
return selSeason;
}
public void setSelSeason(Season selSeason) {
this.selSeason = selSeason;
}
private void setHqlFilter() {
if (selSeason == null) {
hqlFilter.reset();
} else {
hqlFilter.setWhere("SEASON_ID = :season");
hqlFilter.setParam("season", selSeason.getId());
hqlFilter.setDataClass(SeasonsAware.class);
}
}
@Command
@NotifyChange({"dataList", "ableToAdd", "selIndex", "dataBean", "ableToDelete"})
public void filterSeason() {
setHqlFilter();
dataList.clear();
loadFromDbSync();
dataBean = null;
selIndex = -1;
}
public boolean isSeasonFilter() {
for (Class<?> clazz : service.getEntityClasses()) {
if (SeasonsAware.class.isAssignableFrom(clazz)) {
return true;
}
}
return false;
}
}

@ -44,7 +44,7 @@ public class MainMenu
@Command
public void numSeries()
{
Window window = (Window) Executions.createComponents("/settings/numberSeries.zul", null, null);
Window window = (Window) Executions.createComponents("/settings/seasons.zul", null, null);
window.doModal();
}

@ -30,7 +30,7 @@ public class TripRequirementList extends ListViewModel<TripRequirement> {
private boolean showWorkgroup;
private boolean showAll;
@Init
@Init(superclass = true)
public void init() {
service = tripRequirementService;
dataClass = TripRequirement.class;

@ -33,7 +33,7 @@ public class TripRequirementListAll extends RequirementSubpage<TripRequirement>
private List<Workgroup> allCentres;
private List<Workgroup> allWorkgroups;
@Init
@Init(superclass = true)
public void init() {
service = tripRequirementService;
dataClass = TripRequirement.class;

@ -35,7 +35,7 @@ public class TripRequirementListCentre extends RequirementSubpage<TripRequiremen
private List<Workgroup> myCentres;
@Init
@Init(superclass = true)
public void init() {
service = tripRequirementService;
dataClass = TripRequirement.class;

@ -37,7 +37,7 @@ public class TripRequirementListWorkgroup extends RequirementSubpage<TripRequire
private List<Workgroup> myWorkgroups;
@Init
@Init(superclass = true)
public void init() {
service = tripRequirementService;
dataClass = TripRequirement.class;

@ -0,0 +1,101 @@
package info.bukova.isspst.ui.settings;
import info.bukova.isspst.Module;
import info.bukova.isspst.ModuleUtils;
import info.bukova.isspst.StringUtils;
import info.bukova.isspst.data.NumberSeries;
import info.bukova.isspst.data.Season;
import info.bukova.isspst.services.numberseries.NumberSeriesService;
import info.bukova.isspst.services.settings.SeasonService;
import org.zkoss.bind.BindUtils;
import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Init;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Window;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Pepa Rokos
*/
public class SeasonsVM {
@WireVariable
private SeasonService seasonService;
@WireVariable
private NumberSeriesService numericSeriesService;
private List<Season> seasons;
private List<NumberSeries> numSeries;
private Map<String, Module> moduleMap;
@Init
public void init() {
seasons = seasonService.getAll();
numSeries = numericSeriesService.getSeriesForSeason(seasonService.getActive());
moduleMap = new HashMap<String, Module>();
for (Module m : ModuleUtils.getActiveModules()) {
moduleMap.put(m.getId(), m);
}
}
public Map<String, Module> getModuleMap() {
return moduleMap;
}
@Command
//@NotifyChange({"seasons", "numSeries"})
public void addSeason() {
Messagebox.show(StringUtils.localize("SeasonsNewSeasonDialog"), StringUtils.localize("SeasonsNewSeason"), Messagebox.YES | Messagebox.NO, Messagebox.QUESTION,
new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
if (((Integer)event.getData()).intValue() == Messagebox.YES) {
Season newSeason = seasonService.addSeason();
seasons = seasonService.getAll();
numSeries = numericSeriesService.getSeriesForSeason(seasonService.getActive());
BindUtils.postNotifyChange(null, null, SeasonsVM.this, "seasons");
BindUtils.postNotifyChange(null, null, SeasonsVM.this, "numSeries");
}
}
});
}
@Command
public void save(@BindingParam("window") Window win) {
for(Season s: seasons) {
seasonService.update(s);
}
for(NumberSeries n: numSeries) {
numericSeriesService.update(n);
}
win.detach();
}
@Command
@NotifyChange({"numSeries", "seasons"})
public void activate(@BindingParam("season") Season season) {
seasonService.setActive(season);
seasons = seasonService.getAll();
numSeries = numericSeriesService.getSeriesForSeason(season);
}
public List<Season> getSeasons() {
return seasons;
}
public List<NumberSeries> getNumSeries() {
return numSeries;
}
public boolean isCanSave() {
return true;
}
}

@ -38,5 +38,6 @@
<mapping class="info.bukova.isspst.data.TripBillApproval"></mapping>
<mapping class="info.bukova.isspst.data.SignedDocument"></mapping>
<mapping class="info.bukova.isspst.data.SignedDocumentItem"></mapping>
<mapping class="info.bukova.isspst.data.Season"></mapping>
</session-factory>
</hibernate-configuration>

@ -431,3 +431,16 @@ ContextMenu = Volby v kontextovém menu
ErrMaterialOrServiceDescription=Zadejte popis požadavku.
SeasonsSeason = Období
SeasonsNewSeason = Nové období
SeasonsDescription = Popis
SeasonsValidFrom = Platí od
SeasonsValidTo = Platí do
SeasonsActive = Aktivní
SeasonsActivate = Aktivovat
SeasonsActiveNumSeries = Číselné řady pro aktivní období:
SeasonsAgenda = Agenda
SeasonsPrefix = Prefix
SeasonsNewSeasonDialog = Opravdu chcete založit nové období?
Active_season_not_set = Není nastaveno žádné aktivní období.

@ -192,6 +192,10 @@
<aop:scoped-proxy/>
</bean>
<bean id="hqlFilter" class="info.bukova.isspst.services.HqlDataFilter" scope="request">
<aop:scoped-proxy/>
</bean>
<!-- DAO -->
<bean id="queryDao" class="info.bukova.isspst.dao.jpa.QueryDaoJPA">
<property name="sessionFactory" ref="sessionFactory"/>
@ -281,6 +285,10 @@
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="seasonDao" class="info.bukova.isspst.dao.jpa.SeasonDaoJPA">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- Business logic -->
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/>
@ -466,4 +474,8 @@
<bean id="signedDocumentService" class="info.bukova.isspst.services.signeddocs.SignedDocumentServiceImpl">
<property name="dao" ref="signedDocumentDao"/>
</bean>
<bean id="seasonService" class="info.bukova.isspst.services.settings.SeasonServiceImpl">
<property name="dao" ref="seasonDao"/>
</bean>
</beans>

@ -6,5 +6,14 @@
<toolbarbutton image="/img/delete.png" tooltiptext="${labels.ToolbarRecDelete}" id="btnDelete" onClick="@command('delete')" disabled="@load(not vm.ableToDelete)" />
<toolbarbutton image="/img/funnel.png" tooltiptext="${labels.ToolbarRecFilter}" id="btnFilter" onClick="@command('filter')" />
<toolbarbutton image="/img/print.png" tooltiptext="${labels.ToolbarPrint}" id="btnPrint" onClick="@command('onPrint')" />
<label value="${labels.SeasonsSeason}" visible="@load(vm.seasonFilter)"/>
<combobox model="@load(vm.seasons)"
selectedItem="@bind(vm.selSeason)"
onChange="@command('filterSeason')"
visible="@load(vm.seasonFilter)">
<template name="model">
<comboitem label="@load(each.description)" style="@load(each.active ? 'font-weight: bold' : '')"/>
</template>
</combobox>
</toolbar>
</zk>

@ -189,7 +189,7 @@
<listcell label="@load(each.requirement.sumTotal) @converter(vm.standardBigDecimalConverter)" />
<listcell
label="@load(each.totalInvoiced) @converter(vm.standardBigDecimalConverter)"
style="@load(vm.dataBean.totalInvoiced gt vm.dataBean.requirement.sumTotal ? ' color: red;' : '' )" />
style="@load(each.totalInvoiced gt each.requirement.sumTotal ? ' color: red;' : '' )" />
</listitem>
</template>
</listbox>

@ -5,6 +5,8 @@
itemRenderer="@load(vm.requirementsItemRenderer)"
selectedItem="@bind(vm.dataBean)"
model="@load(vm.dataList)"
mold="paging"
autopaging="true"
onAfterRender="@command('afterRender')"
selectedIndex="@bind(vm.selIndex)">
<listhead menupopup="auto">

@ -4,6 +4,8 @@
hflex="7"
itemRenderer="@load(vm.requirementsItemRenderer)"
selectedItem="@bind(vm.dataBean)"
mold="paging"
autopaging="true"
model="@load(vm.dataList)"
onAfterRender="@command('afterRender')"
selectedIndex="@bind(vm.selIndex)">

@ -4,6 +4,8 @@
hflex="7"
itemRenderer="@load(vm.requirementsItemRenderer)"
selectedItem="@bind(vm.dataBean)"
mold="paging"
autopaging="true"
model="@load(vm.dataList)"
onAfterRender="@command('afterRender')"
selectedIndex="@bind(vm.selIndex)">

@ -5,5 +5,14 @@
<toolbarbutton image="/img/delete.png" tooltiptext="${labels.ToolbarRecDelete}" id="btnDelete" onClick="@command('delete')" disabled="@load(not vm.ableToDelete)" />
<toolbarbutton image="/img/funnel.png" tooltiptext="${labels.ToolbarRecFilter}" id="btnFilter" onClick="@command('filter')" />
<toolbarbutton image="/img/print.png" tooltiptext="${labels.ToolbarPrint}" id="btnPrint" onClick="@command('onPrint')" />
<label value="${labels.SeasonsSeason}" visible="@load(vm.seasonFilter)"/>
<combobox model="@load(vm.seasons)"
selectedItem="@bind(vm.selSeason)"
onChange="@command('filterSeason')"
visible="@load(vm.seasonFilter)">
<template name="model">
<comboitem label="@load(each.description)" style="@load(each.active ? 'font-weight: bold' : '')"/>
</template>
</combobox>
</toolbar>
</zk>

@ -10,6 +10,8 @@
vflex="1"
hflex="7"
model="@load(vm.dataList)"
mold="paging"
autopaging="true"
selectedItem="@bind(vm.dataBean)"
itemRenderer="@load(vm.itemRenderer)"
onAfterRender="@command('afterRender')"

@ -2,7 +2,6 @@
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<window
vflex="1"
border="normal"
apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('info.bukova.isspst.ui.requirement.TripRequirementList')">
<include src="/app/toolbar.zul" />

@ -4,7 +4,6 @@
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<window
vflex="1"
border="normal"
apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('info.bukova.isspst.ui.requirement.TripRequirementListAll')">
<include src="/main/toolbar.zul" />
@ -12,6 +11,8 @@
<listbox
model="@load(vm.dataList)"
selectedItem="@bind(vm.dataBean)"
mold="paging"
autopaging="true"
hflex="7"
onAfterRender="@command('afterRender')"
selectedIndex="@bind(vm.selIndex)"

@ -2,7 +2,6 @@
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<window
vflex="1"
border="normal"
apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('info.bukova.isspst.ui.requirement.TripRequirementListCentre')">
<include src="/main/toolbar.zul" />
@ -10,6 +9,8 @@
<listbox
model="@load(vm.dataList)"
selectedItem="@bind(vm.dataBean)"
mold="paging"
autopaging="true"
hflex="7"
onAfterRender="@command('afterRender')"
selectedIndex="@bind(vm.selIndex)"

@ -2,7 +2,6 @@
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<window
vflex="1"
border="normal"
apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('info.bukova.isspst.ui.requirement.TripRequirementListWorkgroup')">
<include src="/main/toolbar.zul" />
@ -10,6 +9,8 @@
<listbox
model="@load(vm.dataList)"
selectedItem="@bind(vm.dataBean)"
mold="paging"
autopaging="true"
hflex="7"
onAfterRender="@command('afterRender')"
selectedIndex="@bind(vm.selIndex)"

@ -0,0 +1,62 @@
<?page title="${labels.TravelOrdersFormTitle}" contentType="text/html;charset=UTF-8"?>
<zk xmlns="http://www.zkoss.org/2005/zul"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd">
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<window id="editWin"
border="normal"
closable="true"
apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('info.bukova.isspst.ui.settings.SeasonsVM')"
width="750px"
height="600px">
<caption
src="/img/global-setting-032.png"
zclass="form-caption"
label="${labels.SeasonsSeason}" />
<vbox>
<button label="${labels.SeasonsNewSeason}" onClick="@command('addSeason')" sclass="nicebutton"/>
<listbox model="@load(vm.seasons)">
<listhead>
<listheader label="${labels.SeasonsDescription}"/>
<listheader label="${labels.SeasonsValidFrom}"/>
<listheader label="${labels.SeasonsValidTo}"/>
<listheader label="${labels.SeasonsActive}"/>
</listhead>
<template name="model">
<listitem>
<listcell>
<textbox value="@bind(each.description)" inplace="true"/>
</listcell>
<listcell label="@load(each.validFrom)"/>
<listcell label="@load(each.validTo)"/>
<listcell>
<button label="${labels.SeasonsActivate}" onClick="@command('activate', season=each)" disabled="@load(each.active)" sclass="nicebutton"/>
</listcell>
</listitem>
</template>
</listbox>
<label value="${labels.SeasonsActiveNumSeries}"/>
<listbox model="@load(vm.numSeries)">
<listhead>
<listheader label="${labels.SeasonsAgenda}"/>
<listheader label="${labels.SeasonsPrefix}"/>
<listheader/>
</listhead>
<template name="model">
<listitem>
<listcell label="@load(vm.moduleMap[each.module].name)"/>
<listcell>
<textbox value="@bind(each.prefix)" inplace="true"/>
</listcell>
<listcell label="@load(each.number)"/>
</listitem>
</template>
</listbox>
<include src="/app/formButtons.zul" />
</vbox>
</window>
</zk>
Loading…
Cancel
Save