Produced by Araxis Merge on 6/11/2019 10:54:11 AM Eastern Daylight 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 | HTRE_P3_v14.5_iter_4_build_14.zip\java\gov\va\med\fw\batchprocess | AbstractDataProcess.java | Wed May 29 15:26:02 2019 UTC |
| 2 | HTRE_P3_v14.5_iter_4_build_14.zip\java\gov\va\med\fw\batchprocess | AbstractDataProcess.java | Mon Jun 10 19:30:04 2019 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 628 |
| 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 | * Copyrii ght 2005 V HA. All ri ghts reser ved | |
| 3 | ********* ********** ********** ********** ********** ********** *********/ | |
| 4 | ||
| 5 | package go v.va.med.f w.batchpro cess; | |
| 6 | ||
| 7 | import jav a.net.Inet Address; | |
| 8 | import jav a.net.Unkn ownHostExc eption; | |
| 9 | import jav a.util.Dat e; | |
| 10 | import jav a.util.Lis t; | |
| 11 | ||
| 12 | import org .apache.co mmons.lang .StringUti ls; | |
| 13 | import org .quartz.Sc heduler; | |
| 14 | ||
| 15 | import gov .va.med.fw .model.bat chprocess. JobConfig; | |
| 16 | import gov .va.med.fw .model.bat chprocess. JobResult; | |
| 17 | import gov .va.med.fw .model.bat chprocess. JobStatus; | |
| 18 | import gov .va.med.fw .schedulin g.Abstract ScheduledP rocess; | |
| 19 | import gov .va.med.fw .schedulin g.Schedule dProcessIn vocationCo ntext; | |
| 20 | import gov .va.med.fw .service.S erviceExce ption; | |
| 21 | ||
| 22 | /** | |
| 23 | * Abstrac t base cla ss for bat ch process ing of bul k data. Da ta can be acquired | |
| 24 | * in any manner tha t sublasse s choose v ia the acq uireData i mplementat ion. | |
| 25 | * | |
| 26 | * <p> | |
| 27 | * Tracks in process statistic s via JobR esult inst ance. Allo ws for arc hival of | |
| 28 | * process statistic s. | |
| 29 | * | |
| 30 | * Created Feb 1, 20 06 3:28:37 PM | |
| 31 | * | |
| 32 | * @author DNS DN S
|
|
| 33 | */ | |
| 34 | public abs tract clas s Abstract DataProces s extends AbstractSc heduledPro cess { | |
| 35 | pu blic stati c final in t DEFAULT_ JOB_RESULT _UPDATE_IN TERVAL = 5 ; | |
| 36 | pr ivate stat ic final S tring JOB_ RESULT_ENT ITY = "job ResultEnti ty"; | |
| 37 | pr ivate stat ic final S tring JOB_ NAME = "jo bName"; | |
| 38 | pr ivate stat ic final S tring JOB_ GROUP_NAME = "jobGro upName"; | |
| 39 | ||
| 40 | pr ivate Batc hProcessSe rvice batc hProcessSe rvice; | |
| 41 | pr ivate Stri ng process Name; | |
| 42 | pr ivate Data ProcessCom pletedHand ler dataPr ocessCompl etedHandle r; | |
| 43 | pr ivate Proc essStatist icsHandler processSt atisticsHa ndler; | |
| 44 | ||
| 45 | pr otected fi nal void e xecuteProc ess(Schedu ledProcess Invocation Context in vocationCo ntext) | |
| 46 | throws Exception { | |
| 47 | Data ProcessExe cutionCont ext contex t = create DataProces sExecution Context(); | |
| 48 | Stri ng jobName = getProc essName(); // used f or JobResu lt/JobConf ig | |
| 49 | // p ersistence (want it to be the | |
| 50 | // o riginating JobDetail name) | |
| 51 | Stri ng jobGrou p = Schedu ler.DEFAUL T_GROUP; | |
| 52 | if ( invocation Context != null) { | |
| 53 | jobGro up = invoc ationConte xt.getJobG roup(); | |
| 54 | contex t.setExecu tionArgume nts(invoca tionContex t.getInvoc ationArgum ents()); | |
| 55 | contex t.setIniti ater(invoc ationConte xt.getExec utionConte xt()); | |
| 56 | jobNam e = invoca tionContex t.getJobNa me(); | |
| 57 | } | |
| 58 | cont ext.getCon textData() .put(JOB_N AME, jobNa me); | |
| 59 | cont ext.getCon textData() .put(JOB_G ROUP_NAME, jobGroup) ; | |
| 60 | ||
| 61 | Proc essStatist ics stats = context. getProcess Statistics (); | |
| 62 | stat s.setProce ssingStart Date(new D ate()); | |
| 63 | stat s.setProce ssName(get ProcessNam e()); | |
| 64 | try { | |
| 65 | stats. setExecute dOnServer( InetAddres s.getLocal Host().get HostName() ); | |
| 66 | } ca tch (Unkno wnHostExce ption e) { | |
| 67 | // oh well, we t ried | |
| 68 | stats. setExecute dOnServer( "Unknown") ; | |
| 69 | } | |
| 70 | ||
| 71 | // c reate a Jo bResult fo r persiste nt trackin g | |
| 72 | JobR esult jobR esult = cr eateJobRes ult(contex t); | |
| 73 | ||
| 74 | bool ean error = false; | |
| 75 | try { | |
| 76 | execut eProcess(c ontext); | |
| 77 | } ca tch (Excep tion e) { | |
| 78 | error = true; | |
| 79 | if (lo gger.isErr orEnabled( )) | |
| 80 | logger.e rror("Abst ractDataPr ocess.exec uteProcess threw exc eption wit h message: " | |
| 81 | + e.getMessa ge(), e); | |
| 82 | throw e; | |
| 83 | } fi nally { | |
| 84 | if (ow nsJobCompl etion(cont ext) || er ror) { | |
| 85 | stats.se tProcessin gEndDate(n ew Date()) ; | |
| 86 | if (this .isInterru pted(conte xt)) { | |
| 87 | // must re -retrieve the JobRes ult since it was upd ated | |
| 88 | // externa lly (avoid StaleObje ctExceptio n) | |
| 89 | jobResult = this.bat chProcessS ervice.get JobResult( jobResult. getId()); | |
| 90 | } | |
| 91 | jobResul t.setEndDa te(stats.g etProcessi ngEndDate( )); | |
| 92 | ||
| 93 | // updat e jobResul t with fin al results (should a lso have b een | |
| 94 | // incre mental upd ates by th e subclass es) | |
| 95 | if (erro r) { | |
| 96 | jobResult. setStatus( JobStatus. ERROR); | |
| 97 | } else i f (isInter rupted(con text)) { | |
| 98 | jobResult. setStatus( JobStatus. CANCELLED) ; | |
| 99 | } else i f (stats.c ontainsErr ors()) { | |
| 100 | jobResult. setStatus( JobStatus. COMPLETE_W ITH_ERROR) ; | |
| 101 | } else { | |
| 102 | jobResult. setStatus( JobStatus. COMPLETE); | |
| 103 | } | |
| 104 | ||
| 105 | jobResul t.setStati stics(stat s.exportAs CSV()); | |
| 106 | batchPro cessServic e.saveJobR esult(jobR esult); | |
| 107 | ||
| 108 | processS tatistics( context); | |
| 109 | } | |
| 110 | } | |
| 111 | } | |
| 112 | ||
| 113 | /* * not fina l for fram ework over rides */ | |
| 114 | pr otected bo olean owns JobComplet ion(DataPr ocessExecu tionContex t context) { | |
| 115 | retu rn true; | |
| 116 | } | |
| 117 | ||
| 118 | pr otected fi nal void u pdateJobRe sult(DataP rocessExec utionConte xt context , JobResul t jobResul t) | |
| 119 | throws Exception { | |
| 120 | if ( this.isInt errupted(c ontext)) { | |
| 121 | if (lo gger.isWar nEnabled() ) | |
| 122 | logger | |
| 123 | .w arn("Prior to updati ng the Job Result, it was disco vered that [" | |
| 124 | + jobR esult.getN ame() | |
| 125 | + "] h as been ca nceled...d eferring c urrent Job Result upd ate until the job wi nds itself out of in terrupted status"); | |
| 126 | } el se { | |
| 127 | batchP rocessServ ice.saveJo bResult(jo bResult); | |
| 128 | } | |
| 129 | } | |
| 130 | ||
| 131 | pr otected fi nal void u pdateJobRe sult(DataP rocessExec utionConte xt context ) { | |
| 132 | JobR esult jobR esult = th is.getJobR esult(cont ext); | |
| 133 | try { | |
| 134 | jobRes ult.setSta tistics(co ntext.getP rocessStat istics().e xportAsCSV ()); | |
| 135 | update JobResult( context, j obResult); | |
| 136 | } ca tch (Excep tion e) { | |
| 137 | this.t hrowIllega lStateExce ption("Una ble to upd ate JobRes ult", e); | |
| 138 | } | |
| 139 | } | |
| 140 | ||
| 141 | pr ivate JobR esult crea teJobResul t(DataProc essExecuti onContext context) t hrows Exce ption { | |
| 142 | JobR esult jobR esult = ne w JobResul t(); | |
| 143 | jobR esult.setS tartDate(c ontext.get ProcessSta tistics(). getProcess ingStartDa te()); | |
| 144 | jobR esult.setC ontext(get JobName(co ntext)); | |
| 145 | jobR esult.setG roup(getJo bGroupName (context)) ; | |
| 146 | jobR esult.setS tatistics( context.ge tProcessSt atistics() .exportAsC SV()); | |
| 147 | jobR esult.setS tatus(JobS tatus.IN_P ROCESS); | |
| 148 | jobR esult.setC ontext(con text.getIn itiater()) ; | |
| 149 | batc hProcessSe rvice.save JobResult( jobResult) ; | |
| 150 | cont ext.getCon textData() .put(JOB_R ESULT_ENTI TY, jobRes ult); | |
| 151 | retu rn jobResu lt; | |
| 152 | } | |
| 153 | ||
| 154 | pr otected Jo bResult ge tJobResult (DataProce ssExecutio nContext c ontext) { | |
| 155 | retu rn (JobRes ult) conte xt.getCont extData(). get(JOB_RE SULT_ENTIT Y); | |
| 156 | } | |
| 157 | ||
| 158 | // not marke d final he re for fra mework ove rrides | |
| 159 | pr otected vo id execute Process(Da taProcessE xecutionCo ntext cont ext) throw s Exceptio n { | |
| 160 | List data = ac quireData( context); | |
| 161 | if ( data != nu ll && !dat a.isEmpty( )) { | |
| 162 | proces sData(cont ext, data) ; | |
| 163 | } | |
| 164 | hand leDataProc essComplet ed(context ); | |
| 165 | } | |
| 166 | ||
| 167 | /* * | |
| 168 | * @return R eturns the interrupt ed. | |
| 169 | * / | |
| 170 | pu blic boole an isInter rupted(Dat aProcessEx ecutionCon text conte xt) { | |
| 171 | if ( context.is Interrupte d()) | |
| 172 | return true; | |
| 173 | ||
| 174 | /* | |
| 175 | * I nterruptio n can eith er be by s omeone 1) calling in terrupt on this | |
| 176 | * i nstance or 2) someon e setting the JobRes ult in the database to be | |
| 177 | * J obResult.C ANCELLED | |
| 178 | * | |
| 179 | * w e must che ck both he re | |
| 180 | */ | |
| 181 | if ( super.isIn terrupted( )) { | |
| 182 | contex t.setInter rupted(tru e); | |
| 183 | return true; | |
| 184 | } | |
| 185 | ||
| 186 | // n eed to rec heck the d atabase | |
| 187 | JobR esult jobR esult = th is.getBatc hProcessSe rvice().ge tJobResult ( | |
| 188 | getJobRe sult(conte xt).getId( )); | |
| 189 | if ( jobResult != null) { | |
| 190 | boolea n interrup ted = jobR esult.getS tatus().ge tCode().eq uals( | |
| 191 | JobStatus. CANCELLED. getCode()) ; | |
| 192 | if (in terrupted) | |
| 193 | context. setInterru pted(true) ; | |
| 194 | return interrupt ed; | |
| 195 | } | |
| 196 | ||
| 197 | retu rn false; | |
| 198 | } | |
| 199 | ||
| 200 | pr otected vo id handleD ataProcess Completed( DataProces sExecution Context co ntext) { | |
| 201 | if ( logger.isE rrorEnable d() && !co ntext.getE xceptionDa ta().isEmp ty()) { | |
| 202 | logger .error("Da ta Process ing result ed in exce ptions for data: " | |
| 203 | + context. getExcepti onData()); | |
| 204 | } | |
| 205 | ||
| 206 | if ( dataProces sCompleted Handler != null) | |
| 207 | dataPr ocessCompl etedHandle r.dataProc essingComp lete(conte xt); | |
| 208 | cont ext.getExc eptionData ().clear() ; | |
| 209 | cont ext.getPro cessedData ().clear() ; | |
| 210 | } | |
| 211 | ||
| 212 | pr otected ab stract voi d processD ata(DataPr ocessExecu tionContex t context, List acqu iredData); | |
| 213 | ||
| 214 | pr otected ab stract Lis t acquireD ata(DataPr ocessExecu tionContex t context) throws Ex ception; | |
| 215 | ||
| 216 | pr otected fi nal void t hrowIllega lStateExce ption(Stri ng message , Throwabl e t) { | |
| 217 | Runt imeExcepti on e = new IllegalSt ateExcepti on(message ); | |
| 218 | e.in itCause(t) ; | |
| 219 | thro w e; | |
| 220 | } | |
| 221 | ||
| 222 | pr otected Da taProcessE xecutionCo ntext crea teDataProc essExecuti onContext( ) { | |
| 223 | Data ProcessExe cutionCont ext contex t = new Da taProcessE xecutionCo ntext(); | |
| 224 | cont ext.setPro cessStatis tics(creat eProcessSt atistics() ); | |
| 225 | retu rn context ; | |
| 226 | } | |
| 227 | ||
| 228 | pr otected Pr ocessStati stics crea teProcessS tatistics( ) { | |
| 229 | retu rn new Pro cessStatis tics(); | |
| 230 | } | |
| 231 | ||
| 232 | pr otected St ring getJo bName(Data ProcessExe cutionCont ext contex t) { | |
| 233 | retu rn (String ) context. getContext Data().get (JOB_NAME) ; | |
| 234 | } | |
| 235 | ||
| 236 | pr otected St ring getJo bGroupName (DataProce ssExecutio nContext c ontext) { | |
| 237 | retu rn (String ) context. getContext Data().get (JOB_GROUP _NAME); | |
| 238 | } | |
| 239 | ||
| 240 | pr otected fi nal void p rocessStat istics(Dat aProcessEx ecutionCon text conte xt) throws Exception { | |
| 241 | Proc essStatist ics stats = context. getProcess Statistics (); | |
| 242 | if ( isInterrup ted(contex t)) | |
| 243 | stats. setWasInte rrupted(tr ue); | |
| 244 | if ( logger.isI nfoEnabled ()) | |
| 245 | logger .info("Pro cessStatis tics [" + stats + "] "); | |
| 246 | if ( processSta tisticsHan dler != nu ll) { | |
| 247 | JobCon fig config = this.ba tchProcess Service.ge tJobConfig (getJobNam e(context) , | |
| 248 | getJobGrou pName(cont ext)); | |
| 249 | if (co nfig != nu ll && Stri ngUtils.is NotBlank(c onfig.getE mailDistri butionList ())) { | |
| 250 | processS tatisticsH andler.pro cessStatis ticsWithDy namicRecip ients(stat s, config | |
| 251 | .g etEmailsAs List()); | |
| 252 | } else { | |
| 253 | processS tatisticsH andler.pro cessStatis tics(stats ); | |
| 254 | } | |
| 255 | } | |
| 256 | } | |
| 257 | ||
| 258 | /* * | |
| 259 | * @return R eturns the processSt atisticsHa ndler. | |
| 260 | * / | |
| 261 | pu blic Proce ssStatisti csHandler getProcess Statistics Handler() { | |
| 262 | retu rn process Statistics Handler; | |
| 263 | } | |
| 264 | ||
| 265 | /* * | |
| 266 | * @param pr ocessStati sticsHandl er | |
| 267 | * The proc essStatist icsHandler to set. | |
| 268 | * / | |
| 269 | pu blic void setProcess Statistics Handler(Pr ocessStati sticsHandl er process Statistics Handler) { | |
| 270 | this .processSt atisticsHa ndler = pr ocessStati sticsHandl er; | |
| 271 | } | |
| 272 | ||
| 273 | pu blic Strin g getProce ssName() { | |
| 274 | retu rn process Name != nu ll ? proce ssName : g etAuditId( ); | |
| 275 | } | |
| 276 | ||
| 277 | /* * | |
| 278 | * @param pr ocessName | |
| 279 | * The proc essName to set. | |
| 280 | * / | |
| 281 | pu blic void setProcess Name(Strin g processN ame) { | |
| 282 | this .processNa me = proce ssName; | |
| 283 | } | |
| 284 | ||
| 285 | /* * | |
| 286 | * @return R eturns the dataProce ssComplete dHandler. | |
| 287 | * / | |
| 288 | pu blic DataP rocessComp letedHandl er getData ProcessCom pletedHand ler() { | |
| 289 | retu rn dataPro cessComple tedHandler ; | |
| 290 | } | |
| 291 | ||
| 292 | /* * | |
| 293 | * @param da taProcessC ompletedHa ndler | |
| 294 | * The data ProcessCom pletedHand ler to set . | |
| 295 | * / | |
| 296 | pu blic void setDataPro cessComple tedHandler ( | |
| 297 | DataPr ocessCompl etedHandle r dataProc essComplet edHandler) { | |
| 298 | this .dataProce ssComplete dHandler = dataProce ssComplete dHandler; | |
| 299 | } | |
| 300 | ||
| 301 | /* * | |
| 302 | * @return R eturns the batchProc essService . | |
| 303 | * / | |
| 304 | pu blic Batch ProcessSer vice getBa tchProcess Service() { | |
| 305 | retu rn batchPr ocessServi ce; | |
| 306 | } | |
| 307 | ||
| 308 | /* * | |
| 309 | * @param ba tchProcess Service | |
| 310 | * The batc hProcessSe rvice to s et. | |
| 311 | * / | |
| 312 | pu blic void setBatchPr ocessServi ce(BatchPr ocessServi ce batchPr ocessServi ce) { | |
| 313 | this .batchProc essService = batchPr ocessServi ce; | |
| 314 | } | |
| 315 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.