Produced by Araxis Merge on 12/13/2018 10:35:24 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\service\report\impl | ReportParameterConversionServiceImpl.java | Fri Dec 7 17:36:42 2018 UTC |
| 2 | v12.5_iter_7_build 51.zip\TRM_Upgrade\src\main\java\gov\va\med\ccht\service\report\impl | ReportParameterConversionServiceImpl.java | Wed Dec 12 22:33:39 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 792 |
| 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 | * Copyrig ht � 2010 VHA. All r ights rese rved | |
| 3 | ********* ********** ********** ********** ********** ********** *********/ | |
| 4 | package go v.va.med.c cht.servic e.report.i mpl; | |
| 5 | ||
| 6 | import jav a.text.Par seExceptio n; | |
| 7 | import jav a.util.Arr ays; | |
| 8 | import jav a.util.Dat e; | |
| 9 | import jav a.util.Has hMap; | |
| 10 | import jav a.util.Has hSet; | |
| 11 | import jav a.util.Ite rator; | |
| 12 | import jav a.util.Lis t; | |
| 13 | import jav a.util.Map ; | |
| 14 | import jav a.util.Set ; | |
| 15 | import jav a.util.Tim eZone; | |
| 16 | ||
| 17 | import org .springfra mework.bea ns.factory .annotatio n.Autowire d; | |
| 18 | import org .springfra mework.ste reotype.Se rvice; | |
| 19 | ||
| 20 | import gov .va.med.cc ht.model.S chedule; | |
| 21 | import gov .va.med.cc ht.model.c ommon.DIRe portParame ters; | |
| 22 | import gov .va.med.cc ht.model.c ommon.Repo rtWeek; | |
| 23 | import gov .va.med.cc ht.model.r eport.Repo rtParamete rs; | |
| 24 | import gov .va.med.cc ht.model.r eport.Repo rtSchedule ; | |
| 25 | import gov .va.med.cc ht.model.r eport.Repo rtSetup; | |
| 26 | import gov .va.med.cc ht.model.r eport.Sche duledRepor t; | |
| 27 | import gov .va.med.cc ht.model.t erminology .DayOfMont h; | |
| 28 | import gov .va.med.cc ht.model.t erminology .DayOfQuar ter; | |
| 29 | import gov .va.med.cc ht.model.t erminology .DayOfWeek ; | |
| 30 | import gov .va.med.cc ht.model.t erminology .Month; | |
| 31 | import gov .va.med.cc ht.model.t erminology .ReportFor mat; | |
| 32 | import gov .va.med.cc ht.model.t erminology .RunFreque ncy; | |
| 33 | import gov .va.med.cc ht.model.t erminology .ScheduleT ype; | |
| 34 | import gov .va.med.cc ht.model.t erminology .WeekOfMon th; | |
| 35 | import gov .va.med.cc ht.service .common.Te rminologyE xception; | |
| 36 | import gov .va.med.cc ht.service .common.Te rminologyS ervice; | |
| 37 | import gov .va.med.cc ht.service .common.fa cility.Fac ilityServi ce; | |
| 38 | import gov .va.med.cc ht.service .common.vi sn.VisnSer vice; | |
| 39 | import gov .va.med.cc ht.service .report.Re portConsta nts; | |
| 40 | import gov .va.med.cc ht.service .report.Re portParame terConvers ionService ; | |
| 41 | import gov .va.med.fw .model.loo kup.Abstra ctLookup; | |
| 42 | import gov .va.med.fw .model.loo kup.Lookup ; | |
| 43 | import gov .va.med.fw .service.A bstractCom ponent; | |
| 44 | import gov .va.med.fw .service.S erviceExce ption; | |
| 45 | import gov .va.med.fw .util.Date Utils; | |
| 46 | import gov .va.med.fw .util.Stri ngUtils; | |
| 47 | import gov .va.med.fw .util.date .DateWithT imeZone; | |
| 48 | ||
| 49 | /** | |
| 50 | * | |
| 51 | * @author DNS | |
| 52 | */ | |
| 53 | @Service | |
| 54 | public cla ss ReportP arameterCo nversionSe rviceImpl extends Ab stractComp onent impl ements | |
| 55 | Repo rtParamete rConversio nService, ReportCons tants { | |
| 56 | ||
| 57 | pr ivate stat ic final l ong serial VersionUID = -424779 5731608103 914L; | |
| 58 | ||
| 59 | @A utowired | |
| 60 | pr ivate Term inologySer vice termi nologyServ ice = null ; | |
| 61 | @A utowired | |
| 62 | pr ivate Faci lityServic e facility Service = null; | |
| 63 | @A utowired | |
| 64 | pr ivate Visn Service vi snService; | |
| 65 | ||
| 66 | pu blic void convertToT ext(Schedu ledReport scheduledR eport) thr ows Servic eException { | |
| 67 | ||
| 68 | if (sc heduledRep ort.getRep ortSchedul e() != nul l) { | |
| 69 | schedule dReport.se tReportSch eduleText( toText(sch eduledRepo rt.getRepo rtSchedule ())); | |
| 70 | } else { | |
| 71 | schedule dReport.se tReportSch eduleText( null); | |
| 72 | } | |
| 73 | if (sc heduledRep ort.getRep ortParamet ers() != n ull) { | |
| 74 | schedule dReport.se tReportPar ameterText (convertRe portParame tersToText (scheduled Report.get ReportPara meters())) ; | |
| 75 | }else { | |
| 76 | schedule dReport.se tReportPar ameterText (null); | |
| 77 | } | |
| 78 | } | |
| 79 | ||
| 80 | pu blic void convertFro mText(Sche duledRepor t schedule dReport) t hrows Serv iceExcepti on, ParseE xception { | |
| 81 | schedu ledReport. setReportS chedule(co nvertTextT oReportSch edule(sche duledRepor t.getRepor tScheduleT ext())); | |
| 82 | schedu ledReport. setReportP arameters( convertTex tToReportP arameters( scheduledR eport.getR eportParam eterText() )); | |
| 83 | ||
| 84 | } | |
| 85 | pu blic void convertToT ext(Report Setup repo rtSetup) t hrows Serv iceExcepti on { | |
| 86 | if (re portSetup. getReportS chedule() != null) { | |
| 87 | reportSe tup.setRep ortSchedul eText(toTe xt(reportS etup.getRe portSchedu le())); | |
| 88 | } else { | |
| 89 | reportSe tup.setRep ortSchedul eText(null ); | |
| 90 | } | |
| 91 | if (re portSetup. getReportP arameters( ) != null) { | |
| 92 | reportSe tup.setRep ortParamet ersText(co nvertRepor tParameter sToText(re portSetup. getReportP arameters( ))); | |
| 93 | }else { | |
| 94 | reportSe tup.setRep ortParamet ersText(nu ll); | |
| 95 | } | |
| 96 | } | |
| 97 | ||
| 98 | ||
| 99 | ||
| 100 | pu blic void convertFro mText(Repo rtSetup re portSetup) throws Se rviceExcep tion, Pars eException { | |
| 101 | report Setup.setR eportSched ule(conver tTextToRep ortSchedul e(reportSe tup.getRep ortSchedul eText())); | |
| 102 | report Setup.setR eportParam eters(conv ertTextToR eportParam eters(repo rtSetup.ge tReportPar ametersTex t())); | |
| 103 | } | |
| 104 | ||
| 105 | pu blic Strin g toText(S chedule re portSchedu le) throws ServiceEx ception{ | |
| 106 | Map<St ring, Stri ng> map = new HashMa p<String, String>(); | |
| 107 | map.pu t("runFreq uency", fr omLookup(r eportSched ule.getRun Frequency( ))); | |
| 108 | map.pu t("schedul eType", fr omLookup(r eportSched ule.getSch eduleType( ))); | |
| 109 | map.pu t("dayOfMo nth", from Lookup(rep ortSchedul e.getDayOf Month())); | |
| 110 | map.pu t("weekOfM onth", fro mLookup(re portSchedu le.getWeek OfMonth()) ); | |
| 111 | map.pu t("dayOfWe ek", fromL ookup(repo rtSchedule .getDayOfW eek())); | |
| 112 | map.pu t("dayOfQu arter", fr omLookup(r eportSched ule.getDay OfQuarter( ))); | |
| 113 | map.pu t("month", fromLooku p(reportSc hedule.get Month())); | |
| 114 | map.pu t("numeric DayOfMonth ", fromInt eger(repor tSchedule. getNumeric DayOfMonth ())); | |
| 115 | map.pu t("dateToG enerate", fromDateWi thTimeZone (reportSch edule.getD ateToGener ate())); | |
| 116 | map.pu t("hour", fromIntege r(reportSc hedule.get Hour())); | |
| 117 | map.pu t("minute" , fromInte ger(report Schedule.g etMinute() )); | |
| 118 | map.pu t("daysOfW eek", from LookupSet( reportSche dule.getDa ysOfWeek() )); | |
| 119 | return exportAsC SV(map); | |
| 120 | ||
| 121 | } | |
| 122 | ||
| 123 | pu blic Sched ule toSche dule(Strin g schedule Text) thro ws Service Exception, ParseExce ption{ | |
| 124 | Sche dule sched ule = new Schedule() ; | |
| 125 | conv ertTextToS chedule(sc heduleText , schedule ); | |
| 126 | retu rn schedul e; | |
| 127 | } | |
| 128 | pr ivate Repo rtSchedule convertTe xtToReport Schedule(S tring repo rtSchedule Text) thro ws Termino logyExcept ion, Parse Exception { | |
| 129 | Repo rtSchedule reportSch edule = ne w ReportSc hedule(); | |
| 130 | conv ertTextToS chedule(re portSchedu leText, re portSchedu le); | |
| 131 | retu rn reportS chedule; | |
| 132 | } | |
| 133 | pr ivate void convertTe xtToSchedu le(String reportSche duleText, Schedule r eportSched ule) throw s Terminol ogyExcepti on, ParseE xception{ | |
| 134 | ||
| 135 | if ( StringUtil s.isNotEmp ty(reportS cheduleTex t)) { | |
| 136 | Map<St ring, Stri ng> map = importFrom CSV(report ScheduleTe xt); | |
| 137 | report Schedule.s etRunFrequ ency(toLoo kup(RunFre quency.cla ss, map.ge t("runFreq uency"))); | |
| 138 | report Schedule.s etSchedule Type(toLoo kup(Schedu leType.cla ss, map.ge t("schedul eType"))); | |
| 139 | report Schedule.s etDayOfMon th(toLooku p(DayOfMon th.class, map.get("d ayOfMonth" ))); | |
| 140 | report Schedule.s etWeekOfMo nth(toLook up(WeekOfM onth.class , map.get( "weekOfMon th"))); | |
| 141 | report Schedule.s etDayOfWee k(toLookup (DayOfWeek .class, ma p.get("day OfWeek"))) ; | |
| 142 | report Schedule.s etDayOfQua rter(toLoo kup(DayOfQ uarter.cla ss, map.ge t("dayOfQu arter"))); | |
| 143 | report Schedule.s etMonth(to Lookup(Mon th.class, map.get("m onth"))); | |
| 144 | report Schedule.s etNumericD ayOfMonth( toInteger( map.get("n umericDayO fMonth"))) ; | |
| 145 | report Schedule.s etDateToGe nerate(toD ateWithTim eZone(map. get("dateT oGenerate" ))); | |
| 146 | report Schedule.s etHour(toI nteger(map .get("hour "))); | |
| 147 | report Schedule.s etMinute(t oInteger(m ap.get("mi nute"))); | |
| 148 | report Schedule.s etDaysOfWe ek(toLooku pSet(DayOf Week.class , map.get( "daysOfWee k"))); | |
| 149 | } | |
| 150 | } | |
| 151 | ||
| 152 | pr ivate Stri ng convert ReportPara metersToTe xt(ReportP arameters reportPara meters) { | |
| 153 | DIRe portParame ters diRep ortParamet ers = (DIR eportParam eters)repo rtParamete rs; | |
| 154 | Map< String, St ring> map = new Hash Map<String , String>( ); | |
| 155 | map. put(REPORT _PARAM_USE R_TIMEZONE , fromTime Zone(diRep ortParamet ers.getUse rTimeZone( ))); | |
| 156 | map. put(REPORT _PARAM_FRO M_DATE, fr omDate(diR eportParam eters.getF romDate()) ); | |
| 157 | map. put(REPORT _PARAM_TO_ DATE, from Date(diRep ortParamet ers.getToD ate())); | |
| 158 | map. put(REPORT _PARAM_AS_ OF_DATE, f romDate(di ReportPara meters.get AsOfDate() )); | |
| 159 | map. put(REPORT _PARAM_REP ORT_FORMAT , fromLook up(diRepor tParameter s.getRepor tFormat()) ); | |
| 160 | map. put(REPORT _SUMMARY_T YPE, diRep ortParamet ers.getRep ortSummary Type()); | |
| 161 | map. put(REPORT _PARAM_REP ORT_WEEK, fromReport Week(diRep ortParamet ers.getRep ortWeek()) ); | |
| 162 | map. put(REPORT _PARAM_SUB TOTAL_TYPE , diReport Parameters .getSubTot alType()); | |
| 163 | map. put(REPORT _PARAM_ALL _VISNS, fr omBoolean( diReportPa rameters.g etAllVisns ())); | |
| 164 | map. put(REPORT _PARAM_VIS N, diRepor tParameter s.getVisn( ) == null ? "" : diR eportParam eters.getV isn().getN ame()); | |
| 165 | map. put(REPORT _PARAM_ALL _FACILITIE S, fromBoo lean(diRep ortParamet ers.getAll Facilities ())); | |
| 166 | map. put(REPORT _PARAM_FAC ILITY, diR eportParam eters.getF acility() == null ? "" : diRep ortParamet ers.getFac ility().ge tStationNu mber()); | |
| 167 | map. put(REPORT _PARAM_ALL _DEVICE_ST ATUSES, fr omBoolean( diReportPa rameters.g etAllDevic eStatuses( ))); | |
| 168 | map. put(DAYS_T O_KEEP_COM PLETED_REP ORTS, from Integer(di ReportPara meters.get DaysToKeep CompletedR eports())) ; | |
| 169 | retu rn exportA sCSV(map); | |
| 170 | } | |
| 171 | ||
| 172 | pr ivate Repo rtParamete rs convert TextToRepo rtParamete rs(String reportPara metersText ) throws S erviceExce ption { | |
| 173 | DIRe portParame ters repor tParameter s = new DI ReportPara meters(); | |
| 174 | if ( StringUtil s.isNotEmp ty(reportP arametersT ext)) { | |
| 175 | Map<St ring, Stri ng> map = importFrom CSV(report Parameters Text); | |
| 176 | report Parameters .setUserTi meZone(toT imeZone(ma p.get(REPO RT_PARAM_U SER_TIMEZO NE))); | |
| 177 | report Parameters .setFromDa te(toDate( map.get(RE PORT_PARAM _FROM_DATE ))); | |
| 178 | report Parameters .setToDate (toDate(ma p.get(REPO RT_PARAM_T O_DATE))); | |
| 179 | report Parameters .setAsOfDa te(toDate( map.get(RE PORT_PARAM _AS_OF_DAT E))); | |
| 180 | report Parameters .setReport Format(toL ookup(Repo rtFormat.c lass, map. get(REPORT _PARAM_REP ORT_FORMAT ))); | |
| 181 | report Parameters .setReport SummaryTyp e(map.get( REPORT_SUM MARY_TYPE) ); | |
| 182 | report Parameters .setReport Week(toRep ortWeek(ma p.get(REPO RT_PARAM_R EPORT_WEEK ))); | |
| 183 | report Parameters .setSubTot alType(map .get(REPOR T_PARAM_SU BTOTAL_TYP E)); | |
| 184 | report Parameters .setAllVis ns(toBoole an(map.get (REPORT_PA RAM_ALL_VI SNS))); | |
| 185 | String visn = ma p.get(REPO RT_PARAM_V ISN); | |
| 186 | if (St ringUtils. isNotEmpty (visn)) { | |
| 187 | reportPa rameters.s etVisn(vis nService.g etSimpleVi sn(visn)); | |
| 188 | } | |
| 189 | report Parameters .setAllFac ilities(to Boolean(ma p.get(REPO RT_PARAM_A LL_FACILIT IES))); | |
| 190 | String facility = map.get( REPORT_PAR AM_FACILIT Y); | |
| 191 | if (St ringUtils. isNotEmpty (facility) ) { | |
| 192 | reportPa rameters.s etFacility (facilityS ervice.get Facility(f acility)); | |
| 193 | } | |
| 194 | report Parameters .setAllDev iceStatuse s(toBoolea n(map.get( REPORT_PAR AM_ALL_DEV ICE_STATUS ES))); | |
| 195 | report Parameters .setDaysTo KeepComple tedReports (toInteger (map.get(D AYS_TO_KEE P_COMPLETE D_REPORTS) )); | |
| 196 | } | |
| 197 | retu rn reportP arameters; | |
| 198 | } | |
| 199 | ||
| 200 | pr otected Da te toDate( String dat e) { | |
| 201 | retu rn StringU tils.isEmp ty(date) ? null : ne w Date(Lon g.parseLon g(date)); | |
| 202 | } | |
| 203 | ||
| 204 | pr otected Re portWeek t oReportWee k(String r eportWeek) { | |
| 205 | Repo rtWeek wee k = null; | |
| 206 | if ( StringUtil s.isEmpty( reportWeek )) { | |
| 207 | return null; | |
| 208 | }els e { | |
| 209 | week = new Repor tWeek(); | |
| 210 | String [] dates = reportWee k.split(": "); | |
| 211 | week.s etStartDat e(toDate(d ates[0])); | |
| 212 | week.s etEndDate( toDate(dat es[1])); | |
| 213 | } | |
| 214 | retu rn week; | |
| 215 | } | |
| 216 | ||
| 217 | pr otected Da teWithTime Zone toDat eWithTimeZ one(String date) thr ows ParseE xception { | |
| 218 | if ( StringUtil s.isEmpty( date)) | |
| 219 | return null; | |
| 220 | ||
| 221 | Date d = null; | |
| 222 | Time Zone tz = null; | |
| 223 | ||
| 224 | if ( date.conta ins(";")) { | |
| 225 | /* new format */ | |
| 226 | String [] pieces = date.spl it(";"); | |
| 227 | if (pi eces.lengt h != 2) | |
| 228 | return n ull; | |
| 229 | ||
| 230 | d = ne w Date(Lon g.parseLon g(pieces[0 ])); | |
| 231 | tz = T imeZone.ge tTimeZone( pieces[1]) ; | |
| 232 | } el se { | |
| 233 | /* tra nsition fr om old for mat */ | |
| 234 | String [] pieces = date.spl it(" "); | |
| 235 | d = Da teUtils.pa rseDate(pi eces[0], D ateUtils.M MDDYYYY); | |
| 236 | tz = T imeZone.ge tTimeZone( pieces[2]) ; | |
| 237 | } | |
| 238 | Date WithTimeZo ne dt = ne w DateWith TimeZone(d , tz); | |
| 239 | retu rn dt; | |
| 240 | } | |
| 241 | ||
| 242 | pr otected Ti meZone toT imeZone(St ring timeZ one){ | |
| 243 | retu rn StringU tils.isEmp ty(timeZon e) ? null : TimeZone .getTimeZo ne(timeZon e); | |
| 244 | } | |
| 245 | ||
| 246 | pr otected <T extends L ookup> T t oLookup(Cl ass<T> cla zz, String code) thr ows Termin ologyExcep tion { | |
| 247 | retu rn StringU tils.isEmp ty(code) ? null : te rminologyS ervice.get ByCode(cla zz, code); | |
| 248 | } | |
| 249 | ||
| 250 | pr otected Se t<String> toSet(Stri ng codes){ | |
| 251 | Set< String> se t = new Ha shSet<Stri ng>(); | |
| 252 | if ( !StringUti ls.isEmpty (codes)) | |
| 253 | for (S tring val : codes.sp lit(":")) | |
| 254 | set.add( val); | |
| 255 | retu rn set; | |
| 256 | } | |
| 257 | ||
| 258 | pr otected <T extends L ookup> Set <T> toLook upSet(Clas s<T> clazz , String c odes) thro ws Termino logyExcept ion { | |
| 259 | Set< T> lookups = new Has hSet<T>(); | |
| 260 | if ( !StringUti ls.isEmpty (codes)) { | |
| 261 | List<S tring> val s = Arrays .asList(co des.split( ":")); | |
| 262 | lookup s.addAll(t erminology Service.ge tByCodes(c lazz, vals ).values() ); | |
| 263 | } | |
| 264 | ||
| 265 | retu rn lookups ; | |
| 266 | } | |
| 267 | ||
| 268 | pr otected In teger toIn teger(Stri ng intValu e) { | |
| 269 | retu rn StringU tils.isEmp ty(intValu e) ? null : Integer. parseInt(i ntValue); | |
| 270 | } | |
| 271 | ||
| 272 | pr otected Bo olean toBo olean(Stri ng boolean Value) { | |
| 273 | retu rn Boolean .parseBool ean(boolea nValue); | |
| 274 | } | |
| 275 | ||
| 276 | pr otected Se t<Boolean> toBoolean Set(String codes){ | |
| 277 | Set< Boolean> s et = new H ashSet<Boo lean>(); | |
| 278 | if ( !StringUti ls.isEmpty (codes)) { | |
| 279 | String [] vals = codes.spli t(":"); | |
| 280 | for (S tring val : vals) { | |
| 281 | set.add( Boolean.pa rseBoolean (val)); | |
| 282 | } | |
| 283 | } | |
| 284 | retu rn set; | |
| 285 | } | |
| 286 | ||
| 287 | pr otected St ring fromB oolean(Boo lean boole anValue) { | |
| 288 | retu rn boolean Value == n ull ? "" : String.va lueOf(bool eanValue); | |
| 289 | } | |
| 290 | ||
| 291 | pr otected St ring fromB ooleanSet( Set<Boolea n> set) { | |
| 292 | if ( set == nul l || set.s ize() == 0 ) { | |
| 293 | return ""; | |
| 294 | } el se { | |
| 295 | String Builder li st = new S tringBuild er(); | |
| 296 | for (I terator<Bo olean> i = set.itera tor(); i.h asNext();) { | |
| 297 | Boolean booleanVal ue = i.nex t(); | |
| 298 | list.app end(boolea nValue == null ? "" : booleanV alue.toStr ing()); | |
| 299 | if (i.ha sNext()) | |
| 300 | list.appen d(":"); | |
| 301 | } | |
| 302 | return list.toSt ring(); | |
| 303 | } | |
| 304 | } | |
| 305 | ||
| 306 | pr otected St ring fromD ate(Date d ate) { | |
| 307 | retu rn date == null ? "" : String. valueOf(da te.getTime ()); | |
| 308 | } | |
| 309 | pr otected St ring fromR eportWeek( ReportWeek reportWee k) { | |
| 310 | retu rn reportW eek == nul l ? "" : | |
| 311 | (repor tWeek.getS tartDate() == null ? "" : Stri ng.valueOf (reportWee k.getStart Date().get Time())) + ":" + | |
| 312 | (repor tWeek.getE ndDate() = = null ? " " : String .valueOf(r eportWeek. getEndDate ().getTime ())); | |
| 313 | } | |
| 314 | pr otected St ring fromD ateWithTim eZone(Date WithTimeZo ne date) { | |
| 315 | retu rn date == null || d ate.getDat e() == nul l || date. getTimeZon e() == nul l ? "" : d ate | |
| 316 | .getDate ().getTime () | |
| 317 | + ";" + date.getTi meZone().g etID(); | |
| 318 | } | |
| 319 | ||
| 320 | pr otected St ring fromT imeZone(Ti meZone tim eZone) { | |
| 321 | retu rn timeZon e == null ? null : t imeZone.ge tID(); | |
| 322 | } | |
| 323 | ||
| 324 | pr otected St ring fromL ookup(Abst ractLookup lookup) { | |
| 325 | retu rn lookup == null ? "" : looku p.getCode( ); | |
| 326 | } | |
| 327 | ||
| 328 | pr otected St ring fromS et(Set<Str ing> set) { | |
| 329 | if ( set == nul l || set.s ize() == 0 ) { | |
| 330 | return ""; | |
| 331 | } el se { | |
| 332 | String Builder li st = new S tringBuild er(); | |
| 333 | for (I terator<St ring> i = set.iterat or(); i.ha sNext();) { | |
| 334 | String v alue = i.n ext(); | |
| 335 | list.app end(value) ; | |
| 336 | if (i.ha sNext()) | |
| 337 | list.appen d(":"); | |
| 338 | } | |
| 339 | return list.toSt ring(); | |
| 340 | } | |
| 341 | } | |
| 342 | ||
| 343 | pr otected St ring fromL ookupSet(S et<? exten ds Lookup> lookupSet ) { | |
| 344 | if ( lookupSet == null || lookupSet .size() == 0) { | |
| 345 | return ""; | |
| 346 | } el se { | |
| 347 | String Builder li st = new S tringBuild er(); | |
| 348 | for (I terator<? extends Lo okup> i = lookupSet. iterator() ; i.hasNex t();) { | |
| 349 | Lookup l ookup = i. next(); | |
| 350 | list.app end(lookup .getCode() ); | |
| 351 | if (i.ha sNext()) | |
| 352 | list.appen d(":"); | |
| 353 | } | |
| 354 | return list.toSt ring(); | |
| 355 | } | |
| 356 | } | |
| 357 | ||
| 358 | pr otected St ring fromI nteger(Int eger intVa lue) { | |
| 359 | retu rn intValu e == null ? "" : Str ing.valueO f(intValue ); | |
| 360 | } | |
| 361 | ||
| 362 | /* * | |
| 363 | * Exports t he map as comma-sepa rated valu es, with e ach entry as a | |
| 364 | * name=valu e pair. If any value is null, we simply append "na me=" (with | |
| 365 | * nothing a fter the e quals sign ). | |
| 366 | * | |
| 367 | * @param ma p | |
| 368 | * @return | |
| 369 | * / | |
| 370 | pu blic final String ex portAsCSV( Map<String , String> map) { | |
| 371 | Stri ngBuilder sb = new S tringBuild er(); | |
| 372 | for (Map.Entry <String, S tring> ent ry : map.e ntrySet()) { | |
| 373 | String key = ent ry.getKey( ); | |
| 374 | String value = e ntry.getVa lue(); | |
| 375 | if (sb .length() > 0) | |
| 376 | sb.appen d(","); | |
| 377 | sb.app end(key).a ppend("=") .append(va lue != nul l ? value : ""); | |
| 378 | } | |
| 379 | ||
| 380 | retu rn sb.toSt ring(); | |
| 381 | } | |
| 382 | ||
| 383 | pu blic final Map<Strin g, String> importFro mCSV(Strin g csv) { | |
| 384 | Map< String, St ring> data = new Has hMap<Strin g, String> (); | |
| 385 | Stri ng[] vals = csv.spli t(","); | |
| 386 | Stri ng[] val = null; | |
| 387 | for (String va l2 : vals) { | |
| 388 | val = val2.split ("="); | |
| 389 | if (va l.length = = 2) | |
| 390 | data.put (val[0].tr im(), val[ 1]); | |
| 391 | } | |
| 392 | retu rn data; | |
| 393 | } | |
| 394 | ||
| 395 | ||
| 396 | ||
| 397 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.