Produced by Araxis Merge on 12/13/2018 10:35:26 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\fw\batchprocess | ProcessStatistics.java | Fri Dec 7 17:36:22 2018 UTC |
| 2 | v12.5_iter_7_build 51.zip\TRM_Upgrade\src\main\java\gov\va\med\fw\batchprocess | ProcessStatistics.java | Wed Dec 12 22:26:41 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 708 |
| 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.text.Sim pleDateFor mat; | |
| 8 | import jav a.util.Arr ayList; | |
| 9 | import jav a.util.Dat e; | |
| 10 | import jav a.util.Has hMap; | |
| 11 | import jav a.util.Ite rator; | |
| 12 | import jav a.util.Lis t; | |
| 13 | import jav a.util.Map ; | |
| 14 | ||
| 15 | import org .apache.co mmons.bean utils.Bean Utils; | |
| 16 | import org .apache.co mmons.bean utils.Conv ertUtils; | |
| 17 | import org .apache.co mmons.coll ections.Co llectionUt ils; | |
| 18 | import org .apache.co mmons.lang .StringUti ls; | |
| 19 | import org .apache.co mmons.lang .builder.T oStringBui lder; | |
| 20 | ||
| 21 | import gov .va.med.fw .conversio n.DateConv erter; | |
| 22 | import gov .va.med.fw .mail.Form attedObjec tMailStyle ; | |
| 23 | import gov .va.med.fw .model.Abs tractEntit y; | |
| 24 | ||
| 25 | /** | |
| 26 | * Base cl ass for ba tch proces s statisti cs. Each s tatistic s hould have a | |
| 27 | * getter/ setter for javabean semantics to be enfo rced. | |
| 28 | * | |
| 29 | * Created Feb 3, 20 06 1:27:00 PM | |
| 30 | * | |
| 31 | * DNS | |
| 32 | */ | |
| 33 | public cla ss Process Statistics { | |
| 34 | /* * | |
| 35 | * serialVer sionUID lo ng | |
| 36 | * / | |
| 37 | pr ivate stat ic final l ong serial VersionUID = -806896 2742827780 928L; | |
| 38 | ||
| 39 | pr ivate Stri ng process Name; | |
| 40 | ||
| 41 | pr ivate Date processin gStartDate ; | |
| 42 | ||
| 43 | pr ivate Date processin gEndDate; | |
| 44 | ||
| 45 | pr ivate int numberOfTo talRecords ; | |
| 46 | ||
| 47 | pr ivate int numberOfSu ccessfulRe cords; | |
| 48 | ||
| 49 | pr ivate int numberOfEr rorRecords ; | |
| 50 | ||
| 51 | pr ivate bool ean wasInt errupted; | |
| 52 | ||
| 53 | pr ivate Stri ng execute dOnServer; | |
| 54 | ||
| 55 | /* * | |
| 56 | * @return R eturns the numberOfE rrorRecord s. | |
| 57 | * / | |
| 58 | pu blic int g etNumberOf ErrorRecor ds() { | |
| 59 | retu rn numberO fErrorReco rds; | |
| 60 | } | |
| 61 | ||
| 62 | pu blic void incrementN umberOfSuc cessfulRec ords() { | |
| 63 | incr ementNumbe rOfSuccess fulRecords (1); | |
| 64 | } | |
| 65 | ||
| 66 | pu blic void incrementN umberOfSuc cessfulRec ords(int r ecordsCoun t) { | |
| 67 | numb erOfSucces sfulRecord s += recor dsCount; | |
| 68 | numb erOfTotalR ecords += recordsCou nt; | |
| 69 | } | |
| 70 | ||
| 71 | pu blic void incrementN umberOfTot alRecords( ) { | |
| 72 | incr ementNumbe rOfTotalRe cords(1); | |
| 73 | } | |
| 74 | ||
| 75 | pu blic void incrementN umberOfTot alRecords( int count) { | |
| 76 | numb erOfTotalR ecords = n umberOfTot alRecords + count; | |
| 77 | } | |
| 78 | ||
| 79 | pu blic void incrementN umberOfErr orRecords( ) { | |
| 80 | incr ementNumbe rOfErrorRe cords(1); | |
| 81 | } | |
| 82 | ||
| 83 | pu blic void incrementN umberOfErr orRecords( int record sCount) { | |
| 84 | numb erOfErrorR ecords += recordsCou nt; | |
| 85 | numb erOfTotalR ecords += recordsCou nt; | |
| 86 | } | |
| 87 | ||
| 88 | pu blic void decrementN umberOfSuc cessfulRec ords() { | |
| 89 | if ( numberOfSu ccessfulRe cords > 0) | |
| 90 | number OfSuccessf ulRecords- -; | |
| 91 | numb erOfErrorR ecords++; | |
| 92 | } | |
| 93 | ||
| 94 | /* * | |
| 95 | * @param nu mberOfErro rRecords | |
| 96 | * The numb erOfErrorR ecords to set. | |
| 97 | * / | |
| 98 | pu blic void setNumberO fErrorReco rds(int nu mberOfErro rRecords) { | |
| 99 | this .numberOfE rrorRecord s = number OfErrorRec ords; | |
| 100 | } | |
| 101 | ||
| 102 | /* * | |
| 103 | * @return R eturns the numberOfS uccessfulR ecords. | |
| 104 | * / | |
| 105 | pu blic int g etNumberOf Successful Records() { | |
| 106 | retu rn numberO fSuccessfu lRecords; | |
| 107 | } | |
| 108 | ||
| 109 | /* * | |
| 110 | * @param nu mberOfSucc essfulReco rds | |
| 111 | * The numb erOfSucces sfulRecord s to set. | |
| 112 | * / | |
| 113 | pu blic void setNumberO fSuccessfu lRecords(i nt numberO fSuccessfu lRecords) { | |
| 114 | this .numberOfS uccessfulR ecords = n umberOfSuc cessfulRec ords; | |
| 115 | } | |
| 116 | ||
| 117 | /* * | |
| 118 | * @return R eturns the processin gStartDate . | |
| 119 | * / | |
| 120 | pu blic Date getProcess ingStartDa te() { | |
| 121 | retu rn process ingStartDa te; | |
| 122 | } | |
| 123 | ||
| 124 | /* * | |
| 125 | * @param pr ocessingSt artDate | |
| 126 | * The proc essingStar tDate to s et. | |
| 127 | * / | |
| 128 | pu blic void setProcess ingStartDa te(Date pr ocessingSt artDate) { | |
| 129 | this .processin gStartDate = process ingStartDa te; | |
| 130 | } | |
| 131 | ||
| 132 | pu blic void setWasInte rrupted(bo olean flag ) { | |
| 133 | wasI nterrupted = flag; | |
| 134 | } | |
| 135 | ||
| 136 | /* | |
| 137 | * (non-Java doc) | |
| 138 | * | |
| 139 | * @see | |
| 140 | * gov.va.me d.fw.model .AbstractE ntity#buil dToString( org.apache .commons.l ang | |
| 141 | * .builder. ToStringBu ilder) | |
| 142 | * / | |
| 143 | pr otected vo id buildTo String(ToS tringBuild er builder ) { | |
| 144 | buil der.append ("processN ame", proc essName); | |
| 145 | buil der.append ("processi ngStartDat e", proces singStartD ate); | |
| 146 | buil der.append ("processi ngEndDate" , processi ngEndDate) ; | |
| 147 | buil der.append ("calculat ed duratio n", getPro cessingDur ation()); | |
| 148 | buil der.append ("numberOf TotalRecor ds", numbe rOfTotalRe cords); | |
| 149 | buil der.append ("numberOf Successful Records", numberOfSu ccessfulRe cords); | |
| 150 | buil der.append ("numberOf ErrorRecor ds", numbe rOfErrorRe cords); | |
| 151 | buil der.append ("executed OnServer", executedO nServer); | |
| 152 | if ( wasInterru pted) | |
| 153 | builde r.append(" IMPORTANT INFO", | |
| 154 | "** THIS P ROCESS WAS MANUALLY INTERRUPTE D AND MAY NOT HAVE C OMPLETED * *"); | |
| 155 | } | |
| 156 | ||
| 157 | pu blic final String to FormattedM ailString( ) { | |
| 158 | ToSt ringBuilde r builder = new ToSt ringBuilde r(this, ne w Formatte dObjectMai lStyle()); | |
| 159 | this .buildToSt ring(build er); | |
| 160 | retu rn builder .toString( ); | |
| 161 | } | |
| 162 | ||
| 163 | pu blic final String to FormattedS tring() { | |
| 164 | retu rn toForma ttedMailSt ring(); | |
| 165 | } | |
| 166 | ||
| 167 | /* * | |
| 168 | * @return R eturns the processin gEndDate. | |
| 169 | * / | |
| 170 | pu blic Date getProcess ingEndDate () { | |
| 171 | retu rn process ingEndDate ; | |
| 172 | } | |
| 173 | ||
| 174 | /* * | |
| 175 | * @param pr ocessingEn dDate | |
| 176 | * The proc essingEndD ate to set . | |
| 177 | * / | |
| 178 | pu blic void setProcess ingEndDate (Date proc essingEndD ate) { | |
| 179 | this .processin gEndDate = processin gEndDate; | |
| 180 | } | |
| 181 | ||
| 182 | pu blic Strin g getProce ssingDurat ion() { | |
| 183 | Stri ng duratio n = String Utils.EMPT Y; | |
| 184 | if ( processing StartDate != null && processin gEndDate ! = null) { | |
| 185 | if (pr ocessingSt artDate.eq uals(proce ssingEndDa te)) | |
| 186 | duration = "0 secs "; | |
| 187 | long d urationMil lis = proc essingEndD ate.getTim e() - proc essingStar tDate.getT ime(); | |
| 188 | durati on = durat ionMillis / 1000.0 + " secs"; | |
| 189 | } | |
| 190 | retu rn duratio n; | |
| 191 | } | |
| 192 | ||
| 193 | /* * | |
| 194 | * @return R eturns the processNa me. | |
| 195 | * / | |
| 196 | pu blic Strin g getProce ssName() { | |
| 197 | retu rn process Name; | |
| 198 | } | |
| 199 | ||
| 200 | /* * | |
| 201 | * @param pr ocessName | |
| 202 | * The proc essName to set. | |
| 203 | * / | |
| 204 | pu blic void setProcess Name(Strin g processN ame) { | |
| 205 | this .processNa me = proce ssName; | |
| 206 | } | |
| 207 | ||
| 208 | /* * | |
| 209 | * @return R eturns the numberOfT otalRecord s. | |
| 210 | * / | |
| 211 | pu blic int g etNumberOf TotalRecor ds() { | |
| 212 | retu rn numberO fTotalReco rds; | |
| 213 | } | |
| 214 | ||
| 215 | /* * | |
| 216 | * @param nu mberOfTota lRecords | |
| 217 | * The numb erOfTotalR ecords to set. | |
| 218 | * / | |
| 219 | pu blic void setNumberO fTotalReco rds(int nu mberOfTota lRecords) { | |
| 220 | this .numberOfT otalRecord s = number OfTotalRec ords; | |
| 221 | } | |
| 222 | ||
| 223 | /* * | |
| 224 | * @return R eturns the wasInterr upted. | |
| 225 | * / | |
| 226 | pu blic boole an getWasI nterrupted () { | |
| 227 | retu rn wasInte rrupted; | |
| 228 | } | |
| 229 | ||
| 230 | pu blic final String ex portAsCSV( ) throws E xception { | |
| 231 | retu rn StringU tils.remov eEnd(Strin gUtils.rem oveStart(s tatsMap(). toString() , "{"), "} "); | |
| 232 | } | |
| 233 | ||
| 234 | /* * can be o verridden by subclas ses for sp ecial hand ling */ | |
| 235 | pr otected Ma p statsMap () throws Exception { | |
| 236 | Map data = Bea nUtils.des cribe(this ); | |
| 237 | form atDateFiel d(data, "p rocessingS tartDate", getProces singStartD ate()); | |
| 238 | form atDateFiel d(data, "p rocessingE ndDate", g etProcessi ngEndDate( )); | |
| 239 | data .remove("c lass"); | |
| 240 | retu rn data; | |
| 241 | } | |
| 242 | ||
| 243 | pr otected fi nal static String li stAsString (List list ) { | |
| 244 | Stri ngBuilder buf = new StringBuil der(); | |
| 245 | Iter ator itr = list != n ull ? list .iterator( ) : null; | |
| 246 | whil e (itr != null && it r.hasNext( )) { | |
| 247 | buf.ap pend(itr.n ext()); | |
| 248 | if (it r.hasNext( )) | |
| 249 | buf.appe nd(":"); | |
| 250 | } | |
| 251 | retu rn buf.toS tring(); | |
| 252 | } | |
| 253 | ||
| 254 | pr otected fi nal static List list FromString (String st r) { | |
| 255 | if ( StringUtil s.isBlank( str)) | |
| 256 | return null; | |
| 257 | List list = ne w ArrayLis t(); | |
| 258 | Coll ectionUtil s.addAll(l ist, str.s plit(":")) ; | |
| 259 | retu rn list; | |
| 260 | } | |
| 261 | ||
| 262 | pr otected fi nal void f ormatDateF ield(Map d ata, Strin g fieldNam e, Date fi eldValue) { | |
| 263 | // n ote the da te format must be on e that is supported by the | |
| 264 | // D ateConvert er used in importFro mCSV | |
| 265 | if ( fieldValue != null) | |
| 266 | data.p ut(fieldNa me, new Si mpleDateFo rmat("yyyy MMddHHmmss ").format( fieldValue )); | |
| 267 | else | |
| 268 | data.r emove(fiel dName); | |
| 269 | } | |
| 270 | ||
| 271 | pu blic final void impo rtFromCSV( String csv ) throws E xception { | |
| 272 | if ( StringUtil s.isBlank( csv)) | |
| 273 | return ; | |
| 274 | ||
| 275 | if ( ConvertUti ls.lookup( Date.class ) == null) | |
| 276 | Conver tUtils.reg ister(new DateConver ter(null), Date.clas s); | |
| 277 | ||
| 278 | Bean Utils.copy Properties (this, map FromCSV(cs v)); | |
| 279 | } | |
| 280 | ||
| 281 | /* * can be o verridden by subclas ses for sp ecial hand ling */ | |
| 282 | pr otected Ma p mapFromC SV(String csv) { | |
| 283 | Map data = new HashMap() ; | |
| 284 | Stri ng[] vals = csv.spli t(","); | |
| 285 | Stri ng[] val = null; | |
| 286 | for (int i = 0 ; i < vals .length; i ++) { | |
| 287 | val = vals[i].sp lit("="); | |
| 288 | if (va l.length = = 2) | |
| 289 | data.put (val[0].tr im(), val[ 1]); | |
| 290 | } | |
| 291 | retu rn data; | |
| 292 | } | |
| 293 | ||
| 294 | /* * can be o verridden by subclas ses for sp ecial hand ling */ | |
| 295 | pu blic boole an contain sErrors() { | |
| 296 | retu rn numberO fErrorReco rds != 0; | |
| 297 | } | |
| 298 | ||
| 299 | pu blic synch ronized fi nal void o verlayStat s(ProcessS tatistics stats) { | |
| 300 | this .setProces sName(stat s.getProce ssName()); | |
| 301 | /* | |
| 302 | * / / since th ese are fo r overall processing time, exc lude from this | |
| 303 | * i ncremental overlay | |
| 304 | * t his.setPro cessingSta rtDate(sta ts.getProc essingStar tDate()); | |
| 305 | * t his.setPro cessingEnd Date(stats .getProces singEndDat e()); | |
| 306 | * t his.setExe cutedOnSer ver(stats. getExecute dOnServer( )); | |
| 307 | */ | |
| 308 | this .setNumber OfTotalRec ords(getNu mberOfTota lRecords() + stats.g etNumberOf TotalRecor ds()); | |
| 309 | this .setNumber OfSuccessf ulRecords( getNumberO fSuccessfu lRecords() | |
| 310 | + stats. getNumberO fSuccessfu lRecords() ); | |
| 311 | this .setNumber OfErrorRec ords(getNu mberOfErro rRecords() + stats.g etNumberOf ErrorRecor ds()); | |
| 312 | appe ndStats(st ats); | |
| 313 | } | |
| 314 | ||
| 315 | pr otected vo id appendS tats(Proce ssStatisti cs stats) { | |
| 316 | // n o-op, subc lasses imp lement thi s | |
| 317 | } | |
| 318 | ||
| 319 | pu blic boole an isTotal NumberMod( int factor ) { | |
| 320 | retu rn getNumb erOfTotalR ecords() ! = 0 ? (get NumberOfTo talRecords () % facto r) == 0 : false; | |
| 321 | } | |
| 322 | ||
| 323 | /* * | |
| 324 | * @return R eturns the executedO nServer. | |
| 325 | * / | |
| 326 | pu blic Strin g getExecu tedOnServe r() { | |
| 327 | retu rn execute dOnServer; | |
| 328 | } | |
| 329 | ||
| 330 | /* * | |
| 331 | * @param ex ecutedOnSe rver | |
| 332 | * The exec utedOnServ er to set. | |
| 333 | * / | |
| 334 | pu blic void setExecute dOnServer( String exe cutedOnSer ver) { | |
| 335 | this .executedO nServer = executedOn Server; | |
| 336 | } | |
| 337 | ||
| 338 | @O verride | |
| 339 | pu blic Strin g toString () { | |
| 340 | fina l StringBu ilder buil der = new StringBuil der(); | |
| 341 | buil der.append ("processN ame=" + pr ocessName + "\n"); | |
| 342 | buil der.append ("processi ngStartDat e=" + proc essingStar tDate + "\ n"); | |
| 343 | buil der.append ("processi ngEndDate= " + proces singEndDat e + "\n"); | |
| 344 | buil der.append ("calculat ed duratio n=" + getP rocessingD uration() + "\n"); | |
| 345 | buil der.append ("numberOf TotalRecor ds=" + num berOfTotal Records + "\n"); | |
| 346 | buil der.append ("numberOf Successful Records=" + numberOf Successful Records + "\n"); | |
| 347 | buil der.append ("numberOf ErrorRecor ds=" + num berOfError Records + "\n"); | |
| 348 | buil der.append ("executed OnServer=" + execute dOnServer + "\n"); | |
| 349 | if ( wasInterru pted) { | |
| 350 | builde r.append(" IMPORTANT INFO" + | |
| 351 | "** THIS P ROCESS WAS MANUALLY INTERRUPTE D AND MAY NOT HAVE C OMPLETED * *"); | |
| 352 | } | |
| 353 | retu rn builder .toString( ); | |
| 354 | } | |
| 355 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.