Josef Rokos 9 years ago
commit 5079d6d55a

@ -1,85 +1,135 @@
package info.bukova.isspst; package info.bukova.isspst;
import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import org.apache.commons.lang.time.DateUtils; import org.apache.commons.lang.time.DateUtils;
public class DateTimeUtils public class DateTimeUtils {
{ public static Date getDate(Date value) {
public static Date getDate(Date value) if (value == null) {
{ return value;
if (value == null) }
{
return value; // Keep date - truncate time
} return DateUtils.truncate(value, Calendar.DAY_OF_MONTH);
}
// Keep date - truncate time
return DateUtils.truncate(value, Calendar.DAY_OF_MONTH); public static int getYear(Date value) {
} if (value == null) {
return 0;
public static boolean isEqualByDate(Date d1, Date d2) }
{
if (d1 != null && d2 != null) Calendar cal =Calendar.getInstance();
{ cal.setTime(value);
d1 = DateTimeUtils.getDate(d1); return cal.get(Calendar.YEAR);
d2 = DateTimeUtils.getDate(d2); }
boolean equals = (d1.compareTo(d2) == 0);
return equals; public static boolean isEqualByDate(Date d1, Date d2) {
} if (d1 != null && d2 != null) {
d1 = DateTimeUtils.getDate(d1);
return false; d2 = DateTimeUtils.getDate(d2);
} boolean equals = (d1.compareTo(d2) == 0);
return equals;
public static boolean isEqualByDateForFilter(Date value, Date search) }
{
if (search == null) return false;
{ }
return true;
} public static boolean isEqualByYear(Date d1, Date d2) {
else if (value != null) if (d1 != null && d2 != null) {
{ int year1 = DateTimeUtils.getYear(d1);
return DateTimeUtils.isEqualByDate(value, search); int year2 = DateTimeUtils.getYear(d2);
} boolean equals = (year1 == year2);
return equals;
return false; }
}
return false;
public static Date getCurrDateTime() }
{ public static boolean isEqualByDateForFilter(Date value, Date search) {
return new Date(); if (search == null) {
} return true;
} else if (value != null) {
public static Date getCurrDate() return DateTimeUtils.isEqualByDate(value, search);
{ }
return DateTimeUtils.getDate(DateTimeUtils.getCurrDateTime());
} return false;
}
public static Calendar getCalendarDelta(Date value, int calendarType, int delta) {
if (value == null) { public static String getFormatedDate(Date value) {
value = DateTimeUtils.getCurrDate(); if (value == null) {
} return "";
}
Calendar calendar = new GregorianCalendar();
calendar.setTime(value); SimpleDateFormat sdf = new SimpleDateFormat(StringUtils.localize("DateFormat"));
int deltaValue = calendar.get(calendarType); String result = sdf.format(value);
calendar.set(calendarType, deltaValue + delta); return result;
return calendar; }
}
public static String getFormatedDirDate(Date value) {
public static Calendar getCalendar(Date value) { if (value == null) {
if (value == null) { return "";
value = DateTimeUtils.getCurrDate(); }
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Calendar calendar = new GregorianCalendar(); String result = sdf.format(value);
calendar.setTime(value); return result;
return calendar; }
}
public static String getFormatedDirDateDDMM(Date value) {
public static Date getDateDelta(Date value, int calendarType, int delta) { if (value == null) {
Calendar calendar = DateTimeUtils.getCalendarDelta(value, calendarType, delta); return "";
return calendar.getTime(); }
}
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();
}
} }

@ -7,11 +7,7 @@ import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption; import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.search.annotations.IndexedEmbedded; import org.hibernate.search.annotations.IndexedEmbedded;
import javax.persistence.CascadeType; import javax.persistence.*;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -20,6 +16,9 @@ import java.util.List;
@Table(name = "SIGNED_DOCUMENTS") @Table(name = "SIGNED_DOCUMENTS")
public class SignedDocument extends BaseData { public class SignedDocument extends BaseData {
@Transient
private String agendaName;
@Column(name = "MODULE_NAME", length = Constants.LEN_TEXT) @Column(name = "MODULE_NAME", length = Constants.LEN_TEXT)
private String moduleName; private String moduleName;
@ -40,7 +39,10 @@ public class SignedDocument extends BaseData {
@IndexedEmbedded @IndexedEmbedded
private List<SignedDocumentItem> items; private List<SignedDocumentItem> items;
public String getModuleName() { public SignedDocument() {
}
public String getModuleName() {
return moduleName; return moduleName;
} }
@ -81,6 +83,9 @@ public class SignedDocument extends BaseData {
} }
public String getAgendaName() { public String getAgendaName() {
if (!StringUtils.isNullOrEmpty(this.agendaName)) {
return this.agendaName;
}
if (StringUtils.isNullOrEmpty(this.moduleName)) { if (StringUtils.isNullOrEmpty(this.moduleName)) {
return ""; return "";
@ -95,7 +100,11 @@ public class SignedDocument extends BaseData {
return ""; return "";
} }
public List<SignedDocumentItem> getItems() { public void setAgendaName(String agendaName) {
this.agendaName = agendaName;
}
public List<SignedDocumentItem> getItems() {
return items; return items;
} }

@ -1,9 +1,13 @@
package info.bukova.isspst.services.signeddocs; package info.bukova.isspst.services.signeddocs;
import info.bukova.isspst.data.DataModel; import info.bukova.isspst.data.DataModel;
import info.bukova.isspst.data.Member;
import info.bukova.isspst.data.SignedDocument; import info.bukova.isspst.data.SignedDocument;
import info.bukova.isspst.data.SignedDocumentItem; import info.bukova.isspst.data.SignedDocumentItem;
import info.bukova.isspst.services.Service; 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; import java.util.List;
@ -17,4 +21,5 @@ public interface SignedDocumentService extends Service<SignedDocument> {
public List<SignedDocument> getActualList(); public List<SignedDocument> getActualList();
public List<SignedDocument> getArchiveList(); public List<SignedDocument> getArchiveList();
public TreeModel<TreeNode<SignedDocumentItem>> getTree();
} }

@ -4,126 +4,239 @@ import info.bukova.isspst.DateTimeUtils;
import info.bukova.isspst.Module; import info.bukova.isspst.Module;
import info.bukova.isspst.ModuleUtils; import info.bukova.isspst.ModuleUtils;
import info.bukova.isspst.data.DataModel; import info.bukova.isspst.data.DataModel;
import info.bukova.isspst.data.Member;
import info.bukova.isspst.data.SignedDocument; import info.bukova.isspst.data.SignedDocument;
import info.bukova.isspst.data.SignedDocumentItem; import info.bukova.isspst.data.SignedDocumentItem;
import info.bukova.isspst.services.AbstractOwnedService; import info.bukova.isspst.services.AbstractOwnedService;
import info.bukova.isspst.services.LazyLoader; import info.bukova.isspst.services.LazyLoader;
import info.bukova.isspst.storage.ReportFileStorage; import info.bukova.isspst.storage.ReportFileStorage;
import java.util.Calendar; import java.util.*;
import java.util.Date;
import java.util.List;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import info.bukova.isspst.ui.signeddocs.SignedDocsTreeNode;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.Query; import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional; 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<SignedDocument> implements SignedDocumentService { public class SignedDocumentServiceImpl extends AbstractOwnedService<SignedDocument> implements SignedDocumentService {
@Autowired @Autowired
private ServletContext servletContext; private ServletContext servletContext;
@Autowired @Autowired
private ReportFileStorage signedDocStorage; private ReportFileStorage signedDocStorage;
@LazyLoader("grid") @LazyLoader("grid")
@Transactional @Transactional
public void lazyLoadItems(SignedDocument signedDocument) { public void lazyLoadItems(SignedDocument signedDocument) {
if (signedDocument == null) { if (signedDocument == null) {
return; return;
} }
SignedDocument sd = dao.getById(signedDocument.getId()); SignedDocument sd = dao.getById(signedDocument.getId());
Hibernate.initialize(sd.getItems()); Hibernate.initialize(sd.getItems());
signedDocument.setItems(sd.getItems()); signedDocument.setItems(sd.getItems());
} }
@Override @Override
@Transactional @Transactional
public SignedDocument getForEntity(DataModel entity) { public SignedDocument getForEntity(DataModel entity) {
Module module = ModuleUtils.getModule(entity, servletContext); Module module = ModuleUtils.getModule(entity, servletContext);
if (module == null) { if (module == null) {
return null; return null;
} }
Query q = dao.getQuery("from SignedDocument where moduleName = :module and recordId = :record"); Query q = dao.getQuery("from SignedDocument where moduleName = :module and recordId = :record");
q.setParameter("module", module.getId()); q.setParameter("module", module.getId());
q.setParameter("record", entity.getId()); q.setParameter("record", entity.getId());
return (SignedDocument) q.uniqueResult(); return (SignedDocument) q.uniqueResult();
} }
@Override @Override
@Transactional @Transactional
public SignedDocumentItem getItem(DataModel entity, long reportId) { public SignedDocumentItem getItem(DataModel entity, long reportId) {
SignedDocument doc = getForEntity(entity); SignedDocument doc = getForEntity(entity);
if (doc == null) { if (doc == null) {
return null; return null;
} }
for (SignedDocumentItem item : doc.getItems()) { for (SignedDocumentItem item : doc.getItems()) {
if (item.getReportId() == reportId) { if (item.getReportId() == reportId) {
return item; return item;
} }
} }
return null; return null;
} }
@Override @Override
public void addFromApprove(SignedDocument document) { public void addFromApprove(SignedDocument document) {
super.add(document); super.add(document);
} }
@Override @Override
public void delFromApprove(SignedDocument document) { public void delFromApprove(SignedDocument document) {
if (document == null) { if (document == null) {
return; return;
} }
super.delete(document); super.delete(document);
for (SignedDocumentItem item : document.getItems()) { for (SignedDocumentItem item : document.getItems()) {
signedDocStorage.removeFile(item); signedDocStorage.removeFile(item);
} }
} }
@Override @Override
@Transactional @Transactional
public void deleteForEntity(DataModel entity) { public void deleteForEntity(DataModel entity) {
SignedDocument doc = getForEntity(entity); SignedDocument doc = getForEntity(entity);
if (doc != null) { if (doc != null) {
delFromApprove(doc); delFromApprove(doc);
} }
} }
private Date getTresholdDate() { private Date getTresholdDate() {
Date date = DateTimeUtils.getDateDelta(DateTimeUtils.getCurrDate(), Calendar.YEAR, -1); Date date = DateTimeUtils.getDateDelta(DateTimeUtils.getCurrDate(), Calendar.MONTH, -6);
return date; return date;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
@Transactional @Transactional
@PreAuthorize("hasPermission(this, 'PERM_READ')") @PreAuthorize("hasPermission(this, 'PERM_READ')")
public List<SignedDocument> getActualList() { public List<SignedDocument> getActualList() {
Query q = dao.getQuery("from SignedDocument where signDate >= :refDate"); Query q = dao.getQuery("from SignedDocument where signDate >= :refDate");
q.setParameter("refDate", this.getTresholdDate()); q.setParameter("refDate", this.getTresholdDate());
return q.list(); return q.list();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
@Transactional @Transactional
@PreAuthorize("hasPermission(this, 'PERM_READ')") @PreAuthorize("hasPermission(this, 'PERM_READ')")
public List<SignedDocument> getArchiveList() { public List<SignedDocument> getArchiveList() {
Query q = dao.getQuery("from SignedDocument where signDate < :refDate"); Query q = dao.getQuery("from SignedDocument where signDate < :refDate");
q.setParameter("refDate", this.getTresholdDate()); q.setParameter("refDate", this.getTresholdDate());
return q.list(); return q.list();
} }
@SuppressWarnings("unchecked")
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_READ')")
public TreeModel<TreeNode<SignedDocumentItem>> 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<SignedDocumentItem> list = q.list();
SignedDocumentItem lastItem = null;
SignedDocument lastRec = null;
List<SignedDocsTreeNode> agendaNameList = new LinkedList<SignedDocsTreeNode>();
List<SignedDocsTreeNode> signYearList = new LinkedList<SignedDocsTreeNode>();
List<SignedDocsTreeNode> signDateList = new LinkedList<SignedDocsTreeNode>();
List<SignedDocsTreeNode> 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<SignedDocsTreeNode>();
filesList.add(itemNode);
}
if (isChangedSignYear) {
if (i > 0) {
SignedDocsTreeNode signYearNode = new SignedDocsTreeNode((i == documentsCount ? item : lastItem), signDateList);
signYearList.add(signYearNode);
}
signDateList = new LinkedList<SignedDocsTreeNode>();
}
if (isChangedAgendaName) {
if (i > 0) {
SignedDocsTreeNode agendaNode = new SignedDocsTreeNode((i == documentsCount ? item : lastItem), signYearList);
agendaNameList.add(agendaNode);
}
signYearList = new LinkedList<SignedDocsTreeNode>();
}
} else {
filesList.add(itemNode);
}
lastItem = item;
lastRec = lastItem.getSignedDocument();
}
Collections.sort(agendaNameList, new Comparator<SignedDocsTreeNode>() {
@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<TreeNode<SignedDocumentItem>> tree = new DefaultTreeModel<SignedDocumentItem>(root);
return tree;
}
} }

@ -44,6 +44,11 @@ public class DocumentFileStorageImpl extends AbstractFileStorage<FileMetainfo> i
this.rootPath = rootPath; this.rootPath = rootPath;
} }
@Override
public String getRootPath() {
return this.rootPath;
}
@Override @Override
public void saveFile(byte[] data, FileMetainfo fileID) { public void saveFile(byte[] data, FileMetainfo fileID) {
String fileName = generateFileName(fileID.getFileName()); String fileName = generateFileName(fileID.getFileName());

@ -9,7 +9,7 @@ import java.io.File;
*/ */
public interface FileStorage<T> { public interface FileStorage<T> {
// public String getRootPath(); public String getRootPath();
public void saveFile(byte[] data, T fileID); public void saveFile(byte[] data, T fileID);
public void saveFile(File file, T fileId); public void saveFile(File file, T fileId);
public void removeFile(T fileID); public void removeFile(T fileID);

@ -12,6 +12,11 @@ public class LocalFileStorage extends AbstractFileStorage<String> {
this.rootPath = rootPath; this.rootPath = rootPath;
} }
@Override
public String getRootPath() {
return this.rootPath;
}
public void setContext(ServletContext ctx) { public void setContext(ServletContext ctx) {
this.context = ctx; this.context = ctx;
} }

@ -16,6 +16,11 @@ public class ReportFileStorageImpl extends AbstractFileStorage<SignedDocumentIte
this.rootPath = rootPath; this.rootPath = rootPath;
} }
@Override
public String getRootPath() {
return this.rootPath;
}
private String getFilePath(String fileName) { private String getFilePath(String fileName) {
return rootPath + "/" + fileName; return rootPath + "/" + fileName;
} }

@ -0,0 +1,186 @@
package info.bukova.isspst.ui.signeddocs;
import info.bukova.isspst.DateTimeUtils;
import info.bukova.isspst.data.SignedDocument;
import info.bukova.isspst.data.SignedDocumentItem;
import info.bukova.isspst.storage.ReportFileStorage;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.AccessDeniedException;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zul.DefaultTreeModel;
import org.zkoss.zul.Filedownload;
import org.zkoss.zul.TreeModel;
import org.zkoss.zul.TreeNode;
import java.io.*;
import java.text.Normalizer;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
public class SignedDocsTreeList extends SignedDocsList {
@SuppressWarnings("unused")
private final static Logger log = LoggerFactory.getLogger(SignedDocsTreeList.class.getName());
@WireVariable
private ReportFileStorage signedDocStorage;
public SignedDocsTreeNode getSelectedNodeItem() {
return selectedNodeItem;
}
public void setSelectedNodeItem(SignedDocsTreeNode selectedNodeItem) {
this.selectedNodeItem = selectedNodeItem;
}
private SignedDocsTreeNode selectedNodeItem;
public SignedDocsTreeList() {
}
@Init(superclass = true)
public void signedDocsTreeListInit() {
}
public TreeModel<TreeNode<SignedDocumentItem>> getTreeBackup() {
try {
return signedDocumentService.getTree();
} catch (AccessDeniedException e) {
// BindUtils.postGlobalCommand(null, null, "disableCentre", null);
// e.printStackTrace();
return new DefaultTreeModel<SignedDocumentItem>(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<SignedDocsTreeNode> 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();
}
}
}
}

@ -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<SignedDocumentItem> {
public SignedDocsTreeNode(SignedDocumentItem data) {
super(data);
}
public SignedDocsTreeNode(SignedDocumentItem data, Collection<? extends TreeNode<SignedDocumentItem>> 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<SignedDocsTreeNode> getLeafs() {
List<SignedDocsTreeNode> list = new LinkedList<SignedDocsTreeNode>();
if (!this.isLeaf()) {
List<TreeNode<SignedDocumentItem>> children = this.getChildren();
for (TreeNode<SignedDocumentItem> 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<TreeNode<SignedDocumentItem>> children = this.getChildren();
for (TreeNode<SignedDocumentItem> item : children) {
SignedDocsTreeNode node = (SignedDocsTreeNode) item;
if (node != null) {
if (node.isLeaf()) {
count += 1;
} else {
count += node.getLeafsCount();
}
}
}
}
return count;
}
}

@ -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<SignedDocsTreeNode> {
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;
}
}
}

@ -415,6 +415,9 @@ Search=Hledat
Pending = Nevyřízené Pending = Nevyřízené
Archive = Archiv Archive = Archiv
Completed = Vyřízeno 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í GenerateBillingForPassengers = Generovat společný požadavek a vyúčtování
Passenger = Pasažér Passenger = Pasažér

@ -183,7 +183,7 @@
<property name="rootPath" value="${storage.root}"/> <property name="rootPath" value="${storage.root}"/>
</bean> </bean>
<bean id="signeDocStorage" class="info.bukova.isspst.storage.ReportFileStorageImpl"> <bean id="signedDocStorage" class="info.bukova.isspst.storage.ReportFileStorageImpl">
<property name="rootPath" value="${storage.signedDocuments}"/> <property name="rootPath" value="${storage.signedDocuments}"/>
</bean> </bean>

@ -93,3 +93,15 @@
.user-disabled { .user-disabled {
background-color: #fff2dd !important; 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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 950 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

@ -3,6 +3,9 @@
<listbox <listbox
vflex="1" vflex="1"
hflex="60" hflex="60"
mold="paging"
pagingPosition="bottom"
autopaging="true"
selectedItem="@bind(vm.dataBean)" selectedItem="@bind(vm.dataBean)"
onSelect="@command('onChangeSelectSignedDocs', ctrl=self)" onSelect="@command('onChangeSelectSignedDocs', ctrl=self)"
model="@load(vm.dataList)"> model="@load(vm.dataList)">

@ -0,0 +1,12 @@
<zk>
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<window
vflex="1"
border="none"
apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('info.bukova.isspst.ui.signeddocs.SignedDocsTreeList')">
<include
vflex="1"
src="/lists/signeddocs/treeBackup.zul" />
</window>
</zk>

@ -4,6 +4,7 @@
<zscript> <zscript>
String gridActual = "/lists/signeddocs/headListActual.zul"; String gridActual = "/lists/signeddocs/headListActual.zul";
String gridArchive = "/lists/signeddocs/headListArchive.zul"; String gridArchive = "/lists/signeddocs/headListArchive.zul";
String treeBackup = "/lists/signeddocs/headListBackup.zul";
</zscript> </zscript>
<window <window
vflex="1" vflex="1"

@ -5,6 +5,7 @@
<tabs> <tabs>
<tab label="${labels.ActualDocuments}" /> <tab label="${labels.ActualDocuments}" />
<tab label="${labels.Archive}" /> <tab label="${labels.Archive}" />
<tab label="${labels.Backup}" />
</tabs> </tabs>
<tabpanels> <tabpanels>
<tabpanel> <tabpanel>
@ -13,5 +14,8 @@
<tabpanel> <tabpanel>
<include src="${gridArchive}" /> <include src="${gridArchive}" />
</tabpanel> </tabpanel>
<tabpanel>
<include src="${treeBackup}" />
</tabpanel>
</tabpanels> </tabpanels>
</tabbox> </tabbox>

@ -0,0 +1,25 @@
<hlayout vflex="1" hflex="max">
<tree id="tree"
vflex="1" hflex="max"
model="@load(vm.treeBackup)"
selectedItem="@bind(vm.selectedNodeItem)"
itemRenderer="info.bukova.isspst.ui.signeddocs.SignedDocsTreeRenderer"
sclass="addScrollbar">
<treecols>
<treecol hflex="7" label="${labels.AgendaName}"/>
<treecol hflex="4" label="${labels.SigningYear}"/>
<treecol hflex="5" label="${labels.SigningDate}"/>
<treecol hflex="5" label="${labels.Number}"/>
<treecol hflex="15" label="${labels.OrderFormDescription}"/>
<treecol hflex="6" label="${labels.ReportReport}"/>
</treecols>
</tree>
<menupopup id="popupMenu">
<menuitem
image="/img/zip-032.png"
label="${labels.DownloadZipArchive}..."
onClick="@command('onCreateZipArchive')"
/>
</menupopup>
</hlayout>
Loading…
Cancel
Save