diff --git a/src/main/java/info/bukova/isspst/Constants.java b/src/main/java/info/bukova/isspst/Constants.java index e7fd3fb2..8d1065de 100644 --- a/src/main/java/info/bukova/isspst/Constants.java +++ b/src/main/java/info/bukova/isspst/Constants.java @@ -6,7 +6,6 @@ import info.bukova.isspst.data.PermissionType; import info.bukova.isspst.data.Requirement; import info.bukova.isspst.data.RequirementType; import info.bukova.isspst.data.Role; -import info.bukova.isspst.data.SignedDocument; import info.bukova.isspst.data.TripBill; import info.bukova.isspst.data.TripBillApproval; import info.bukova.isspst.data.TripRequirement; @@ -24,6 +23,7 @@ import info.bukova.isspst.services.reqsubjects.ServiceItemService; import info.bukova.isspst.services.requirement.RequirementService; import info.bukova.isspst.services.requirement.RequirementTypeService; import info.bukova.isspst.services.requirement.TripRequirementService; +import info.bukova.isspst.services.signeddocs.SignedDocumentService; import info.bukova.isspst.services.tripbill.TripBillService; import info.bukova.isspst.services.users.RoleService; import info.bukova.isspst.services.users.UserService; @@ -105,7 +105,7 @@ public class Constants { new Module(MOD_ORDER, "Objednávky", OrderService.class), new Module(MOD_INVOICING, "Fakturace požadavků", InvoicingService.class), new Module(MOD_SEARCH, "Fulltextové vyhledávání", FullTextService.class, true, false), - new Module(MOD_SIGNEDDOCS, "Podepsané dokumenty", SignedDocument.class, true, false), + new Module(MOD_SIGNEDDOCS, "Podepsané dokumenty", SignedDocumentService.class, true, false), }; public final static String PERM_APPROVE = "PERM_APPROVE"; diff --git a/src/main/java/info/bukova/isspst/data/SignedDocument.java b/src/main/java/info/bukova/isspst/data/SignedDocument.java index a0575882..55190466 100644 --- a/src/main/java/info/bukova/isspst/data/SignedDocument.java +++ b/src/main/java/info/bukova/isspst/data/SignedDocument.java @@ -5,11 +5,18 @@ import info.bukova.isspst.Module; import info.bukova.isspst.StringUtils; import java.util.Date; +import java.util.List; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.OneToMany; import javax.persistence.Table; +import org.hibernate.annotations.LazyCollection; +import org.hibernate.annotations.LazyCollectionOption; +import org.hibernate.search.annotations.IndexedEmbedded; + @Entity @Table(name = "SIGNED_DOCUMENTS") public class SignedDocument extends BaseData { @@ -29,6 +36,11 @@ public class SignedDocument extends BaseData { @Column(name = "SIGN_DATE") private Date signDate; + @OneToMany(cascade = CascadeType.ALL, mappedBy = "signedDocument", orphanRemoval = true) + @LazyCollection(LazyCollectionOption.TRUE) + @IndexedEmbedded + private List items; + public String getModuleName() { return moduleName; } @@ -76,11 +88,24 @@ public class SignedDocument extends BaseData { } for (Module m : Constants.MODULES) { - if (m.getId() == this.moduleName) { + if (this.moduleName.equals(m.getId())) { return m.getName(); } } return ""; } + + public List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } + + public void addItem(SignedDocumentItem item) { + item.setSignedDocument(this); + this.items.add(item); + } } diff --git a/src/main/java/info/bukova/isspst/data/SignedDocumentItem.java b/src/main/java/info/bukova/isspst/data/SignedDocumentItem.java index e76d507c..2e59e058 100644 --- a/src/main/java/info/bukova/isspst/data/SignedDocumentItem.java +++ b/src/main/java/info/bukova/isspst/data/SignedDocumentItem.java @@ -1,6 +1,8 @@ package info.bukova.isspst.data; import info.bukova.isspst.Constants; +import info.bukova.isspst.reporting.Report; +import info.bukova.isspst.reporting.ReportMapping; import javax.persistence.Column; import javax.persistence.Entity; @@ -56,6 +58,18 @@ public class SignedDocumentItem { this.reportName = reportName; } + public String getActualReportName() { + for (ReportMapping rm : Constants.REPORTS) { + Report rep = rm.getReport(); + + if (this.reportId == rep.getReportId()) { + return rep.getName(); + } + } + + return reportName; + } + public String getFileName() { return fileName; } diff --git a/src/main/java/info/bukova/isspst/filters/SignedDocumentFilter.java b/src/main/java/info/bukova/isspst/filters/SignedDocumentFilter.java new file mode 100644 index 00000000..2be38e8c --- /dev/null +++ b/src/main/java/info/bukova/isspst/filters/SignedDocumentFilter.java @@ -0,0 +1,64 @@ +package info.bukova.isspst.filters; + +import info.bukova.isspst.DateTimeUtils; +import info.bukova.isspst.StringUtils; +import info.bukova.isspst.data.SignedDocument; + +import org.hamcrest.Description; +import org.hamcrest.Factory; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; + +public class SignedDocumentFilter implements Filter +{ + private SignedDocument condition; + + public SignedDocumentFilter(SignedDocument cond) + { + this.condition = cond; + } + + private static class SignedDocumentMatcher extends TypeSafeMatcher + { + private SignedDocument condition; + + public SignedDocumentMatcher(SignedDocument cond) + { + this.condition = cond; + } + + @Override + public void describeTo(Description desc) + { + desc.appendText("SignedDocument matches"); + } + + @Override + public boolean matchesSafely(SignedDocument item) + { + boolean foundAgendaName = StringUtils.isEqualForFilter(item.getAgendaName(), condition.getAgendaName()); + boolean foundNumSer = StringUtils.isEqualForFilter(item.getNumser(), condition.getNumser()); + boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription()); + boolean foundSignDate = DateTimeUtils.isEqualByDateForFilter(item.getSignDate(), condition.getSignDate()); + return (foundAgendaName && foundNumSer && foundDescription && foundSignDate); + } + + @Factory + public static Matcher matchBuilding(SignedDocument item) + { + return new SignedDocumentMatcher(item); + } + } + + @Override + public SignedDocumentMatcher matcher() + { + return new SignedDocumentMatcher(condition); + } + + @Override + public String queryString() + { + return ""; + } +} diff --git a/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentServiceImpl.java b/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentServiceImpl.java index 7582c7b0..8779dc3c 100644 --- a/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentServiceImpl.java @@ -2,6 +2,21 @@ package info.bukova.isspst.services.signeddocs; import info.bukova.isspst.data.SignedDocument; import info.bukova.isspst.services.AbstractOwnedService; +import info.bukova.isspst.services.LazyLoader; + +import org.hibernate.Hibernate; +import org.springframework.transaction.annotation.Transactional; public class SignedDocumentServiceImpl extends AbstractOwnedService implements SignedDocumentService { + @LazyLoader("grid") + @Transactional + public void lazyLoadItems(SignedDocument signedDocument) { + if (signedDocument == null) { + return; + } + + SignedDocument sd = dao.getById(signedDocument.getId()); + Hibernate.initialize(sd.getItems()); + signedDocument.setItems(sd.getItems()); + } } diff --git a/src/main/java/info/bukova/isspst/ui/signeddocs/SignedDocsList.java b/src/main/java/info/bukova/isspst/ui/signeddocs/SignedDocsList.java new file mode 100644 index 00000000..d5ee9511 --- /dev/null +++ b/src/main/java/info/bukova/isspst/ui/signeddocs/SignedDocsList.java @@ -0,0 +1,73 @@ +package info.bukova.isspst.ui.signeddocs; + +import info.bukova.isspst.data.SignedDocument; +import info.bukova.isspst.data.SignedDocumentItem; +import info.bukova.isspst.filters.SignedDocumentFilter; +import info.bukova.isspst.services.signeddocs.SignedDocumentService; +import info.bukova.isspst.ui.ListViewModel; + +import java.util.ArrayList; +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +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.select.annotation.WireVariable; +import org.zkoss.zul.Listbox; + +public class SignedDocsList extends ListViewModel +{ + @SuppressWarnings("unused") + private final static Logger log = LoggerFactory.getLogger(SignedDocsList.class.getName()); + + @WireVariable + protected SignedDocumentService signedDocumentService; + + protected SignedDocumentItem signedDocumentItem; + + protected List signedDocumentItems; + + @Init(superclass = true) + public void initSignedDocsList() { + service = signedDocumentService; + dataClass = SignedDocument.class; + formZul = "form.zul"; + dataFilter = new SignedDocumentFilter(getFilterTemplate()); + this.signedDocumentItem = null; + this.signedDocumentItems = new ArrayList(); + } + + public SignedDocumentItem getSignedDocumentItem() { + return signedDocumentItem; + } + + public void setSignedDocumentItem(SignedDocumentItem signedDocumentItem) { + this.signedDocumentItem = signedDocumentItem; + } + + public List getSignedDocumentItems() { + return signedDocumentItems; + } + + public void setSignedDocumentItems(List signedDocumentItems) { + this.signedDocumentItems = signedDocumentItems; + } + + @Command + @NotifyChange("signedDocumentItems") + public void onChangeSelectSignedDocs(@BindingParam("ctrl") Listbox lb) { + if (lb == null) { + return; + } + + if (lb.getSelectedIndex() > -1) { + this.signedDocumentItems = this.getDataBean().getItems(); + } + else { + this.signedDocumentItems = new ArrayList(); + } + } +} diff --git a/src/main/webapp/WEB-INF/locales/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties index 86267529..92db7881 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -1,6 +1,11 @@ # Default file AppName=Informační systém SPŠ Třebíč AgendaSignedDocuments=Podepsané dokumenty +ActualDocuments=Aktuální dokumenty +AgendaName=Název agendy +SigningDate=Datum podepsání +PrintReports=Tiskové sestavy +FileName=Název souboru AgendaActRequirements=Aktuální požadavky AgendaRequirementsHistory=Ukončené požadavky diff --git a/src/main/webapp/lists/signeddocs/grid.zul b/src/main/webapp/lists/signeddocs/grid.zul new file mode 100644 index 00000000..74b72e37 --- /dev/null +++ b/src/main/webapp/lists/signeddocs/grid.zul @@ -0,0 +1,209 @@ + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+ + + + + + + +
+
+ + + +
+
+
+
\ No newline at end of file diff --git a/src/main/webapp/lists/signeddocs/toolbar.zul b/src/main/webapp/lists/signeddocs/toolbar.zul new file mode 100644 index 00000000..9332f089 --- /dev/null +++ b/src/main/webapp/lists/signeddocs/toolbar.zul @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file