Umožněn upload souborů k požadavkům na služební cesty a k vyúčtování služební cesty.
closes #131
This commit is contained in:
@@ -1,12 +1,13 @@
|
|||||||
package info.bukova.isspst.data;
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Cascade;
|
||||||
|
import org.hibernate.annotations.CascadeType;
|
||||||
import org.hibernate.search.annotations.Analyze;
|
import org.hibernate.search.annotations.Analyze;
|
||||||
import org.hibernate.search.annotations.Field;
|
import org.hibernate.search.annotations.Field;
|
||||||
import org.hibernate.search.annotations.Index;
|
import org.hibernate.search.annotations.Index;
|
||||||
import org.hibernate.search.annotations.Indexed;
|
import org.hibernate.search.annotations.Indexed;
|
||||||
import org.hibernate.search.annotations.IndexedEmbedded;
|
import org.hibernate.search.annotations.IndexedEmbedded;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
@@ -29,8 +30,9 @@ public class FileMetainfo extends BaseData {
|
|||||||
@Column(name = "RECORD_ID")
|
@Column(name = "RECORD_ID")
|
||||||
private int recordId;
|
private int recordId;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
|
@ManyToOne(fetch = FetchType.EAGER)
|
||||||
@JoinColumn(name = "CONTENT_ID")
|
@JoinColumn(name = "CONTENT_ID")
|
||||||
|
@Cascade(CascadeType.SAVE_UPDATE)
|
||||||
@IndexedEmbedded
|
@IndexedEmbedded
|
||||||
private FileContent content;
|
private FileContent content;
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package info.bukova.isspst.data;
|
package info.bukova.isspst.data;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import info.bukova.isspst.storage.EntityWithAttachment;
|
||||||
import java.util.ArrayList;
|
import org.hibernate.annotations.LazyCollection;
|
||||||
import java.util.Date;
|
import org.hibernate.annotations.LazyCollectionOption;
|
||||||
import java.util.List;
|
import org.hibernate.search.annotations.Indexed;
|
||||||
|
import org.hibernate.search.annotations.IndexedEmbedded;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
@@ -13,16 +14,15 @@ import javax.persistence.JoinColumn;
|
|||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.OneToOne;
|
import javax.persistence.OneToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
import java.util.ArrayList;
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
import java.util.Date;
|
||||||
import org.hibernate.search.annotations.Indexed;
|
import java.util.List;
|
||||||
import org.hibernate.search.annotations.IndexedEmbedded;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "TRIP_BILL")
|
@Table(name = "TRIP_BILL")
|
||||||
@Indexed
|
@Indexed
|
||||||
public class TripBill extends BaseData {
|
public class TripBill extends BaseData implements EntityWithAttachment {
|
||||||
|
|
||||||
@OneToOne(fetch = FetchType.EAGER)
|
@OneToOne(fetch = FetchType.EAGER)
|
||||||
@JoinColumn(name = "REQUIREMENT_ID")
|
@JoinColumn(name = "REQUIREMENT_ID")
|
||||||
@@ -47,13 +47,14 @@ public class TripBill extends BaseData {
|
|||||||
private BigDecimal downPayment;
|
private BigDecimal downPayment;
|
||||||
@Column(name = "TOTAL", precision = 15, scale = 4)
|
@Column(name = "TOTAL", precision = 15, scale = 4)
|
||||||
private BigDecimal total;
|
private BigDecimal total;
|
||||||
@OneToMany
|
@OneToMany(cascade = CascadeType.ALL)
|
||||||
@LazyCollection(LazyCollectionOption.TRUE)
|
@LazyCollection(LazyCollectionOption.TRUE)
|
||||||
@IndexedEmbedded
|
@IndexedEmbedded
|
||||||
private List<FileMetainfo> attachedFiles;
|
private List<FileMetainfo> attachedFiles;
|
||||||
|
|
||||||
public TripBill() {
|
public TripBill() {
|
||||||
billItems = new ArrayList<TripBillItem>();
|
billItems = new ArrayList<TripBillItem>();
|
||||||
|
attachedFiles = new ArrayList<FileMetainfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TripRequirement getRequirement() {
|
public TripRequirement getRequirement() {
|
||||||
@@ -132,6 +133,16 @@ public class TripBill extends BaseData {
|
|||||||
return attachedFiles;
|
return attachedFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addAttachment(FileMetainfo metaInfo) {
|
||||||
|
attachedFiles.add(metaInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeAttachment(FileMetainfo metainfo) {
|
||||||
|
attachedFiles.remove(metainfo);
|
||||||
|
}
|
||||||
|
|
||||||
public void setAttachedFiles(List<FileMetainfo> attachedFiles) {
|
public void setAttachedFiles(List<FileMetainfo> attachedFiles) {
|
||||||
this.attachedFiles = attachedFiles;
|
this.attachedFiles = attachedFiles;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package info.bukova.isspst.services;
|
package info.bukova.isspst.services;
|
||||||
|
|
||||||
import java.util.Date;
|
import info.bukova.isspst.data.OwnedDataModel;
|
||||||
|
import info.bukova.isspst.data.User;
|
||||||
import org.hibernate.NonUniqueResultException;
|
import org.hibernate.NonUniqueResultException;
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
@@ -9,8 +9,7 @@ import org.springframework.security.core.context.SecurityContextHolder;
|
|||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import info.bukova.isspst.data.OwnedDataModel;
|
import java.util.Date;
|
||||||
import info.bukova.isspst.data.User;
|
|
||||||
|
|
||||||
public class AbstractOwnedService<T extends OwnedDataModel> extends AbstractService<T> {
|
public class AbstractOwnedService<T extends OwnedDataModel> extends AbstractService<T> {
|
||||||
|
|
||||||
@@ -32,6 +31,7 @@ public class AbstractOwnedService<T extends OwnedDataModel> extends AbstractServ
|
|||||||
entity.setModifiedBy(getLoggedInUser());
|
entity.setModifiedBy(getLoggedInUser());
|
||||||
entity.setModified(new Date());
|
entity.setModified(new Date());
|
||||||
dao.modify(entity);
|
dao.modify(entity);
|
||||||
|
maintainStorrage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package info.bukova.isspst.services;
|
package info.bukova.isspst.services;
|
||||||
|
|
||||||
import static ch.lambdaj.Lambda.filter;
|
|
||||||
import info.bukova.isspst.Module;
|
import info.bukova.isspst.Module;
|
||||||
import info.bukova.isspst.ModuleUtils;
|
import info.bukova.isspst.ModuleUtils;
|
||||||
import info.bukova.isspst.SessionData;
|
import info.bukova.isspst.SessionData;
|
||||||
@@ -11,7 +10,15 @@ import info.bukova.isspst.data.NumberSeries;
|
|||||||
import info.bukova.isspst.filters.Filter;
|
import info.bukova.isspst.filters.Filter;
|
||||||
import info.bukova.isspst.reporting.Report;
|
import info.bukova.isspst.reporting.Report;
|
||||||
import info.bukova.isspst.services.numberseries.NumberSeriesService;
|
import info.bukova.isspst.services.numberseries.NumberSeriesService;
|
||||||
|
import info.bukova.isspst.storage.DocumentFileStorage;
|
||||||
|
import org.hibernate.NonUniqueResultException;
|
||||||
|
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.validation.ConstraintViolation;
|
||||||
|
import javax.validation.Validator;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@@ -20,14 +27,7 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.validation.ConstraintViolation;
|
import static ch.lambdaj.Lambda.filter;
|
||||||
import javax.validation.Validator;
|
|
||||||
|
|
||||||
import org.hibernate.NonUniqueResultException;
|
|
||||||
import org.hibernate.Query;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
public abstract class AbstractService<T extends DataModel> implements Service<T> {
|
public abstract class AbstractService<T extends DataModel> implements Service<T> {
|
||||||
|
|
||||||
@@ -37,9 +37,14 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|||||||
protected SessionData sessionData;
|
protected SessionData sessionData;
|
||||||
@Autowired
|
@Autowired
|
||||||
protected QueryDao queryDao;
|
protected QueryDao queryDao;
|
||||||
|
private DocumentFileStorage documentFileStorage;
|
||||||
|
|
||||||
private NumberSeriesService numberSeriesService;
|
private NumberSeriesService numberSeriesService;
|
||||||
|
|
||||||
|
|
||||||
|
public void setDocumentFileStorage(DocumentFileStorage storage) {
|
||||||
|
this.documentFileStorage = storage;
|
||||||
|
}
|
||||||
|
|
||||||
public NumberSeriesService getNumberSeriesService()
|
public NumberSeriesService getNumberSeriesService()
|
||||||
{
|
{
|
||||||
@@ -62,6 +67,12 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|||||||
public String getDeleteEntityPermission() {
|
public String getDeleteEntityPermission() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void maintainStorrage() {
|
||||||
|
if (documentFileStorage != null) {
|
||||||
|
documentFileStorage.purge();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@PreAuthorize("hasPermission(this, 'PERM_ADD')")
|
@PreAuthorize("hasPermission(this, 'PERM_ADD')")
|
||||||
@@ -101,6 +112,7 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|||||||
validate(entity);
|
validate(entity);
|
||||||
entity.setModified(new Date());
|
entity.setModified(new Date());
|
||||||
dao.modify(entity);
|
dao.modify(entity);
|
||||||
|
maintainStorrage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -114,8 +126,10 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|||||||
if (getModule() != null && !getModule().isActive()) {
|
if (getModule() != null && !getModule().isActive()) {
|
||||||
throw new ModuleNotActiveException();
|
throw new ModuleNotActiveException();
|
||||||
}
|
}
|
||||||
|
|
||||||
dao.delete(entity);
|
dao.delete(entity);
|
||||||
|
|
||||||
|
maintainStorrage(); // poklidit přiložené soubory
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -7,13 +7,7 @@ import info.bukova.isspst.data.TripRequirement;
|
|||||||
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.services.settings.GlobalSettingsService;
|
import info.bukova.isspst.services.settings.GlobalSettingsService;
|
||||||
|
import org.hibernate.Hibernate;
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.hibernate.LazyInitializationException;
|
import org.hibernate.LazyInitializationException;
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
@@ -24,6 +18,12 @@ 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 java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class TripBillServiceImpl extends AbstractOwnedService<TripBill> implements
|
public class TripBillServiceImpl extends AbstractOwnedService<TripBill> implements
|
||||||
TripBillService {
|
TripBillService {
|
||||||
|
|
||||||
@@ -80,6 +80,14 @@ public class TripBillServiceImpl extends AbstractOwnedService<TripBill> implemen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@LazyLoader("form")
|
||||||
|
public void loadAttachments(TripBill entity) {
|
||||||
|
TripBill e = dao.getById(entity.getId());
|
||||||
|
Hibernate.initialize(e.getAttachedFiles());
|
||||||
|
entity.setAttachedFiles(e.getAttachedFiles());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calculate(TripBill bill) {
|
public void calculate(TripBill bill) {
|
||||||
bill.setTotal(BigDecimal.ZERO);
|
bill.setTotal(BigDecimal.ZERO);
|
||||||
|
|||||||
@@ -61,6 +61,12 @@ public interface DocumentFileStorage extends FileStorage<FileMetainfo> {
|
|||||||
*
|
*
|
||||||
* @param entity Entita s přílohami
|
* @param entity Entita s přílohami
|
||||||
*/
|
*/
|
||||||
public void removaAllAttachments(EntityWithAttachment entity);
|
public void removeAllAttachments(EntityWithAttachment entity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uklidí soubory, na které neexistuje reference v databázi a z tabulky FILE_CONTENTS vymaže záznamy, na které
|
||||||
|
* neexistuje refernece z FILE_METAINFO
|
||||||
|
*/
|
||||||
|
public void purge();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import info.bukova.isspst.services.fulltext.Extractor;
|
|||||||
import info.bukova.isspst.services.fulltext.ExtractorFactory;
|
import info.bukova.isspst.services.fulltext.ExtractorFactory;
|
||||||
import org.apache.commons.codec.binary.Hex;
|
import org.apache.commons.codec.binary.Hex;
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
|
import org.hibernate.SQLQuery;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -173,7 +174,7 @@ public class DocumentFileStorageImpl extends AbstractFileStorage<FileMetainfo> i
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<FileMetainfo> infosForPath(String path) {
|
private List<FileMetainfo> infosForPath(String path) {
|
||||||
Query q = queryDao.getQuery("from FileMetainfo info where info.pathInFilesystem = :path");
|
Query q = queryDao.getQuery("from FileMetainfo info where info.content.pathInFilesystem = :path");
|
||||||
q.setString("path", path);
|
q.setString("path", path);
|
||||||
|
|
||||||
return q.list();
|
return q.list();
|
||||||
@@ -224,11 +225,37 @@ public class DocumentFileStorageImpl extends AbstractFileStorage<FileMetainfo> i
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void removaAllAttachments(EntityWithAttachment entity) {
|
public void removeAllAttachments(EntityWithAttachment entity) {
|
||||||
for (FileMetainfo metaInfo : entity.getAttachedFiles()) {
|
for (FileMetainfo metaInfo : entity.getAttachedFiles()) {
|
||||||
removeFile(metaInfo);
|
removeFile(metaInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.getAttachedFiles().clear();
|
entity.getAttachedFiles().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void purge() {
|
||||||
|
File folder = new File(rootPath);
|
||||||
|
File[] allFiles = folder.listFiles();
|
||||||
|
Query q = queryDao.getQuery("from FileMetainfo");
|
||||||
|
List<FileMetainfo> infos = q.list();
|
||||||
|
|
||||||
|
for (File f : allFiles) {
|
||||||
|
boolean fileExists = false;
|
||||||
|
|
||||||
|
for (FileMetainfo info : infos) {
|
||||||
|
if (info.getContent().getPathInFilesystem().equals(f.getName())) {
|
||||||
|
fileExists = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fileExists && f.isFile()) {
|
||||||
|
f.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SQLQuery sql = queryDao.getSession().createSQLQuery("delete from file_contents where id not in(select CONTENT_ID from file_metainfo)");
|
||||||
|
sql.executeUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package info.bukova.isspst.ui;
|
||||||
|
|
||||||
|
import info.bukova.isspst.data.DataModel;
|
||||||
|
import info.bukova.isspst.data.FileMetainfo;
|
||||||
|
import info.bukova.isspst.storage.DocumentFileStorage;
|
||||||
|
import info.bukova.isspst.storage.EntityWithAttachment;
|
||||||
|
import org.zkoss.bind.annotation.BindingParam;
|
||||||
|
import org.zkoss.bind.annotation.Command;
|
||||||
|
import org.zkoss.bind.annotation.ContextParam;
|
||||||
|
import org.zkoss.bind.annotation.ContextType;
|
||||||
|
import org.zkoss.bind.annotation.Init;
|
||||||
|
import org.zkoss.bind.annotation.NotifyChange;
|
||||||
|
import org.zkoss.zk.ui.event.UploadEvent;
|
||||||
|
import org.zkoss.zk.ui.select.annotation.WireVariable;
|
||||||
|
import org.zkoss.zul.Filedownload;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Pepa Rokos
|
||||||
|
*/
|
||||||
|
public class FormWithUpload<T extends DataModel> extends FormViewModel<T> {
|
||||||
|
|
||||||
|
private List<FileMetainfo> attachments;
|
||||||
|
private List<FileMetainfo> forDelete;
|
||||||
|
@WireVariable
|
||||||
|
private DocumentFileStorage documentStorage;
|
||||||
|
|
||||||
|
@Init(superclass = true)
|
||||||
|
public void initFormWithUpload() {
|
||||||
|
if (getDataBean() instanceof EntityWithAttachment) {
|
||||||
|
attachments = ((EntityWithAttachment)getDataBean()).getAttachedFiles();
|
||||||
|
}
|
||||||
|
forDelete = new ArrayList<FileMetainfo>(); // kolekce příloh na smazání v případě uložení záznamu
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command
|
||||||
|
@NotifyChange("attachments")
|
||||||
|
public void uploadAttachment(@ContextParam(ContextType.TRIGGER_EVENT) UploadEvent upEvent) {
|
||||||
|
FileMetainfo metaInfo = documentStorage.saveAndCreateInfo(upEvent.getMedia().getByteData(),
|
||||||
|
upEvent.getMedia().getName());
|
||||||
|
|
||||||
|
((EntityWithAttachment)getDataBean()).addAttachment(metaInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command
|
||||||
|
@NotifyChange("attachments")
|
||||||
|
public void deleteAttachment(@BindingParam("attachment") FileMetainfo metaInfo) {
|
||||||
|
((EntityWithAttachment)getDataBean()).removeAttachment(metaInfo);
|
||||||
|
forDelete.add(metaInfo); // smazat až v případě uložení záznamu
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command
|
||||||
|
public void downloadAttachment(@BindingParam("attachment") FileMetainfo metaInfo) {
|
||||||
|
Filedownload.save(documentStorage.fileData(metaInfo), metaInfo.getContentType(), metaInfo.getFileName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FileMetainfo> getAttachments() {
|
||||||
|
return attachments;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doSave() {
|
||||||
|
for (FileMetainfo info : forDelete) {
|
||||||
|
documentStorage.removeFile(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.doSave();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,23 +1,26 @@
|
|||||||
package info.bukova.isspst.ui.requirement;
|
package info.bukova.isspst.ui.requirement;
|
||||||
|
|
||||||
import info.bukova.isspst.data.*;
|
import info.bukova.isspst.data.SettingsData;
|
||||||
|
import info.bukova.isspst.data.TripRequirement;
|
||||||
|
import info.bukova.isspst.data.User;
|
||||||
|
import info.bukova.isspst.data.Workgroup;
|
||||||
import info.bukova.isspst.services.requirement.RequirementTypeService;
|
import info.bukova.isspst.services.requirement.RequirementTypeService;
|
||||||
import info.bukova.isspst.services.requirement.TripRequirementService;
|
import info.bukova.isspst.services.requirement.TripRequirementService;
|
||||||
import info.bukova.isspst.services.settings.GlobalSettingsService;
|
import info.bukova.isspst.services.settings.GlobalSettingsService;
|
||||||
import info.bukova.isspst.services.users.UserService;
|
import info.bukova.isspst.services.users.UserService;
|
||||||
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
||||||
import info.bukova.isspst.storage.DocumentFileStorage;
|
import info.bukova.isspst.storage.DocumentFileStorage;
|
||||||
import info.bukova.isspst.ui.FormViewModel;
|
import info.bukova.isspst.ui.FormWithUpload;
|
||||||
import info.bukova.isspst.validators.TripRequirementFormValidator;
|
import info.bukova.isspst.validators.TripRequirementFormValidator;
|
||||||
import org.zkoss.bind.annotation.*;
|
import org.zkoss.bind.annotation.BindingParam;
|
||||||
import org.zkoss.zk.ui.event.UploadEvent;
|
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.zk.ui.select.annotation.WireVariable;
|
||||||
import org.zkoss.zul.Filedownload;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TripRequirementForm extends FormViewModel<TripRequirement> {
|
public class TripRequirementForm extends FormWithUpload<TripRequirement> {
|
||||||
|
|
||||||
@WireVariable
|
@WireVariable
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
@@ -34,8 +37,6 @@ public class TripRequirementForm extends FormViewModel<TripRequirement> {
|
|||||||
private List<Workgroup> centres;
|
private List<Workgroup> centres;
|
||||||
private List<User> users;
|
private List<User> users;
|
||||||
private List<User> passengers;
|
private List<User> passengers;
|
||||||
private List<FileMetainfo> attachments;
|
|
||||||
private List<FileMetainfo> forDelete;
|
|
||||||
private User selUser;
|
private User selUser;
|
||||||
private TripRequirementFormValidator validator;
|
private TripRequirementFormValidator validator;
|
||||||
|
|
||||||
@@ -45,8 +46,6 @@ public class TripRequirementForm extends FormViewModel<TripRequirement> {
|
|||||||
centres = reqTypeService.filterCentres(getDataBean().getType(), workgroupService.getUserCentres(userService.getCurrent()));
|
centres = reqTypeService.filterCentres(getDataBean().getType(), workgroupService.getUserCentres(userService.getCurrent()));
|
||||||
users = userService.getUsersForCombo();
|
users = userService.getUsersForCombo();
|
||||||
passengers = getDataBean().getPassengers();
|
passengers = getDataBean().getPassengers();
|
||||||
attachments = getDataBean().getAttachedFiles();
|
|
||||||
forDelete = new ArrayList<FileMetainfo>(); // kolekce příloh na smazání v případě uložení záznamu
|
|
||||||
validator = new TripRequirementFormValidator();
|
validator = new TripRequirementFormValidator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,37 +89,4 @@ public class TripRequirementForm extends FormViewModel<TripRequirement> {
|
|||||||
return passengers;
|
return passengers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command
|
|
||||||
@NotifyChange("attachments")
|
|
||||||
public void uploadAttachment(@ContextParam(ContextType.TRIGGER_EVENT) UploadEvent upEvent) {
|
|
||||||
FileMetainfo metaInfo = documentStorage.saveAndCreateInfo(upEvent.getMedia().getByteData(),
|
|
||||||
upEvent.getMedia().getName());
|
|
||||||
|
|
||||||
getDataBean().addAttachment(metaInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command
|
|
||||||
@NotifyChange("attachments")
|
|
||||||
public void deleteAttachment(@BindingParam("attachment") FileMetainfo metaInfo) {
|
|
||||||
getDataBean().removeAttachment(metaInfo);
|
|
||||||
forDelete.add(metaInfo); // smazat až v případě uložení záznamu
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command
|
|
||||||
public void downloadAttachment(@BindingParam("attachment") FileMetainfo metaInfo) {
|
|
||||||
Filedownload.save(documentStorage.fileData(metaInfo), metaInfo.getContentType(), metaInfo.getFileName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<FileMetainfo> getAttachments() {
|
|
||||||
return attachments;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doSave() {
|
|
||||||
for (FileMetainfo info : forDelete) {
|
|
||||||
documentStorage.removeFile(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
super.doSave();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,17 +4,16 @@ import info.bukova.isspst.data.TripBill;
|
|||||||
import info.bukova.isspst.data.Vehicle;
|
import info.bukova.isspst.data.Vehicle;
|
||||||
import info.bukova.isspst.services.settings.GlobalSettingsService;
|
import info.bukova.isspst.services.settings.GlobalSettingsService;
|
||||||
import info.bukova.isspst.services.tripbill.TripBillService;
|
import info.bukova.isspst.services.tripbill.TripBillService;
|
||||||
import info.bukova.isspst.ui.FormViewModel;
|
import info.bukova.isspst.ui.FormWithUpload;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.zkoss.bind.annotation.Command;
|
import org.zkoss.bind.annotation.Command;
|
||||||
import org.zkoss.bind.annotation.Init;
|
import org.zkoss.bind.annotation.Init;
|
||||||
import org.zkoss.bind.annotation.NotifyChange;
|
import org.zkoss.bind.annotation.NotifyChange;
|
||||||
import org.zkoss.zk.ui.select.annotation.WireVariable;
|
import org.zkoss.zk.ui.select.annotation.WireVariable;
|
||||||
|
|
||||||
public class TripBillForm extends FormViewModel<TripBill> {
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TripBillForm extends FormWithUpload<TripBill> {
|
||||||
|
|
||||||
@WireVariable
|
@WireVariable
|
||||||
private TripBillService tripBillService;
|
private TripBillService tripBillService;
|
||||||
|
|||||||
@@ -422,11 +422,13 @@
|
|||||||
<property name="dao" ref="tripReqDao"/>
|
<property name="dao" ref="tripReqDao"/>
|
||||||
<property name="validator" ref="validator"/>
|
<property name="validator" ref="validator"/>
|
||||||
<property name="numberSeriesService" ref="numericSeriesService"/>
|
<property name="numberSeriesService" ref="numericSeriesService"/>
|
||||||
|
<property name="documentFileStorage" ref="documentStorage"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="tripBillService" class="info.bukova.isspst.services.tripbill.TripBillServiceImpl">
|
<bean id="tripBillService" class="info.bukova.isspst.services.tripbill.TripBillServiceImpl">
|
||||||
<property name="dao" ref="tripBillDao"/>
|
<property name="dao" ref="tripBillDao"/>
|
||||||
<property name="validator" ref="validator"/>
|
<property name="validator" ref="validator"/>
|
||||||
|
<property name="documentFileStorage" ref="documentStorage"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="orderService" class="info.bukova.isspst.services.orders.OrderServiceImpl">
|
<bean id="orderService" class="info.bukova.isspst.services.orders.OrderServiceImpl">
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?page title="${labels.TravelOrdersFormTitle}" contentType="text/html;charset=UTF-8"?>
|
||||||
|
|
||||||
|
<zk xmlns="http://www.zkoss.org/2005/zul"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd">
|
||||||
|
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
|
||||||
|
|
||||||
|
<vbox>
|
||||||
|
<button image="/img/upload-016.png"
|
||||||
|
label="Připojit soubor"
|
||||||
|
upload="true"
|
||||||
|
onUpload="@command('uploadAttachment')"
|
||||||
|
sclass="nicebutton" />
|
||||||
|
<grid model="@load(vm.attachments)" height="180px">
|
||||||
|
<columns>
|
||||||
|
<column label="Soubor" width="220px"/>
|
||||||
|
<column label="Popis" hflex="max"/>
|
||||||
|
<column width="200px"/>
|
||||||
|
</columns>
|
||||||
|
<rows>
|
||||||
|
<template name="model">
|
||||||
|
<row>
|
||||||
|
<a href="@load('/api/dl/'.concat(each.pathInFilesystem).concat('/').concat(each.fileName))"
|
||||||
|
label="@load(each.fileName)"
|
||||||
|
target="blank"/>
|
||||||
|
<textbox value="@bind(each.description)" sclass="grid-textbox-max"/>
|
||||||
|
<hbox>
|
||||||
|
<button image="/img/delete-016.png" label="Odebrat" onClick="@command('deleteAttachment', attachment=each)" sclass="nicebutton"/>
|
||||||
|
<button image="/img/download-016.png" label="Stáhnout" onClick="@command('downloadAttachment', attachment=each)" sclass="nicebutton"/>
|
||||||
|
</hbox>
|
||||||
|
</row>
|
||||||
|
</template>
|
||||||
|
</rows>
|
||||||
|
</grid>
|
||||||
|
</vbox>
|
||||||
|
|
||||||
|
</zk>
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 789 B |
Binary file not shown.
|
After Width: | Height: | Size: 734 B |
Binary file not shown.
|
After Width: | Height: | Size: 197 B |
Binary file not shown.
|
After Width: | Height: | Size: 650 B |
@@ -18,7 +18,7 @@
|
|||||||
zclass="form-caption"
|
zclass="form-caption"
|
||||||
label="${labels.TravelOrdersFormTitle}" />
|
label="${labels.TravelOrdersFormTitle}" />
|
||||||
<vlayout vflex="1">
|
<vlayout vflex="1">
|
||||||
<include src="../tripBillInterior.zul"/>
|
<include src="../tripBillInterior.zul" vflex="1"/>
|
||||||
<include src="/app/formButtons.zul" />
|
<include src="/app/formButtons.zul" />
|
||||||
</vlayout>
|
</vlayout>
|
||||||
</window>
|
</window>
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
<window
|
<window
|
||||||
id="editWin"
|
id="editWin"
|
||||||
closable="true"
|
closable="true"
|
||||||
|
width="95%"
|
||||||
|
height="95%"
|
||||||
border="normal"
|
border="normal"
|
||||||
position="center"
|
position="center"
|
||||||
apply="org.zkoss.bind.BindComposer"
|
apply="org.zkoss.bind.BindComposer"
|
||||||
@@ -128,30 +130,7 @@
|
|||||||
</row>
|
</row>
|
||||||
</rows>
|
</rows>
|
||||||
</grid>
|
</grid>
|
||||||
<vbox>
|
<include src="/app/uploadComponents.zul"/>
|
||||||
<button label="Připojit"
|
|
||||||
upload="true"
|
|
||||||
onUpload="@command('uploadAttachment')"
|
|
||||||
sclass="nicebutton" />
|
|
||||||
<grid model="@load(vm.attachments)">
|
|
||||||
<columns>
|
|
||||||
<column/>
|
|
||||||
</columns>
|
|
||||||
<rows>
|
|
||||||
<template name="model">
|
|
||||||
<row>
|
|
||||||
<a href="@load('/api/dl/'.concat(each.pathInFilesystem).concat('/').concat(each.fileName))"
|
|
||||||
label="@load(each.fileName)"
|
|
||||||
target="blank"/>
|
|
||||||
<hbox>
|
|
||||||
<button label="Odebrat" onClick="@command('deleteAttachment', attachment=each)"/>
|
|
||||||
<button label="Stáhnout" onClick="@command('downloadAttachment', attachment=each)"/>
|
|
||||||
</hbox>
|
|
||||||
</row>
|
|
||||||
</template>
|
|
||||||
</rows>
|
|
||||||
</grid>
|
|
||||||
</vbox>
|
|
||||||
</hbox>
|
</hbox>
|
||||||
<vbox>
|
<vbox>
|
||||||
<label value="${labels.RequirementsFormPassengers}"/>
|
<label value="${labels.RequirementsFormPassengers}"/>
|
||||||
|
|||||||
@@ -75,6 +75,10 @@
|
|||||||
</row>
|
</row>
|
||||||
</rows>
|
</rows>
|
||||||
</grid>
|
</grid>
|
||||||
|
<groupbox closable="true" mold="3d" open="false">
|
||||||
|
<caption src="/img/expand-016.png" label="Přiložené soubory"/>
|
||||||
|
<include src="/app/uploadComponents.zul"/>
|
||||||
|
</groupbox>
|
||||||
<grid
|
<grid
|
||||||
model="@load(vm.dataBean.billItems)"
|
model="@load(vm.dataBean.billItems)"
|
||||||
vflex="1">
|
vflex="1">
|
||||||
|
|||||||
Reference in New Issue
Block a user