Produced by Araxis Merge on 11/14/2017 6:57:21 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\service | BatchService.java | Thu Nov 9 14:19:42 2017 UTC |
| 2 | cbs.zip\cbs\cbs\src\main\java\gov\va\cpss\service | BatchService.java | Tue Nov 14 12:27:08 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 668 |
| 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. service; | |
| 2 | ||
| 3 | import sta tic gov.va .cpss.ESAP I.EsapiVal idationTyp e.LOG_FORG ING; | |
| 4 | import sta tic gov.va .cpss.ESAP I.EsapiVal idator.val idateStrin gInput; | |
| 5 | ||
| 6 | import jav a.sql.Time stamp; | |
| 7 | import jav a.util.Arr ayList; | |
| 8 | import jav a.util.Cal endar; | |
| 9 | import jav a.util.Lis t; | |
| 10 | ||
| 11 | import org .apache.lo g4j.Logger ; | |
| 12 | import org .springfra mework.ste reotype.Se rvice; | |
| 13 | ||
| 14 | import gov .va.cpss.d ao.BatchCo nfigDAO; | |
| 15 | import gov .va.cpss.d ao.BatchJo bDAO; | |
| 16 | import gov .va.cpss.d ao.BatchRu nDAO; | |
| 17 | import gov .va.cpss.d ao.BatchSr cTypeDAO; | |
| 18 | import gov .va.cpss.d ao.BatchSt atusDAO; | |
| 19 | import gov .va.cpss.d ao.BatchTy peDAO; | |
| 20 | import gov .va.cpss.m odel.Batch Config; | |
| 21 | import gov .va.cpss.m odel.Batch Item; | |
| 22 | import gov .va.cpss.m odel.Batch Job; | |
| 23 | import gov .va.cpss.m odel.Batch Run; | |
| 24 | import gov .va.cpss.m odel.Batch SrcType; | |
| 25 | import gov .va.cpss.m odel.Batch Status; | |
| 26 | import gov .va.cpss.m odel.Batch Type; | |
| 27 | ||
| 28 | /** | |
| 29 | * Service class for handling activities relating to running batch job s. | |
| 30 | * | |
| 31 | * @author DN S BROWNL | |
| 32 | */ | |
| 33 | @Service | |
| 34 | public cla ss BatchSe rvice { | |
| 35 | ||
| 36 | pr ivate Logg er logger = Logger.g etLogger(B atchServic e.class.ge tCanonical Name()); | |
| 37 | ||
| 38 | pr ivate Batc hTypeDAO b atchTypeDA O; | |
| 39 | pr ivate Batc hJobDAO ba tchJobDAO; | |
| 40 | pr ivate Batc hRunDAO ba tchRunDAO; | |
| 41 | pr ivate Batc hStatusDAO batchStat usDAO; | |
| 42 | pr ivate Batc hSrcTypeDA O batchSrc TypeDAO; | |
| 43 | pr ivate Batc hConfigDAO batchConf igDAO; | |
| 44 | ||
| 45 | pu blic Batch Service() { | |
| 46 | } | |
| 47 | ||
| 48 | pu blic Batch JobDAO get BatchJobDA O() { | |
| 49 | retu rn batchJo bDAO; | |
| 50 | } | |
| 51 | ||
| 52 | pu blic void setBatchJo bDAO(Batch JobDAO bat chJobDAO) { | |
| 53 | this .batchJobD AO = batch JobDAO; | |
| 54 | } | |
| 55 | ||
| 56 | pu blic Batch RunDAO get BatchRunDA O() { | |
| 57 | retu rn batchRu nDAO; | |
| 58 | } | |
| 59 | ||
| 60 | pu blic void setBatchRu nDAO(Batch RunDAO bat chRunDAO) { | |
| 61 | this .batchRunD AO = batch RunDAO; | |
| 62 | } | |
| 63 | ||
| 64 | pu blic Batch TypeDAO ge tBatchType DAO() { | |
| 65 | retu rn batchTy peDAO; | |
| 66 | } | |
| 67 | ||
| 68 | pu blic void setBatchTy peDAO(Batc hTypeDAO b atchTypeDA O) { | |
| 69 | this .batchType DAO = batc hTypeDAO; | |
| 70 | } | |
| 71 | ||
| 72 | pu blic Batch StatusDAO getBatchSt atusDAO() { | |
| 73 | retu rn batchSt atusDAO; | |
| 74 | } | |
| 75 | ||
| 76 | pu blic void setBatchSt atusDAO(Ba tchStatusD AO batchSt atusDAO) { | |
| 77 | this .batchStat usDAO = ba tchStatusD AO; | |
| 78 | } | |
| 79 | ||
| 80 | pu blic Batch SrcTypeDAO getBatchS rcTypeDAO( ) { | |
| 81 | retu rn batchSr cTypeDAO; | |
| 82 | } | |
| 83 | ||
| 84 | pu blic void setBatchSr cTypeDAO(B atchSrcTyp eDAO batch SrcTypeDAO ) { | |
| 85 | this .batchSrcT ypeDAO = b atchSrcTyp eDAO; | |
| 86 | } | |
| 87 | ||
| 88 | pu blic Batch ConfigDAO getBatchCo nfigDAO() { | |
| 89 | retu rn batchCo nfigDAO; | |
| 90 | } | |
| 91 | ||
| 92 | pu blic void setBatchCo nfigDAO(Ba tchConfigD AO batchCo nfigDAO) { | |
| 93 | this .batchConf igDAO = ba tchConfigD AO; | |
| 94 | } | |
| 95 | ||
| 96 | pu blic List< BatchType> getBatchT ypeList() { | |
| 97 | ||
| 98 | retu rn batchTy peDAO.batc hTypeList( ); | |
| 99 | } | |
| 100 | ||
| 101 | pu blic Batch Item getLa testBatchI temById(in t id) { | |
| 102 | ||
| 103 | Batc hJob bj = batchJobDA O.getBatch Job(id); | |
| 104 | bj.s etBatchCon fig(batchC onfigDAO.g etBatchCon fig(id)); | |
| 105 | ||
| 106 | retu rn getBatc hItemForJo b(bj); | |
| 107 | } | |
| 108 | ||
| 109 | pu blic Batch Item getBa tchItemFor Job(BatchJ ob bj) { | |
| 110 | ||
| 111 | if ( bj != null ) { | |
| 112 | // Set the job t ype from t he db. | |
| 113 | bj.set BatchType( batchTypeD AO.getBatc hType(bj.g etTypeId() )); | |
| 114 | bj.set BatchConfi g(batchCon figDAO.get BatchConfi g(bj.getId ())); | |
| 115 | ||
| 116 | } | |
| 117 | ||
| 118 | Batc hRun run = batchRunD AO.getLast RunByBatch JobId(bj.g etId()); | |
| 119 | ||
| 120 | if ( run != nul l) { | |
| 121 | run.se tBatchStat us(batchSt atusDAO.ge tStatusTyp e(run.getS tatusId()) ); | |
| 122 | } | |
| 123 | ||
| 124 | retu rn new Bat chItem(bj, run); | |
| 125 | } | |
| 126 | ||
| 127 | pu blic List< BatchJob> getBatchJo bList() { | |
| 128 | ||
| 129 | List <BatchJob> bjL = bat chJobDAO.b atchList() ; | |
| 130 | ||
| 131 | for (BatchJob bj : bjL) { | |
| 132 | // Set the job t ype from t he db. | |
| 133 | bj.set BatchType( batchTypeD AO.getBatc hType(bj.g etTypeId() )); | |
| 134 | bj.set BatchConfi g(batchCon figDAO.get BatchConfi g(bj.getId ())); | |
| 135 | ||
| 136 | } | |
| 137 | ||
| 138 | retu rn bjL; | |
| 139 | } | |
| 140 | ||
| 141 | pu blic List< BatchItem> getCBSSLa testBatchI temsList() { | |
| 142 | ||
| 143 | List <BatchItem > batchIte mL = new A rrayList<> (); | |
| 144 | ||
| 145 | List <BatchJob> jobL = ba tchJobDAO. cbssBatchL ist(); | |
| 146 | ||
| 147 | // G et all of the jobs. | |
| 148 | for (BatchJob bj : jobL) { | |
| 149 | batchI temL.add(g etBatchIte mForJob(bj )); | |
| 150 | } | |
| 151 | ||
| 152 | retu rn batchIt emL; | |
| 153 | } | |
| 154 | ||
| 155 | pu blic List< BatchItem> getAPPSLa testBatchI temsList() { | |
| 156 | ||
| 157 | List <BatchItem > batchIte mL = new A rrayList<> (); | |
| 158 | ||
| 159 | List <BatchJob> jobL = ba tchJobDAO. appsBatchL ist(); | |
| 160 | ||
| 161 | // G et all of the jobs. | |
| 162 | for (BatchJob bj : jobL) { | |
| 163 | batchI temL.add(g etBatchIte mForJob(bj )); | |
| 164 | } | |
| 165 | ||
| 166 | retu rn batchIt emL; | |
| 167 | } | |
| 168 | ||
| 169 | ||
| 170 | pu blic Batch Job getBat chJobByNam e(String n ame) { | |
| 171 | ||
| 172 | // G et the job from the db. | |
| 173 | Batc hJob bj = batchJobDA O.getBatch JobByName( name); | |
| 174 | ||
| 175 | if ( bj != null ) { | |
| 176 | ||
| 177 | // Set the job t ype from t he db. | |
| 178 | bj.set BatchType( batchTypeD AO.getBatc hType(bj.g etTypeId() )); | |
| 179 | bj.set BatchConfi g(batchCon figDAO.get BatchConfi g(bj.getId ())); | |
| 180 | ||
| 181 | } | |
| 182 | ||
| 183 | retu rn bj; | |
| 184 | } | |
| 185 | ||
| 186 | pu blic Batch Job getBat chJobByNam eAndSource Type(Strin g name, in t sourceTy pe) { | |
| 187 | ||
| 188 | // G et the job from the db. | |
| 189 | Batc hJob bj = batchJobDA O.getBatch JobByNameA ndSourceTy pe(name, s ourceType) ; | |
| 190 | ||
| 191 | if ( bj != null ) { | |
| 192 | ||
| 193 | // Set the job t ype from t he db. | |
| 194 | bj.set BatchType( batchTypeD AO.getBatc hType(bj.g etTypeId() )); | |
| 195 | bj.set BatchConfi g(batchCon figDAO.get BatchConfi g(bj.getId ())); | |
| 196 | ||
| 197 | } | |
| 198 | ||
| 199 | retu rn bj; | |
| 200 | } | |
| 201 | ||
| 202 | pu blic Batch Job getBat chJobById( int id) { | |
| 203 | ||
| 204 | // G et the job from the db. | |
| 205 | Batc hJob bj = batchJobDA O.getBatch Job(id); | |
| 206 | ||
| 207 | if ( bj != null ) { | |
| 208 | ||
| 209 | // Set the job t ype from t he db. | |
| 210 | bj.set BatchType( batchTypeD AO.getBatc hType(bj.g etTypeId() )); | |
| 211 | bj.set BatchConfi g(batchCon figDAO.get BatchConfi g(bj.getId ())); | |
| 212 | ||
| 213 | } | |
| 214 | retu rn bj; | |
| 215 | } | |
| 216 | ||
| 217 | pu blic Batch Run startR un(int id) { | |
| 218 | ||
| 219 | Batc hRun bR = null; | |
| 220 | ||
| 221 | Inte ger startS tatus = ba tchStatusD AO.getStat usFromEnum (BatchStat us.JobStat us.RUNNING ); | |
| 222 | ||
| 223 | if ( startStatu s != null) { | |
| 224 | Timest amp startD ate = new Timestamp( Calendar.g etInstance ().getTime ().getTime ()); | |
| 225 | bR = n ew BatchRu n(id, star tDate, sta rtStatus); | |
| 226 | int ru nId = batc hRunDAO.sa ve(bR); | |
| 227 | bR.set Id(runId); | |
| 228 | } el se { | |
| 229 | logger .error("Un able to ob tain statu s mapping for: " + B atchStatus .JobStatus .RUNNING); | |
| 230 | } | |
| 231 | ||
| 232 | retu rn bR; | |
| 233 | } | |
| 234 | ||
| 235 | pu blic boole an complet eRun(Batch Run bR) { | |
| 236 | ||
| 237 | bool ean succes s = false; | |
| 238 | ||
| 239 | Inte ger endSta tus = batc hStatusDAO .getStatus FromEnum(B atchStatus .JobStatus .COMPLETE) ; | |
| 240 | ||
| 241 | if ( endStatus != null) { | |
| 242 | Timest amp endDat e = new Ti mestamp(Ca lendar.get Instance() .getTime() .getTime() ); | |
| 243 | ||
| 244 | bR.set EndDate(en dDate); | |
| 245 | bR.set StatusId(e ndStatus); | |
| 246 | bR.set BatchStatu s(batchSta tusDAO.get StatusType (endStatus )); | |
| 247 | ||
| 248 | batchR unDAO.upda te(bR); | |
| 249 | ||
| 250 | succes s = true; | |
| 251 | ||
| 252 | } el se { | |
| 253 | logger .error("Un able to ob tain statu s mapping for: " + B atchStatus .JobStatus .COMPLETE) ; | |
| 254 | } | |
| 255 | ||
| 256 | retu rn success ; | |
| 257 | } | |
| 258 | ||
| 259 | pu blic boole an errorRu n(BatchRun bR) { | |
| 260 | ||
| 261 | bool ean succes s = false; | |
| 262 | ||
| 263 | Inte ger endSta tus = batc hStatusDAO .getStatus FromEnum(B atchStatus .JobStatus .ERROR); | |
| 264 | ||
| 265 | if ( endStatus != null) { | |
| 266 | Timest amp endDat e = new Ti mestamp(Ca lendar.get Instance() .getTime() .getTime() ); | |
| 267 | ||
| 268 | bR.set EndDate(en dDate); | |
| 269 | bR.set StatusId(e ndStatus); | |
| 270 | bR.set BatchStatu s(batchSta tusDAO.get StatusType (endStatus )); | |
| 271 | ||
| 272 | batchR unDAO.upda te(bR); | |
| 273 | ||
| 274 | succes s = true; | |
| 275 | ||
| 276 | } el se { | |
| 277 | logger .error("Un able to ob tain statu s mapping for: " + B atchStatus .JobStatus .ERROR); | |
| 278 | } | |
| 279 | ||
| 280 | retu rn success ; | |
| 281 | } | |
| 282 | ||
| 283 | pu blic boole an setNotR unningById (BatchJob batchJob) { | |
| 284 | ||
| 285 | bool ean reset = false; | |
| 286 | ||
| 287 | Inte ger runnin gStatus = batchStatu sDAO.getSt atusFromEn um(BatchSt atus.JobSt atus.RUNNI NG); | |
| 288 | Inte ger notRun ningStatus = batchSt atusDAO.ge tStatusFro mEnum(Batc hStatus.Jo bStatus.NO T_RUNNING) ; | |
| 289 | ||
| 290 | if ( (runningSt atus != nu ll) && (no tRunningSt atus != nu ll)) { | |
| 291 | ||
| 292 | // Upd ate existi ng status from Runni ng to NotR unning. | |
| 293 | BatchR un run = b atchRunDAO .getLastRu nByBatchJo bId(batchJ ob.getId() ); | |
| 294 | ||
| 295 | if ((r un != null ) && (run. getStatusI d() == run ningStatus )) { | |
| 296 | run.setS tatusId(no tRunningSt atus); | |
| 297 | batchRun DAO.update (run); | |
| 298 | reset = true; | |
| 299 | } | |
| 300 | ||
| 301 | } el se { | |
| 302 | logger .error("Un able to ob tain statu s mapping for: " + B atchStatus .JobStatus .RUNNING + " or " | |
| 303 | + BatchSta tus.JobSta tus.NOT_RU NNING + " when attem pting to c heck for r unning job (" | |
| 304 | + validate StringInpu t(batchJob .getName() , LOG_FORG ING) + ")" ); | |
| 305 | } | |
| 306 | ||
| 307 | retu rn reset; | |
| 308 | } | |
| 309 | ||
| 310 | pu blic Batch Type getBa tchTypeFor Job(BatchJ ob batchJo b) { | |
| 311 | retu rn batchTy peDAO.getB atchType(b atchJob.ge tTypeId()) ; | |
| 312 | } | |
| 313 | ||
| 314 | pu blic Batch Config get BatchConfi gForJob(Ba tchJob bat chJob){ | |
| 315 | retu rn batchCo nfigDAO.ge tBatchConf ig(batchJo b.getId()) ; | |
| 316 | } | |
| 317 | ||
| 318 | pu blic void updateBatc hJob(Batch Job batchJ ob) { | |
| 319 | batc hJobDAO.up date(batch Job); | |
| 320 | if(g etBatchTyp eForJob(ba tchJob).ge tJobType() .equals(Ba tchType.Jo bType.SCHE DULED)){ | |
| 321 | batchC onfigDAO.u pdateOrIns ert(batchJ ob); | |
| 322 | } | |
| 323 | } | |
| 324 | ||
| 325 | pu blic int g etBatchSrc TypeId(Bat chSrcType. SrcType sr cType){ | |
| 326 | for( BatchSrcTy pe bst : b atchSrcTyp eDAO.batch SrcTypeLis t()) { | |
| 327 | if(bst .getName() .equals(sr cType.getN ame())) { | |
| 328 | return b st.getId() ; | |
| 329 | } | |
| 330 | } | |
| 331 | ||
| 332 | logg er.error(" No batch s ource type ID for so urce type: "+srcType .getName() ); | |
| 333 | retu rn -1; | |
| 334 | } | |
| 335 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.