Produced by Araxis Merge on 11/14/2017 6:57:20 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\sendbill | SendBillDataItemProcessor.java | Thu Nov 9 14:19:54 2017 UTC |
| 2 | cbs.zip\cbs\cbs\src\main\java\gov\va\cpss\job\sendbill | SendBillDataItemProcessor.java | Tue Nov 14 12:26:29 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 618 |
| 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.sendbi ll; | |
| 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.PRO CESSING_FA ILURE_STAT US; | |
| 6 | import sta tic gov.va .cpss.job. sendbill.S endBillDat aProcessin gConstants .TOTAL_BIL L_PATIENT_ DATA_PROCE SSED; | |
| 7 | import sta tic gov.va .cpss.job. sendbill.S endBillDat aProcessin gConstants .SEND_BILL _TOTAL_REC ORD_COUNT; | |
| 8 | import jav a.util.Arr ayList; | |
| 9 | import jav a.util.Lis t; | |
| 10 | ||
| 11 | import sta tic gov.va .cpss.job. sendbill.S endBillDat aProcessin gConstants .SEND_BILL _ID_KEY; | |
| 12 | ||
| 13 | import org .apache.lo g4j.Logger ; | |
| 14 | import org .springfra mework.bat ch.core.It emProcessL istener; | |
| 15 | import org .springfra mework.bat ch.core.Jo bExecution ; | |
| 16 | import org .springfra mework.bat ch.core.St epExecutio n; | |
| 17 | import org .springfra mework.bat ch.core.an notation.A fterStep; | |
| 18 | import org .springfra mework.bat ch.core.an notation.B eforeStep; | |
| 19 | import org .springfra mework.bat ch.item.It emProcesso r; | |
| 20 | ||
| 21 | import gov .va.cpss.m odel.bal.S iteBalance ; | |
| 22 | import gov .va.cpss.s ervice.Sen dBillDataS ervice; | |
| 23 | ||
| 24 | /** | |
| 25 | * Custom ItemProces sor used b y the Proc ess FPS Da ta batch j ob to regi ster the | |
| 26 | * ICN. | |
| 27 | * | |
| 28 | * @author DN S BROWNL | |
| 29 | */ | |
| 30 | public cla ss SendBil lDataItemP rocessor i mplements ItemProces sor<SiteBa lance, Lis t<SendBill StringDTO> >, | |
| 31 | Item ProcessLis tener<Site Balance, L ist<SendBi llStringDT O>> { | |
| 32 | ||
| 33 | /* | |
| 34 | * Flag to i ndicate th at the job has been forcefully stopped a nd should no | |
| 35 | * longer at tempt proc essing. | |
| 36 | * / | |
| 37 | pr ivate bool ean forceS top = fals e; | |
| 38 | ||
| 39 | pr ivate fina l Logger p rocessorLo gger; | |
| 40 | ||
| 41 | pr ivate JobE xecution j obExecutio n; | |
| 42 | ||
| 43 | pr ivate int batchRunId ; | |
| 44 | ||
| 45 | pr ivate Send BillDataSe rvice send BillDataSe rvice; | |
| 46 | ||
| 47 | /* * | |
| 48 | * @return t he sendBil lDataServi ce | |
| 49 | * / | |
| 50 | pu blic SendB illDataSer vice getSe ndBillData Service() { | |
| 51 | retu rn sendBil lDataServi ce; | |
| 52 | } | |
| 53 | ||
| 54 | /* * | |
| 55 | * @param se ndBillData Service | |
| 56 | * the send BillDataSe rvice to s et | |
| 57 | * / | |
| 58 | pu blic void setSendBil lDataServi ce(SendBil lDataServi ce sendBil lDataServi ce) { | |
| 59 | this .sendBillD ataService = sendBil lDataServi ce; | |
| 60 | } | |
| 61 | ||
| 62 | pr ivate Send BillString DTO combin edDTO; | |
| 63 | ||
| 64 | /* * | |
| 65 | * @return t he combine dDTO | |
| 66 | * / | |
| 67 | pu blic SendB illStringD TO getComb inedDTO() { | |
| 68 | retu rn combine dDTO; | |
| 69 | } | |
| 70 | ||
| 71 | /* * | |
| 72 | * @param co mbinedDTO | |
| 73 | * the comb inedDTO to set | |
| 74 | * / | |
| 75 | pu blic void setCombine dDTO(SendB illStringD TO combine dDTO) { | |
| 76 | this .combinedD TO = combi nedDTO; | |
| 77 | } | |
| 78 | ||
| 79 | pu blic SendB illDataIte mProcessor () { | |
| 80 | proc essorLogge r = Logger .getLogger (this.getC lass().get CanonicalN ame()); | |
| 81 | } | |
| 82 | ||
| 83 | @O verride | |
| 84 | pu blic List< SendBillSt ringDTO> p rocess(Sit eBalance p ojo) throw s Exceptio n { | |
| 85 | ||
| 86 | proc essorLogge r.debug("B egin Proce ss Current ly in Item Processor "); | |
| 87 | proc essorLogge r.debug("T otal Patie nt Count h as Been De creased: " + jobExec ution.getE xecutionCo ntext().ge tInt(SEND_ BILL_TOTAL _RECORD_CO UNT)); | |
| 88 | // D o not atte mpt to pro cess if fo rced stop. | |
| 89 | if ( forceStop) { | |
| 90 | proces sorLogger. debug("FOR CE STOP"); | |
| 91 | return null; | |
| 92 | } | |
| 93 | ||
| 94 | List <SendBillS tringDTO> writeDTO = new Array List<SendB illStringD TO>(); | |
| 95 | ||
| 96 | try { | |
| 97 | ||
| 98 | long cur rentAccoun tId = pojo .getCbsAcc ount().get Id(); | |
| 99 | ||
| 100 | if (getC ombinedDTO () != null ) { | |
| 101 | if (curren tAccountId == getCom binedDTO() .getCbssId ()) { | |
| 102 | se tCombinedD TO(getSend BillDataSe rvice().pr ocessExist ingBillRec ord(pojo, getCombine dDTO())); | |
| 103 | ac crueProces singCount( TOTAL_BILL _PATIENT_D ATA_PROCES SED, 1); | |
| 104 | pr ocessorLog ger.debug( "Number of Patients Processed is: " + jo bExecution .getExecut ionContext ().getLong (TOTAL_BIL L_PATIENT_ DATA_PROCE SSED)); | |
| 105 | ||
| 106 | if (decreaseT otalPatien Count(SEND _BILL_TOTA L_RECORD_C OUNT, 1)) | |
| 107 | { | |
| 108 | writ eDTO.add(g etCombined DTO()); | |
| 109 | } | |
| 110 | ||
| 111 | } else { | |
| 112 | // jobExecuti on.getExec utionConte xt(). | |
| 113 | // Existing is ready t o write. | |
| 114 | pr ocessorLog ger.debug( "Number of Patients Processed is: " + jo bExecution .getExecut ionContext ().getLong (TOTAL_BIL L_PATIENT_ DATA_PROCE SSED)); | |
| 115 | pr ocessorLog ger.debug( "--------- ---------- -The Data is being W ritten---- ---------- -"); | |
| 116 | wr iteDTO.add (getCombin edDTO()); | |
| 117 | pr ocessorLog ger.debug( "Write Com plete Reci eving New Record"); | |
| 118 | // Received a new reco rd. True | |
| 119 | se tCombinedD TO(getSend BillDataSe rvice().pr ocessNewBi llRecord(p ojo)); | |
| 120 | ac crueProces singCount( TOTAL_BILL _PATIENT_D ATA_PROCES SED, 1); | |
| 121 | ||
| 122 | if (decreaseT otalPatien Count(SEND _BILL_TOTA L_RECORD_C OUNT, 1)) | |
| 123 | { | |
| 124 | writ eDTO.add(g etCombined DTO()); | |
| 125 | } | |
| 126 | ||
| 127 | ||
| 128 | } | |
| 129 | } else { | |
| 130 | // Create new record True | |
| 131 | se tCombinedD TO(getSend BillDataSe rvice().pr ocessNewBi llRecord(p ojo)); | |
| 132 | ac crueProces singCount( TOTAL_BILL _PATIENT_D ATA_PROCES SED, 1); | |
| 133 | pr ocessorLog ger.debug( "Number of Patients Processed is: " + jo bExecution .getExecut ionContext ().getLong (TOTAL_BIL L_PATIENT_ DATA_PROCE SSED)); | |
| 134 | if (decreaseT otalPatien Count(SEND _BILL_TOTA L_RECORD_C OUNT, 1)) | |
| 135 | { | |
| 136 | writ eDTO.add(g etCombined DTO()); | |
| 137 | } | |
| 138 | ||
| 139 | } | |
| 140 | ||
| 141 | } catc h (Excepti on e) { | |
| 142 | ||
| 143 | // Unrec overable e rror so st op the job . | |
| 144 | stopJob( PROCESSING _FAILURE_S TATUS, "Un recoverabl e processi ng error: " + e.getM essage()); | |
| 145 | } | |
| 146 | ||
| 147 | ||
| 148 | proc essorLogge r.debug("E nd Process "); | |
| 149 | if(w riteDTO.is Empty()) | |
| 150 | { | |
| 151 | return null; | |
| 152 | } | |
| 153 | retu rn writeDT O; | |
| 154 | ||
| 155 | } | |
| 156 | ||
| 157 | /* * | |
| 158 | * Before pr ocessing c apture the job execu tion and t he receive d id for d ata | |
| 159 | * processin g. | |
| 160 | * | |
| 161 | * @param st epExecutio n | |
| 162 | * / | |
| 163 | @B eforeStep | |
| 164 | pu blic void beforeStep (StepExecu tion stepE xecution) { | |
| 165 | proc essorLogge r.info("Be fore Step Execution" ); | |
| 166 | ||
| 167 | // S ave the jo b executio n at the b eginning o f the step . | |
| 168 | // T he executi on context will be u sed to set key value s as data is | |
| 169 | // p rocessed. | |
| 170 | jobE xecution = stepExecu tion.getJo bExecution (); | |
| 171 | // S ets The De fault Pati ents Proce ssed Value | |
| 172 | jobE xecution.g etExecutio nContext() .putLong(T OTAL_BILL_ PATIENT_DA TA_PROCESS ED, 0); | |
| 173 | // S ave the ba tchRunId a t the begi nning of t he step. | |
| 174 | ||
| 175 | } | |
| 176 | ||
| 177 | /* * | |
| 178 | * After pro cessing ch eck for un expected c onditions that sugge st an erro r. | |
| 179 | * | |
| 180 | * @param st epExecutio n | |
| 181 | * / | |
| 182 | @A fterStep | |
| 183 | pu blic void afterStep( StepExecut ion stepEx ecution) { | |
| 184 | ||
| 185 | proc essorLogge r.info("Af ter Step E xecution") ; | |
| 186 | } | |
| 187 | ||
| 188 | @O verride | |
| 189 | pu blic void beforeProc ess(SiteBa lance item ) { | |
| 190 | proc essorLogge r.debug("B efore Proc ess"); | |
| 191 | forc eStop = fa lse; | |
| 192 | if ( jobExecuti on.getExec utionConte xt().conta insKey(JOB _FAILURE_K EY)) { | |
| 193 | proces sorLogger. error("Sys tem failur e detected ."); | |
| 194 | forceS top = true ; | |
| 195 | } | |
| 196 | // G et the id of the Bat chRun reco rd for thi s job. | |
| 197 | setB atchRunId( jobExecuti on.getJobP arameters( ).getLong( SEND_BILL_ ID_KEY).in tValue()); | |
| 198 | } | |
| 199 | ||
| 200 | @O verride | |
| 201 | pu blic void afterProce ss(SiteBal ance item, List<Send BillString DTO> resul t) { | |
| 202 | // D o not need to do any thing afte r process. | |
| 203 | } | |
| 204 | ||
| 205 | @O verride | |
| 206 | pu blic void onProcessE rror(SiteB alance ite m, Excepti on e) { | |
| 207 | proc essorLogge r.error("P rocessor e ncountered system er ror and fo rced stop" ); | |
| 208 | ||
| 209 | Stri ngBuilder error = ne w StringBu ilder(); | |
| 210 | erro r.append(" Unable to process it em because of "); | |
| 211 | erro r.append(e .getClass( ).getSimpl eName()); | |
| 212 | erro r.append(" \nMessage: "); | |
| 213 | erro r.append(e .getMessag e()); | |
| 214 | erro r.append(" \nCause: " ); | |
| 215 | erro r.append(e .getCause( ).getMessa ge().trim( )); | |
| 216 | ||
| 217 | // S et failure and messa ge. | |
| 218 | stop Job(PROCES SING_FAILU RE_STATUS, "Unrecove rable proc essor erro r"); | |
| 219 | } | |
| 220 | ||
| 221 | /* * | |
| 222 | * Forcefull y stop the job proce ssing beca use a fail ure was de tected. | |
| 223 | * | |
| 224 | * @return R eturn a nu ll record to stop st ep process ing. | |
| 225 | * / | |
| 226 | pr ivate void stopJob(f inal Strin g status, final Stri ng message ) { | |
| 227 | ||
| 228 | // S et the fla g to indic ate the jo b has been forcefull y stopped. | |
| 229 | forc eStop = tr ue; | |
| 230 | ||
| 231 | // L og message . | |
| 232 | proc essorLogge r.error("P rocessor e xecution e ncountered unrecover able error and force d stop"); | |
| 233 | ||
| 234 | // S et failure and messa ge. | |
| 235 | setF ailureStat us(status) ; | |
| 236 | ||
| 237 | // S et failure message. | |
| 238 | setF ailureMess age(messag e); | |
| 239 | } | |
| 240 | ||
| 241 | /* * | |
| 242 | * Set the f ailure in the job ex ecution co ntext. | |
| 243 | * | |
| 244 | * @param st atus | |
| 245 | * The fail ure status . | |
| 246 | * / | |
| 247 | pr ivate void setFailur eStatus(fi nal String status) { | |
| 248 | ||
| 249 | // L og job fai lure statu s. | |
| 250 | proc essorLogge r.error("J ob failed with statu s: " + sta tus); | |
| 251 | ||
| 252 | // S et job fai lure. | |
| 253 | jobE xecution.g etExecutio nContext() .putString (JOB_FAILU RE_KEY, st atus); | |
| 254 | } | |
| 255 | ||
| 256 | /* * | |
| 257 | * Set the f ailure mes sage in th e job exec ution cont ext. | |
| 258 | * | |
| 259 | * @param me ssage | |
| 260 | * The mess age to ass ociate wit h the erro r status. | |
| 261 | * / | |
| 262 | pr ivate void setFailur eMessage(f inal Strin g message) { | |
| 263 | ||
| 264 | // L og job fai lure messa ge. | |
| 265 | proc essorLogge r.error("J ob failure message: " + messag e); | |
| 266 | ||
| 267 | // S et job fai lure messa ge. | |
| 268 | jobE xecution.g etExecutio nContext() .putString (JOB_FAILU RE_MESSAGE _KEY, mess age); | |
| 269 | } | |
| 270 | ||
| 271 | pu blic int g etBatchRun Id() { | |
| 272 | retu rn batchRu nId; | |
| 273 | } | |
| 274 | ||
| 275 | pu blic void setBatchRu nId(int ba tchRunId) { | |
| 276 | this .batchRunI d = batchR unId; | |
| 277 | } | |
| 278 | ||
| 279 | /* * | |
| 280 | * Accrue th e given pr ocessing c ount in th e job exec ution cont ext. | |
| 281 | * | |
| 282 | * @param ke y | |
| 283 | * Name of the proces sing count . | |
| 284 | * @param nu mOfBills | |
| 285 | * Amount t o add to t he process ing count. | |
| 286 | * / | |
| 287 | pr ivate void accruePro cessingCou nt(final S tring key, final int numOfBill s) { | |
| 288 | long totalStmt s = jobExe cution.get ExecutionC ontext().g etLong(key ); | |
| 289 | tota lStmts += numOfBills ; | |
| 290 | jobE xecution.g etExecutio nContext() .putLong(k ey, totalS tmts); | |
| 291 | } | |
| 292 | ||
| 293 | pr ivate bool ean decrea seTotalPat ienCount(f inal Strin g key, fin al Integer numOfPati ents) { | |
| 294 | int totalStmts = jobExec ution.getE xecutionCo ntext().ge tInt(key); | |
| 295 | proc essorLogge r.debug("T otal Patie nt Count i s: " + tot alStmts); | |
| 296 | if ( totalStmts > 0) { | |
| 297 | totalS tmts = tot alStmts - numOfPatie nts; | |
| 298 | proces sorLogger. debug("Tot al Patient Count has Been Decr eased: " + totalStmt s); | |
| 299 | jobExe cution.get ExecutionC ontext().p utInt(key, totalStmt s); | |
| 300 | if (to talStmts = = 0) { | |
| 301 | return t rue; | |
| 302 | } else { | |
| 303 | return f alse; | |
| 304 | } | |
| 305 | } el se { | |
| 306 | return true; | |
| 307 | } | |
| 308 | } | |
| 309 | ||
| 310 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.