From b70041bffff48865e4f77ce9320428f0ddefe2f4 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Fri, 10 Jul 2015 15:29:44 +0200 Subject: [PATCH] =?UTF-8?q?Zm=C4=9Bn=C4=9Bn=20zp=C5=AFsob=20ukl=C3=A1d?= =?UTF-8?q?=C3=A1n=C3=AD=20PDF=20dokumentu.=20Data=20se=20p=C5=99ed=C3=A1v?= =?UTF-8?q?=C3=A1j=C3=AD=20ve=20ViewModelu,=20tak=20nem=C5=AF=C5=BEe=20doj?= =?UTF-8?q?=C3=ADt=20k=20tomu,=20=C5=BEe=20by=20se=20schv=C3=A1len=C3=ADm?= =?UTF-8?q?=20jin=C3=A9ho=20z=C3=A1znamu=20v=20druh=C3=A9m=20okn=C4=9B=20p?= =?UTF-8?q?rohl=C3=AD=C5=BEe=C4=8De=20ulo=C5=BEilo=20jin=C3=A9=20PDF.=20re?= =?UTF-8?q?fs=20#243?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/info/bukova/isspst/ModuleUtils.java | 2 + .../requirement/RequirementBaseService.java | 2 +- .../RequirementBaseServiceImpl.java | 67 ++++++++++--------- .../requirement/RequirementServiceImpl.java | 2 +- .../tripbill/TripBillApprovalServiceImpl.java | 2 +- .../isspst/ui/main/ApproveDialogVM.java | 4 +- 6 files changed, 45 insertions(+), 34 deletions(-) diff --git a/src/main/java/info/bukova/isspst/ModuleUtils.java b/src/main/java/info/bukova/isspst/ModuleUtils.java index 9596ea2e..b588358d 100644 --- a/src/main/java/info/bukova/isspst/ModuleUtils.java +++ b/src/main/java/info/bukova/isspst/ModuleUtils.java @@ -63,6 +63,8 @@ public class ModuleUtils { } } + continue; + } catch (ClassCastException e) { //nestandardní moduly neřeší... continue; } diff --git a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseService.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseService.java index 588491f5..860c4044 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseService.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseService.java @@ -22,7 +22,7 @@ public interface RequirementBaseService 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 getNextApprover(T entity); public boolean prepareSignData(T entity, Date approveDate); diff --git a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java index d337cd14..93427584 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java @@ -245,7 +245,7 @@ public abstract class RequirementBaseServiceImpl 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 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 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 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,23 +476,16 @@ public abstract class RequirementBaseServiceImpl exte sessionData.setProperty(Constants.KEY_SIGN_GUID, data.getSignGuid()); reportDefinition.clear(); - reportDefinition.setSingleObject(entityForReport(entity)); - - Module module = ModuleUtils.getModule(entityForReport(entity), servletContext); - Report report = null; + reportDefinition.setSingleObject(entityForSignReport(entity)); - for (Report r : module.getReports()) { - if (r.isSignable()) { - report = r; - break; - } - } + Report report = getSignReport(entity); if (report == null) { return false; } reportDefinition.setReport(report); + Module module = ModuleUtils.getModule(entityForSignReport(entity), servletContext); reportDefinition.setService((Service) ModuleUtils.getServiceInstance(module, servletContext)); paramFiller.fill(); @@ -503,7 +494,7 @@ public abstract class RequirementBaseServiceImpl exte data.setDescription(entity.getDescription()); data.setNumser(entity.getNumser()); data.setSignDate(approveDate); - data.setSigned(signedDocumentService.getItem(entityForReport(entity), report.getReportId()) != null); + data.setSigned(signedDocumentService.getItem(entityForSignReport(entity), report.getReportId()) != null); if (entity.getState() == RequirementState.NEW) { data.setAreaId(1); @@ -512,12 +503,28 @@ public abstract class RequirementBaseServiceImpl exte data.setAreaId(entity.getAuthorization().size() + 1); } - data.setSignImg(storage.fileData(userService.getUserSettings().getSignatureFile())); + if (userService.getUserSettings().getSignatureFile() != null) { + data.setSignImg(storage.fileData(userService.getUserSettings().getSignatureFile())); + } return true; } - protected DataModel entityForReport(T entity) { + 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()) { + if (r.isSignable()) { + report = r; + break; + } + } + + return report; + } } diff --git a/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java index 1e33ee45..857857b0 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java @@ -60,7 +60,7 @@ public class RequirementServiceImpl extends RequirementBaseServiceImpl