Produced by Araxis Merge on 12/13/2018 10:35:23 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\ccht\persistent\hibernate | SurveyTrendChartsDAOImpl.java | Fri Dec 7 17:36:32 2018 UTC |
| 2 | v12.5_iter_7_build 51.zip\TRM_Upgrade\src\main\java\gov\va\med\ccht\persistent\hibernate | SurveyTrendChartsDAOImpl.java | Wed Dec 12 19:45:44 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 570 |
| 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.med.c cht.persis tent.hiber nate; | |
| 2 | ||
| 3 | import jav a.util.Arr ayList; | |
| 4 | import jav a.util.Cal endar; | |
| 5 | import jav a.util.Dat e; | |
| 6 | import jav a.util.Lin kedList; | |
| 7 | import jav a.util.Lis t; | |
| 8 | ||
| 9 | import jav ax.persist ence.Query ; | |
| 10 | import jav ax.transac tion.Trans actional; | |
| 11 | ||
| 12 | import org .hibernate .Session; | |
| 13 | import org .hibernate .SessionFa ctory; | |
| 14 | import org .springfra mework.bea ns.factory .annotatio n.Autowire d; | |
| 15 | import org .springfra mework.ste reotype.Re pository; | |
| 16 | ||
| 17 | import gov .va.med.cc ht.model.p ssreport.S urveyTrend ChartResul t; | |
| 18 | import gov .va.med.cc ht.persist ent.Survey TrendChart sDAO; | |
| 19 | import gov .va.med.cc ht.service .common.fa cility.Fac ilityServi ce; | |
| 20 | import gov .va.med.cc ht.service .htreports .CensusAct ivityRepor tsConstant s; | |
| 21 | import gov .va.med.cc ht.ui.mode l.PSSRepor tForm; | |
| 22 | ||
| 23 | /** | |
| 24 | * | |
| 25 | * @author D N S | |
| 26 | * | |
| 27 | */ | |
| 28 | ||
| 29 | @Repositor y | |
| 30 | @Transacti onal | |
| 31 | public cla ss SurveyT rendCharts DAOImpl im plements S urveyTrend ChartsDAO, | |
| 32 | Ce nsusActivi tyReportsC onstants { | |
| 33 | ||
| 34 | pr ivate stat ic final i nt MONTH = 0; | |
| 35 | pr ivate stat ic final i nt VISN = 0; | |
| 36 | pr ivate stat ic final i nt NUM_OF_ SURVEYS_AL L_VISNS = 1; | |
| 37 | pr ivate stat ic final i nt NUM_OF_ SURVEYS_FA CILITIES = 1; | |
| 38 | pr ivate stat ic final i nt NUM_OF_ SURVEYS = 2; | |
| 39 | ||
| 40 | pu blic stati c final in t NATIONAL _SELECTION = 1; | |
| 41 | pu blic stati c final in t VISN_SEL ECTION = 2 ; | |
| 42 | pu blic stati c final in t FACILITY _SELECTION = 3; | |
| 43 | ||
| 44 | @A utowired | |
| 45 | pr ivate Sess ionFactory sessionFa ctory; | |
| 46 | ||
| 47 | pu blic Surve yTrendChar tsDAOImpl( ) { | |
| 48 | } | |
| 49 | ||
| 50 | pu blic Surve yTrendChar tsDAOImpl( SessionFac tory facto ry) { | |
| 51 | sess ionFactory = factory ; | |
| 52 | } | |
| 53 | ||
| 54 | pr otected Se ssion getS ession() { | |
| 55 | retu rn this.se ssionFacto ry.getCurr entSession (); | |
| 56 | } | |
| 57 | ||
| 58 | @S uppressWar nings("unu sed") | |
| 59 | @O verride | |
| 60 | pu blic Linke dList<Surv eyTrendCha rtResult> getSurveyT rendCharts ReportData (PSSReport Form form) { | |
| 61 | ||
| 62 | Quer y query = null; | |
| 63 | ||
| 64 | swit ch (form.g etTypeButt onSelectio n()) { | |
| 65 | ||
| 66 | case NATIONAL _SELECTION : | |
| 67 | query = getNatio nalReportQ uery(form) ; | |
| 68 | break; | |
| 69 | case VISN_SELE CTION: | |
| 70 | if(for m.getVisnI d().equals IgnoreCase (ALL_VISNS )) { | |
| 71 | query = getAllVisn ReportQuer y(form); | |
| 72 | } | |
| 73 | else { | |
| 74 | query = getVisnRep ortQuery(f orm); | |
| 75 | // if qu ery is for a single visn sets query para meter for that visn | |
| 76 | query.se tParameter ("visnId", form.getV isnId()); | |
| 77 | } | |
| 78 | break; | |
| 79 | case FACILITY_ SELECTION: | |
| 80 | if(for m.getFacil ityId().eq ualsIgnore Case(ALL_F ACILITIES) ) { | |
| 81 | query = getAllFaci lityReport (form); | |
| 82 | } | |
| 83 | else { | |
| 84 | query = getFacilit yReportQue ry(form); | |
| 85 | // if qu ery is for a single facility s ets query parameter for that f acility | |
| 86 | query.se tParameter ("facility Id", form. getFacilit yId()); | |
| 87 | } | |
| 88 | break; | |
| 89 | defa ult: | |
| 90 | return new Linke dList<Surv eyTrendCha rtResult>( ); | |
| 91 | } | |
| 92 | ||
| 93 | //fo rtify Fix, Null Dere ference | |
| 94 | if(q uery == nu ll) { | |
| 95 | return new Linke dList<Surv eyTrendCha rtResult>( ); | |
| 96 | } | |
| 97 | ||
| 98 | //fo rtify Fix, Null Dere ference | |
| 99 | // S hould neve r be null, has defau lt value | |
| 100 | if(f orm.getSho rtFormatRe portFromDa te() == nu ll || form .getShortF ormatRepor tToDate() == null) { | |
| 101 | // ret urn empty list to av oid errors , will res ult in emp ty report. | |
| 102 | return new Linke dList<Surv eyTrendCha rtResult>( ); | |
| 103 | } | |
| 104 | else { | |
| 105 | query. setParamet er("fromDa te", form. getShortFo rmatReport FromDate() ); | |
| 106 | ||
| 107 | //Cale ndar defau lts to the 1st of th e month so adding an additiona l month | |
| 108 | //to i nclude the entire mo nth in the report | |
| 109 | Calend ar toDate = Calendar .getInstan ce(); | |
| 110 | toDate .setTime(f orm.getSho rtFormatRe portToDate ()); | |
| 111 | toDate .add(Calen dar.MONTH, 1); | |
| 112 | ||
| 113 | query. setParamet er("toDate ", toDate. getTime()) ; | |
| 114 | } | |
| 115 | ||
| 116 | List <Object[]> reportDat a = query. getResultL ist(); | |
| 117 | ||
| 118 | Link edList <Su rveyTrendC hartResult > results = new Link edList<Sur veyTrendCh artResult> (); | |
| 119 | ||
| 120 | //If report is being run for All v isns the d ata return ed is each visn | |
| 121 | // & the numbe r of surve ys over th e selected time peri od | |
| 122 | if(f orm.getTyp eButtonSel ection() = = VISN_SEL ECTION && form.getVi snId().equ als(ALL_VI SNS)) { | |
| 123 | for(Ob ject[] ent ry : repor tData) { | |
| 124 | SurveyTr endChartRe sult row = new Surve yTrendChar tResult(); | |
| 125 | row.setV isn(entry[ VISN].toSt ring()); | |
| 126 | row.setN umOfSurvey s(Integer. parseInt(e ntry[NUM_O F_SURVEYS_ ALL_VISNS] .toString( ))); | |
| 127 | results. add(row); | |
| 128 | } | |
| 129 | } | |
| 130 | //Fo r all othe r reports the data i s the mont h and the total numb er of surv eys for th at month | |
| 131 | else if(form.g etTypeButt onSelectio n() == FAC ILITY_SELE CTION){ | |
| 132 | for(Ob ject[] ent ry : repor tData) { | |
| 133 | SurveyTr endChartRe sult row = new Surve yTrendChar tResult(); | |
| 134 | row.setM onth(entry [MONTH].to String()); | |
| 135 | row.setN umOfSurvey s(Integer. parseInt(e ntry[NUM_O F_SURVEYS_ FACILITIES ].toString ())); | |
| 136 | results. add(row); | |
| 137 | } | |
| 138 | }els e{ | |
| 139 | for(Ob ject[] ent ry : repor tData) { | |
| 140 | SurveyTr endChartRe sult row = new Surve yTrendChar tResult(); | |
| 141 | row.setM onth(entry [MONTH].to String()); | |
| 142 | row.setN umOfSurvey s(Integer. parseInt(e ntry[NUM_O F_SURVEYS] .toString( ))); | |
| 143 | results. add(row); | |
| 144 | } | |
| 145 | } | |
| 146 | retu rn results ; | |
| 147 | } | |
| 148 | ||
| 149 | /* * | |
| 150 | * Creates qu ery for Na tional tot als | |
| 151 | * @param fo rm | |
| 152 | * @return q uery for n ational to tals | |
| 153 | * / | |
| 154 | pr ivate Quer y getNatio nalReportQ uery(PSSRe portForm f orm) { | |
| 155 | ||
| 156 | Stri ngBuilder sql = new StringBuil der(); | |
| 157 | sql. append("SE LECT conve rt(char(3) , received _date) as [Month], " ); | |
| 158 | sql. append("da tepart(mon th, receiv ed_date) a s [MonthNu m], "); | |
| 159 | sql. append("co unt(*) as [Count] ") ; | |
| 160 | sql. append("fr om Surveye d_Activity _Response a, surveye d_activity b "); | |
| 161 | sql. append("wh ere a.surv eyed_activ ity_id= b. surveyed_a ctivity_id "); | |
| 162 | sql. append("an d (a.surve y_id != 1) "); //do not includ e VR-12 da ta | |
| 163 | sql. append("an d a.survey _accepted_ status = 1 "); | |
| 164 | sql. append("an d received _date "); | |
| 165 | sql. append("BE TWEEN :fro mDate AND :toDate ") ; | |
| 166 | sql. append("gr oup by con vert(char( 3), receiv ed_date),d atepart(mo nth, recei ved_date) "); | |
| 167 | sql. append("or der by 2") ; | |
| 168 | ||
| 169 | retu rn getSess ion().crea teNativeQu ery(sql.to String()); | |
| 170 | } | |
| 171 | ||
| 172 | /* * | |
| 173 | * Creates q uery for A ll VISNS | |
| 174 | * whi ch returns results b y visn ins tead of by month | |
| 175 | * @param fo rm | |
| 176 | * @return q uery for a ll visns b y visn ins tead of mo nth | |
| 177 | * / | |
| 178 | pr ivate Quer y getAllVi snReportQu ery(PSSRep ortForm fo rm) { | |
| 179 | Stri ngBuilder sql = new StringBuil der(); | |
| 180 | ||
| 181 | sql. append("SE LECT 'Visn ' + conver t(varchar( 2), b.visn _id) "); | |
| 182 | sql. append("as [VISN], " ); | |
| 183 | sql. append("co unt(*) as [Count] ") ; | |
| 184 | sql. append("fr om Surveye d_Activity _Response a, surveye d_activity b "); | |
| 185 | sql. append("wh ere a.surv eyed_activ ity_id= b. surveyed_a ctivity_id "); | |
| 186 | sql. append("an d (a.surve y_id != 1) "); //do not includ e vr-12 da ta | |
| 187 | sql. append("an d a.survey _accepted_ status = 1 "); | |
| 188 | sql. append("an d received _date "); | |
| 189 | sql. append("BE TWEEN :fro mDate AND :toDate ") ; | |
| 190 | sql. append("gr oup by b.v isn_id ") ; | |
| 191 | sql. append("or der by b.v isn_id"); | |
| 192 | ||
| 193 | retu rn getSess ion().crea teNativeQu ery(sql.to String()); | |
| 194 | } | |
| 195 | ||
| 196 | /* * | |
| 197 | * Creates q uery for a single vi sn | |
| 198 | * @param fo rm | |
| 199 | * @return q uery for s ingle visn by month | |
| 200 | * / | |
| 201 | pr ivate Quer y getVisnR eportQuery (PSSReport Form form) { | |
| 202 | Stri ngBuilder sql = new StringBuil der(); | |
| 203 | ||
| 204 | sql. append("SE LECT conve rt(char(3) , received _date) as [Month], " ); | |
| 205 | sql. append("da tepart(mon th, receiv ed_date) a s [MonthNu m], "); | |
| 206 | sql. append("co unt(*) as [Count] ") ; | |
| 207 | sql. append("fr om Surveye d_Activity _Response a, surveye d_activity b "); | |
| 208 | sql. append("wh ere a.surv eyed_activ ity_id= b. surveyed_a ctivity_id "); | |
| 209 | sql. append("an d b.visn_i d= :visnId "); | |
| 210 | sql. append("an d (a.surve y_id != 1) "); //do not includ e vr-12 da ta | |
| 211 | sql. append("an d a.survey _accepted_ status = 1 "); | |
| 212 | sql. append("an d received _date "); | |
| 213 | sql. append("BE TWEEN :fro mDate AND :toDate ") ; | |
| 214 | sql. append("gr oup by con vert(char( 3), receiv ed_date),d atepart(mo nth, recei ved_date), b.visn_id "); | |
| 215 | sql. append("or der by 2, b.visn_id "); | |
| 216 | ||
| 217 | retu rn getSess ion().crea teNativeQu ery(sql.to String()); | |
| 218 | } | |
| 219 | ||
| 220 | /* * | |
| 221 | * Creates q uery for A ll Facilit ies | |
| 222 | * @param fo rm | |
| 223 | * @return q uery for a ll facilit ies by mon th | |
| 224 | * / | |
| 225 | pr ivate Quer y getAllFa cilityRepo rt(PSSRepo rtForm for m) { | |
| 226 | Stri ngBuilder sql = new StringBuil der(); | |
| 227 | sql. append("SE LECT conve rt(char(3) , received _date) as [Month], " ); | |
| 228 | sql. append("co unt(*) as [Count], " ); | |
| 229 | sql. append("da tepart(mon th, receiv ed_date) " ); | |
| 230 | sql. append("fr om Surveye d_Activity _Response a, surveye d_activity b "); | |
| 231 | sql. append("wh ere a.surv eyed_activ ity_id= b. surveyed_a ctivity_id "); | |
| 232 | sql. append("an d (a.surve y_id != 1) "); //do not includ e vr-12 da ta | |
| 233 | sql. append("an d a.survey _accepted_ status = 1 "); | |
| 234 | sql. append("an d received _date "); | |
| 235 | sql. append("BE TWEEN :fro mDate AND :toDate ") ; | |
| 236 | sql. append("GR OUP BY CON VERT(char( 3), a.Rece ived_Date) ,DATEPART( month, a.R eceived_Da te) "); | |
| 237 | sql. append("or der by 3") ; | |
| 238 | ||
| 239 | retu rn getSess ion().crea teNativeQu ery(sql.to String()); | |
| 240 | } | |
| 241 | ||
| 242 | /* * | |
| 243 | * Creates q uery for a single fa cility | |
| 244 | * @param fo rm | |
| 245 | * @return q uery for s ingle faci lity by mo nth | |
| 246 | * / | |
| 247 | pr ivate Quer y getFacil ityReportQ uery(PSSRe portForm f orm) { | |
| 248 | ||
| 249 | Stri ngBuilder sql = new StringBuil der(); | |
| 250 | sql. append("SE LECT conve rt(char(3) , received _date) as [Month], " ); | |
| 251 | sql. append("co unt(*) as [Count], " ); | |
| 252 | sql. append("da tepart(mon th, receiv ed_date) " ); | |
| 253 | sql. append("fr om Surveye d_Activity _Response a, surveye d_activity b, facili ties c "); | |
| 254 | sql. append("wh ere a.surv eyed_activ ity_id= b. surveyed_a ctivity_id "); | |
| 255 | sql. append("an d c.id = b .Facility_ id and b.F acility_id = :facilit yId "); | |
| 256 | sql. append("an d (a.surve y_id != 1) "); //do not includ e vr-12 da ta | |
| 257 | sql. append("an d a.survey _accepted_ status = 1 "); | |
| 258 | sql. append("an d received _date "); | |
| 259 | sql. append("BE TWEEN :fro mDate AND :toDate ") ; | |
| 260 | sql. append("GR OUP BY CON VERT(char( 3), a.Rece ived_Date) ,"); | |
| 261 | sql. append("DA TEPART(mon th, a.Rece ived_Date) , c.Facili ty_Name ") ; | |
| 262 | sql. append("or der by 3") ; | |
| 263 | ||
| 264 | retu rn getSess ion().crea teNativeQu ery(sql.to String()); | |
| 265 | } | |
| 266 | ||
| 267 | @S uppressWar nings("dep recation") | |
| 268 | @O verride | |
| 269 | pu blic List< Date> getD atesByMont h() { | |
| 270 | // T ODO: Conne ct to the database f or the dat es if nece ssary. | |
| 271 | // F or now, th e business logic alw ays starts in Januar y of 2006. | |
| 272 | ||
| 273 | Cale ndar lastD ate = Cale ndar.getIn stance(); | |
| 274 | last Date.set(2 006, Calen dar.JANUAR Y, 1); | |
| 275 | List <Date> dat esList = n ew ArrayLi st<Date>() ; | |
| 276 | Cale ndar curre nt = Calen dar.getIns tance(); | |
| 277 | Date today = C alendar.ge tInstance( ).getTime( ); | |
| 278 | curr ent.set(to day.getYea r() + 1900 , today.ge tMonth(), 1); | |
| 279 | whil e(current. getTime(). after(last Date.getTi me())) { | |
| 280 | datesL ist.add(cu rrent.getT ime()); | |
| 281 | curren t.add(Cale ndar.MONTH , -1); | |
| 282 | } | |
| 283 | date sList.add( current.ge tTime()); // add las t month | |
| 284 | retu rn datesLi st; | |
| 285 | } | |
| 286 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.