From d37076cd2785a3171a9c3f0cdef82153b79d1aed Mon Sep 17 00:00:00 2001 From: Franta Pribyl Date: Mon, 19 Jan 2015 13:20:43 +0100 Subject: [PATCH] =?UTF-8?q?Implementov=C3=A1na=20verze=20DB=20a=20p=C5=99e?= =?UTF-8?q?vod=20DB.=20Nov=C3=A9=20DB=20maj=C3=AD=20d=C3=A9lku=20nastaveno?= =?UTF-8?q?u=20anotac=C3=AD.=20ZUL=20soubory=20jsou=20omezeny=20atributem?= =?UTF-8?q?=20maxlength.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #186 --- .../info/bukova/isspst/AppInitListener.java | 23 ++++ .../java/info/bukova/isspst/Constants.java | 15 ++- .../info/bukova/isspst/dao/DbInfoDao.java | 7 ++ .../bukova/isspst/dao/jpa/DbInfoDaoJPA.java | 9 ++ .../java/info/bukova/isspst/data/Address.java | 3 +- .../info/bukova/isspst/data/Building.java | 4 +- .../java/info/bukova/isspst/data/DbInfo.java | 28 +++++ .../java/info/bukova/isspst/data/MUnit.java | 3 +- .../info/bukova/isspst/data/MUnitEmb.java | 3 +- .../java/info/bukova/isspst/data/Order.java | 10 +- .../info/bukova/isspst/data/OrderItem.java | 4 +- .../info/bukova/isspst/data/Permission.java | 4 +- .../bukova/isspst/data/RequirementBase.java | 4 +- .../bukova/isspst/data/RequirementItem.java | 4 +- .../isspst/data/RequirementSubject.java | 4 +- .../bukova/isspst/data/RequirementType.java | 6 +- .../java/info/bukova/isspst/data/Role.java | 4 +- .../info/bukova/isspst/data/TripBillItem.java | 4 +- .../java/info/bukova/isspst/data/Vehicle.java | 4 +- .../isspst/services/dbinfo/DbInfoService.java | 11 ++ .../services/dbinfo/DbInfoServiceImpl.java | 117 ++++++++++++++++++ .../bukova/isspst/ui/DocumentViewModel.java | 11 ++ .../info/bukova/isspst/ui/mail/MailForm.java | 6 +- .../isspst/ui/reporting/ColSelectVM.java | 7 +- .../isspst/ui/reporting/OrderOptionsVM.java | 7 +- .../isspst/ui/reporting/ReportDialogVM.java | 6 +- .../bukova/isspst/ui/reporting/ReportVM.java | 8 +- .../bukova/isspst/ui/requirement/LimitVM.java | 7 +- .../ui/requirement/OfferedCentresVM.java | 17 +-- .../isspst/ui/settings/GlobalSettingsVM.java | 6 +- .../isspst/ui/settings/NumberSeriesVM.java | 16 +-- .../isspst/ui/settings/UserSettingsVM.java | 7 +- .../info/bukova/isspst/ui/users/PasswdVM.java | 6 +- src/main/resources/hibernate.cfg.xml | 1 + .../webapp/WEB-INF/spring/root-context.xml | 10 +- src/main/webapp/admin/users/userForm.zul | 32 +++-- src/main/webapp/admin/users/users.zul | 28 ++++- .../webapp/admin/workgroups/workgroupForm.zul | 27 +++- .../webapp/admin/workgroups/workgroups.zul | 2 + src/main/webapp/app/mailForm.zul | 14 ++- src/main/webapp/app/passwd.zul | 24 +++- src/main/webapp/app/reporting/colSelect.zul | 5 +- src/main/webapp/lists/addressbook/address.zul | 54 ++++++-- .../webapp/lists/addressbook/addressbook.zul | 42 ++++++- src/main/webapp/lists/buildings/building.zul | 3 + .../webapp/lists/buildings/buildingForm.zul | 8 ++ src/main/webapp/lists/material/material.zul | 3 + .../webapp/lists/material/materialForm.zul | 3 + src/main/webapp/lists/munits/munitsForm.zul | 2 + src/main/webapp/lists/munits/munitsGrid.zul | 2 + src/main/webapp/lists/service/service.zul | 3 + src/main/webapp/lists/service/serviceForm.zul | 3 + .../webapp/main/invoicing/invoicingForm.zul | 8 +- .../webapp/main/invoicing/invoicingGrid.zul | 4 + src/main/webapp/main/orders/approved/grid.zul | 8 ++ src/main/webapp/main/orders/created/grid.zul | 3 + .../webapp/main/orders/created/orderForm.zul | 40 ++++++ .../main/orders/material/selectMaterial.zul | 3 + .../main/orders/requirements/reqForm.zul | 10 ++ .../main/orders/requirements/reqListMy.zul | 3 + .../main/orders/requirements/reqListMyAll.zul | 3 + .../orders/requirements/reqListMyCenters.zul | 3 + .../requirements/reqListMyWorkgroups.zul | 3 + .../main/orders/requirements/selectItems.zul | 6 + .../main/orders/services/selectServices.zul | 3 + .../webapp/main/trips/bill/tripBillForm.zul | 50 ++++++-- .../webapp/main/trips/bill/tripBillGrid.zul | 2 + .../main/trips/requirements/reqListMy.zul | 3 + .../main/trips/requirements/reqListMyAll.zul | 3 + .../trips/requirements/reqListMyCenters.zul | 3 + .../requirements/reqListMyWorkgroups.zul | 3 + .../trips/requirements/requirementsForm.zul | 10 +- src/main/webapp/settings/global/address.zul | 66 ++++++++-- src/main/webapp/settings/global/bank.zul | 16 ++- src/main/webapp/settings/global/email.zul | 21 +++- .../webapp/settings/global/travelOrders.zul | 36 +++++- src/main/webapp/settings/numberSeries.zul | 4 +- src/main/webapp/settings/workflow/limit.zul | 4 +- 78 files changed, 823 insertions(+), 136 deletions(-) create mode 100644 src/main/java/info/bukova/isspst/dao/DbInfoDao.java create mode 100644 src/main/java/info/bukova/isspst/dao/jpa/DbInfoDaoJPA.java create mode 100644 src/main/java/info/bukova/isspst/data/DbInfo.java create mode 100644 src/main/java/info/bukova/isspst/services/dbinfo/DbInfoService.java create mode 100644 src/main/java/info/bukova/isspst/services/dbinfo/DbInfoServiceImpl.java diff --git a/src/main/java/info/bukova/isspst/AppInitListener.java b/src/main/java/info/bukova/isspst/AppInitListener.java index 1f9a3e73..faf46c08 100644 --- a/src/main/java/info/bukova/isspst/AppInitListener.java +++ b/src/main/java/info/bukova/isspst/AppInitListener.java @@ -11,6 +11,7 @@ import info.bukova.isspst.data.User; import info.bukova.isspst.reporting.Report; import info.bukova.isspst.reporting.ReportMapping; import info.bukova.isspst.reporting.ReportType; +import info.bukova.isspst.services.dbinfo.DbInfoService; import info.bukova.isspst.services.munits.MUnitService; import info.bukova.isspst.services.numberseries.NumberSeriesService; import info.bukova.isspst.services.requirement.RequirementTypeService; @@ -33,6 +34,8 @@ import org.springframework.web.context.support.WebApplicationContextUtils; public class AppInitListener implements ServletContextListener { + + private DbInfoService dbInfoService; private MUnitService mUnitsService; private RoleService roleService; private UserService userService; @@ -52,6 +55,7 @@ public class AppInitListener implements ServletContextListener { logger.info("Initializing database"); WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(evt.getServletContext()); + dbInfoService = ctx.getBean(DbInfoService.class); mUnitsService = ctx.getBean(MUnitService.class); roleService = ctx.getBean(RoleService.class); userService = ctx.getBean(UserService.class); @@ -61,6 +65,7 @@ public class AppInitListener implements ServletContextListener { reqTypeService = ctx.getBean(RequirementTypeService.class); userService.grantAdmin(); + this.checkDbInfo(); checkMUnits(); checkRoles(); checkUsers(); @@ -74,6 +79,24 @@ public class AppInitListener implements ServletContextListener { loadModuleReports(); } + private void checkDbInfo() + { + List userList = userService.getAll(); + + if (userList.isEmpty()) + { + // Database is new/empty, column definition is anotated - set actual + // database version + dbInfoService.updateDatabaseVersion(); + } + else + { + // Existing database - try change structure and set actual database + // version... + dbInfoService.changeDatabase(); + } + } + private void checkMUnits() { List mUnits = mUnitsService.getAll(); diff --git a/src/main/java/info/bukova/isspst/Constants.java b/src/main/java/info/bukova/isspst/Constants.java index 4ec1b8db..024e15f1 100644 --- a/src/main/java/info/bukova/isspst/Constants.java +++ b/src/main/java/info/bukova/isspst/Constants.java @@ -1,9 +1,5 @@ package info.bukova.isspst; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - import info.bukova.isspst.data.Permission; import info.bukova.isspst.data.PermissionType; import info.bukova.isspst.data.Requirement; @@ -28,8 +24,14 @@ import info.bukova.isspst.services.users.RoleService; import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.services.workgroups.WorkgroupService; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + public class Constants { - + + public final static long DB_VERSION = 1; + public final static String DEF_ADMIN = "admin"; public final static String DEF_ADMIN_PASSWD = "admin"; public final static String ROLE_USER = "ROLE_USER"; @@ -145,4 +147,7 @@ public class Constants { put(Requirement.class, "/main/orders/"); put(TripRequirement.class, "/main/trips/requirements/"); }} ); + + public final static int LEN_TEXT = 255; + public final static int LEN_DESCRIPTION = 8192; } diff --git a/src/main/java/info/bukova/isspst/dao/DbInfoDao.java b/src/main/java/info/bukova/isspst/dao/DbInfoDao.java new file mode 100644 index 00000000..22ff69e1 --- /dev/null +++ b/src/main/java/info/bukova/isspst/dao/DbInfoDao.java @@ -0,0 +1,7 @@ +package info.bukova.isspst.dao; + +import info.bukova.isspst.data.DbInfo; + +public interface DbInfoDao extends BaseDao +{ +} diff --git a/src/main/java/info/bukova/isspst/dao/jpa/DbInfoDaoJPA.java b/src/main/java/info/bukova/isspst/dao/jpa/DbInfoDaoJPA.java new file mode 100644 index 00000000..8ca0fa37 --- /dev/null +++ b/src/main/java/info/bukova/isspst/dao/jpa/DbInfoDaoJPA.java @@ -0,0 +1,9 @@ +package info.bukova.isspst.dao.jpa; + +import info.bukova.isspst.dao.DbInfoDao; +import info.bukova.isspst.data.DbInfo; + +public class DbInfoDaoJPA extends BaseDaoJPA implements DbInfoDao +{ + +} diff --git a/src/main/java/info/bukova/isspst/data/Address.java b/src/main/java/info/bukova/isspst/data/Address.java index 1f8e6bed..51235fa5 100644 --- a/src/main/java/info/bukova/isspst/data/Address.java +++ b/src/main/java/info/bukova/isspst/data/Address.java @@ -1,5 +1,6 @@ package info.bukova.isspst.data; +import info.bukova.isspst.Constants; import info.bukova.isspst.StringUtils; import java.util.ArrayList; @@ -45,7 +46,7 @@ public class Address extends BaseData private String email; @Column(name = "WEB") private String web; - @Column(name = "DESCRIPTION") + @Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION) private String description; @NotNull(message = "Zadejte firmu") diff --git a/src/main/java/info/bukova/isspst/data/Building.java b/src/main/java/info/bukova/isspst/data/Building.java index 424ce803..d5b196a6 100644 --- a/src/main/java/info/bukova/isspst/data/Building.java +++ b/src/main/java/info/bukova/isspst/data/Building.java @@ -1,5 +1,7 @@ package info.bukova.isspst.data; +import info.bukova.isspst.Constants; + import java.util.ArrayList; import java.util.List; @@ -23,7 +25,7 @@ public class Building extends BaseData implements DataModel { @Column(name = "NAME") private String name; - @Column(name = "DESCRIPTION") + @Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION) private String description; @OneToMany(cascade = CascadeType.ALL, mappedBy = "building", orphanRemoval = true) diff --git a/src/main/java/info/bukova/isspst/data/DbInfo.java b/src/main/java/info/bukova/isspst/data/DbInfo.java new file mode 100644 index 00000000..936d498f --- /dev/null +++ b/src/main/java/info/bukova/isspst/data/DbInfo.java @@ -0,0 +1,28 @@ +package info.bukova.isspst.data; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Table; + +@Entity +@Table(name = "DBINFO") +public class DbInfo extends BaseSimpleData +{ + @Column(name = "VERSION") + private long version; + + public DbInfo() + { + this.version = 0; + } + + public long getVersion() + { + return version; + } + + public void setVersion(long version) + { + this.version = version; + } +} diff --git a/src/main/java/info/bukova/isspst/data/MUnit.java b/src/main/java/info/bukova/isspst/data/MUnit.java index a7fcdc12..ceb87658 100644 --- a/src/main/java/info/bukova/isspst/data/MUnit.java +++ b/src/main/java/info/bukova/isspst/data/MUnit.java @@ -1,5 +1,6 @@ package info.bukova.isspst.data; +import info.bukova.isspst.Constants; import info.bukova.isspst.StringUtils; import javax.persistence.Column; @@ -13,7 +14,7 @@ public class MUnit extends BaseData @Column(name = "NAME") private String name; - @Column(name = "DESCRIPTION") + @Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION) private String description; public String getName() diff --git a/src/main/java/info/bukova/isspst/data/MUnitEmb.java b/src/main/java/info/bukova/isspst/data/MUnitEmb.java index eac5c9db..710ba805 100644 --- a/src/main/java/info/bukova/isspst/data/MUnitEmb.java +++ b/src/main/java/info/bukova/isspst/data/MUnitEmb.java @@ -1,5 +1,6 @@ package info.bukova.isspst.data; +import info.bukova.isspst.Constants; import info.bukova.isspst.StringUtils; import javax.persistence.Column; @@ -14,7 +15,7 @@ public class MUnitEmb @Column(name = "MUNIT_NAME") private String name; - @Column(name = "MUNIT_DESCRIPTION") + @Column(name = "MUNIT_DESCRIPTION", length = Constants.LEN_DESCRIPTION) private String description; public MUnitEmb() diff --git a/src/main/java/info/bukova/isspst/data/Order.java b/src/main/java/info/bukova/isspst/data/Order.java index 79348edb..854c3c40 100644 --- a/src/main/java/info/bukova/isspst/data/Order.java +++ b/src/main/java/info/bukova/isspst/data/Order.java @@ -1,5 +1,7 @@ package info.bukova.isspst.data; +import info.bukova.isspst.Constants; + import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; @@ -35,7 +37,7 @@ public class Order extends BaseData implements Cloneable @AttributeOverride(name = "company", column = @Column(name = "SUPPLIER_COMPANY")), @AttributeOverride(name = "contactName", column = @Column(name = "SUPPLIER_CONTACT_NAME")), @AttributeOverride(name = "department", column = @Column(name = "SUPPLIER_DEPARTMENT")), - @AttributeOverride(name = "description", column = @Column(name = "SUPPLIER_DESCRIPTION")), + @AttributeOverride(name = "description", column = @Column(name = "SUPPLIER_DESCRIPTION", length = Constants.LEN_DESCRIPTION)), @AttributeOverride(name = "dic", column = @Column(name = "SUPPLIER_DIC")), @AttributeOverride(name = "email", column = @Column(name = "SUPPLIER_EMAIL")), @AttributeOverride(name = "houseNumber", column = @Column(name = "SUPPLIER_HOUSENUMBER")), @@ -54,7 +56,7 @@ public class Order extends BaseData implements Cloneable @AttributeOverride(name = "company", column = @Column(name = "INVOICE_COMPANY")), @AttributeOverride(name = "contactName", column = @Column(name = "INVOICE_CONTACT_NAME")), @AttributeOverride(name = "department", column = @Column(name = "INVOICE_DEPARTMENT")), - @AttributeOverride(name = "description", column = @Column(name = "INVOICE_DESCRIPTION")), + @AttributeOverride(name = "description", column = @Column(name = "INVOICE_DESCRIPTION", length = Constants.LEN_DESCRIPTION)), @AttributeOverride(name = "dic", column = @Column(name = "INVOICE_DIC")), @AttributeOverride(name = "email", column = @Column(name = "INVOICE_EMAIL")), @AttributeOverride(name = "houseNumber", column = @Column(name = "INVOICE_HOUSENUMBER")), @@ -73,7 +75,7 @@ public class Order extends BaseData implements Cloneable @AttributeOverride(name = "company", column = @Column(name = "DELIVERY_COMPANY")), @AttributeOverride(name = "contactName", column = @Column(name = "DELIVERY_CONTACT_NAME")), @AttributeOverride(name = "department", column = @Column(name = "DELIVERY_DEPARTMENT")), - @AttributeOverride(name = "description", column = @Column(name = "DELIVERY_DESCRIPTION")), + @AttributeOverride(name = "description", column = @Column(name = "DELIVERY_DESCRIPTION", length = Constants.LEN_DESCRIPTION)), @AttributeOverride(name = "dic", column = @Column(name = "DELIVERY_DIC")), @AttributeOverride(name = "email", column = @Column(name = "DELIVERY_EMAIL")), @AttributeOverride(name = "houseNumber", column = @Column(name = "DELIVERY_HOUSENUMBER")), @@ -94,7 +96,7 @@ public class Order extends BaseData implements Cloneable @Column(name = "DELIVERY_TYPE") private String deliveryType; - @Column(name = "DESCRIPTION") + @Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION) private String description; @OneToMany(cascade = CascadeType.ALL, mappedBy = "order", orphanRemoval = true) diff --git a/src/main/java/info/bukova/isspst/data/OrderItem.java b/src/main/java/info/bukova/isspst/data/OrderItem.java index 16f26a24..7cd3ff3f 100644 --- a/src/main/java/info/bukova/isspst/data/OrderItem.java +++ b/src/main/java/info/bukova/isspst/data/OrderItem.java @@ -1,5 +1,7 @@ package info.bukova.isspst.data; +import info.bukova.isspst.Constants; + import java.math.BigDecimal; import javax.persistence.Column; @@ -43,7 +45,7 @@ public class OrderItem @Column(name = "TOTAL", precision = 15, scale = 4) private BigDecimal total; - @Column(name = "DESCRIPTION") + @Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION) private String description; @ManyToOne(fetch = FetchType.EAGER) diff --git a/src/main/java/info/bukova/isspst/data/Permission.java b/src/main/java/info/bukova/isspst/data/Permission.java index 5ab15ab4..a56619f1 100644 --- a/src/main/java/info/bukova/isspst/data/Permission.java +++ b/src/main/java/info/bukova/isspst/data/Permission.java @@ -1,5 +1,7 @@ package info.bukova.isspst.data; +import info.bukova.isspst.Constants; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.EnumType; @@ -19,7 +21,7 @@ public class Permission extends BaseSimpleData implements GrantedAuthority { @Column(name="AUTHORITY") private String authority; - @Column(name="DESCRIPTION") + @Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION) private String description; @Column(name="MODULE") private String module; diff --git a/src/main/java/info/bukova/isspst/data/RequirementBase.java b/src/main/java/info/bukova/isspst/data/RequirementBase.java index a9a549a3..035ce2ef 100644 --- a/src/main/java/info/bukova/isspst/data/RequirementBase.java +++ b/src/main/java/info/bukova/isspst/data/RequirementBase.java @@ -1,5 +1,7 @@ package info.bukova.isspst.data; +import info.bukova.isspst.Constants; + import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -32,7 +34,7 @@ public class RequirementBase extends BaseData implements FilterableRequirement { private String numser; @Column(name = "REQ_DATE") private Date reqDate; - @Column(name = "DESCRIPTION") + @Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION) private String description; @ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "CENTRE_ID") diff --git a/src/main/java/info/bukova/isspst/data/RequirementItem.java b/src/main/java/info/bukova/isspst/data/RequirementItem.java index 20c7e95a..c8e8011c 100644 --- a/src/main/java/info/bukova/isspst/data/RequirementItem.java +++ b/src/main/java/info/bukova/isspst/data/RequirementItem.java @@ -1,5 +1,7 @@ package info.bukova.isspst.data; +import info.bukova.isspst.Constants; + import java.math.BigDecimal; import javax.persistence.Column; @@ -50,7 +52,7 @@ public class RequirementItem @Column(name = "TOTAL", precision=15, scale=4) private BigDecimal total; - @Column(name = "DESCRIPTION") + @Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION) private String description; @Column(name = "DELIVERED") diff --git a/src/main/java/info/bukova/isspst/data/RequirementSubject.java b/src/main/java/info/bukova/isspst/data/RequirementSubject.java index 8b05b9ea..ef88f442 100644 --- a/src/main/java/info/bukova/isspst/data/RequirementSubject.java +++ b/src/main/java/info/bukova/isspst/data/RequirementSubject.java @@ -1,5 +1,7 @@ package info.bukova.isspst.data; +import info.bukova.isspst.Constants; + import java.util.Date; import javax.persistence.Column; @@ -42,7 +44,7 @@ public abstract class RequirementSubject implements OwnedDataModel { private String code; @Column(name = "NAME") private String name; - @Column(name = "DESCRIPTION") + @Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION) private String description; @NotEmpty(message = "{MaterialFormCodeConstr}") diff --git a/src/main/java/info/bukova/isspst/data/RequirementType.java b/src/main/java/info/bukova/isspst/data/RequirementType.java index af399193..6adaabbb 100644 --- a/src/main/java/info/bukova/isspst/data/RequirementType.java +++ b/src/main/java/info/bukova/isspst/data/RequirementType.java @@ -1,13 +1,15 @@ package info.bukova.isspst.data; +import info.bukova.isspst.Constants; + import java.util.ArrayList; import java.util.List; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; -import javax.persistence.JoinTable; import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.OneToMany; import javax.persistence.OrderBy; @@ -22,7 +24,7 @@ public class RequirementType extends BaseData { @Column(name = "TYPE") private String type; - @Column(name = "DESCRIPTION") + @Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION) private String description; @OneToMany(cascade = CascadeType.ALL, orphanRemoval=true) @LazyCollection(LazyCollectionOption.FALSE) diff --git a/src/main/java/info/bukova/isspst/data/Role.java b/src/main/java/info/bukova/isspst/data/Role.java index 338681bf..ad7876cd 100644 --- a/src/main/java/info/bukova/isspst/data/Role.java +++ b/src/main/java/info/bukova/isspst/data/Role.java @@ -1,5 +1,7 @@ package info.bukova.isspst.data; +import info.bukova.isspst.Constants; + import java.util.ArrayList; import java.util.List; @@ -25,7 +27,7 @@ public class Role extends BaseSimpleData implements GrantedAuthority, DataModel @Column(name="AUTHORITY", unique=true) private String authority; - @Column(name="DESCRIPTION") + @Column(name = "DESCRIPTION", length = Constants.LEN_DESCRIPTION) private String description; @ManyToMany @LazyCollection(LazyCollectionOption.FALSE) diff --git a/src/main/java/info/bukova/isspst/data/TripBillItem.java b/src/main/java/info/bukova/isspst/data/TripBillItem.java index 153e54ac..577f01a6 100644 --- a/src/main/java/info/bukova/isspst/data/TripBillItem.java +++ b/src/main/java/info/bukova/isspst/data/TripBillItem.java @@ -1,5 +1,7 @@ package info.bukova.isspst.data; +import info.bukova.isspst.Constants; + import java.math.BigDecimal; import java.util.Date; @@ -33,7 +35,7 @@ public class TripBillItem extends BaseData { @Embedded @AttributeOverrides({ @AttributeOverride(name = "code", column = @Column(name = "BACK_VEHICLE_CODE")), - @AttributeOverride(name = "description", column = @Column(name = "BACK_VEHICLE_DESCRIPTION")) + @AttributeOverride(name = "description", column = @Column(name = "BACK_VEHICLE_DESCRIPTION", length = Constants.LEN_DESCRIPTION)) }) private Vehicle backVehicle; @Column(name = "BEGIN_WORK") diff --git a/src/main/java/info/bukova/isspst/data/Vehicle.java b/src/main/java/info/bukova/isspst/data/Vehicle.java index e0a9da88..e587c90f 100644 --- a/src/main/java/info/bukova/isspst/data/Vehicle.java +++ b/src/main/java/info/bukova/isspst/data/Vehicle.java @@ -1,5 +1,7 @@ package info.bukova.isspst.data; +import info.bukova.isspst.Constants; + import javax.persistence.Column; import javax.persistence.Embeddable; @@ -8,7 +10,7 @@ public class Vehicle { @Column(name = "VEHICLE_CODE") private String code; - @Column(name = "VEHICLE_DESCRIPTION") + @Column(name = "VEHICLE_DESCRIPTION", length = Constants.LEN_DESCRIPTION) private String description; public String getCode() { diff --git a/src/main/java/info/bukova/isspst/services/dbinfo/DbInfoService.java b/src/main/java/info/bukova/isspst/services/dbinfo/DbInfoService.java new file mode 100644 index 00000000..e6470a72 --- /dev/null +++ b/src/main/java/info/bukova/isspst/services/dbinfo/DbInfoService.java @@ -0,0 +1,11 @@ +package info.bukova.isspst.services.dbinfo; + +import info.bukova.isspst.data.DbInfo; +import info.bukova.isspst.services.Service; + +public interface DbInfoService extends Service +{ + public void changeDatabase(); + + public void updateDatabaseVersion(); +} diff --git a/src/main/java/info/bukova/isspst/services/dbinfo/DbInfoServiceImpl.java b/src/main/java/info/bukova/isspst/services/dbinfo/DbInfoServiceImpl.java new file mode 100644 index 00000000..a859a28e --- /dev/null +++ b/src/main/java/info/bukova/isspst/services/dbinfo/DbInfoServiceImpl.java @@ -0,0 +1,117 @@ +package info.bukova.isspst.services.dbinfo; + +import info.bukova.isspst.Constants; +import info.bukova.isspst.data.DbInfo; +import info.bukova.isspst.services.AbstractService; + +import java.util.ArrayList; +import java.util.List; + +import org.hibernate.SQLQuery; +import org.springframework.transaction.annotation.Transactional; + +public class DbInfoServiceImpl extends AbstractService implements DbInfoService +{ + private DbInfo getDbInfo() + { + DbInfo dbInfo = null; + + List list = this.getAll(); + + if (list.isEmpty()) + { + dbInfo = new DbInfo(); + this.add(dbInfo); + list = this.getAll(); + } + + for (DbInfo item : list) + { + dbInfo = item; + break; + } + + return dbInfo; + } + + @Override + @Transactional + public void changeDatabase() + { + class Str2Str + { + private String key; + private String value; + + public Str2Str(String key, String value) + { + this.key = key; + this.value = value; + } + + public String getKey() + { + return this.key; + } + + public String getValue() + { + return this.value; + } + } + + long dbVersion = this.getDbInfo().getVersion(); + + if (Constants.DB_VERSION > dbVersion) + { + if (dbVersion < 1) + { + List tables = new ArrayList(); + tables.add(new Str2Str("address", "DESCRIPTION")); + tables.add(new Str2Str("building", "DESCRIPTION")); + tables.add(new Str2Str("material", "DESCRIPTION")); + tables.add(new Str2Str("munit", "DESCRIPTION")); + tables.add(new Str2Str("orders", "DESCRIPTION")); + tables.add(new Str2Str("order_item", "DESCRIPTION")); + tables.add(new Str2Str("permission", "DESCRIPTION")); + tables.add(new Str2Str("requirement", "DESCRIPTION")); + tables.add(new Str2Str("requirementtype", "DESCRIPTION")); + tables.add(new Str2Str("requirement_items", "DESCRIPTION")); + tables.add(new Str2Str("role", "DESCRIPTION")); + tables.add(new Str2Str("service", "DESCRIPTION")); + tables.add(new Str2Str("triprequirement", "DESCRIPTION")); + + tables.add(new Str2Str("material", "MUNIT_DESCRIPTION")); + tables.add(new Str2Str("orders", "INVOICE_DESCRIPTION")); + tables.add(new Str2Str("orders", "DELIVERY_DESCRIPTION")); + tables.add(new Str2Str("orders", "SUPPLIER_DESCRIPTION")); + tables.add(new Str2Str("order_item", "MUNIT_DESCRIPTION")); + tables.add(new Str2Str("requirement_items", "MUNIT_DESCRIPTION")); + tables.add(new Str2Str("triprequirement", "VEHICLE_DESCRIPTION")); + tables.add(new Str2Str("trip_bill_items", "BACK_VEHICLE_DESCRIPTION")); + tables.add(new Str2Str("trip_bill_items", "VEHICLE_DESCRIPTION")); + + SQLQuery sq = null; + String sql = ""; + + for (Str2Str item : tables) + { + sql = "ALTER TABLE " + item.getKey() + " MODIFY " + item.getValue() + " VARCHAR(" + String.valueOf(Constants.LEN_DESCRIPTION) + ")"; + sq = this.dao.getSession().createSQLQuery(sql); + sq.executeUpdate(); + } + } + + this.updateDatabaseVersion(); + } + } + + @Override + @Transactional + public void updateDatabaseVersion() + { + DbInfo dbInfo = this.getDbInfo(); + dbInfo.setVersion(Constants.DB_VERSION); + this.update(dbInfo); + } +} diff --git a/src/main/java/info/bukova/isspst/ui/DocumentViewModel.java b/src/main/java/info/bukova/isspst/ui/DocumentViewModel.java index 793fb02c..a753f618 100644 --- a/src/main/java/info/bukova/isspst/ui/DocumentViewModel.java +++ b/src/main/java/info/bukova/isspst/ui/DocumentViewModel.java @@ -1,5 +1,6 @@ package info.bukova.isspst.ui; +import info.bukova.isspst.Constants; import info.bukova.isspst.StringUtils; import java.util.ArrayList; @@ -39,6 +40,16 @@ public class DocumentViewModel this.standardBoolConverter = standardBoolConverter; } + final public int getLengthText() + { + return Constants.LEN_TEXT; + } + + final public int getLengthDescription() + { + return Constants.LEN_DESCRIPTION; + } + @Init public void initDocumentViewModel() { diff --git a/src/main/java/info/bukova/isspst/ui/mail/MailForm.java b/src/main/java/info/bukova/isspst/ui/mail/MailForm.java index 3251f430..8d37b12d 100644 --- a/src/main/java/info/bukova/isspst/ui/mail/MailForm.java +++ b/src/main/java/info/bukova/isspst/ui/mail/MailForm.java @@ -14,6 +14,7 @@ import info.bukova.isspst.reporting.GeneratorFactory; import info.bukova.isspst.reporting.ReportDefinition; import info.bukova.isspst.services.addressbook.AdbService; import info.bukova.isspst.services.users.UserService; +import info.bukova.isspst.ui.DocumentViewModel; import java.util.ArrayList; import java.util.List; @@ -27,7 +28,8 @@ import org.zkoss.bind.annotation.NotifyChange; import org.zkoss.zk.ui.select.annotation.WireVariable; import org.zkoss.zul.Window; -public class MailForm { +public class MailForm extends DocumentViewModel +{ @WireVariable private Mailer mailer; @@ -52,7 +54,7 @@ public class MailForm { private int adbType; private String findAddress; - @Init + @Init(superclass = true) public void init(@ExecutionArgParam("report") Boolean report) { message = new MailMessage(); message.setHtml(true); diff --git a/src/main/java/info/bukova/isspst/ui/reporting/ColSelectVM.java b/src/main/java/info/bukova/isspst/ui/reporting/ColSelectVM.java index f22bd68b..0e4b0417 100644 --- a/src/main/java/info/bukova/isspst/ui/reporting/ColSelectVM.java +++ b/src/main/java/info/bukova/isspst/ui/reporting/ColSelectVM.java @@ -4,6 +4,7 @@ import info.bukova.isspst.reporting.Report; import info.bukova.isspst.reporting.ReportDefinition; import info.bukova.isspst.reporting.ReportType; import info.bukova.isspst.sort.ReflectionTools; +import info.bukova.isspst.ui.DocumentViewModel; import info.bukova.isspst.ui.ListChecks; import info.bukova.isspst.ui.LocaleConverter; @@ -12,13 +13,13 @@ import java.util.List; import org.zkoss.bind.annotation.Init; import org.zkoss.zk.ui.select.annotation.WireVariable; -public class ColSelectVM { - +public class ColSelectVM extends DocumentViewModel +{ @WireVariable private ReportDefinition reportDefinition; private LocaleConverter locConverter; - @Init + @Init(superclass = true) public void init() { locConverter = new LocaleConverter(); } diff --git a/src/main/java/info/bukova/isspst/ui/reporting/OrderOptionsVM.java b/src/main/java/info/bukova/isspst/ui/reporting/OrderOptionsVM.java index 789ab185..05d7784e 100644 --- a/src/main/java/info/bukova/isspst/ui/reporting/OrderOptionsVM.java +++ b/src/main/java/info/bukova/isspst/ui/reporting/OrderOptionsVM.java @@ -1,17 +1,18 @@ package info.bukova.isspst.ui.reporting; import info.bukova.isspst.reporting.ReportDefinition; +import info.bukova.isspst.ui.DocumentViewModel; import org.zkoss.bind.annotation.Init; import org.zkoss.zk.ui.select.annotation.WireVariable; -public class OrderOptionsVM { - +public class OrderOptionsVM extends DocumentViewModel +{ private boolean printPrices; @WireVariable private ReportDefinition reportDefinition; - @Init + @Init(superclass = true) public void init() { printPrices = true; reportDefinition.setParam("SET_PRICES", true); diff --git a/src/main/java/info/bukova/isspst/ui/reporting/ReportDialogVM.java b/src/main/java/info/bukova/isspst/ui/reporting/ReportDialogVM.java index fd56e04b..08086e7d 100644 --- a/src/main/java/info/bukova/isspst/ui/reporting/ReportDialogVM.java +++ b/src/main/java/info/bukova/isspst/ui/reporting/ReportDialogVM.java @@ -4,6 +4,7 @@ import info.bukova.isspst.reporting.Report; import info.bukova.isspst.reporting.ReportDefinition; import info.bukova.isspst.reporting.ReportType; import info.bukova.isspst.services.Service; +import info.bukova.isspst.ui.DocumentViewModel; import java.util.List; @@ -16,7 +17,8 @@ import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.select.annotation.WireVariable; import org.zkoss.zul.Window; -public class ReportDialogVM { +public class ReportDialogVM extends DocumentViewModel +{ private List reports; private Report selected; @@ -25,7 +27,7 @@ public class ReportDialogVM { private List dataList; private Object singleObject; - @Init + @Init(superclass = true) public void init(@ExecutionArgParam("reports") List reports, @ExecutionArgParam("data") List data, @ExecutionArgParam("singleObject") Object singleObject, diff --git a/src/main/java/info/bukova/isspst/ui/reporting/ReportVM.java b/src/main/java/info/bukova/isspst/ui/reporting/ReportVM.java index dd0f4dcd..976eb9e7 100644 --- a/src/main/java/info/bukova/isspst/ui/reporting/ReportVM.java +++ b/src/main/java/info/bukova/isspst/ui/reporting/ReportVM.java @@ -1,5 +1,7 @@ package info.bukova.isspst.ui.reporting; +import info.bukova.isspst.ui.DocumentViewModel; + import java.util.HashMap; import java.util.Map; @@ -8,9 +10,9 @@ import org.zkoss.bind.annotation.Init; import org.zkoss.zk.ui.Executions; import org.zkoss.zul.Window; -public class ReportVM { - - @Init +public class ReportVM extends DocumentViewModel +{ + @Init(superclass = true) public void init() { } diff --git a/src/main/java/info/bukova/isspst/ui/requirement/LimitVM.java b/src/main/java/info/bukova/isspst/ui/requirement/LimitVM.java index 84994981..3ac722b3 100644 --- a/src/main/java/info/bukova/isspst/ui/requirement/LimitVM.java +++ b/src/main/java/info/bukova/isspst/ui/requirement/LimitVM.java @@ -1,6 +1,7 @@ package info.bukova.isspst.ui.requirement; import info.bukova.isspst.data.Workflow; +import info.bukova.isspst.ui.DocumentViewModel; import org.zkoss.bind.annotation.BindingParam; import org.zkoss.bind.annotation.Command; @@ -8,11 +9,11 @@ import org.zkoss.bind.annotation.ExecutionArgParam; import org.zkoss.bind.annotation.Init; import org.zkoss.zul.Window; -public class LimitVM { - +public class LimitVM extends DocumentViewModel +{ private Workflow workflow; - @Init + @Init(superclass = true) public void init(@ExecutionArgParam("workflow") Workflow workflow) { this.workflow = workflow; } diff --git a/src/main/java/info/bukova/isspst/ui/requirement/OfferedCentresVM.java b/src/main/java/info/bukova/isspst/ui/requirement/OfferedCentresVM.java index 0d6de93c..16ec1760 100644 --- a/src/main/java/info/bukova/isspst/ui/requirement/OfferedCentresVM.java +++ b/src/main/java/info/bukova/isspst/ui/requirement/OfferedCentresVM.java @@ -1,5 +1,11 @@ package info.bukova.isspst.ui.requirement; +import info.bukova.isspst.data.RequirementType; +import info.bukova.isspst.data.Workgroup; +import info.bukova.isspst.services.workgroups.WorkgroupService; +import info.bukova.isspst.ui.DocumentViewModel; +import info.bukova.isspst.ui.ListChecks; + import org.zkoss.bind.annotation.BindingParam; import org.zkoss.bind.annotation.Command; import org.zkoss.bind.annotation.ExecutionArgParam; @@ -7,19 +13,14 @@ import org.zkoss.bind.annotation.Init; import org.zkoss.zk.ui.select.annotation.WireVariable; import org.zkoss.zul.Window; -import info.bukova.isspst.data.RequirementType; -import info.bukova.isspst.data.Workgroup; -import info.bukova.isspst.services.workgroups.WorkgroupService; -import info.bukova.isspst.ui.ListChecks; - -public class OfferedCentresVM { - +public class OfferedCentresVM extends DocumentViewModel +{ private RequirementType selectedType; @WireVariable private WorkgroupService workgroupService; private ListChecks wgChecks; - @Init + @Init(superclass = true) public void init(@ExecutionArgParam("type") RequirementType type) { this.selectedType = type; wgChecks = new ListChecks(selectedType.getOfferedCentres(), workgroupService.getCentres()); diff --git a/src/main/java/info/bukova/isspst/ui/settings/GlobalSettingsVM.java b/src/main/java/info/bukova/isspst/ui/settings/GlobalSettingsVM.java index 62389f38..fdeda412 100644 --- a/src/main/java/info/bukova/isspst/ui/settings/GlobalSettingsVM.java +++ b/src/main/java/info/bukova/isspst/ui/settings/GlobalSettingsVM.java @@ -9,6 +9,7 @@ import info.bukova.isspst.mail.MailMessage; import info.bukova.isspst.services.settings.GlobalSettingsService; import info.bukova.isspst.sort.ReflectionTools; import info.bukova.isspst.storage.FileStorage; +import info.bukova.isspst.ui.DocumentViewModel; import info.bukova.isspst.ui.LocaleConverter; import info.bukova.isspst.ui.SecurityHelper; @@ -31,7 +32,8 @@ import org.zkoss.zk.ui.event.UploadEvent; import org.zkoss.zk.ui.select.annotation.WireVariable; import org.zkoss.zul.Window; -public class GlobalSettingsVM { +public class GlobalSettingsVM extends DocumentViewModel +{ @WireVariable private GlobalSettingsService settingsService; @@ -42,7 +44,7 @@ public class GlobalSettingsVM { @WireVariable private FileStorage storage; - @Init + @Init(superclass = true) public void init() { settings = settingsService.getSettings(); locConverter = new LocaleConverter(); diff --git a/src/main/java/info/bukova/isspst/ui/settings/NumberSeriesVM.java b/src/main/java/info/bukova/isspst/ui/settings/NumberSeriesVM.java index 7e739c1a..17ca3508 100644 --- a/src/main/java/info/bukova/isspst/ui/settings/NumberSeriesVM.java +++ b/src/main/java/info/bukova/isspst/ui/settings/NumberSeriesVM.java @@ -1,5 +1,11 @@ package info.bukova.isspst.ui.settings; +import info.bukova.isspst.Constants; +import info.bukova.isspst.Module; +import info.bukova.isspst.data.NumberSeries; +import info.bukova.isspst.services.numberseries.NumberSeriesService; +import info.bukova.isspst.ui.DocumentViewModel; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -11,19 +17,15 @@ import org.zkoss.bind.annotation.Init; import org.zkoss.zk.ui.select.annotation.WireVariable; import org.zkoss.zul.Window; -import info.bukova.isspst.Constants; -import info.bukova.isspst.Module; -import info.bukova.isspst.data.NumberSeries; -import info.bukova.isspst.services.numberseries.NumberSeriesService; - -public class NumberSeriesVM { +public class NumberSeriesVM extends DocumentViewModel +{ @WireVariable private NumberSeriesService numericSeriesService; private List numberSeriesList; private Map moduleMap; - @Init + @Init(superclass = true) public void init() { numberSeriesList = new ArrayList(numericSeriesService.getAll()); moduleMap = new HashMap(); diff --git a/src/main/java/info/bukova/isspst/ui/settings/UserSettingsVM.java b/src/main/java/info/bukova/isspst/ui/settings/UserSettingsVM.java index 536261e2..09a23a64 100644 --- a/src/main/java/info/bukova/isspst/ui/settings/UserSettingsVM.java +++ b/src/main/java/info/bukova/isspst/ui/settings/UserSettingsVM.java @@ -3,6 +3,7 @@ package info.bukova.isspst.ui.settings; import info.bukova.isspst.data.UserSettingsData; import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.storage.FileStorage; +import info.bukova.isspst.ui.DocumentViewModel; import java.awt.image.RenderedImage; import java.io.IOException; @@ -19,15 +20,15 @@ import org.zkoss.zk.ui.event.UploadEvent; import org.zkoss.zk.ui.select.annotation.WireVariable; import org.zkoss.zul.Window; -public class UserSettingsVM { - +public class UserSettingsVM extends DocumentViewModel +{ @WireVariable private UserService userService; @WireVariable private FileStorage storage; private UserSettingsData settings; - @Init + @Init(superclass = true) public void init() { settings = userService.getUserSettings(); } diff --git a/src/main/java/info/bukova/isspst/ui/users/PasswdVM.java b/src/main/java/info/bukova/isspst/ui/users/PasswdVM.java index 47286063..a5dac645 100644 --- a/src/main/java/info/bukova/isspst/ui/users/PasswdVM.java +++ b/src/main/java/info/bukova/isspst/ui/users/PasswdVM.java @@ -2,6 +2,7 @@ package info.bukova.isspst.ui.users; import info.bukova.isspst.data.User; import info.bukova.isspst.services.users.UserService; +import info.bukova.isspst.ui.DocumentViewModel; import org.zkoss.bind.annotation.BindingParam; import org.zkoss.bind.annotation.Command; @@ -10,7 +11,8 @@ import org.zkoss.zk.ui.select.annotation.WireVariable; import org.zkoss.zul.Messagebox; import org.zkoss.zul.Window; -public class PasswdVM { +public class PasswdVM extends DocumentViewModel +{ private String oldPw; private String newPw; @@ -19,7 +21,7 @@ public class PasswdVM { @WireVariable private UserService userService; - @Init + @Init(superclass = true) public void init() { user = userService.getCurrent(); } diff --git a/src/main/resources/hibernate.cfg.xml b/src/main/resources/hibernate.cfg.xml index 70d8f8ef..e5ab354a 100644 --- a/src/main/resources/hibernate.cfg.xml +++ b/src/main/resources/hibernate.cfg.xml @@ -5,6 +5,7 @@ + diff --git a/src/main/webapp/WEB-INF/spring/root-context.xml b/src/main/webapp/WEB-INF/spring/root-context.xml index aa91bad8..37b0dfde 100644 --- a/src/main/webapp/WEB-INF/spring/root-context.xml +++ b/src/main/webapp/WEB-INF/spring/root-context.xml @@ -183,6 +183,10 @@ + + + + @@ -258,6 +262,10 @@ + + + + @@ -373,7 +381,7 @@ - + diff --git a/src/main/webapp/admin/users/userForm.zul b/src/main/webapp/admin/users/userForm.zul index 76a75f2c..0b06617c 100644 --- a/src/main/webapp/admin/users/userForm.zul +++ b/src/main/webapp/admin/users/userForm.zul @@ -34,6 +34,7 @@ value="@bind(vm.dataBean.username)" instant="true" disabled="@load(vm.editRec)" + maxlength="@load(vm.lengthText)" onChange="@command('checkLogin')" />