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

@ -35,7 +35,7 @@ import java.util.Map;
public class Constants { 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 = "admin";
public final static String DEF_ADMIN_PASSWD = "admin"; public final static String DEF_ADMIN_PASSWD = "admin";
@ -151,10 +151,17 @@ public class Constants {
new ReportMapping(MOD_REQUIREMENTS, new Report(8, true, "Protokol o kontrole", "orderRequirement", false, true)) 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>() {{ public final static Map<Class<?>, Integer> SIGN_REPORT_MAP = Collections.unmodifiableMap(new HashMap<Class<?>, Integer>() {{
put(TripBillApproval.class, 4); put(TripBillApproval.class, 4);
put(TripRequirement.class, 7); 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_ORDER = "ORDER";
public final static String REQTYPE_BUSINESSTRIP = "BUSINESSTRIP"; public final static String REQTYPE_BUSINESSTRIP = "BUSINESSTRIP";

@ -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.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
@Entity @Entity
@ -17,6 +19,10 @@ public class NumberSeries extends BaseSimpleData
@Column(name = "NUMBER") @Column(name = "NUMBER")
private int number; private int number;
@OneToOne
@JoinColumn(name = "SEASON_ID")
private Season season;
public String getCurrentNumber() public String getCurrentNumber()
{ {
return String.format("%s%06d", this.getPrefix(), this.getNumber()); return String.format("%s%06d", this.getPrefix(), this.getNumber());
@ -51,4 +57,12 @@ public class NumberSeries extends BaseSimpleData
{ {
this.number = number; 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; package info.bukova.isspst.data;
import info.bukova.isspst.Constants; import info.bukova.isspst.Constants;
import org.hibernate.annotations.LazyCollection;
import java.math.BigDecimal; import org.hibernate.annotations.LazyCollectionOption;
import java.util.ArrayList; import org.hibernate.search.annotations.Analyze;
import java.util.Date; import org.hibernate.search.annotations.Field;
import java.util.List; 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.AttributeOverride;
import javax.persistence.AttributeOverrides; import javax.persistence.AttributeOverrides;
@ -13,21 +15,20 @@ import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Embedded; import javax.persistence.Embedded;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import java.math.BigDecimal;
import org.hibernate.annotations.LazyCollection; import java.util.ArrayList;
import org.hibernate.annotations.LazyCollectionOption; import java.util.Date;
import org.hibernate.search.annotations.Analyze; import java.util.List;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
@Entity @Entity
@Table(name = "ORDERS") @Table(name = "ORDERS")
@Indexed @Indexed
public class Order extends BaseData implements Cloneable public class Order extends BaseData implements Cloneable, SeasonsAware
{ {
@Column(name = "NUMSER") @Column(name = "NUMSER")
@ -121,6 +122,10 @@ public class Order extends BaseData implements Cloneable
@Column(name = "DELIVERED") @Column(name = "DELIVERED")
private boolean delivered; private boolean delivered;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "SEASON_ID")
private Season season;
public Order() public Order()
{ {
this.items = new ArrayList<OrderItem>(); this.items = new ArrayList<OrderItem>();
@ -288,4 +293,12 @@ public class Order extends BaseData implements Cloneable
cloned.setTotal(new BigDecimal(this.getTotal().toString())); cloned.setTotal(new BigDecimal(this.getTotal().toString()));
return cloned; return cloned;
} }
public Season getSeason() {
return season;
}
public void setSeason(Season season) {
this.season = season;
}
} }

@ -1,10 +1,12 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import info.bukova.isspst.Constants; import info.bukova.isspst.Constants;
import org.hibernate.annotations.LazyCollection;
import java.util.ArrayList; import org.hibernate.annotations.LazyCollectionOption;
import java.util.Date; import org.hibernate.search.annotations.Analyze;
import java.util.List; 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.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
@ -16,17 +18,13 @@ import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.OrderBy; import javax.persistence.OrderBy;
import java.util.ArrayList;
import org.hibernate.annotations.LazyCollection; import java.util.Date;
import org.hibernate.annotations.LazyCollectionOption; import java.util.List;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
@MappedSuperclass @MappedSuperclass
@Indexed @Indexed
public class RequirementBase extends BaseData implements FilterableRequirement { public class RequirementBase extends BaseData implements FilterableRequirement, SeasonsAware {
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "TYPE_ID") @JoinColumn(name = "TYPE_ID")
@ -56,6 +54,9 @@ public class RequirementBase extends BaseData implements FilterableRequirement {
@Column(name = "STATE") @Column(name = "STATE")
@Enumerated(EnumType.ORDINAL) @Enumerated(EnumType.ORDINAL)
private RequirementState state; private RequirementState state;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "SEASON_ID")
private Season season;
public RequirementBase() { public RequirementBase() {
authorization = new ArrayList<AuthItem>(); authorization = new ArrayList<AuthItem>();
@ -152,4 +153,11 @@ public class RequirementBase extends BaseData implements FilterableRequirement {
return authorization.get(authorization.size() - 1).getAuthDate(); 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.Entity;
import javax.persistence.FetchType; import javax.persistence.FetchType;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.OneToOne; import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
@ -26,7 +27,7 @@ import java.util.List;
@Entity @Entity
@Table(name = "TRIP_BILL") @Table(name = "TRIP_BILL")
@Indexed @Indexed
public class TripBill extends BaseData implements EntityWithAttachment { public class TripBill extends BaseData implements EntityWithAttachment, SeasonsAware {
@OneToOne(fetch = FetchType.EAGER) @OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "REQUIREMENT_ID") @JoinColumn(name = "REQUIREMENT_ID")
@ -69,6 +70,9 @@ public class TripBill extends BaseData implements EntityWithAttachment {
private Boolean paid; private Boolean paid;
@Column(name = "PAID_DATE") @Column(name = "PAID_DATE")
private Date paidDate; private Date paidDate;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "SEASON_ID")
private Season season;
public TripBill() { public TripBill() {
billItems = new ArrayList<TripBillItem>(); billItems = new ArrayList<TripBillItem>();
@ -206,4 +210,13 @@ public class TripBill extends BaseData implements EntityWithAttachment {
public void setPaidDate(Date paidDate) { public void setPaidDate(Date paidDate) {
this.paidDate = 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 @Autowired
protected SessionData sessionData; protected SessionData sessionData;
@Autowired @Autowired
protected HqlDataFilter hqlFilter;
@Autowired
protected QueryDao queryDao; protected QueryDao queryDao;
private DocumentFileStorage documentFileStorage; 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 @Override
@PreAuthorize("hasPermission(this, 'PERM_ADD')") @PreAuthorize("hasPermission(this, 'PERM_ADD')")
public final T create() { public final T create() {
@ -199,8 +245,10 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
if (getModule() != null && !getModule().isActive()) { if (getModule() != null && !getModule().isActive()) {
throw new ModuleNotActiveException(); throw new ModuleNotActiveException();
} }
Query q = dao.getQuery("from " + dao.getEntityName());
return dao.getAll(); return filterQuery(q).list();
} }
@Override @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.Constants;
import info.bukova.isspst.data.DbInfo; import info.bukova.isspst.data.DbInfo;
import info.bukova.isspst.services.AbstractService; import info.bukova.isspst.services.AbstractService;
import org.hibernate.SQLQuery;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.hibernate.SQLQuery;
import org.springframework.transaction.annotation.Transactional;
public class DbInfoServiceImpl extends AbstractService<DbInfo> implements DbInfoService public class DbInfoServiceImpl extends AbstractService<DbInfo> implements DbInfoService
{ {
private DbInfo getDbInfo() private DbInfo getDbInfo()
@ -142,6 +141,76 @@ public class DbInfoServiceImpl extends AbstractService<DbInfo> implements DbInfo
sq.executeUpdate(); 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(); this.updateDatabaseVersion();
} }
} }

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

@ -1,24 +1,48 @@
package info.bukova.isspst.services.numberseries; package info.bukova.isspst.services.numberseries;
import info.bukova.isspst.data.NumberSeries; import info.bukova.isspst.data.NumberSeries;
import info.bukova.isspst.data.Season;
import info.bukova.isspst.services.AbstractService; 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 org.springframework.transaction.annotation.Transactional;
import java.util.List;
public class NumberSeriesServiceImpl extends AbstractService<NumberSeries> implements NumberSeriesService public class NumberSeriesServiceImpl extends AbstractService<NumberSeries> implements NumberSeriesService
{ {
@Autowired
private SeasonService seasonService;
@Transactional
@Override
public NumberSeries getNumberSerie(String module) {
return getNumberSerieForSeason(module, seasonService.getActive());
}
@Transactional @Transactional
@Override @Override
public NumberSeries getNumberSerie(String module) public NumberSeries getNumberSerieForSeason(String module, Season season) {
{ Query q = dao.getQuery("from NumberSeries where module = :m and season = :s");
return this.selectSingle("from NumberSeries where MODULE = '" + module + "'"); q.setParameter("m", module);
q.setParameter("s", season);
return (NumberSeries) q.uniqueResult();
} }
@Transactional @Transactional
@Override @Override
public void increase(NumberSeries ns) public void increase(NumberSeries ns) {
{
ns.setNumber(ns.getNumber() + 1); ns.setNumber(ns.getNumber() + 1);
this.update(ns); 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.AbstractOwnedService;
import info.bukova.isspst.services.LazyLoader; import info.bukova.isspst.services.LazyLoader;
import info.bukova.isspst.services.settings.GlobalSettingsService; 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.Hibernate;
import org.hibernate.Query; import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional; 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 public class OrderServiceImpl extends AbstractOwnedService<Order> implements
OrderService { OrderService {
@ -76,7 +75,7 @@ public class OrderServiceImpl extends AbstractOwnedService<Order> implements
public List<Order> getAll() public List<Order> getAll()
{ {
Query q = dao.getQuery("select o from Order o join fetch o.ownedBy"); Query q = dao.getQuery("select o from Order o join fetch o.ownedBy");
return q.list(); return filterQuery(q).list();
} }
@LazyLoader("form") @LazyLoader("form")

@ -3,17 +3,14 @@ package info.bukova.isspst.services.requirement;
import info.bukova.isspst.Constants; import info.bukova.isspst.Constants;
import info.bukova.isspst.data.Requirement; import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.data.RequirementState; 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.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostFilter; import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
public class ReqMaterialServiceImpl extends RequirementServiceImpl implements RequirementService, RequirementBaseService<Requirement> public class ReqMaterialServiceImpl extends RequirementServiceImpl implements RequirementService, RequirementBaseService<Requirement>
{ {
@Autowired @Autowired
@ -38,10 +35,10 @@ public class ReqMaterialServiceImpl extends RequirementServiceImpl implements Re
@PreAuthorize("hasPermission(this, 'PERM_READ')") @PreAuthorize("hasPermission(this, 'PERM_READ')")
public List<Requirement> getMy() public List<Requirement> getMy()
{ {
Query q = dao.getQuery("from " + dao.getEntityName() + " where ownedBy = :owner and kind = :kind"); hqlFilter.setDataClass(Requirement.class);
q.setParameter("owner", getLoggedInUser()); hqlFilter.andFilter("kind = :kind");
q.setParameter("kind", Constants.REQ_TYPE_MATERIAL); hqlFilter.setParam("kind", Constants.REQ_TYPE_MATERIAL);
return q.list(); return super.getMy();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -51,11 +48,10 @@ public class ReqMaterialServiceImpl extends RequirementServiceImpl implements Re
@PostFilter("hasPermission(filterObject, 'PERM_SHOW_CENTRE_REQ')") @PostFilter("hasPermission(filterObject, 'PERM_SHOW_CENTRE_REQ')")
public List<Requirement> getCentreReq() public List<Requirement> getCentreReq()
{ {
List<Workgroup> wgList = workgroupService.getUserCentres(getLoggedInUser()); hqlFilter.setDataClass(Requirement.class);
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"); hqlFilter.andFilter("kind = :kind");
q.setParameterList("wgList", wgList); hqlFilter.setParam("kind", Constants.REQ_TYPE_MATERIAL);
q.setParameter("kind", Constants.REQ_TYPE_MATERIAL); return super.getCentreReq();
return q.list();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -65,13 +61,10 @@ public class ReqMaterialServiceImpl extends RequirementServiceImpl implements Re
@PostFilter("hasPermission(filterObject, 'PERM_SHOW_WORKGROUP_REQ')") @PostFilter("hasPermission(filterObject, 'PERM_SHOW_WORKGROUP_REQ')")
public List<Requirement> getWorkgroupReq() public List<Requirement> getWorkgroupReq()
{ {
List<Workgroup> wgList = workgroupService.getUserWorkgroups(getLoggedInUser()); hqlFilter.setDataClass(Requirement.class);
Query q = dao.getQuery("select tr from " hqlFilter.andFilter("kind = :kind");
+ dao.getEntityName() hqlFilter.setParam("kind", Constants.REQ_TYPE_MATERIAL);
+ " tr join fetch tr.ownedBy join tr.workgroup w where w in (:wgList) and kind = :kind order by tr.numser"); return super.getWorkgroupReq();
q.setParameterList("wgList", wgList);
q.setParameter("kind", Constants.REQ_TYPE_MATERIAL);
return q.list();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -80,8 +73,9 @@ public class ReqMaterialServiceImpl extends RequirementServiceImpl implements Re
@PreAuthorize("hasPermission(this, 'PERM_SHOW_ALL_REQ')") @PreAuthorize("hasPermission(this, 'PERM_SHOW_ALL_REQ')")
public List<Requirement> getAll() public List<Requirement> getAll()
{ {
Query q = dao.getQuery("from " + dao.getEntityName() + " as tr join fetch tr.ownedBy where kind = :kind order by tr.numser"); hqlFilter.setDataClass(Requirement.class);
q.setParameter("kind", Constants.REQ_TYPE_MATERIAL); hqlFilter.andFilter("kind = :kind");
return q.list(); 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.Constants;
import info.bukova.isspst.data.Requirement; import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.data.RequirementState; 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.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostFilter; import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
public class ReqServicesServiceImpl extends RequirementServiceImpl implements RequirementService, RequirementBaseService<Requirement> public class ReqServicesServiceImpl extends RequirementServiceImpl implements RequirementService, RequirementBaseService<Requirement>
{ {
@Autowired @Autowired
@ -38,10 +35,10 @@ public class ReqServicesServiceImpl extends RequirementServiceImpl implements Re
@PreAuthorize("hasPermission(this, 'PERM_READ')") @PreAuthorize("hasPermission(this, 'PERM_READ')")
public List<Requirement> getMy() public List<Requirement> getMy()
{ {
Query q = dao.getQuery("from " + dao.getEntityName() + " where ownedBy = :owner and kind = :kind"); hqlFilter.setDataClass(Requirement.class);
q.setParameter("owner", getLoggedInUser()); hqlFilter.andFilter("kind = :kind");
q.setParameter("kind", Constants.REQ_TYPE_SERVICES); hqlFilter.setParam("kind", Constants.REQ_TYPE_SERVICES);
return q.list(); return super.getMy();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -51,11 +48,10 @@ public class ReqServicesServiceImpl extends RequirementServiceImpl implements Re
@PostFilter("hasPermission(filterObject, 'PERM_SHOW_CENTRE_REQ')") @PostFilter("hasPermission(filterObject, 'PERM_SHOW_CENTRE_REQ')")
public List<Requirement> getCentreReq() public List<Requirement> getCentreReq()
{ {
List<Workgroup> wgList = workgroupService.getUserCentres(getLoggedInUser()); hqlFilter.setDataClass(Requirement.class);
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"); hqlFilter.andFilter("kind = :kind");
q.setParameterList("wgList", wgList); hqlFilter.setParam("kind", Constants.REQ_TYPE_SERVICES);
q.setParameter("kind", Constants.REQ_TYPE_SERVICES); return super.getCentreReq();
return q.list();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -65,13 +61,10 @@ public class ReqServicesServiceImpl extends RequirementServiceImpl implements Re
@PostFilter("hasPermission(filterObject, 'PERM_SHOW_WORKGROUP_REQ')") @PostFilter("hasPermission(filterObject, 'PERM_SHOW_WORKGROUP_REQ')")
public List<Requirement> getWorkgroupReq() public List<Requirement> getWorkgroupReq()
{ {
List<Workgroup> wgList = workgroupService.getUserWorkgroups(getLoggedInUser()); hqlFilter.setDataClass(Requirement.class);
Query q = dao.getQuery("select tr from " hqlFilter.andFilter("kind = :kind");
+ dao.getEntityName() hqlFilter.setParam("kind", Constants.REQ_TYPE_SERVICES);
+ " tr join fetch tr.ownedBy join tr.workgroup w where w in (:wgList) and kind = :kind order by tr.numser"); return super.getWorkgroupReq();
q.setParameterList("wgList", wgList);
q.setParameter("kind", Constants.REQ_TYPE_SERVICES);
return q.list();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -80,8 +73,9 @@ public class ReqServicesServiceImpl extends RequirementServiceImpl implements Re
@PreAuthorize("hasPermission(this, 'PERM_SHOW_ALL_REQ')") @PreAuthorize("hasPermission(this, 'PERM_SHOW_ALL_REQ')")
public List<Requirement> getAll() public List<Requirement> getAll()
{ {
Query q = dao.getQuery("from " + dao.getEntityName() + " as tr join fetch tr.ownedBy where kind = :kind order by tr.numser"); hqlFilter.setDataClass(Requirement.class);
q.setParameter("kind", Constants.REQ_TYPE_SERVICES); hqlFilter.andFilter("kind = :kind");
return q.list(); 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.Report;
import info.bukova.isspst.reporting.ReportDefinition; import info.bukova.isspst.reporting.ReportDefinition;
import info.bukova.isspst.services.AbstractOwnedService; import info.bukova.isspst.services.AbstractOwnedService;
import info.bukova.isspst.services.HqlDataFilter;
import info.bukova.isspst.services.LazyLoader; import info.bukova.isspst.services.LazyLoader;
import info.bukova.isspst.services.Service; import info.bukova.isspst.services.Service;
import info.bukova.isspst.services.settings.GlobalSettingsService; 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.signeddocs.SignedDocumentService;
import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.services.users.UserService;
import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.services.workgroups.WorkgroupService;
@ -82,6 +84,9 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
@Autowired @Autowired
private ReportFileStorage signedDocStorage; private ReportFileStorage signedDocStorage;
@Autowired
private SeasonService seasonService;
@Override @Override
@Transactional @Transactional
@PreAuthorize("hasPermission(this, 'PERM_ADD')") @PreAuthorize("hasPermission(this, 'PERM_ADD')")
@ -433,9 +438,10 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
@PreAuthorize("hasPermission(this, 'PERM_READ')") @PreAuthorize("hasPermission(this, 'PERM_READ')")
public List<T> getMy() public List<T> getMy()
{ {
Query q = dao.getQuery("from " + dao.getEntityName() + " where ownedBy = :owner"); Query q = dao.getQuery("from " + dao.getEntityName());
q.setParameter("owner", getLoggedInUser()); HqlDataFilter f = new HqlDataFilter("ownedBy = :owner");
return q.list(); f.setParam("owner", getLoggedInUser());
return filterQuery(q, f).list();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -446,9 +452,10 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
public List<T> getCentreReq() public List<T> getCentreReq()
{ {
List<Workgroup> wgList = workgroupService.getUserCentres(getLoggedInUser()); 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"); Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.centre c");
q.setParameterList("wgList", wgList); HqlDataFilter f = new HqlDataFilter("c in (:wgList)", "tr.numser desc");
return q.list(); f.setParam("wgList", wgList);
return filterQuery(q, f).list();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -459,9 +466,10 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
public List<T> getWorkgroupReq() public List<T> getWorkgroupReq()
{ {
List<Workgroup> wgList = workgroupService.getUserWorkgroups(getLoggedInUser()); 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"); Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.workgroup w");
q.setParameterList("wgList", wgList); HqlDataFilter f = new HqlDataFilter("w in (:wgList)", "tr.numser desc");
return q.list(); f.setParam("wgList", wgList);
return filterQuery(q, f).list();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -470,8 +478,9 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
@PreAuthorize("hasPermission(this, 'PERM_SHOW_ALL_REQ')") @PreAuthorize("hasPermission(this, 'PERM_SHOW_ALL_REQ')")
public List<T> getAll() public List<T> getAll()
{ {
Query q = dao.getQuery("from " + dao.getEntityName() + " as tr join fetch tr.ownedBy order by tr.numser"); Query q = dao.getQuery("from " + dao.getEntityName() + " as tr join fetch tr.ownedBy");
return q.list(); HqlDataFilter f = new HqlDataFilter("", "tr.numser desc");
return filterQuery(q, f).list();
} }
@Override @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.TripBillItem;
import info.bukova.isspst.data.TripRequirement; import info.bukova.isspst.data.TripRequirement;
import info.bukova.isspst.services.AbstractOwnedService; import info.bukova.isspst.services.AbstractOwnedService;
import info.bukova.isspst.services.HqlDataFilter;
import info.bukova.isspst.services.LazyLoader; import info.bukova.isspst.services.LazyLoader;
import info.bukova.isspst.services.settings.GlobalSettingsService; import info.bukova.isspst.services.settings.GlobalSettingsService;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
@ -179,9 +180,10 @@ public class TripBillServiceImpl extends AbstractOwnedService<TripBill> implemen
@Transactional @Transactional
@PreAuthorize("hasPermission(this, 'PERM_READ')") @PreAuthorize("hasPermission(this, 'PERM_READ')")
public List<TripBill> getMy() { public List<TripBill> getMy() {
Query q = dao.getQuery("from TripBill where ownedBy = :owner"); Query q = dao.getQuery("from TripBill");
q.setParameter("owner", getLoggedInUser()); HqlDataFilter f = new HqlDataFilter("ownedBy = :owner");
return q.list(); f.setParam("owner", getLoggedInUser());
return filterQuery(q, f).list();
} }
@Override @Override

@ -2,9 +2,13 @@ package info.bukova.isspst.ui;
import info.bukova.isspst.StringUtils; import info.bukova.isspst.StringUtils;
import info.bukova.isspst.data.DataModel; 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.filters.Filter;
import info.bukova.isspst.services.HqlDataFilter;
import info.bukova.isspst.services.IsspstException; import info.bukova.isspst.services.IsspstException;
import info.bukova.isspst.services.Service; import info.bukova.isspst.services.Service;
import info.bukova.isspst.services.settings.SeasonService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.dao.DataIntegrityViolationException; 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.Executions;
import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zul.Messagebox; import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Window; import org.zkoss.zul.Window;
@ -44,6 +49,13 @@ public class ListViewModel<T extends DataModel> extends DocumentViewModel
private boolean newRec = false; private boolean newRec = false;
private boolean fullFill = 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 Service<T> service;
protected Class<T> dataClass; protected Class<T> dataClass;
protected String formZul; protected String formZul;
@ -53,6 +65,13 @@ public class ListViewModel<T extends DataModel> extends DocumentViewModel
public void initListViewModel() public void initListViewModel()
{ {
super.initDocumentViewModel(); 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() { public List<T> getDataList() {
@ -303,6 +322,9 @@ public class ListViewModel<T extends DataModel> extends DocumentViewModel
} }
if (id > 0) { if (id > 0) {
selSeason = null;
setHqlFilter();
dataList = getListFromService();
for (int i = 0; i < dataList.size(); i++) { for (int i = 0; i < dataList.size(); i++) {
if (dataList.get(i).getId() == id) { if (dataList.get(i).getId() == id) {
selIndex = i; selIndex = i;
@ -397,11 +419,61 @@ public class ListViewModel<T extends DataModel> extends DocumentViewModel
public boolean isAbleToDelete() public boolean isAbleToDelete()
{ {
if (isSeasonFilter()
&&(!seasonService.getActive().equals(selSeason))) {
return false;
}
return this.isRecordSelected(); return this.isRecordSelected();
} }
public boolean isAbleToAdd() public boolean isAbleToAdd()
{ {
if (isSeasonFilter()
&&(!seasonService.getActive().equals(selSeason))) {
return false;
}
return true; 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 @Command
public void numSeries() 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(); window.doModal();
} }

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

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

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

@ -37,7 +37,7 @@ public class TripRequirementListWorkgroup extends RequirementSubpage<TripRequire
private List<Workgroup> myWorkgroups; private List<Workgroup> myWorkgroups;
@Init @Init(superclass = true)
public void init() { public void init() {
service = tripRequirementService; service = tripRequirementService;
dataClass = TripRequirement.class; 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.TripBillApproval"></mapping>
<mapping class="info.bukova.isspst.data.SignedDocument"></mapping> <mapping class="info.bukova.isspst.data.SignedDocument"></mapping>
<mapping class="info.bukova.isspst.data.SignedDocumentItem"></mapping> <mapping class="info.bukova.isspst.data.SignedDocumentItem"></mapping>
<mapping class="info.bukova.isspst.data.Season"></mapping>
</session-factory> </session-factory>
</hibernate-configuration> </hibernate-configuration>

@ -431,3 +431,16 @@ ContextMenu = Volby v kontextovém menu
ErrMaterialOrServiceDescription=Zadejte popis požadavku. 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í.

@ -191,6 +191,10 @@
<bean id="sessionData" class="info.bukova.isspst.SessionData" scope="session"> <bean id="sessionData" class="info.bukova.isspst.SessionData" scope="session">
<aop:scoped-proxy/> <aop:scoped-proxy/>
</bean> </bean>
<bean id="hqlFilter" class="info.bukova.isspst.services.HqlDataFilter" scope="request">
<aop:scoped-proxy/>
</bean>
<!-- DAO --> <!-- DAO -->
<bean id="queryDao" class="info.bukova.isspst.dao.jpa.QueryDaoJPA"> <bean id="queryDao" class="info.bukova.isspst.dao.jpa.QueryDaoJPA">
@ -280,6 +284,10 @@
<bean id="signedDocumentDao" class="info.bukova.isspst.dao.jpa.SignedDocumentDaoJPA"> <bean id="signedDocumentDao" class="info.bukova.isspst.dao.jpa.SignedDocumentDaoJPA">
<property name="sessionFactory" ref="sessionFactory"/> <property name="sessionFactory" ref="sessionFactory"/>
</bean> </bean>
<bean id="seasonDao" class="info.bukova.isspst.dao.jpa.SeasonDaoJPA">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- Business logic --> <!-- Business logic -->
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/> <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/>
@ -466,4 +474,8 @@
<bean id="signedDocumentService" class="info.bukova.isspst.services.signeddocs.SignedDocumentServiceImpl"> <bean id="signedDocumentService" class="info.bukova.isspst.services.signeddocs.SignedDocumentServiceImpl">
<property name="dao" ref="signedDocumentDao"/> <property name="dao" ref="signedDocumentDao"/>
</bean> </bean>
<bean id="seasonService" class="info.bukova.isspst.services.settings.SeasonServiceImpl">
<property name="dao" ref="seasonDao"/>
</bean>
</beans> </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/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/funnel.png" tooltiptext="${labels.ToolbarRecFilter}" id="btnFilter" onClick="@command('filter')" />
<toolbarbutton image="/img/print.png" tooltiptext="${labels.ToolbarPrint}" id="btnPrint" onClick="@command('onPrint')" /> <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> </toolbar>
</zk> </zk>

@ -189,7 +189,7 @@
<listcell label="@load(each.requirement.sumTotal) @converter(vm.standardBigDecimalConverter)" /> <listcell label="@load(each.requirement.sumTotal) @converter(vm.standardBigDecimalConverter)" />
<listcell <listcell
label="@load(each.totalInvoiced) @converter(vm.standardBigDecimalConverter)" 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> </listitem>
</template> </template>
</listbox> </listbox>

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

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

@ -4,6 +4,8 @@
hflex="7" hflex="7"
itemRenderer="@load(vm.requirementsItemRenderer)" itemRenderer="@load(vm.requirementsItemRenderer)"
selectedItem="@bind(vm.dataBean)" selectedItem="@bind(vm.dataBean)"
mold="paging"
autopaging="true"
model="@load(vm.dataList)" model="@load(vm.dataList)"
onAfterRender="@command('afterRender')" onAfterRender="@command('afterRender')"
selectedIndex="@bind(vm.selIndex)"> 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/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/funnel.png" tooltiptext="${labels.ToolbarRecFilter}" id="btnFilter" onClick="@command('filter')" />
<toolbarbutton image="/img/print.png" tooltiptext="${labels.ToolbarPrint}" id="btnPrint" onClick="@command('onPrint')" /> <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> </toolbar>
</zk> </zk>

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

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

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

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

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