From cc374a3bf1a4efd3e3811b2cf93d0e9eaea53e93 Mon Sep 17 00:00:00 2001 From: Franta Pribyl Date: Mon, 5 Oct 2015 13:09:20 +0200 Subject: [PATCH] =?UTF-8?q?Podepsan=C3=A9=20dokumenty=20se=20nyn=C3=AD=20z?= =?UTF-8?q?obrazuj=C3=AD=20ve=20dvou=20z=C3=A1lo=C5=BEk=C3=A1ch=20-=20Aktu?= =?UTF-8?q?=C3=A1ln=C3=AD=20dokumenty=20a=20Archiv.=20V=20Archivu=20se=20z?= =?UTF-8?q?obrazuj=C3=AD=20dokumenty=20star=C5=A1=C3=AD=20ne=C5=BE=20rok.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #225 --- .../info/bukova/isspst/DateTimeUtils.java | 28 ++ .../signeddocs/SignedDocumentService.java | 4 + .../signeddocs/SignedDocumentServiceImpl.java | 35 +- .../ui/signeddocs/SignedDocsActualList.java | 29 ++ .../ui/signeddocs/SignedDocsArchiveList.java | 30 ++ src/main/webapp/lists/signeddocs/grid.zul | 345 +++++++----------- .../lists/signeddocs/headListActual.zul | 13 + .../lists/signeddocs/headListArchive.zul | 13 + src/main/webapp/lists/signeddocs/index.zul | 2 +- src/main/webapp/lists/signeddocs/setup.zul | 19 + .../webapp/lists/signeddocs/tabPanels.zul | 17 + 11 files changed, 315 insertions(+), 220 deletions(-) create mode 100644 src/main/java/info/bukova/isspst/ui/signeddocs/SignedDocsActualList.java create mode 100644 src/main/java/info/bukova/isspst/ui/signeddocs/SignedDocsArchiveList.java create mode 100644 src/main/webapp/lists/signeddocs/headListActual.zul create mode 100644 src/main/webapp/lists/signeddocs/headListArchive.zul create mode 100644 src/main/webapp/lists/signeddocs/setup.zul create mode 100644 src/main/webapp/lists/signeddocs/tabPanels.zul diff --git a/src/main/java/info/bukova/isspst/DateTimeUtils.java b/src/main/java/info/bukova/isspst/DateTimeUtils.java index 884c5bf7..eb57b0b9 100644 --- a/src/main/java/info/bukova/isspst/DateTimeUtils.java +++ b/src/main/java/info/bukova/isspst/DateTimeUtils.java @@ -2,6 +2,7 @@ package info.bukova.isspst; import java.util.Calendar; import java.util.Date; +import java.util.GregorianCalendar; import org.apache.commons.lang.time.DateUtils; @@ -54,4 +55,31 @@ public class DateTimeUtils { return DateTimeUtils.getDate(DateTimeUtils.getCurrDateTime()); } + + public static Calendar getCalendarDelta(Date value, int calendarType, int delta) { + if (value == null) { + value = DateTimeUtils.getCurrDate(); + } + + Calendar calendar = new GregorianCalendar(); + calendar.setTime(value); + int deltaValue = calendar.get(calendarType); + calendar.set(calendarType, deltaValue + delta); + return calendar; + } + + public static Calendar getCalendar(Date value) { + if (value == null) { + value = DateTimeUtils.getCurrDate(); + } + + Calendar calendar = new GregorianCalendar(); + calendar.setTime(value); + return calendar; + } + + public static Date getDateDelta(Date value, int calendarType, int delta) { + Calendar calendar = DateTimeUtils.getCalendarDelta(value, calendarType, delta); + return calendar.getTime(); + } } diff --git a/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentService.java b/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentService.java index e01e2146..fc992b08 100644 --- a/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentService.java +++ b/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentService.java @@ -5,6 +5,8 @@ import info.bukova.isspst.data.SignedDocument; import info.bukova.isspst.data.SignedDocumentItem; import info.bukova.isspst.services.Service; +import java.util.List; + public interface SignedDocumentService extends Service { SignedDocument getForEntity(DataModel entity); @@ -13,4 +15,6 @@ public interface SignedDocumentService extends Service { void delFromApprove(SignedDocument document); void deleteForEntity(DataModel entity); + public List getActualList(); + public List getArchiveList(); } 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 e4053e82..22803b2d 100644 --- a/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentServiceImpl.java @@ -1,5 +1,6 @@ package info.bukova.isspst.services.signeddocs; +import info.bukova.isspst.DateTimeUtils; import info.bukova.isspst.Module; import info.bukova.isspst.ModuleUtils; import info.bukova.isspst.data.DataModel; @@ -7,15 +8,20 @@ import info.bukova.isspst.data.SignedDocument; import info.bukova.isspst.data.SignedDocumentItem; import info.bukova.isspst.services.AbstractOwnedService; import info.bukova.isspst.services.LazyLoader; - import info.bukova.isspst.storage.ReportFileStorage; + +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import javax.servlet.ServletContext; + import org.hibernate.Hibernate; import org.hibernate.Query; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.transaction.annotation.Transactional; -import javax.servlet.ServletContext; - public class SignedDocumentServiceImpl extends AbstractOwnedService implements SignedDocumentService { @Autowired @@ -96,5 +102,28 @@ public class SignedDocumentServiceImpl extends AbstractOwnedService getActualList() { + Query q = dao.getQuery("from SignedDocument where signDate >= :refDate"); + q.setParameter("refDate", this.getTresholdDate()); + return q.list(); + } + + @SuppressWarnings("unchecked") + @Override + @Transactional + @PreAuthorize("hasPermission(this, 'PERM_READ')") + public List getArchiveList() { + Query q = dao.getQuery("from SignedDocument where signDate < :refDate"); + q.setParameter("refDate", this.getTresholdDate()); + return q.list(); + } } diff --git a/src/main/java/info/bukova/isspst/ui/signeddocs/SignedDocsActualList.java b/src/main/java/info/bukova/isspst/ui/signeddocs/SignedDocsActualList.java new file mode 100644 index 00000000..d2ec51bb --- /dev/null +++ b/src/main/java/info/bukova/isspst/ui/signeddocs/SignedDocsActualList.java @@ -0,0 +1,29 @@ +package info.bukova.isspst.ui.signeddocs; + +import info.bukova.isspst.data.SignedDocument; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.security.access.AccessDeniedException; +import org.zkoss.bind.annotation.Init; + +public class SignedDocsActualList extends SignedDocsList { + + @Init(superclass = true) + public void SignedDocsActualListInit() { + + } + + @Override + protected List getListFromService() { + try { + return signedDocumentService.getActualList(); + } + catch (AccessDeniedException e) { + // BindUtils.postGlobalCommand(null, null, "disableCentre", null); + // e.printStackTrace(); + return new ArrayList(); + } + } +} diff --git a/src/main/java/info/bukova/isspst/ui/signeddocs/SignedDocsArchiveList.java b/src/main/java/info/bukova/isspst/ui/signeddocs/SignedDocsArchiveList.java new file mode 100644 index 00000000..17bb174d --- /dev/null +++ b/src/main/java/info/bukova/isspst/ui/signeddocs/SignedDocsArchiveList.java @@ -0,0 +1,30 @@ +package info.bukova.isspst.ui.signeddocs; + +import info.bukova.isspst.data.SignedDocument; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.security.access.AccessDeniedException; +import org.zkoss.bind.annotation.Init; + +public class SignedDocsArchiveList extends SignedDocsList { + + @Init(superclass = true) + public void SignedDocsArchiveListInit() { + + } + + @Override + protected List getListFromService() { + try { + return signedDocumentService.getArchiveList(); + } + catch (AccessDeniedException e) { + // BindUtils.postGlobalCommand(null, null, "disableCentre", null); + // e.printStackTrace(); + return new ArrayList(); + } + } + +} diff --git a/src/main/webapp/lists/signeddocs/grid.zul b/src/main/webapp/lists/signeddocs/grid.zul index e361df43..52aa0453 100644 --- a/src/main/webapp/lists/signeddocs/grid.zul +++ b/src/main/webapp/lists/signeddocs/grid.zul @@ -1,216 +1,129 @@ - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
- -
-
-
- -
-
- -
-
- -
-
-
- -
-
- -
-
- -
-
-
- -
-
- -
-
- -
-
-
-
- -
- - - - - - - - -
-
- - - -
-
-
-
\ No newline at end of file + + + + + + + + + + + +
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+ + + + + + + + +
diff --git a/src/main/webapp/lists/signeddocs/headListActual.zul b/src/main/webapp/lists/signeddocs/headListActual.zul new file mode 100644 index 00000000..c3173790 --- /dev/null +++ b/src/main/webapp/lists/signeddocs/headListActual.zul @@ -0,0 +1,13 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/lists/signeddocs/headListArchive.zul b/src/main/webapp/lists/signeddocs/headListArchive.zul new file mode 100644 index 00000000..e29b3ad8 --- /dev/null +++ b/src/main/webapp/lists/signeddocs/headListArchive.zul @@ -0,0 +1,13 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/lists/signeddocs/index.zul b/src/main/webapp/lists/signeddocs/index.zul index 044bc7f7..9304094c 100644 --- a/src/main/webapp/lists/signeddocs/index.zul +++ b/src/main/webapp/lists/signeddocs/index.zul @@ -2,7 +2,7 @@ - String gridZul = "grid.zul"; + String gridZul = "setup.zul"; diff --git a/src/main/webapp/lists/signeddocs/setup.zul b/src/main/webapp/lists/signeddocs/setup.zul new file mode 100644 index 00000000..2432fd12 --- /dev/null +++ b/src/main/webapp/lists/signeddocs/setup.zul @@ -0,0 +1,19 @@ + + + + + String gridActual = "/lists/signeddocs/headListActual.zul"; + String gridArchive = "/lists/signeddocs/headListArchive.zul"; + + + + + + \ No newline at end of file diff --git a/src/main/webapp/lists/signeddocs/tabPanels.zul b/src/main/webapp/lists/signeddocs/tabPanels.zul new file mode 100644 index 00000000..5a74b669 --- /dev/null +++ b/src/main/webapp/lists/signeddocs/tabPanels.zul @@ -0,0 +1,17 @@ + + + + + + + + + + + + + +