From 35131d555df3d0a58627e9d43ae022da3305e1ff Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Mon, 30 Jun 2014 13:13:36 +0200 Subject: [PATCH] =?UTF-8?q?Do=20agendy=20materi=C3=A1l=20byla=20p=C5=99ida?= =?UTF-8?q?n=C3=A1=20m=C4=9Brn=C3=A1=20jednotka.=20refs=20#94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../info/bukova/isspst/data/MUnitEmb.java | 81 +++++++++++++++++++ .../info/bukova/isspst/data/Material.java | 12 ++- .../isspst/ui/material/MaterialForm.java | 22 ++++- .../webapp/WEB-INF/locales/columns.properties | 5 +- src/main/webapp/lists/material/material.zul | 6 +- .../webapp/lists/material/materialForm.zul | 10 +++ 6 files changed, 131 insertions(+), 5 deletions(-) create mode 100644 src/main/java/info/bukova/isspst/data/MUnitEmb.java diff --git a/src/main/java/info/bukova/isspst/data/MUnitEmb.java b/src/main/java/info/bukova/isspst/data/MUnitEmb.java new file mode 100644 index 00000000..19ee5cfc --- /dev/null +++ b/src/main/java/info/bukova/isspst/data/MUnitEmb.java @@ -0,0 +1,81 @@ +package info.bukova.isspst.data; + +import javax.persistence.Column; +import javax.persistence.Embeddable; + +@Embeddable +public class MUnitEmb { + @Column(name = "MUNIT_ID") + private Integer id; + @Column(name = "MUNIT_CODE") + private String code; + @Column(name = "MUNIT_DESCRIPTION") + private String description; + @Column(name = "MUNIT_NAME") + private String name; + + public MUnitEmb() { + + } + + public MUnitEmb(MUnit munit) { + this.id = munit.getId(); + this.code = munit.getCode(); + this.description = munit.getDescription(); + this.name = munit.getName(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public boolean eqWith(MUnit munit) { + return this.id == munit.getId() + && this.code.equals(munit.getCode()) + && this.name.equals(munit.getName()) + && this.description.equals(munit.getDescription()); + } + + @Override + public boolean equals(Object munit) { + return munit != null + && (munit instanceof MUnitEmb) + && this.id == ((MUnitEmb)munit).getId() + && (this.code == ((MUnitEmb)munit).getCode() || this.code.equals(((MUnitEmb)munit).getCode())) + && (this.name == ((MUnitEmb)munit).getName() || this.name.equals(((MUnitEmb)munit).getName())) + && (this.description == ((MUnitEmb)munit).getDescription() || this.description.equals(((MUnitEmb)munit).getDescription())); + } + + @Override + public String toString() { + return this.code + " - " + this.name; + } +} diff --git a/src/main/java/info/bukova/isspst/data/Material.java b/src/main/java/info/bukova/isspst/data/Material.java index 0b57148a..1aee860c 100644 --- a/src/main/java/info/bukova/isspst/data/Material.java +++ b/src/main/java/info/bukova/isspst/data/Material.java @@ -1,5 +1,6 @@ package info.bukova.isspst.data; +import javax.persistence.Embedded; import javax.persistence.Entity; import javax.persistence.Table; @@ -7,6 +8,15 @@ import javax.persistence.Table; @Table(name="MATERIAL") public class Material extends RequirementSubject { - + @Embedded + private MUnitEmb munit; + + public MUnitEmb getMunit() { + return munit; + } + + public void setMunit(MUnitEmb munit) { + this.munit = munit; + } } diff --git a/src/main/java/info/bukova/isspst/ui/material/MaterialForm.java b/src/main/java/info/bukova/isspst/ui/material/MaterialForm.java index 2bab7210..aaf52ee8 100644 --- a/src/main/java/info/bukova/isspst/ui/material/MaterialForm.java +++ b/src/main/java/info/bukova/isspst/ui/material/MaterialForm.java @@ -1,15 +1,35 @@ package info.bukova.isspst.ui.material; +import java.util.ArrayList; +import java.util.List; + import org.zkoss.bind.annotation.Init; +import org.zkoss.zk.ui.select.annotation.WireVariable; +import info.bukova.isspst.data.MUnit; +import info.bukova.isspst.data.MUnitEmb; import info.bukova.isspst.data.Material; +import info.bukova.isspst.services.munits.MUnitService; import info.bukova.isspst.ui.FormViewModel; public class MaterialForm extends FormViewModel { + @WireVariable + private MUnitService munitService; + private List munits; + @Init(superclass = true) public void init() { - + List mu = munitService.getAll(); + munits = new ArrayList(); + for (MUnit m : mu) { + MUnitEmb muEmb = new MUnitEmb(m); + munits.add(muEmb); + } + } + + public List getMunits() { + return munits; } } diff --git a/src/main/webapp/WEB-INF/locales/columns.properties b/src/main/webapp/WEB-INF/locales/columns.properties index 0c067f53..e86db2e6 100644 --- a/src/main/webapp/WEB-INF/locales/columns.properties +++ b/src/main/webapp/WEB-INF/locales/columns.properties @@ -39,4 +39,7 @@ username=Uživatelské jméno #Skupiny centre=Středisko -members=Členové \ No newline at end of file +members=Členové + +#Materiál +munit=Měrná jednotka \ No newline at end of file diff --git a/src/main/webapp/lists/material/material.zul b/src/main/webapp/lists/material/material.zul index fc549c14..cd71cc64 100644 --- a/src/main/webapp/lists/material/material.zul +++ b/src/main/webapp/lists/material/material.zul @@ -8,8 +8,9 @@ - - + + + @@ -50,6 +51,7 @@ + diff --git a/src/main/webapp/lists/material/materialForm.zul b/src/main/webapp/lists/material/materialForm.zul index 0270c94b..356a4a05 100644 --- a/src/main/webapp/lists/material/materialForm.zul +++ b/src/main/webapp/lists/material/materialForm.zul @@ -28,6 +28,16 @@ + + ${labels.munit} : + + + + + +