From b633309b74b3cebce00767e1a42bb56b7caf9bcb Mon Sep 17 00:00:00 2001 From: Franta Pribyl Date: Wed, 9 Jul 2014 10:19:09 +0200 Subject: [PATCH] =?UTF-8?q?Pro=20org.codehaus.castor=20p=C5=99id=C3=A1na?= =?UTF-8?q?=20vazba=20na=20xercesImpl.=20Implicitn=C3=AD=20pln=C4=9Bn?= =?UTF-8?q?=C3=AD=20m=C4=9Brn=C3=BDch=20jednotek.=20P=C5=99=C3=ADprava=20p?= =?UTF-8?q?olo=C5=BEek=20pro=20nov=C3=A9=20po=C5=BEadavky.=20Logov=C3=A1n?= =?UTF-8?q?=C3=AD=20ud=C3=A1lost=C3=AD=20prob=C3=ADh=C3=A1=20od=20=C3=BAro?= =?UTF-8?q?vn=C4=9B=20warning.=20Logov=C3=A1n=C3=AD=20hibernate=20dotaz?= =?UTF-8?q?=C5=AF=20deaktivov=C3=A1no.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refs #100 --- pom.xml | 6 + .../info/bukova/isspst/AppInitListener.java | 105 ++++++++++++++ .../java/info/bukova/isspst/data/MUnit.java | 25 +++- .../info/bukova/isspst/data/Requirement.java | 17 +++ .../bukova/isspst/data/RequirementItem.java | 136 ++++++++++++++++++ .../isspst/data/RequirementSubject.java | 2 +- .../ui/requirement/RequirementForm.java | 38 ++--- .../isspst/ui/requirements/SelectItems.java | 82 +++++++++++ src/main/resources/hibernate.cfg.xml | 1 + src/main/resources/log4j.xml | 4 + .../WEB-INF/locales/zk-label.properties | 10 ++ src/main/webapp/lists/munits/munitsGrid.zul | 4 +- .../requirements/actual/requirementsForm.zul | 84 +++++++++++ .../requirements/selectitems/selectItems.zul | 108 ++++++++++++++ 14 files changed, 602 insertions(+), 20 deletions(-) create mode 100644 src/main/java/info/bukova/isspst/data/RequirementItem.java create mode 100644 src/main/java/info/bukova/isspst/ui/requirements/SelectItems.java create mode 100644 src/main/webapp/requirements/selectitems/selectItems.zul diff --git a/pom.xml b/pom.xml index a39e85ea..43dde998 100644 --- a/pom.xml +++ b/pom.xml @@ -294,6 +294,12 @@ spring-xml 1.2.1 + + + xerces + xercesImpl + 2.8.1 + diff --git a/src/main/java/info/bukova/isspst/AppInitListener.java b/src/main/java/info/bukova/isspst/AppInitListener.java index 46e6cbef..e9227b1b 100644 --- a/src/main/java/info/bukova/isspst/AppInitListener.java +++ b/src/main/java/info/bukova/isspst/AppInitListener.java @@ -1,6 +1,7 @@ package info.bukova.isspst; import info.bukova.isspst.data.GlobalSettings; +import info.bukova.isspst.data.MUnit; import info.bukova.isspst.data.NumberSeries; import info.bukova.isspst.data.Permission; import info.bukova.isspst.data.RequirementType; @@ -9,6 +10,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.munits.MUnitService; import info.bukova.isspst.services.numberseries.NumberSeriesService; import info.bukova.isspst.services.requirement.RequirementTypeService; import info.bukova.isspst.services.settings.GlobalSettingsService; @@ -29,6 +31,7 @@ import org.springframework.web.context.support.WebApplicationContextUtils; public class AppInitListener implements ServletContextListener { + private MUnitService mUnitsService; private RoleService roleService; private UserService userService; private PermissionService permService; @@ -47,6 +50,7 @@ public class AppInitListener implements ServletContextListener { logger.info("Initializing database"); WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(evt.getServletContext()); + mUnitsService = ctx.getBean(MUnitService.class); roleService = ctx.getBean(RoleService.class); userService = ctx.getBean(UserService.class); permService = ctx.getBean(PermissionService.class); @@ -55,6 +59,7 @@ public class AppInitListener implements ServletContextListener { reqTypeService = ctx.getBean(RequirementTypeService.class); userService.grantAdmin(); + checkMUnits(); checkRoles(); checkUsers(); checkPermissions(); @@ -67,6 +72,106 @@ public class AppInitListener implements ServletContextListener { loadModuleReports(); } + private void checkMUnits() + { + List mUnits = mUnitsService.getAll(); + + if (mUnits.isEmpty()) + { + MUnit mUnit = new MUnit(); + + mUnit.setCode("ks"); + mUnit.setName("ks"); + mUnit.setDescription("kus (množství)"); + mUnitsService.add(mUnit); + + mUnit.setCode("SI-m"); + mUnit.setName("m"); + mUnit.setDescription("metr (délka)"); + mUnitsService.add(mUnit); + + mUnit.setCode("VEDL-km"); + mUnit.setName("km"); + mUnit.setDescription("kilometr (délka)"); + mUnitsService.add(mUnit); + + mUnit.setCode("SI-kg"); + mUnit.setName("kg"); + mUnit.setDescription("kilogram (hmotnost)"); + mUnitsService.add(mUnit); + + mUnit.setCode("VEDL-g"); + mUnit.setName("g"); + mUnit.setDescription("gram (hmotnost)"); + mUnitsService.add(mUnit); + + mUnit.setCode("VEDL-dkg"); + mUnit.setName("dkg"); + mUnit.setDescription("dekagram (hmotnost)"); + mUnitsService.add(mUnit); + + mUnit.setCode("VEDL-t"); + mUnit.setName("t"); + mUnit.setDescription("tuna (hmotnost)"); + mUnitsService.add(mUnit); + + mUnit.setCode("SI-s"); + mUnit.setName("s"); + mUnit.setDescription("sekunda (čas)"); + mUnitsService.add(mUnit); + + mUnit.setCode("VEDL-min"); + mUnit.setName("min"); + mUnit.setDescription("minuta (čas)"); + mUnitsService.add(mUnit); + + mUnit.setCode("VEDL-hod"); + mUnit.setName("hod"); + mUnit.setDescription("hodina (čas)"); + mUnitsService.add(mUnit); + + mUnit.setCode("ODV-m2"); + mUnit.setName("m[up]2[/up]"); + mUnit.setDescription("metr čtverečný (plocha)"); + mUnitsService.add(mUnit); + + mUnit.setCode("ODV-ha"); + mUnit.setName("ha"); + mUnit.setDescription("hektar = 10.000 m² (plocha)"); + mUnitsService.add(mUnit); + + mUnit.setCode("ODV-m3"); + mUnit.setName("m³"); + mUnit.setDescription("metr krychlový (objem)"); + mUnitsService.add(mUnit); + + mUnit.setCode("ODV-l"); + mUnit.setName("l"); + mUnit.setDescription("litr = 10E-3 m³ (objem)"); + mUnitsService.add(mUnit); + + mUnit.setCode("SI-A"); + mUnit.setName("A"); + mUnit.setDescription("ampér (elektrický proud)"); + mUnitsService.add(mUnit); + + mUnit.setCode("SI-K"); + mUnit.setName("K"); + mUnit.setDescription("kelvin (termodynamická teplota)"); + mUnitsService.add(mUnit); + + mUnit.setCode("SI-cd"); + mUnit.setName("cd"); + mUnit.setDescription("kandela (svítivost)"); + mUnitsService.add(mUnit); + + mUnit.setCode("SI-mol"); + mUnit.setName("mol"); + mUnit.setDescription("mol (látkové množství)"); + mUnitsService.add(mUnit); + } + } + private void checkRoles() { for (Role role : Constants.ROLES) { diff --git a/src/main/java/info/bukova/isspst/data/MUnit.java b/src/main/java/info/bukova/isspst/data/MUnit.java index 8cdb5da9..55438e21 100644 --- a/src/main/java/info/bukova/isspst/data/MUnit.java +++ b/src/main/java/info/bukova/isspst/data/MUnit.java @@ -39,7 +39,7 @@ public class MUnit extends BaseData implements DataModel { * @return the name */ public String getName() { - return name; + return this.name; } /** @@ -49,6 +49,29 @@ public class MUnit extends BaseData implements DataModel { public void setName(String name) { this.name = name; } + + public String getNameSpecial() + { + String special = this.getName(); + + if (special != null) + { + special = special.replace("[up]2[/up]", "²"); + } + + return special; + } + + public void setNameSpecial(String special) + { + if (special != null) + { + special = special.replace("²", "[up]2[/up]"); + + } + + this.setName(special); + } /** * @return the description diff --git a/src/main/java/info/bukova/isspst/data/Requirement.java b/src/main/java/info/bukova/isspst/data/Requirement.java index 6e6ecaff..17889b5c 100644 --- a/src/main/java/info/bukova/isspst/data/Requirement.java +++ b/src/main/java/info/bukova/isspst/data/Requirement.java @@ -1,12 +1,15 @@ package info.bukova.isspst.data; import java.util.Date; +import java.util.List; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; import javax.persistence.Table; @Entity @@ -29,6 +32,20 @@ public class Requirement extends BaseData implements DataModel @Column(name = "DESCRIPTION") private String description; + @OneToMany(fetch = FetchType.EAGER, cascade=CascadeType.ALL) + @JoinColumn(name = "REQUIREMENT_ID") + private List items; + + public List getItems() + { + return items; + } + + public void setItems(List items) + { + this.items = items; + } + public String getNumser() { return numser; diff --git a/src/main/java/info/bukova/isspst/data/RequirementItem.java b/src/main/java/info/bukova/isspst/data/RequirementItem.java new file mode 100644 index 00000000..642a3283 --- /dev/null +++ b/src/main/java/info/bukova/isspst/data/RequirementItem.java @@ -0,0 +1,136 @@ +package info.bukova.isspst.data; + +import java.math.BigDecimal; + +import javax.persistence.Column; +import javax.persistence.Embedded; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +@Entity +@Table(name = "REQUIREMENT_ITEMS") +public class RequirementItem +{ + @Id + @Column(name="ID") + @GeneratedValue + private int id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "REQSUBJECT_ID") + private RequirementSubject reqSubject; + + @Column(name = "CODE") + private String code; + + @Column(name = "NAME") + private String name; + + @Column(name = "QUANTITY", precision=15, scale=4) + private BigDecimal quantity; + + @Embedded + private MUnitEmb mUnit; + + @Column(name = "UNITPRICE", precision=15, scale=4) + private BigDecimal unitPrice; + + @Column(name = "TOTAL", precision=15, scale=4) + private BigDecimal total; + + @Column(name = "DESCRIPTION") + private String description; + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id = id; + } + + public RequirementSubject getReqSubject() + { + return reqSubject; + } + + public void setReqSubject(RequirementSubject reqSubject) + { + this.reqSubject = reqSubject; + } + + public String getCode() + { + return code; + } + + public void setCode(String code) + { + this.code = code; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public BigDecimal getQuantity() + { + return quantity; + } + + public void setQuantity(BigDecimal quantity) + { + this.quantity = quantity; + } + + public MUnitEmb getMUnit() { + return mUnit; + } + + public void setMUnit(MUnitEmb mUnit) { + this.mUnit = mUnit; + } + + public BigDecimal getUnitPrice() + { + return unitPrice; + } + + public void setUnitPrice(BigDecimal unitPrice) + { + this.unitPrice = unitPrice; + } + + public BigDecimal getTotal() + { + return total; + } + + public void setTotal(BigDecimal total) + { + this.total = total; + } + + public String getDescription() + { + return description; + } + + public void setDescription(String description) + { + this.description = description; + } +} diff --git a/src/main/java/info/bukova/isspst/data/RequirementSubject.java b/src/main/java/info/bukova/isspst/data/RequirementSubject.java index 7a49bd6c..cd4d6268 100644 --- a/src/main/java/info/bukova/isspst/data/RequirementSubject.java +++ b/src/main/java/info/bukova/isspst/data/RequirementSubject.java @@ -22,7 +22,7 @@ public abstract class RequirementSubject implements OwnedDataModel { //OwnedDataModel @Id - @Column(name =" ID") + @Column(name = "ID") @GeneratedValue(strategy = GenerationType.TABLE) private int id; @ManyToOne(fetch=FetchType.LAZY) diff --git a/src/main/java/info/bukova/isspst/ui/requirement/RequirementForm.java b/src/main/java/info/bukova/isspst/ui/requirement/RequirementForm.java index d2c3646e..2bb5ce11 100644 --- a/src/main/java/info/bukova/isspst/ui/requirement/RequirementForm.java +++ b/src/main/java/info/bukova/isspst/ui/requirement/RequirementForm.java @@ -1,7 +1,7 @@ package info.bukova.isspst.ui.requirement; import info.bukova.isspst.data.Requirement; -import info.bukova.isspst.data.RequirementSubject; +import info.bukova.isspst.data.RequirementItem; import info.bukova.isspst.data.Workgroup; import info.bukova.isspst.services.requirement.RequirementService; import info.bukova.isspst.services.users.UserService; @@ -10,26 +10,31 @@ import info.bukova.isspst.ui.FormViewModel; import java.util.List; +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.Executions; import org.zkoss.zk.ui.select.annotation.WireVariable; +import org.zkoss.zul.Window; public class RequirementForm extends FormViewModel { @WireVariable private UserService userService; - + @WireVariable private WorkgroupService workgroupService; - public List getCentres() { + public List getCentres() + { return workgroupService.getUserCentres(userService.getCurrent()); } + @WireVariable private RequirementService requirementService; - private RequirementSubject item; + private RequirementItem item; private int selItemIndex; @@ -39,12 +44,12 @@ public class RequirementForm extends FormViewModel this.setSelItemIndex(-1); } - public RequirementSubject getItem() + public RequirementItem getItem() { return item; } - public void setItem(RequirementSubject item) + public void setItem(RequirementItem item) { this.item = item; } @@ -60,18 +65,19 @@ public class RequirementForm extends FormViewModel } @Command - @NotifyChange({"dataBean", "selItemIndex"}) - public void addItem() { -// RequirementSubject item = new Material(); -// requirementService.addItem(getDataBean(), item); -// selItemIndex = getDataBean().getItems().indexOf(item); + @NotifyChange({ "dataBean", "selItemIndex" }) + public void addItem() + { + Window window = (Window) Executions.createComponents("/requirements/selectitems/selectItems.zul", null, null); + window.doModal(); } -/* + @Command - @NotifyChange({"dataBean", "selItemIndex"}) - public void removeItem(@BindingParam("item") RequirementItem item) { - requirementService.removeItem(getDataBean(), item); + @NotifyChange({ "dataBean", "selItemIndex" }) + public void removeItem(@BindingParam("item") RequirementItem item) + { +// requirementService.removeItem(getDataBean(), item); selItemIndex = -1; } -*/ + } diff --git a/src/main/java/info/bukova/isspst/ui/requirements/SelectItems.java b/src/main/java/info/bukova/isspst/ui/requirements/SelectItems.java new file mode 100644 index 00000000..5eaf669e --- /dev/null +++ b/src/main/java/info/bukova/isspst/ui/requirements/SelectItems.java @@ -0,0 +1,82 @@ +package info.bukova.isspst.ui.requirements; + +import info.bukova.isspst.data.Material; +import info.bukova.isspst.data.ServiceItem; +import info.bukova.isspst.services.reqsubjects.MaterialService; +import info.bukova.isspst.services.reqsubjects.ServiceItemService; + +import java.util.List; + +import org.zkoss.bind.annotation.Command; +import org.zkoss.bind.annotation.Init; +import org.zkoss.zk.ui.select.annotation.WireVariable; + +public class SelectItems +{ + @WireVariable + private MaterialService materialService; + + @WireVariable + private ServiceItemService serviceItemService; + + private List materialList; + + private List serviceItemList; + + private Material selectedMaterial; + + private ServiceItem selectedServiceItem; + + @Init + public void init() + { + this.setMaterialList(materialService.getAll()); + this.setServiceItemList(serviceItemService.getAll()); + } + + public List getMaterialList() + { + return materialList; + } + + public void setMaterialList(List materialList) + { + this.materialList = materialList; + } + + public List getServiceItemList() + { + return serviceItemList; + } + + public void setServiceItemList(List serviceItemList) + { + this.serviceItemList = serviceItemList; + } + + public Material getSelectedMaterial() + { + return selectedMaterial; + } + + public void setSelectedMaterial(Material selectedMaterial) + { + this.selectedMaterial = selectedMaterial; + } + + public ServiceItem getSelectedServiceItem() + { + return selectedServiceItem; + } + + public void setSelectedServiceItem(ServiceItem selectedServiceItem) + { + this.selectedServiceItem = selectedServiceItem; + } + + @Command + public void addItem() + { + //this + } +} diff --git a/src/main/resources/hibernate.cfg.xml b/src/main/resources/hibernate.cfg.xml index 115c5d51..9c9798a9 100644 --- a/src/main/resources/hibernate.cfg.xml +++ b/src/main/resources/hibernate.cfg.xml @@ -18,6 +18,7 @@ + diff --git a/src/main/resources/log4j.xml b/src/main/resources/log4j.xml index 5281aee1..a77e3a18 100644 --- a/src/main/resources/log4j.xml +++ b/src/main/resources/log4j.xml @@ -36,6 +36,10 @@ + + + + diff --git a/src/main/webapp/WEB-INF/locales/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties index b68bf9f2..e03661cb 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -22,6 +22,15 @@ RequirementsGridCenter=Středisko RequirementsGridDescription=Popis RequirementsGridDeliveryDate=Datum dodání +RequirementItemCode=Kód +RequirementItemName=Text +RequirementItemQuantity=Množství +RequirementItemMUnit=MJ +RequirementItemUnitPrice=Jedn. cena +RequirementItemTotal=Celkem +RequirementItemDescription=Poznámka + + AgendaMyOrders=Aktuální AgendaOrdersHistory=Ukončené @@ -180,4 +189,5 @@ false=Ne DateFormat=dd. MM. yyyy AddItem=Přidat položku... +RemoveItem=Smazat položku... \ No newline at end of file diff --git a/src/main/webapp/lists/munits/munitsGrid.zul b/src/main/webapp/lists/munits/munitsGrid.zul index 04947096..36cb0ff0 100644 --- a/src/main/webapp/lists/munits/munitsGrid.zul +++ b/src/main/webapp/lists/munits/munitsGrid.zul @@ -26,7 +26,7 @@
- +
@@ -48,7 +48,7 @@ diff --git a/src/main/webapp/requirements/actual/requirementsForm.zul b/src/main/webapp/requirements/actual/requirementsForm.zul index 958234f0..a6832141 100644 --- a/src/main/webapp/requirements/actual/requirementsForm.zul +++ b/src/main/webapp/requirements/actual/requirementsForm.zul @@ -82,6 +82,90 @@ onClick="@command('addItem')" sclass="nicebutton" /> + + + + + + + + + + + + + diff --git a/src/main/webapp/requirements/selectitems/selectItems.zul b/src/main/webapp/requirements/selectitems/selectItems.zul new file mode 100644 index 00000000..819ac6c5 --- /dev/null +++ b/src/main/webapp/requirements/selectitems/selectItems.zul @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
\ No newline at end of file