Produced by Araxis Merge on 11/14/2017 6:57:19 AM Central 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 | cbs.zip\cbs\cbs\src\main\java\gov\va\cpss\job\cbs | CbsPatientMapItemReader.java | Thu Nov 9 14:19:54 2017 UTC |
| 2 | cbs.zip\cbs\cbs\src\main\java\gov\va\cpss\job\cbs | CbsPatientMapItemReader.java | Tue Nov 14 12:26:15 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 524 |
| 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 | package go v.va.cpss. job.cbs; | |
| 2 | ||
| 3 | import sta tic gov.va .cpss.job. CbssJobPro cessingCon stants.JOB _FAILURE_K EY; | |
| 4 | import sta tic gov.va .cpss.job. CbssJobPro cessingCon stants.JOB _FAILURE_M ESSAGE_KEY ; | |
| 5 | import sta tic gov.va .cpss.job. CbssJobPro cessingCon stants.MEM ORY_OPEN_E RROR_STATU S; | |
| 6 | import sta tic gov.va .cpss.job. CbssJobPro cessingCon stants.REA D_FAILURE_ STATUS; | |
| 7 | ||
| 8 | import jav a.util.Lis t; | |
| 9 | import jav a.util.Map .Entry; | |
| 10 | ||
| 11 | import org .apache.lo g4j.Logger ; | |
| 12 | import org .springfra mework.bat ch.core.Ex itStatus; | |
| 13 | import org .springfra mework.bat ch.core.It emReadList ener; | |
| 14 | import org .springfra mework.bat ch.core.Jo bExecution ; | |
| 15 | import org .springfra mework.bat ch.core.St epExecutio n; | |
| 16 | import org .springfra mework.bat ch.core.St epExecutio nListener; | |
| 17 | import org .springfra mework.bat ch.item.Pa rseExcepti on; | |
| 18 | import org .springfra mework.bat ch.item.Un expectedIn putExcepti on; | |
| 19 | import org .springfra mework.bat ch.item.su pport.Abst ractItemCo untingItem StreamItem Reader; | |
| 20 | import org .springfra mework.uti l.ClassUti ls; | |
| 21 | ||
| 22 | import gov .va.cpss.m odel.fps.P SPatient; | |
| 23 | ||
| 24 | /** | |
| 25 | * Impleme ntation of AbstractI temCountin gItemStrea mItemReade r used by the Genera te CBS | |
| 26 | * batch j ob to read data from an in-mem ory map of CBS Accou nt ID to l ist of PSP atient rec ords. | |
| 27 | * | |
| 28 | * @author DN S BROWNL | |
| 29 | */ | |
| 30 | public cla ss CbsPati entMapItem Reader<T> extends Ab stractItem CountingIt emStreamIt emReader<E ntry<Long, List<PSPa tient>>> | |
| 31 | impl ements Ite mReadListe ner<Entry< Long, List <PSPatient >>>, StepE xecutionLi stener { | |
| 32 | ||
| 33 | /* | |
| 34 | * Flag to i ndicate th at the job has been forcefully stopped a nd should no | |
| 35 | * longer at tempt read . | |
| 36 | * / | |
| 37 | pr ivate bool ean forceS top = fals e; | |
| 38 | ||
| 39 | /* | |
| 40 | * Flag to i ndicate th e map has been opene d. | |
| 41 | * / | |
| 42 | pr ivate bool ean opened = false; | |
| 43 | ||
| 44 | pr ivate CbsR untimeStat e cbsRunti meState; | |
| 45 | ||
| 46 | pr ivate JobE xecution j obExecutio n; | |
| 47 | ||
| 48 | pr ivate fina l Logger r eaderLogge r; | |
| 49 | ||
| 50 | /* | |
| 51 | * The count of entrie s read. | |
| 52 | * / | |
| 53 | pr ivate int lineCount = 0; | |
| 54 | ||
| 55 | pu blic CbsPa tientMapIt emReader() { | |
| 56 | setN ame(ClassU tils.getSh ortName(Cb sPatientMa pItemReade r.class)); | |
| 57 | read erLogger = Logger.ge tLogger(th is.getClas s().getCan onicalName ()); | |
| 58 | } | |
| 59 | ||
| 60 | pu blic CbsRu ntimeState getCbsRun timeState( ) { | |
| 61 | retu rn cbsRunt imeState; | |
| 62 | } | |
| 63 | ||
| 64 | pu blic void setCbsRunt imeState(C bsRuntimeS tate cbsRu ntimeState ) { | |
| 65 | this .cbsRuntim eState = c bsRuntimeS tate; | |
| 66 | } | |
| 67 | ||
| 68 | @O verride | |
| 69 | pr otected vo id doOpen( ) throws E xception { | |
| 70 | ||
| 71 | open ed = false ; | |
| 72 | ||
| 73 | if ( cbsRuntime State.isEm pty()) { | |
| 74 | ||
| 75 | stopJo b(MEMORY_O PEN_ERROR_ STATUS, | |
| 76 | "Unable to open memo ry map for reading b ecause the re was no data detec ted"); | |
| 77 | ||
| 78 | } el se if (cbs RuntimeSta te.isDataE rror()) { | |
| 79 | ||
| 80 | stopJo b(MEMORY_O PEN_ERROR_ STATUS, | |
| 81 | "Unable to open memo ry map for reading b ecause dat a error wa s encounte red"); | |
| 82 | } el se { | |
| 83 | ||
| 84 | opened = true; | |
| 85 | } | |
| 86 | } | |
| 87 | ||
| 88 | @O verride | |
| 89 | pu blic Entry <Long, Lis t<PSPatien t>> read() throws Ex ception, U nexpectedI nputExcept ion, Parse Exception { | |
| 90 | ||
| 91 | // D o not atte mpt to rea d if force d stop. | |
| 92 | if ( forceStop) { | |
| 93 | reader Logger.err or("Unreco verable sy stem error forcing r eader to s top proces sing"); | |
| 94 | return null; | |
| 95 | } | |
| 96 | ||
| 97 | try { | |
| 98 | ||
| 99 | return super.rea d(); | |
| 100 | ||
| 101 | } ca tch (Excep tion e) { | |
| 102 | ||
| 103 | String Builder er ror = new StringBuil der(); | |
| 104 | error. append("Un able to re ad item be cause of " ); | |
| 105 | error. append(e.g etClass(). getSimpleN ame()); | |
| 106 | error. append("\n Message: " ); | |
| 107 | error. append(e.g etMessage( )); | |
| 108 | error. append("\n Cause: "); | |
| 109 | error. append(e.g etCause(). getMessage ().trim()) ; | |
| 110 | ||
| 111 | stopJo b(READ_FAI LURE_STATU S, error.t oString()) ; | |
| 112 | } | |
| 113 | ||
| 114 | // N ull respon se will ca use step t o end. | |
| 115 | retu rn null; | |
| 116 | } | |
| 117 | ||
| 118 | @O verride | |
| 119 | pr otected En try<Long, List<PSPat ient>> doR ead() thro ws Excepti on { | |
| 120 | ||
| 121 | // I f not open ed then re turn null which will effective ly stop | |
| 122 | // p rocessing. | |
| 123 | if ( !opened) { | |
| 124 | return null; | |
| 125 | } | |
| 126 | ||
| 127 | // I f null is read then return nul l which wi ll effecti vely stop | |
| 128 | // p rocessing. | |
| 129 | retu rn readEnt ry(); | |
| 130 | } | |
| 131 | ||
| 132 | /* * | |
| 133 | * Read the entry from the map. | |
| 134 | * | |
| 135 | * @return T he next en try in the map. | |
| 136 | * / | |
| 137 | pr ivate Entr y<Long, Li st<PSPatie nt>> readE ntry() { | |
| 138 | ||
| 139 | Entr y<Long, Li st<PSPatie nt>> entry = cbsRunt imeState.p ollCurrent PSPatientM (); | |
| 140 | ||
| 141 | if ( entry == n ull) { | |
| 142 | return null; | |
| 143 | } | |
| 144 | ||
| 145 | line Count++; | |
| 146 | ||
| 147 | retu rn entry; | |
| 148 | } | |
| 149 | ||
| 150 | @O verride | |
| 151 | pr otected vo id doClose () throws Exception { | |
| 152 | ||
| 153 | // R eset the s top flag o n close. | |
| 154 | forc eStop = fa lse; | |
| 155 | ||
| 156 | // R eset the o pen flag o n close. | |
| 157 | open ed = false ; | |
| 158 | ||
| 159 | // B e sure to reset the line count . | |
| 160 | line Count = 0; | |
| 161 | } | |
| 162 | ||
| 163 | @O verride | |
| 164 | pu blic void beforeRead () { | |
| 165 | forc eStop = fa lse; | |
| 166 | if ( jobExecuti on.getExec utionConte xt().conta insKey(JOB _FAILURE_K EY)) { | |
| 167 | reader Logger.err or("System failure d etected.") ; | |
| 168 | forceS top = true ; | |
| 169 | } | |
| 170 | } | |
| 171 | ||
| 172 | @O verride | |
| 173 | pu blic void onReadErro r(Exceptio n e) { | |
| 174 | ||
| 175 | read erLogger.e rror("Read er encount ered syste m error an d forced s top"); | |
| 176 | ||
| 177 | Stri ngBuilder error = ne w StringBu ilder(); | |
| 178 | erro r.append(" Unable to read item because of "); | |
| 179 | erro r.append(e .getClass( ).getSimpl eName()); | |
| 180 | erro r.append(" \nMessage: "); | |
| 181 | erro r.append(e .getMessag e()); | |
| 182 | erro r.append(" \nCause: " ); | |
| 183 | erro r.append(e .getCause( ).getMessa ge().trim( )); | |
| 184 | ||
| 185 | // S et failure and messa ge. | |
| 186 | stop Job(READ_F AILURE_STA TUS, error .toString( )); | |
| 187 | } | |
| 188 | ||
| 189 | @O verride | |
| 190 | pu blic void afterRead( Entry<Long , List<PSP atient>> i tem) { | |
| 191 | // D o not need to do any thing afte r read. | |
| 192 | } | |
| 193 | ||
| 194 | @O verride | |
| 195 | pu blic void beforeStep (StepExecu tion stepE xecution) { | |
| 196 | read erLogger.i nfo("Befor e Step Exe cution"); | |
| 197 | // S ave the jo b executio n at the b eginning o f the step . | |
| 198 | // T he executi on context will be u sed to set exit stat us if a fa ilure | |
| 199 | // d uring read processin g. | |
| 200 | jobE xecution = stepExecu tion.getJo bExecution (); | |
| 201 | } | |
| 202 | ||
| 203 | @O verride | |
| 204 | pu blic ExitS tatus afte rStep(Step Execution stepExecut ion) { | |
| 205 | read erLogger.i nfo("After Step Exec ution"); | |
| 206 | // D o not do a nything sp ecial here . | |
| 207 | retu rn null; | |
| 208 | } | |
| 209 | ||
| 210 | /* * | |
| 211 | * Forcefull y stop the job proce ssing beca use a fail ure was de tected. | |
| 212 | * | |
| 213 | * @param st atus | |
| 214 | * The stat us for the failure. | |
| 215 | * @param me ssage | |
| 216 | * The mess age associ ated with the status failure. | |
| 217 | * / | |
| 218 | pr ivate void stopJob(f inal Strin g status, final Stri ng message ) { | |
| 219 | ||
| 220 | // S et the fla g to indic ate the jo b has been forcefull y stopped. | |
| 221 | forc eStop = tr ue; | |
| 222 | ||
| 223 | // L og message . | |
| 224 | read erLogger.e rror("Read er executi on encount ered unrec overable e rror and f orced stop "); | |
| 225 | ||
| 226 | // S et failure and messa ge. | |
| 227 | setF ailureStat us(status) ; | |
| 228 | ||
| 229 | // S et failure message. | |
| 230 | setF ailureMess age(messag e); | |
| 231 | } | |
| 232 | ||
| 233 | /* * | |
| 234 | * Set the f ailure in the job ex ecution co ntext. | |
| 235 | * | |
| 236 | * @param st atus | |
| 237 | * The fail ure status . | |
| 238 | * / | |
| 239 | pr ivate void setFailur eStatus(fi nal String status) { | |
| 240 | ||
| 241 | // L og job fai lure statu s. | |
| 242 | read erLogger.e rror("Read failed wi th status: " + statu s); | |
| 243 | ||
| 244 | // S et job fai lure. | |
| 245 | jobE xecution.g etExecutio nContext() .putString (JOB_FAILU RE_KEY, st atus); | |
| 246 | } | |
| 247 | ||
| 248 | /* * | |
| 249 | * Set the f ailure mes sage in th e job exec ution cont ext. | |
| 250 | * | |
| 251 | * @param me ssage | |
| 252 | * The mess age to ass ociate wit h the erro r status. | |
| 253 | * / | |
| 254 | pr ivate void setFailur eMessage(f inal Strin g message) { | |
| 255 | ||
| 256 | // L og job fai lure messa ge. | |
| 257 | read erLogger.e rror("Read failure m essage: " + message) ; | |
| 258 | ||
| 259 | // S et job fai lure messa ge. | |
| 260 | jobE xecution.g etExecutio nContext() .putString (JOB_FAILU RE_MESSAGE _KEY, mess age); | |
| 261 | } | |
| 262 | ||
| 263 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.