Změněn způsob ukládání PDF dokumentu. Data se předávájí ve ViewModelu, tak nemůže dojít k tomu, že by se schválením jiného záznamu v druhém okně prohlížeče uložilo jiné PDF.
refs #243
This commit is contained in:
@@ -63,6 +63,8 @@ public class ModuleUtils {
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
} catch (ClassCastException e) { //nestandardní moduly neřeší...
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public interface RequirementBaseService<T extends RequirementBase> extends Servi
|
||||
public void loadType(T data);
|
||||
public void loadWorkflow(T data);
|
||||
public void approve(T entity);
|
||||
public void approve(T entity, Date approveDate);
|
||||
public void approve(T entity, Date approveDate, byte[] signedPdf);
|
||||
public boolean canApprove(T entity);
|
||||
public List<User> getNextApprover(T entity);
|
||||
public boolean prepareSignData(T entity, Date approveDate);
|
||||
|
||||
+55
-48
@@ -245,7 +245,7 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
||||
}
|
||||
}
|
||||
|
||||
protected void approve(T entity, User user, Date approveDate) {
|
||||
protected void approve(T entity, User user, Date approveDate, byte[] signedPdf) {
|
||||
T e = (T) dao.getById(entity.getId());
|
||||
|
||||
if (e.getReqDate().getTime() > approveDate.getTime()) {
|
||||
@@ -300,12 +300,16 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
||||
}
|
||||
}
|
||||
|
||||
saveSignedDoc(e);
|
||||
if (signedPdf != null)
|
||||
{
|
||||
saveSignedDoc(e, signedPdf);
|
||||
}
|
||||
|
||||
postApprove(e);
|
||||
}
|
||||
|
||||
protected void approve(T entity, User user) {
|
||||
approve(entity, user, new Date());
|
||||
approve(entity, user, new Date(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -318,8 +322,8 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
||||
@Override
|
||||
@Transactional
|
||||
@PreAuthorize("this.canApprove(#entity)")
|
||||
public void approve(T entity, Date approveDate) {
|
||||
approve(entity, getLoggedInUser(), approveDate);
|
||||
public void approve(T entity, Date approveDate, byte[] signedPdf) {
|
||||
approve(entity, getLoggedInUser(), approveDate, signedPdf);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -342,33 +346,27 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
||||
|
||||
}
|
||||
|
||||
protected void saveSignedDoc(T entity) {
|
||||
/*
|
||||
if (!entity.equals(reportDefinition.getDataSet().get(0))) {
|
||||
throw new ApproveException();
|
||||
}*/
|
||||
|
||||
DataModel reportEntity = (DataModel) reportDefinition.getDataSet().get(0);
|
||||
SignedDocumentItem signedItem = signedDocumentService.getItem(entity, reportDefinition.getReport().getReportId());
|
||||
SignData data = (SignData) sessionData.getProperty(Constants.KEY_SIGN_DATA);
|
||||
protected void saveSignedDoc(T entity, byte[] signedPdf) {
|
||||
DataModel reportEntity = entityForSignReport(entity);
|
||||
SignedDocumentItem signedItem = signedDocumentService.getItem(entityForSignReport(entity), getSignReport(entity).getReportId());
|
||||
|
||||
if (signedItem == null) {
|
||||
data = (SignData) sessionData.getProperty(Constants.KEY_SIGN_DATA);
|
||||
SignedDocument signDoc = new SignedDocument();
|
||||
signDoc.setDescription(entity.getDescription());
|
||||
signDoc.setNumser(entity.getNumser());
|
||||
signDoc.setRecordId(reportEntity.getId());
|
||||
signDoc.setModuleName(ModuleUtils.getModule(reportEntity, servletContext).getId());
|
||||
signDoc.setSignDate(entity.getLastApproveDate());
|
||||
|
||||
SignedDocumentItem item = new SignedDocumentItem();
|
||||
item.setReportId(reportDefinition.getReport().getReportId());
|
||||
item.setReportName(reportDefinition.getReport().getName());
|
||||
signDoc.addItem(item);
|
||||
|
||||
signedDocStorage.saveFile(data.getPdfData(), item);
|
||||
signedDocStorage.saveFile(signedPdf, item);
|
||||
signedDocumentService.addFromApprove(signDoc);
|
||||
} else {
|
||||
signedDocStorage.saveFile(data.getPdfData(), signedItem);
|
||||
signedDocStorage.saveFile(signedPdf, signedItem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -478,9 +476,46 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
||||
sessionData.setProperty(Constants.KEY_SIGN_GUID, data.getSignGuid());
|
||||
|
||||
reportDefinition.clear();
|
||||
reportDefinition.setSingleObject(entityForReport(entity));
|
||||
reportDefinition.setSingleObject(entityForSignReport(entity));
|
||||
|
||||
Module module = ModuleUtils.getModule(entityForReport(entity), servletContext);
|
||||
Report report = getSignReport(entity);
|
||||
|
||||
if (report == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
reportDefinition.setReport(report);
|
||||
Module module = ModuleUtils.getModule(entityForSignReport(entity), servletContext);
|
||||
reportDefinition.setService((Service<Object>) ModuleUtils.getServiceInstance(module, servletContext));
|
||||
|
||||
paramFiller.fill();
|
||||
Generator gen = genFactory.createGenerator(reportDefinition);
|
||||
data.setPdfData(gen.generate());
|
||||
data.setDescription(entity.getDescription());
|
||||
data.setNumser(entity.getNumser());
|
||||
data.setSignDate(approveDate);
|
||||
data.setSigned(signedDocumentService.getItem(entityForSignReport(entity), report.getReportId()) != null);
|
||||
|
||||
if (entity.getState() == RequirementState.NEW) {
|
||||
data.setAreaId(1);
|
||||
} else {
|
||||
loadAuthItems(entity);
|
||||
data.setAreaId(entity.getAuthorization().size() + 1);
|
||||
}
|
||||
|
||||
if (userService.getUserSettings().getSignatureFile() != null) {
|
||||
data.setSignImg(storage.fileData(userService.getUserSettings().getSignatureFile()));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected DataModel entityForSignReport(T entity) {
|
||||
return entity;
|
||||
}
|
||||
|
||||
private Report getSignReport(T entity) {
|
||||
Module module = ModuleUtils.getModule(entityForSignReport(entity), servletContext);
|
||||
Report report = null;
|
||||
|
||||
for (Report r : module.getReports()) {
|
||||
@@ -490,34 +525,6 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
|
||||
}
|
||||
}
|
||||
|
||||
if (report == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
reportDefinition.setReport(report);
|
||||
reportDefinition.setService((Service<Object>) ModuleUtils.getServiceInstance(module, servletContext));
|
||||
|
||||
paramFiller.fill();
|
||||
Generator gen = genFactory.createGenerator(reportDefinition);
|
||||
data.setPdfData(gen.generate());
|
||||
data.setDescription(entity.getDescription());
|
||||
data.setNumser(entity.getNumser());
|
||||
data.setSignDate(approveDate);
|
||||
data.setSigned(signedDocumentService.getItem(entityForReport(entity), report.getReportId()) != null);
|
||||
|
||||
if (entity.getState() == RequirementState.NEW) {
|
||||
data.setAreaId(1);
|
||||
} else {
|
||||
loadAuthItems(entity);
|
||||
data.setAreaId(entity.getAuthorization().size() + 1);
|
||||
}
|
||||
|
||||
data.setSignImg(storage.fileData(userService.getUserSettings().getSignatureFile()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected DataModel entityForReport(T entity) {
|
||||
return entity;
|
||||
return report;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class RequirementServiceImpl extends RequirementBaseServiceImpl<Requireme
|
||||
if ((entity.getSumTotal() != null)
|
||||
&& (entity.getSumTotal().compareTo(nextWf.getLimit()) == -1))
|
||||
{
|
||||
approve(entity, approvers.get(0), approveDate);
|
||||
approve(entity, approvers.get(0), approveDate, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class TripBillApprovalServiceImpl extends RequirementBaseServiceImpl<Trip
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DataModel entityForReport(TripBillApproval entity) {
|
||||
protected DataModel entityForSignReport(TripBillApproval entity) {
|
||||
return entity.getBill();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ public class ApproveDialogVM {
|
||||
private SessionData sessionData;
|
||||
private boolean signed;
|
||||
private boolean timer;
|
||||
private byte[] signedPdf;
|
||||
|
||||
public Date getApproveDate() {
|
||||
return approveDate;
|
||||
@@ -59,7 +60,7 @@ public class ApproveDialogVM {
|
||||
@Command
|
||||
public void approve(@BindingParam("window") Window window) {
|
||||
try {
|
||||
service.approve(requirement, approveDate);
|
||||
service.approve(requirement, approveDate, signedPdf);
|
||||
BindUtils.postNotifyChange(null, null, grid, "dataBean");
|
||||
BindUtils.postNotifyChange(null, null, grid, "canApprove");
|
||||
BindUtils.postGlobalCommand(null, null, "reload", null);
|
||||
@@ -88,6 +89,7 @@ public class ApproveDialogVM {
|
||||
if (guid.equals(data.getSignGuid()) && data.isSignSuccess()) {
|
||||
signed = true;
|
||||
timer = false;
|
||||
signedPdf = data.getPdfData();
|
||||
} else {
|
||||
signed = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user