Produced by Araxis Merge on 12/13/2018 10:35:25 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 | AbstractDataQueryIncrementalProcess.java | Fri Dec 7 17:36:24 2018 UTC |
| 2 | v12.5_iter_7_build 51.zip\TRM_Upgrade\src\main\java\gov\va\med\fw\batchprocess | AbstractDataQueryIncrementalProcess.java | Wed Dec 12 22:26:41 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 390 |
| 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.util.Lis t; | |
| 8 | ||
| 9 | import gov .va.med.fw .persisten t.QueryInc rementTrac ker; | |
| 10 | import gov .va.med.fw .persisten t.QueryInf o; | |
| 11 | import gov .va.med.fw .persisten t.Scrollab leCallback ; | |
| 12 | import gov .va.med.fw .util.Inva lidConfigu rationExce ption; | |
| 13 | ||
| 14 | /** | |
| 15 | * Special ization of AbstractD ataQueryPr ocess that allows fo r record p rocessing | |
| 16 | * in incr ements at a time, ra ther than the entire List of d ata at onc e. | |
| 17 | * | |
| 18 | * <p> | |
| 19 | * Queries that can return mil lions of r ecords sho uld not us e this def ault | |
| 20 | * increme ntal appro ach as it will execu te potenti ally costl y query ov er and | |
| 21 | * over, w ith each e xecution b ecoming sl ower (depe nding on D AO impleme ntation). | |
| 22 | * A custo m approach that only allows th e JDBC Fet ch size to manage th e memory | |
| 23 | * usage i s preferre d in that case. | |
| 24 | * | |
| 25 | * <p> | |
| 26 | * This as sumes the processing of data i s idempote nt (at lea st until a ll | |
| 27 | * increme nts are co mpleted). In other w ords, proc essing of data in in crement #1 | |
| 28 | * will no t affect t he ability to get in crement #2 acquired data (enti re query | |
| 29 | * is run again and again for each incre ment). | |
| 30 | * | |
| 31 | * <p> | |
| 32 | * Non-ide mpotent pr ocessing m ust set id empotent f lag to fal se and thi s assumes | |
| 33 | * the und erlying JD BC driver supports d atabase cu rsors. If the driver does not, | |
| 34 | * an Ille galStateEx ception wi ll be thro wn. If tha t is throw n, a custo m solution | |
| 35 | * needs t o be craft ed or impl ementation processin g must cha nge (eg, u se a | |
| 36 | * databas e temp tab le). | |
| 37 | * | |
| 38 | * Created Feb 17, 2 006 3:19:5 9 PM | |
| 39 | * | |
| 40 | * DNS | |
| 41 | */ | |
| 42 | public abs tract clas s Abstract DataQueryI ncremental Process ex tends Abst ractDataQu eryProcess | |
| 43 | impl ements Scr ollableCal lback { | |
| 44 | pr otected st atic int J DBC_FETCH_ SIZE = 100 ; | |
| 45 | ||
| 46 | pr ivate int fetchSize = 100; // default | |
| 47 | pr ivate bool ean handle EachFetchS eparately = false; | |
| 48 | pr ivate bool ean isIdem potent = t rue; // ma ke getter and setter s as well | |
| 49 | ||
| 50 | // not marke d final fo r framewor k override s | |
| 51 | pr otected vo id execute Process(Da taProcessE xecutionCo ntext cont ext) throw s Exceptio n { | |
| 52 | List acquiredD ata = null ; | |
| 53 | ||
| 54 | Data QueryProce ssExecutio nContext q ueryContex t = (DataQ ueryProces sExecution Context) c ontext; | |
| 55 | quer yContext.s etCurrentD ataQuery(g etQueryDet ail()); | |
| 56 | getQ ueryDetail ().setIncr emental(tr ue); | |
| 57 | ||
| 58 | whil e (!isInte rrupted(co ntext)) { | |
| 59 | acquir edData = a cquireData (queryCont ext); | |
| 60 | if (ac quiredData == null | | acquired Data.isEmp ty()) | |
| 61 | break; | |
| 62 | proces sData(cont ext, acqui redData); | |
| 63 | if (ha ndleEachFe tchSeparat ely) | |
| 64 | handleDa taProcessC ompleted(c ontext); | |
| 65 | } | |
| 66 | if ( isAllProce ssingCompl ete() && ! handleEach FetchSepar ately) | |
| 67 | handle DataProces sCompleted (context); | |
| 68 | } | |
| 69 | ||
| 70 | pr otected fi nal void p rocessData (DataProce ssExecutio nContext c ontext, Li st acquire dData) { | |
| 71 | if ( acquiredDa ta == null || acquir edData.isE mpty()) | |
| 72 | return ; | |
| 73 | Data QueryProce ssExecutio nContext q ueryContex t = (DataQ ueryProces sExecution Context) c ontext; | |
| 74 | proc essData(qu eryContext , acquired Data); | |
| 75 | if ( shouldUpda teJobResul t(queryCon text)) | |
| 76 | this.u pdateJobRe sult(query Context); | |
| 77 | } | |
| 78 | ||
| 79 | /* * | |
| 80 | * To be ove rriden for classes i nvoking co ncurrent p rocesses | |
| 81 | * | |
| 82 | * @return | |
| 83 | * / | |
| 84 | ||
| 85 | pr otected bo olean isAl lProcessin gComplete( ) { | |
| 86 | retu rn true; | |
| 87 | } | |
| 88 | ||
| 89 | pr otected ab stract voi d processD ata(DataQu eryProcess ExecutionC ontext con text, List acquiredD ata); | |
| 90 | ||
| 91 | pu blic void handleScro lledData(Q ueryIncrem entTracker tracker) { | |
| 92 | proc essData((D ataQueryPr ocessExecu tionContex t) tracker , tracker. getIncreme ntalData() ); | |
| 93 | } | |
| 94 | ||
| 95 | pu blic boole an continu eScrolling (QueryIncr ementTrack er tracker ) { | |
| 96 | retu rn !isInte rrupted((D ataProcess ExecutionC ontext) tr acker); | |
| 97 | } | |
| 98 | ||
| 99 | pr otected fi nal List a cquireData (DataQuery ProcessExe cutionCont ext contex t) throws Exception { | |
| 100 | int currentRec ord = cont ext.getCur rentRecord (); | |
| 101 | ||
| 102 | List acquiredD ata = doAc quireData( context); | |
| 103 | if ( acquiredDa ta != null ) { | |
| 104 | contex t.setCurre ntRecord(c urrentReco rd + acqui redData.si ze()); | |
| 105 | // let this happ en indirec tly by imp lementatio n use of | |
| 106 | // inc rementNumb erOf*Recor ds | |
| 107 | // con text.getPr ocessStati stics().se tNumberOfT otalRecord s(context. getCurrent Record()); | |
| 108 | if (lo gger.isInf oEnabled() && acquir edData != null) | |
| 109 | logger.i nfo("Abstr actDataQue ryIncremen talProcess acquired " + acquir edData.siz e() | |
| 110 | + " data rec ords"); | |
| 111 | } | |
| 112 | retu rn acquire dData; | |
| 113 | } | |
| 114 | ||
| 115 | // subclasse s can over ride (eg, use execut ionArgs in context t o filter d ata | |
| 116 | // even more ) | |
| 117 | pr otected Li st doAcqui reData(Dat aQueryProc essExecuti onContext context) t hrows Exce ption { | |
| 118 | List acquiredD ata = null ; | |
| 119 | if ( isIdempote nt) { | |
| 120 | acquir edData = e xecuteQuer y(context) ; | |
| 121 | } el se { | |
| 122 | QueryI nfo query = context. getCurrent DataQuery( ).getQuery (); | |
| 123 | query. setFetchSi ze(fetchSi ze); // th is process wins out on definin g | |
| 124 | // the fetchSize | |
| 125 | getDao ().scroll( this, quer y, context ); | |
| 126 | } | |
| 127 | retu rn acquire dData; | |
| 128 | } | |
| 129 | ||
| 130 | // subclasse s can over ride | |
| 131 | pr otected Li st execute Query(Data QueryProce ssExecutio nContext c ontext) th rows Excep tion { | |
| 132 | Data QueryDetai l currentQ uery = con text.getCu rrentDataQ uery(); | |
| 133 | retu rn getDao( ).find(cur rentQuery. getQuery() .getQuery( ), | |
| 134 | currentQ uery.getQu ery().getP aramNames( ), current Query.getQ uery().get ParamValue s(), | |
| 135 | context. getCurrent Record(), fetchSize, calculate JDBCFetchS ize()); | |
| 136 | } | |
| 137 | ||
| 138 | pr otected in t calculat eJDBCFetch Size() { | |
| 139 | retu rn fetchSi ze > JDBC_ FETCH_SIZE ? fetchSi ze : JDBC_ FETCH_SIZE ; | |
| 140 | } | |
| 141 | ||
| 142 | /* * | |
| 143 | * @return R eturns the fetchSize . | |
| 144 | * / | |
| 145 | pu blic int g etFetchSiz e() { | |
| 146 | retu rn fetchSi ze; | |
| 147 | } | |
| 148 | ||
| 149 | /* * | |
| 150 | * @param fe tchSize | |
| 151 | * The fetc hSize to s et. | |
| 152 | * / | |
| 153 | pu blic void setFetchSi ze(int fet chSize) { | |
| 154 | this .fetchSize = fetchSi ze; | |
| 155 | } | |
| 156 | ||
| 157 | pu blic void afterPrope rtiesSet() { | |
| 158 | supe r.afterPro pertiesSet (); | |
| 159 | if ( fetchSize <= 0) | |
| 160 | throw new Invali dConfigura tionExcept ion("fetch Size must be positiv e"); | |
| 161 | } | |
| 162 | ||
| 163 | /* * | |
| 164 | * @return R eturns the handleEac hFetchSepa rately. | |
| 165 | * / | |
| 166 | pu blic boole an isHandl eEachFetch Separately () { | |
| 167 | retu rn handleE achFetchSe parately; | |
| 168 | } | |
| 169 | ||
| 170 | /* * | |
| 171 | * @param ha ndleEachFe tchSeparat ely | |
| 172 | * The hand leEachFetc hSeparatel y to set. | |
| 173 | * / | |
| 174 | pu blic void setHandleE achFetchSe parately(b oolean han dleEachFet chSeparate ly) { | |
| 175 | this .handleEac hFetchSepa rately = h andleEachF etchSepara tely; | |
| 176 | } | |
| 177 | ||
| 178 | /* * | |
| 179 | * @return R eturns the isIdempot ent. | |
| 180 | * / | |
| 181 | pu blic boole an isIdemp otent() { | |
| 182 | retu rn isIdemp otent; | |
| 183 | } | |
| 184 | ||
| 185 | /* * | |
| 186 | * @param is Idempotent | |
| 187 | * The isId empotent t o set. | |
| 188 | * / | |
| 189 | pu blic void setIdempot ent(boolea n isIdempo tent) { | |
| 190 | this .isIdempot ent = isId empotent; | |
| 191 | } | |
| 192 | ||
| 193 | pr otected bo olean shou ldUpdateJo bResult(Da taQueryPro cessExecut ionContext context) { | |
| 194 | retu rn true; | |
| 195 | } | |
| 196 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.