Produced by Araxis Merge on 12/13/2018 10:35:24 AM Eastern Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | v12.5_iter_7_build 51.zip\TRM_Upgrade\src\main\java\gov\va\med\ccht\service\report\impl | DatabaseReportPersister.java | Fri Dec 7 17:36:42 2018 UTC |
| 2 | v12.5_iter_7_build 51.zip\TRM_Upgrade\src\main\java\gov\va\med\ccht\service\report\impl | DatabaseReportPersister.java | Wed Dec 12 19:46:44 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 386 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | /********* ********** ********** ********** ********** ********** ********* | |
| 2 | * Copyrig ht � 2010 VHA. All r ights rese rved | |
| 3 | ********* ********** ********** ********** ********** ********** *********/ | |
| 4 | // Package | |
| 5 | package go v.va.med.c cht.servic e.report.i mpl; | |
| 6 | ||
| 7 | import jav a.io.ByteA rrayOutput Stream; | |
| 8 | import jav a.io.IOExc eption; | |
| 9 | import jav a.util.Cal endar; | |
| 10 | import jav a.util.Dat e; | |
| 11 | import jav a.util.Has hMap; | |
| 12 | import jav a.util.Map ; | |
| 13 | import jav a.util.Tim eZone; | |
| 14 | ||
| 15 | import org .apache.co mmons.lang 3.Validate ; | |
| 16 | import org .springfra mework.bea ns.factory .annotatio n.Autowire d; | |
| 17 | import org .springfra mework.bea ns.factory .annotatio n.Qualifie r; | |
| 18 | import org .springfra mework.mai l.SimpleMa ilMessage; | |
| 19 | import org .springfra mework.ste reotype.Se rvice; | |
| 20 | ||
| 21 | import gov .va.med.cc ht.model.r eport.Comp letedRepor t; | |
| 22 | import gov .va.med.cc ht.model.r eport.Repo rtParamete rs; | |
| 23 | import gov .va.med.cc ht.model.r eport.Repo rtSetup; | |
| 24 | import gov .va.med.cc ht.persist ent.Report DAO; | |
| 25 | import gov .va.med.cc ht.service .common.im pl.Abstrac tBusinessS ervice; | |
| 26 | import gov .va.med.cc ht.service .report.Re portPersis tenceServi ce; | |
| 27 | import gov .va.med.cc ht.service .report.St andardRepo rtCriteria ; | |
| 28 | import gov .va.med.fw .persisten t.DAOExcep tion; | |
| 29 | import gov .va.med.fw .report.Re portConfig uration; | |
| 30 | import gov .va.med.fw .report.Re portExcept ion; | |
| 31 | import gov .va.med.fw .report.da ta.QueryCr iteria; | |
| 32 | import gov .va.med.fw .service.S erviceExce ption; | |
| 33 | import gov .va.med.fw .util.Stri ngUtils; | |
| 34 | import gov .va.med.fw .util.date .TimeZoneU tils; | |
| 35 | ||
| 36 | ||
| 37 | /** | |
| 38 | * | |
| 39 | * | |
| 40 | * Project : Common</ br> Create d on: 11:1 0:56 AM </ br> | |
| 41 | * | |
| 42 | * @author DN S
|
|
| 43 | */ | |
| 44 | @Service | |
| 45 | public cla ss Databas eReportPer sister ext ends Abstr actBusines sService i mplements ReportPers istenceSer vice { | |
| 46 | ||
| 47 | pr ivate stat ic final l ong serial VersionUID = 8051680 4577925362 51L; | |
| 48 | ||
| 49 | @A utowired | |
| 50 | pr ivate Repo rtDAO repo rtDAO = nu ll; | |
| 51 | @A utowired | |
| 52 | @Q ualifier(" reportNoti ficationMa ilMessage" ) | |
| 53 | pr ivate Simp leMailMess age messag eTemplate = null; | |
| 54 | ||
| 55 | pu blic Datab aseReportP ersister() { | |
| 56 | supe r(); | |
| 57 | } | |
| 58 | ||
| 59 | /* * | |
| 60 | * @see gov. va.med.fw. service.Ab stractComp onent#afte rPropertie sSet() | |
| 61 | * / | |
| 62 | pu blic void afterPrope rtiesSet() throws Ex ception { | |
| 63 | supe r.afterPro pertiesSet (); | |
| 64 | Vali date.notNu ll(reportD AO, "A rep ort DAO mu st be conf igured"); | |
| 65 | Vali date.notNu ll(message Template, "A message template must be co nfigured") ; | |
| 66 | } | |
| 67 | ||
| 68 | /* * | |
| 69 | * @param re portDAO | |
| 70 | * The repo rtDAO to s et. | |
| 71 | * / | |
| 72 | pu blic void setReportD AO(ReportD AO reportD AO) { | |
| 73 | this .reportDAO = reportD AO; | |
| 74 | } | |
| 75 | ||
| 76 | /* * | |
| 77 | * @param re portDAO | |
| 78 | * The repo rtDAO to s et. | |
| 79 | * / | |
| 80 | pu blic void setMessage Template(S impleMailM essage tem plate) { | |
| 81 | this .messageTe mplate = t emplate; | |
| 82 | } | |
| 83 | ||
| 84 | /* * | |
| 85 | * @see gov. va.med.fw. report.Rep ortPersist er#persist (gov.va.me d.fw.repor t.ReportCo nfiguratio n, | |
| 86 | * java .io.ByteAr rayOutputS tream) | |
| 87 | * / | |
| 88 | pu blic void persist(Re portConfig uration co nfig, Byte ArrayOutpu tStream st ream) | |
| 89 | throws ReportExc eption { | |
| 90 | ||
| 91 | // E xtract dat a from a r eport conf iguration | |
| 92 | Quer yCriteria criteria = config.ge tQueryCrit eria(); | |
| 93 | Stan dardReport Criteria r eportCrite ria = crit eria insta nceof Stan dardReport Criteria ? (Standard ReportCrit eria) crit eria | |
| 94 | : null; | |
| 95 | Repo rtSetup re portSetup = reportCr iteria != null ? rep ortCriteri a.getRepor tSetup() : null; | |
| 96 | ||
| 97 | Comp letedRepor t report = createCom pletedRepo rt(reportS etup); | |
| 98 | ||
| 99 | try { | |
| 100 | // Set a generat ed report to a Compl etedReport for persi stence | |
| 101 | stream .flush(); | |
| 102 | report .setReport FileConten t(stream.t oByteArray ()); | |
| 103 | stream .close(); | |
| 104 | } ca tch (IOExc eption e) { | |
| 105 | logger .error("Fa iled to wr ite a repo rt to a st ream ", e) ; | |
| 106 | throw new Report Exception( "Failed to write a r eport to a stream ", e); | |
| 107 | } | |
| 108 | ||
| 109 | try { | |
| 110 | report DAO.saveCo mpletedRep ort(report ); | |
| 111 | } ca tch (DAOEx ception e) { | |
| 112 | logger .error("Fa iled to pe rsist a re port", e); | |
| 113 | throw new Report Exception( "Failed to persist a report", e); | |
| 114 | } | |
| 115 | ||
| 116 | try { | |
| 117 | sendNo tification Mail(repor tSetup, re port.getCo mpletedDat e()); | |
| 118 | } ca tch (Excep tion e) { | |
| 119 | // Do nothing he re just lo g exceptio n | |
| 120 | if (lo gger.isInf oEnabled() ) { | |
| 121 | logger.i nfo("Faile d to send notificati on message ", e); | |
| 122 | } | |
| 123 | } | |
| 124 | } | |
| 125 | ||
| 126 | @O verride | |
| 127 | pu blic void saveReport Criteria(R eportSetup reportSet up) | |
| 128 | throws ServiceEx ception { | |
| 129 | Comp letedRepor t report = createCom pletedRepo rt(reportS etup); | |
| 130 | ||
| 131 | try { | |
| 132 | report DAO.saveCo mpletedRep ort(report ); | |
| 133 | } ca tch (DAOEx ception e) { | |
| 134 | logger .error("Fa iled to pe rsist a re port", e); | |
| 135 | throw new Report Exception( "Failed to persist a report", e); | |
| 136 | } | |
| 137 | ||
| 138 | try { | |
| 139 | sendNo tification Mail(repor tSetup, re port.getCo mpletedDat e()); | |
| 140 | } ca tch (Excep tion e) { | |
| 141 | // Do nothing he re just lo g exceptio n | |
| 142 | if (lo gger.isInf oEnabled() ) { | |
| 143 | logger.i nfo("Faile d to send notificati on message ", e); | |
| 144 | } | |
| 145 | } | |
| 146 | } | |
| 147 | ||
| 148 | pr ivate void sendNotif icationMai l(ReportSe tup report Setup, Dat e complete dDate) thr ows Servic eException { | |
| 149 | Stri ng email = reportSet up.getEmai lAddress() ; | |
| 150 | if ( !StringUti ls.isBlank (email)) { | |
| 151 | Map<St ring, Obje ct> data = new HashM ap<String, Object>() ; | |
| 152 | data .put("repo rt", repor tSetup.get StandardRe port()); | |
| 153 | data .put("runD ate", Time ZoneUtils. convertDat eToTimeZon e(complete dDate, Tim eZone.getD efault())) ; | |
| 154 | data .put("webA ppUrl", ge tWebAppUrl ()); | |
| 155 | Simp leMailMess age templa te = proce ssMailTemp late(data, messageTem plate); | |
| 156 | temp late.setTo (StringUti ls.split(e mail, ",") ); | |
| 157 | send (template) ; | |
| 158 | } | |
| 159 | } | |
| 160 | ||
| 161 | pr ivate Comp letedRepor t createCo mpletedRep ort(Report Setup repo rtSetup) { | |
| 162 | ||
| 163 | // P opulate a completed report obj ect | |
| 164 | Comp letedRepor t report = new Compl etedReport (); | |
| 165 | Date createdDa te = Calen dar.getIns tance().ge tTime(); | |
| 166 | ||
| 167 | Repo rtParamete rs paramet ers = repo rtSetup.ge tReportPar ameters(); | |
| 168 | Inte ger daysTo KeepComple tedReports = paramet ers.getDay sToKeepCom pletedRepo rts(); | |
| 169 | ||
| 170 | Cale ndar cal = Calendar. getInstanc e(); | |
| 171 | cal. setTime(cr eatedDate) ; | |
| 172 | if ( daysToKeep CompletedR eports != null) { | |
| 173 | cal.ad d(Calendar .DATE, day sToKeepCom pletedRepo rts); | |
| 174 | } el se { | |
| 175 | /* For manual re ports, kee p default to 1 year */ | |
| 176 | cal.ad d(Calendar .YEAR, 1); | |
| 177 | } | |
| 178 | Date expireDat e = cal.ge tTime(); | |
| 179 | repo rt.setExpi rationDate (expireDat e); | |
| 180 | repo rt.setComp letedDate( createdDat e); | |
| 181 | //re port.setCo mpletedDat e(new Date WithTimeZo ne(created Date, para meters.get UserTimeZo ne())); | |
| 182 | repo rt.setUser Name(repor tSetup.get SetupUser( )); | |
| 183 | repo rt.setStan dardReport (reportSet up.getStan dardReport ()); | |
| 184 | repo rt.setFile Type(repor tSetup.get FileType() ); | |
| 185 | repo rt.setRepo rtParamete rText(repo rtSetup.ge tReportPar ametersTex t()); | |
| 186 | if ( StringUtil s.isEmpty( parameters .getReport Name())) { | |
| 187 | report .setReport Name(repor tSetup.get StandardRe port().get Name()); | |
| 188 | }els e { | |
| 189 | report .setReport Name(param eters.getR eportName( )); | |
| 190 | } | |
| 191 | retu rn report; | |
| 192 | } | |
| 193 | // TODO: T his is a o ne line co mment | |
| 194 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.