From 47e90b4287db5fcb3f364e685ee588c3666427ac Mon Sep 17 00:00:00 2001 From: Franta Pribyl Date: Mon, 29 Feb 2016 13:13:00 +0100 Subject: [PATCH] =?UTF-8?q?Do=20podepsan=C3=BDch=20dokument=C5=AF=20implem?= =?UTF-8?q?entov=C3=A1na=20z=C3=A1lo=C5=BEka=20pro=20archivaci=20soubor?= =?UTF-8?q?=C5=AF=20do=20ZIP.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #265 --- .../info/bukova/isspst/DateTimeUtils.java | 202 ++++++----- .../bukova/isspst/data/SignedDocument.java | 23 +- .../signeddocs/SignedDocumentService.java | 5 + .../signeddocs/SignedDocumentServiceImpl.java | 323 ++++++++++++------ .../storage/DocumentFileStorageImpl.java | 5 + .../bukova/isspst/storage/FileStorage.java | 2 +- .../isspst/storage/LocalFileStorage.java | 5 + .../isspst/storage/ReportFileStorageImpl.java | 5 + .../ui/signeddocs/SignedDocsTreeList.java | 186 ++++++++++ .../ui/signeddocs/SignedDocsTreeNode.java | 79 +++++ .../ui/signeddocs/SignedDocsTreeRenderer.java | 41 +++ .../WEB-INF/locales/zk-label.properties | 3 + .../webapp/WEB-INF/spring/root-context.xml | 2 +- src/main/webapp/css/zk-modify.css | 12 + src/main/webapp/img/zip-016.png | Bin 0 -> 950 bytes src/main/webapp/img/zip-032.png | Bin 0 -> 2585 bytes src/main/webapp/lists/signeddocs/grid.zul | 3 + .../lists/signeddocs/headListBackup.zul | 12 + src/main/webapp/lists/signeddocs/setup.zul | 1 + .../webapp/lists/signeddocs/tabPanels.zul | 4 + .../webapp/lists/signeddocs/treeBackup.zul | 25 ++ 21 files changed, 748 insertions(+), 190 deletions(-) create mode 100644 src/main/java/info/bukova/isspst/ui/signeddocs/SignedDocsTreeList.java create mode 100644 src/main/java/info/bukova/isspst/ui/signeddocs/SignedDocsTreeNode.java create mode 100644 src/main/java/info/bukova/isspst/ui/signeddocs/SignedDocsTreeRenderer.java create mode 100644 src/main/webapp/img/zip-016.png create mode 100644 src/main/webapp/img/zip-032.png create mode 100644 src/main/webapp/lists/signeddocs/headListBackup.zul create mode 100644 src/main/webapp/lists/signeddocs/treeBackup.zul diff --git a/src/main/java/info/bukova/isspst/DateTimeUtils.java b/src/main/java/info/bukova/isspst/DateTimeUtils.java index eb57b0b9..5a672440 100644 --- a/src/main/java/info/bukova/isspst/DateTimeUtils.java +++ b/src/main/java/info/bukova/isspst/DateTimeUtils.java @@ -1,85 +1,135 @@ package info.bukova.isspst; +import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import org.apache.commons.lang.time.DateUtils; -public class DateTimeUtils -{ - public static Date getDate(Date value) - { - if (value == null) - { - return value; - } - - // Keep date - truncate time - return DateUtils.truncate(value, Calendar.DAY_OF_MONTH); - } - - public static boolean isEqualByDate(Date d1, Date d2) - { - if (d1 != null && d2 != null) - { - d1 = DateTimeUtils.getDate(d1); - d2 = DateTimeUtils.getDate(d2); - boolean equals = (d1.compareTo(d2) == 0); - return equals; - } - - return false; - } - - public static boolean isEqualByDateForFilter(Date value, Date search) - { - if (search == null) - { - return true; - } - else if (value != null) - { - return DateTimeUtils.isEqualByDate(value, search); - } - - return false; - } - - public static Date getCurrDateTime() - { - return new Date(); - } - - public static Date getCurrDate() - { - 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(); - } +public class DateTimeUtils { + public static Date getDate(Date value) { + if (value == null) { + return value; + } + + // Keep date - truncate time + return DateUtils.truncate(value, Calendar.DAY_OF_MONTH); + } + + public static int getYear(Date value) { + if (value == null) { + return 0; + } + + Calendar cal =Calendar.getInstance(); + cal.setTime(value); + return cal.get(Calendar.YEAR); + } + + public static boolean isEqualByDate(Date d1, Date d2) { + if (d1 != null && d2 != null) { + d1 = DateTimeUtils.getDate(d1); + d2 = DateTimeUtils.getDate(d2); + boolean equals = (d1.compareTo(d2) == 0); + return equals; + } + + return false; + } + + public static boolean isEqualByYear(Date d1, Date d2) { + if (d1 != null && d2 != null) { + int year1 = DateTimeUtils.getYear(d1); + int year2 = DateTimeUtils.getYear(d2); + boolean equals = (year1 == year2); + return equals; + } + + return false; + } + public static boolean isEqualByDateForFilter(Date value, Date search) { + if (search == null) { + return true; + } else if (value != null) { + return DateTimeUtils.isEqualByDate(value, search); + } + + return false; + } + + public static String getFormatedDate(Date value) { + if (value == null) { + return ""; + } + + SimpleDateFormat sdf = new SimpleDateFormat(StringUtils.localize("DateFormat")); + String result = sdf.format(value); + return result; + } + + public static String getFormatedDirDate(Date value) { + if (value == null) { + return ""; + } + + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); + String result = sdf.format(value); + return result; + } + + public static String getFormatedDirDateDDMM(Date value) { + if (value == null) { + return ""; + } + + SimpleDateFormat sdf = new SimpleDateFormat("MMdd"); + String result = sdf.format(value); + return result; + } + + public static String getFormatedYear(Date value) { + if (value == null) { + return ""; + } + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); + String result = sdf.format(value); + return result; + } + + public static Date getCurrDateTime() { + return new Date(); + } + + public static Date getCurrDate() { + 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/data/SignedDocument.java b/src/main/java/info/bukova/isspst/data/SignedDocument.java index 608aae43..9b75093c 100644 --- a/src/main/java/info/bukova/isspst/data/SignedDocument.java +++ b/src/main/java/info/bukova/isspst/data/SignedDocument.java @@ -7,11 +7,7 @@ import org.hibernate.annotations.LazyCollection; import org.hibernate.annotations.LazyCollectionOption; import org.hibernate.search.annotations.IndexedEmbedded; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.OneToMany; -import javax.persistence.Table; +import javax.persistence.*; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -20,6 +16,9 @@ import java.util.List; @Table(name = "SIGNED_DOCUMENTS") public class SignedDocument extends BaseData { + @Transient + private String agendaName; + @Column(name = "MODULE_NAME", length = Constants.LEN_TEXT) private String moduleName; @@ -40,7 +39,10 @@ public class SignedDocument extends BaseData { @IndexedEmbedded private List items; - public String getModuleName() { + public SignedDocument() { + } + + public String getModuleName() { return moduleName; } @@ -81,6 +83,9 @@ public class SignedDocument extends BaseData { } public String getAgendaName() { + if (!StringUtils.isNullOrEmpty(this.agendaName)) { + return this.agendaName; + } if (StringUtils.isNullOrEmpty(this.moduleName)) { return ""; @@ -95,7 +100,11 @@ public class SignedDocument extends BaseData { return ""; } - public List getItems() { + public void setAgendaName(String agendaName) { + this.agendaName = agendaName; + } + + public List getItems() { return items; } 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 fc992b08..a4534772 100644 --- a/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentService.java +++ b/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentService.java @@ -1,9 +1,13 @@ package info.bukova.isspst.services.signeddocs; import info.bukova.isspst.data.DataModel; +import info.bukova.isspst.data.Member; import info.bukova.isspst.data.SignedDocument; import info.bukova.isspst.data.SignedDocumentItem; import info.bukova.isspst.services.Service; +import info.bukova.isspst.ui.signeddocs.SignedDocsTreeNode; +import org.zkoss.zul.TreeModel; +import org.zkoss.zul.TreeNode; import java.util.List; @@ -17,4 +21,5 @@ public interface SignedDocumentService extends Service { public List getActualList(); public List getArchiveList(); + public TreeModel> getTree(); } 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 22803b2d..98029423 100644 --- a/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/signeddocs/SignedDocumentServiceImpl.java @@ -4,126 +4,239 @@ import info.bukova.isspst.DateTimeUtils; import info.bukova.isspst.Module; import info.bukova.isspst.ModuleUtils; import info.bukova.isspst.data.DataModel; +import info.bukova.isspst.data.Member; 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 java.util.*; import javax.servlet.ServletContext; +import info.bukova.isspst.ui.signeddocs.SignedDocsTreeNode; 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 org.zkoss.zul.DefaultTreeModel; +import org.zkoss.zul.DefaultTreeNode; +import org.zkoss.zul.TreeModel; +import org.zkoss.zul.TreeNode; public class SignedDocumentServiceImpl extends AbstractOwnedService implements SignedDocumentService { - @Autowired - private ServletContext servletContext; - @Autowired - private ReportFileStorage signedDocStorage; - - @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()); - } - - @Override - @Transactional - public SignedDocument getForEntity(DataModel entity) { - Module module = ModuleUtils.getModule(entity, servletContext); - - if (module == null) { - return null; - } - - Query q = dao.getQuery("from SignedDocument where moduleName = :module and recordId = :record"); - q.setParameter("module", module.getId()); - q.setParameter("record", entity.getId()); - - return (SignedDocument) q.uniqueResult(); - } - - @Override - @Transactional - public SignedDocumentItem getItem(DataModel entity, long reportId) { - SignedDocument doc = getForEntity(entity); - - if (doc == null) { - return null; - } - - for (SignedDocumentItem item : doc.getItems()) { - if (item.getReportId() == reportId) { - return item; - } - } - - return null; - } - - @Override - public void addFromApprove(SignedDocument document) { - super.add(document); - } - - @Override - public void delFromApprove(SignedDocument document) { - if (document == null) { - return; - } - - super.delete(document); - - for (SignedDocumentItem item : document.getItems()) { - signedDocStorage.removeFile(item); - } - } - - @Override - @Transactional - public void deleteForEntity(DataModel entity) { - SignedDocument doc = getForEntity(entity); - if (doc != null) { - delFromApprove(doc); - } - } - - private Date getTresholdDate() { - Date date = DateTimeUtils.getDateDelta(DateTimeUtils.getCurrDate(), Calendar.YEAR, -1); - return date; - } - - @SuppressWarnings("unchecked") - @Override - @Transactional - @PreAuthorize("hasPermission(this, 'PERM_READ')") - public List 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(); - } + @Autowired + private ServletContext servletContext; + @Autowired + private ReportFileStorage signedDocStorage; + + @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()); + } + + @Override + @Transactional + public SignedDocument getForEntity(DataModel entity) { + Module module = ModuleUtils.getModule(entity, servletContext); + + if (module == null) { + return null; + } + + Query q = dao.getQuery("from SignedDocument where moduleName = :module and recordId = :record"); + q.setParameter("module", module.getId()); + q.setParameter("record", entity.getId()); + + return (SignedDocument) q.uniqueResult(); + } + + @Override + @Transactional + public SignedDocumentItem getItem(DataModel entity, long reportId) { + SignedDocument doc = getForEntity(entity); + + if (doc == null) { + return null; + } + + for (SignedDocumentItem item : doc.getItems()) { + if (item.getReportId() == reportId) { + return item; + } + } + + return null; + } + + @Override + public void addFromApprove(SignedDocument document) { + super.add(document); + } + + @Override + public void delFromApprove(SignedDocument document) { + if (document == null) { + return; + } + + super.delete(document); + + for (SignedDocumentItem item : document.getItems()) { + signedDocStorage.removeFile(item); + } + } + + @Override + @Transactional + public void deleteForEntity(DataModel entity) { + SignedDocument doc = getForEntity(entity); + if (doc != null) { + delFromApprove(doc); + } + } + + private Date getTresholdDate() { + Date date = DateTimeUtils.getDateDelta(DateTimeUtils.getCurrDate(), Calendar.MONTH, -6); + return date; + } + + @SuppressWarnings("unchecked") + @Override + @Transactional + @PreAuthorize("hasPermission(this, 'PERM_READ')") + public List 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(); + } + + @SuppressWarnings("unchecked") + @Override + @Transactional + @PreAuthorize("hasPermission(this, 'PERM_READ')") + public TreeModel> getTree() { + Query q = queryDao.getQuery("select item " + + "from SignedDocumentItem as item left join item.signedDocument as rec " + + "order by rec.moduleName, rec.signDate desc, item.reportName, item.fileName " + ); + List list = q.list(); + + SignedDocumentItem lastItem = null; + SignedDocument lastRec = null; + List agendaNameList = new LinkedList(); + List signYearList = new LinkedList(); + List signDateList = new LinkedList(); + List filesList = null; + + int documentsCount = list.size() - 1; + + for (int i = 0; i <= documentsCount; i++) { + SignedDocumentItem item = list.get(i); + SignedDocument rec = item.getSignedDocument(); + SignedDocsTreeNode itemNode = new SignedDocsTreeNode(item); + + boolean isChangedAgendaName = ((i == 0) + || (i == documentsCount) + || !lastRec.getAgendaName().equals(rec.getAgendaName()) + ); + boolean isChangedSignYear = ((i == 0) + || (i == documentsCount) + || isChangedAgendaName + || !DateTimeUtils.isEqualByYear(lastRec.getSignDate(), rec.getSignDate()) + ); + boolean isChangedSignDate = ((i == 0) + || (i == documentsCount) + || isChangedSignYear + || !DateTimeUtils.isEqualByDate(lastRec.getSignDate(), rec.getSignDate()) + ); + + if (isChangedAgendaName || isChangedSignYear || isChangedSignDate) { + + if (isChangedSignDate) { + if (i > 0) { + SignedDocsTreeNode signDateNode = new SignedDocsTreeNode((i == documentsCount ? item : lastItem), filesList); + signDateList.add(signDateNode); + } + + filesList = new LinkedList(); + filesList.add(itemNode); + } + + if (isChangedSignYear) { + if (i > 0) { + SignedDocsTreeNode signYearNode = new SignedDocsTreeNode((i == documentsCount ? item : lastItem), signDateList); + signYearList.add(signYearNode); + } + + signDateList = new LinkedList(); + } + + if (isChangedAgendaName) { + if (i > 0) { + SignedDocsTreeNode agendaNode = new SignedDocsTreeNode((i == documentsCount ? item : lastItem), signYearList); + agendaNameList.add(agendaNode); + } + + signYearList = new LinkedList(); + } + } else { + filesList.add(itemNode); + } + + lastItem = item; + lastRec = lastItem.getSignedDocument(); + } + + Collections.sort(agendaNameList, new Comparator() { + @Override + public int compare(SignedDocsTreeNode nodeL, SignedDocsTreeNode nodeR) { + if ((nodeL != null) && (nodeR != null)) { + SignedDocumentItem itemL = nodeL.getData(); + SignedDocumentItem itemR = nodeR.getData(); + + if ((itemL != null) && (itemR != null)) { + SignedDocument recL = itemL.getSignedDocument(); + SignedDocument recR = itemR.getSignedDocument(); + + if ((recL != null) && (recR != null)) { + String nameL = recL.getAgendaName(); + String nameR = recR.getAgendaName(); + + if ((nameL != null) && (nameR != null)) { + return nameL.compareTo(nameR); + } + } + } + } + + return 0; + } + } + ); + + SignedDocsTreeNode root = new SignedDocsTreeNode(null, agendaNameList); + TreeModel> tree = new DefaultTreeModel(root); + return tree; + } } diff --git a/src/main/java/info/bukova/isspst/storage/DocumentFileStorageImpl.java b/src/main/java/info/bukova/isspst/storage/DocumentFileStorageImpl.java index 4ff84e90..bb5bf8d8 100644 --- a/src/main/java/info/bukova/isspst/storage/DocumentFileStorageImpl.java +++ b/src/main/java/info/bukova/isspst/storage/DocumentFileStorageImpl.java @@ -44,6 +44,11 @@ public class DocumentFileStorageImpl extends AbstractFileStorage i this.rootPath = rootPath; } + @Override + public String getRootPath() { + return this.rootPath; + } + @Override public void saveFile(byte[] data, FileMetainfo fileID) { String fileName = generateFileName(fileID.getFileName()); diff --git a/src/main/java/info/bukova/isspst/storage/FileStorage.java b/src/main/java/info/bukova/isspst/storage/FileStorage.java index 90a0eea2..9f384b58 100644 --- a/src/main/java/info/bukova/isspst/storage/FileStorage.java +++ b/src/main/java/info/bukova/isspst/storage/FileStorage.java @@ -9,7 +9,7 @@ import java.io.File; */ public interface FileStorage { -// public String getRootPath(); + public String getRootPath(); public void saveFile(byte[] data, T fileID); public void saveFile(File file, T fileId); public void removeFile(T fileID); diff --git a/src/main/java/info/bukova/isspst/storage/LocalFileStorage.java b/src/main/java/info/bukova/isspst/storage/LocalFileStorage.java index 00d86515..f1bc3ea0 100644 --- a/src/main/java/info/bukova/isspst/storage/LocalFileStorage.java +++ b/src/main/java/info/bukova/isspst/storage/LocalFileStorage.java @@ -12,6 +12,11 @@ public class LocalFileStorage extends AbstractFileStorage { this.rootPath = rootPath; } + @Override + public String getRootPath() { + return this.rootPath; + } + public void setContext(ServletContext ctx) { this.context = ctx; } diff --git a/src/main/java/info/bukova/isspst/storage/ReportFileStorageImpl.java b/src/main/java/info/bukova/isspst/storage/ReportFileStorageImpl.java index 93f59998..470e6026 100644 --- a/src/main/java/info/bukova/isspst/storage/ReportFileStorageImpl.java +++ b/src/main/java/info/bukova/isspst/storage/ReportFileStorageImpl.java @@ -16,6 +16,11 @@ public class ReportFileStorageImpl extends AbstractFileStorage> getTreeBackup() { + try { + return signedDocumentService.getTree(); + } catch (AccessDeniedException e) { + // BindUtils.postGlobalCommand(null, null, "disableCentre", null); + // e.printStackTrace(); + return new DefaultTreeModel(null); + } + } + + public static void addToZipFile(String filePath, String zipPath, ZipOutputStream zos) throws FileNotFoundException, IOException { + + //System.out.println("Writing '" + filePath + "' to zip file"); + + File file = new File(filePath); + FileInputStream fis = new FileInputStream(file); + ZipEntry zipEntry = new ZipEntry(zipPath); + zos.putNextEntry(zipEntry); + + byte[] bytes = new byte[1024]; + int length; + while ((length = fis.read(bytes)) >= 0) { + zos.write(bytes, 0, length); + } + + zos.closeEntry(); + fis.close(); + } + + public static String getNormalizedPath(String path) { + String result = path.replaceAll("[ ]", "_"); + result = Normalizer.normalize(result, Normalizer.Form.NFD); + result = result.replaceAll("[^-a-zA-Z0-9_./]", ""); + return result; + } + + public static String getCheckedString(String str, int maxLength) { + String result = ""; + + if (str != null) { + + int len = str.length(); + + if (len > 0) { + result = str.substring(0, len > maxLength ? maxLength - 1 : len); + result += "-"; + } + } + + return result; + } + + public static String getCheckedString(String str) { + return SignedDocsTreeList.getCheckedString(str, 50); + } + + @Command + public void onCreateZipArchive() { + if (this.selectedNodeItem == null) { + return; + } + + List leafs = this.selectedNodeItem.getLeafs(); + + if (leafs.size() > 0) { + int deep = this.selectedNodeItem.getDeep(); + + try { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ZipOutputStream zos = new ZipOutputStream(bos); + + for (SignedDocsTreeNode node : leafs) { + SignedDocumentItem item = node.getData(); + String pdfFileName = item.getFileName(); + + SignedDocument doc = item.getSignedDocument(); + String zipDirs = ""; + + + String zipFileName = ""; + + if (deep == 3 || deep == 4) { + zipFileName += SignedDocsTreeList.getCheckedString(DateTimeUtils.getFormatedDirDate(doc.getSignDate())); + } + + zipFileName += SignedDocsTreeList.getCheckedString(item.getReportName()); + zipFileName += SignedDocsTreeList.getCheckedString(doc.getNumser()); + zipFileName += SignedDocsTreeList.getCheckedString(doc.getDescription()); + zipFileName += SignedDocsTreeList.getCheckedString(pdfFileName); + + if (deep == 1 || deep == 2 || deep == 3) { + zipDirs += doc.getAgendaName(); + zipDirs += "/"; + } + + if (deep == 1) { + zipDirs += DateTimeUtils.getFormatedYear(doc.getSignDate()); + zipDirs += "/"; + } + + if (deep == 1) { + zipDirs += DateTimeUtils.getFormatedDirDateDDMM(doc.getSignDate()); + zipDirs += "/"; + } + if (deep == 2) { + zipDirs += DateTimeUtils.getFormatedDirDate(doc.getSignDate()); + zipDirs += "/"; + } + String rootPath = signedDocStorage.getRootPath(); + + String diskPath = rootPath + "/" + pdfFileName; + String zipPath = zipDirs + zipFileName; + + zipPath = SignedDocsTreeList.getNormalizedPath(zipPath); + + if (new File(diskPath).isFile()) { + SignedDocsTreeList.addToZipFile(diskPath, zipPath, zos); + } else { + log.warn("Missing file '" + diskPath + "' !!!"); + log.warn(doc.getAgendaName()); + log.warn(doc.getDescription()); + log.warn(item.getReportName()); + } + } + + zos.close(); + bos.close(); + + Filedownload.save(bos.toByteArray(), "application/zip", "temp" + Long.toString(System.nanoTime()) + ".zip"); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/info/bukova/isspst/ui/signeddocs/SignedDocsTreeNode.java b/src/main/java/info/bukova/isspst/ui/signeddocs/SignedDocsTreeNode.java new file mode 100644 index 00000000..1d8e5f1f --- /dev/null +++ b/src/main/java/info/bukova/isspst/ui/signeddocs/SignedDocsTreeNode.java @@ -0,0 +1,79 @@ +package info.bukova.isspst.ui.signeddocs; + +import info.bukova.isspst.data.SignedDocumentItem; +import org.zkoss.zul.DefaultTreeNode; +import org.zkoss.zul.TreeNode; + +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + +public class SignedDocsTreeNode extends DefaultTreeNode { + public SignedDocsTreeNode(SignedDocumentItem data) { + super(data); + } + + public SignedDocsTreeNode(SignedDocumentItem data, Collection> children) { + super(data, children); + } + + public SignedDocsTreeNode getParentNode() { + return (SignedDocsTreeNode) this.getParent(); + } + + public int getDeep() { + int iDeep = 0; + SignedDocsTreeNode node = this.getParentNode(); + + while (node != null) { + node = node.getParentNode(); + iDeep++; + } + + return iDeep; + } + + public List getLeafs() { + List list = new LinkedList(); + + if (!this.isLeaf()) { + List> children = this.getChildren(); + + for (TreeNode item : children) { + SignedDocsTreeNode node = (SignedDocsTreeNode) item; + + if (node != null) { + if (node.isLeaf()) { + list.add(node); + } else { + list.addAll(node.getLeafs()); + } + } + } + } + + return list; + } + + public int getLeafsCount() { + int count = 0; + + if (!this.isLeaf()) { + List> children = this.getChildren(); + + for (TreeNode item : children) { + SignedDocsTreeNode node = (SignedDocsTreeNode) item; + + if (node != null) { + if (node.isLeaf()) { + count += 1; + } else { + count += node.getLeafsCount(); + } + } + } + } + + return count; + } +} diff --git a/src/main/java/info/bukova/isspst/ui/signeddocs/SignedDocsTreeRenderer.java b/src/main/java/info/bukova/isspst/ui/signeddocs/SignedDocsTreeRenderer.java new file mode 100644 index 00000000..3ec299fd --- /dev/null +++ b/src/main/java/info/bukova/isspst/ui/signeddocs/SignedDocsTreeRenderer.java @@ -0,0 +1,41 @@ +package info.bukova.isspst.ui.signeddocs; + +import info.bukova.isspst.DateTimeUtils; +import info.bukova.isspst.StringUtils; +import info.bukova.isspst.data.SignedDocument; +import info.bukova.isspst.data.SignedDocumentItem; +import org.zkoss.zul.*; + +public class SignedDocsTreeRenderer implements TreeitemRenderer { + public void render(Treeitem item, SignedDocsTreeNode data, int index) throws Exception { + + int deep = data.getDeep(); + + boolean node1 = (deep == 1);//data.getParent().getParent() == null; + boolean node3 = (deep == 3);//data.isLeaf(); + boolean node2 = (deep == 2);//!node1 && !node3; + boolean node4 = (deep == 4);//!node1 && !node3; + + SignedDocumentItem signedDocumentItem = data.getData(); + SignedDocument signedDocument = signedDocumentItem.getSignedDocument(); + + Treerow tr = new Treerow(); + tr.setContext("popupMenu"); + + item.appendChild(tr); + tr.appendChild(new Treecell(node1 ? signedDocument.getAgendaName() : "")); + tr.appendChild(new Treecell(node2 ? DateTimeUtils.getFormatedYear(signedDocument.getSignDate()) : "")); + tr.appendChild(new Treecell(node3 ? DateTimeUtils.getFormatedDate(signedDocument.getSignDate()) : "")); + tr.appendChild(new Treecell(node4 ? signedDocument.getNumser() : "")); + tr.appendChild(new Treecell(node4 ? signedDocument.getDescription() : "")); + tr.appendChild(new Treecell(node4 ? signedDocumentItem.getReportName() : data.getLeafsCount() + " souborů")); +// tr.appendChild(new Treecell(node3 ? signedDocumentItem.getFileName() : "")); + + switch (deep) { + case 1 : tr.setSclass("signed-doc-agenda"); break; + case 2 : tr.setSclass("signed-doc-year"); break; + case 3 : tr.setSclass("signed-doc-date"); break; + case 4 : tr.setSclass(""); break; + } + } +} diff --git a/src/main/webapp/WEB-INF/locales/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties index 1a920bb8..4472b8c9 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -415,6 +415,9 @@ Search=Hledat Pending = Nevyřízené Archive = Archiv Completed = Vyřízeno +Backup = Zálohování +SigningYear = Rok podepsání +DownloadZipArchive = Stáhnout ZIP archiv... GenerateBillingForPassengers = Generovat společný požadavek a vyúčtování Passenger = Pasažér diff --git a/src/main/webapp/WEB-INF/spring/root-context.xml b/src/main/webapp/WEB-INF/spring/root-context.xml index 8e325a1d..cc08388d 100644 --- a/src/main/webapp/WEB-INF/spring/root-context.xml +++ b/src/main/webapp/WEB-INF/spring/root-context.xml @@ -183,7 +183,7 @@ - + diff --git a/src/main/webapp/css/zk-modify.css b/src/main/webapp/css/zk-modify.css index a6039d62..2c9142f2 100644 --- a/src/main/webapp/css/zk-modify.css +++ b/src/main/webapp/css/zk-modify.css @@ -93,3 +93,15 @@ .user-disabled { background-color: #fff2dd !important; } + +.signed-doc-agenda { + background-color: #d0d0d0 !important; +} + +.signed-doc-year { + background-color: #e0e0e0 !important; +} + +.signed-doc-date { + background-color: #f0f0f0 !important; +} \ No newline at end of file diff --git a/src/main/webapp/img/zip-016.png b/src/main/webapp/img/zip-016.png new file mode 100644 index 0000000000000000000000000000000000000000..57fa131db2435e989d86b90aaa9f6769f4323a00 GIT binary patch literal 950 zcmV;n14;aeP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02p*dSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E;(#7eog=Y11CvDK~y+Tt(4&hYx{ineSbdt{_!RMt+bUJ?6qP~UtOI~(4d4BI?}i$Vx)<6N+;cP!YQXT z(d@CD$0{zqtgZ3(Q;XaeO^gu&z(^%pcd0hjX zhJ`A?w^{_z%>}6AEkSpw+ihxr>b1wRj_SZ4I%N#T1`_l*7}Ij~k}2vh@o*J)!?|S~ z`y1u>u1$ox^D5*O`=BiMTuroX!8b-fpTcOTp5jlZDSfgq*bAhf$BW@pEdG_FL_#C; zzd*j$Z@)j>8iZl_QH-=7`{mPbs)iugo#Dg$++%p(N~7)#S;Ne?dOto0?cx3a0MPPzx`YGyv^dFGO$sbOJ2x&ykVozOM= zP9lDO4mSLk*qvU0mAnEpRYg)+P0eQXzHrSW9m0jz`^(lr^KK&sBwiT!FxkC?EwI_n zhQqe=aM^bjg*+c<>O9e3=7G+Ki?c{;rgfC^$ug)a)<7Xzi{3Zx=y~miu2=365 z|IjPg8yth+$ZL2d+=Z`ItD$_d9P(V-+eE^(4Cs2`f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>o#9Go4jBvK z^$8H(P=+v+MPt|q!c`#T2$MhM{k#Ab7&y=tY`*aV2VCeTO&Y=*EE=vUqv6VUw1m*s z1}gpLZmT#`ZqK|Wp56jUJk8~}r2uiX0)&A)oOe`+Cr=HzH^W_zS;9-}Rrq|s6WA{pb%MOOPq4Dw`_IOG6h;#vu%p-&hQ#>7Ix zL_vY!uG3426@;~%)#LeE&dQqRe#)8_zO2?FZ)L5;CzQtVEop2vp-sF+aHdLxtnycF vT$Ur@CjSAK^hgxsaD8t4g$n-%8^in?9%x>FZ9`t@00000NkvXXu0mjf^%vmQ literal 0 HcmV?d00001 diff --git a/src/main/webapp/lists/signeddocs/grid.zul b/src/main/webapp/lists/signeddocs/grid.zul index 52aa0453..aa1fa4d1 100644 --- a/src/main/webapp/lists/signeddocs/grid.zul +++ b/src/main/webapp/lists/signeddocs/grid.zul @@ -3,6 +3,9 @@ diff --git a/src/main/webapp/lists/signeddocs/headListBackup.zul b/src/main/webapp/lists/signeddocs/headListBackup.zul new file mode 100644 index 00000000..54ca730d --- /dev/null +++ b/src/main/webapp/lists/signeddocs/headListBackup.zul @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/src/main/webapp/lists/signeddocs/setup.zul b/src/main/webapp/lists/signeddocs/setup.zul index 2432fd12..fe181283 100644 --- a/src/main/webapp/lists/signeddocs/setup.zul +++ b/src/main/webapp/lists/signeddocs/setup.zul @@ -4,6 +4,7 @@ String gridActual = "/lists/signeddocs/headListActual.zul"; String gridArchive = "/lists/signeddocs/headListArchive.zul"; + String treeBackup = "/lists/signeddocs/headListBackup.zul"; + @@ -13,5 +14,8 @@ + + + diff --git a/src/main/webapp/lists/signeddocs/treeBackup.zul b/src/main/webapp/lists/signeddocs/treeBackup.zul new file mode 100644 index 00000000..b8f3e23f --- /dev/null +++ b/src/main/webapp/lists/signeddocs/treeBackup.zul @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + +