Produced by Araxis Merge on 6/11/2019 10:54:09 AM Eastern Daylight 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 | HTRE_P3_v14.5_iter_4_build_14.zip\java\gov\va\med\ccht\service\common\impl | TerminologyServiceImpl.java | Wed May 29 15:26:30 2019 UTC |
| 2 | HTRE_P3_v14.5_iter_4_build_14.zip\java\gov\va\med\ccht\service\common\impl | TerminologyServiceImpl.java | Mon Jun 10 19:30:04 2019 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 636 |
| 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.common.i mpl; | |
| 5 | ||
| 6 | import jav a.util.Arr ays; | |
| 7 | import jav a.util.Col lection; | |
| 8 | import jav a.util.Has hMap; | |
| 9 | import jav a.util.Lis t; | |
| 10 | import jav a.util.Map ; | |
| 11 | ||
| 12 | import org .apache.co mmons.logg ing.LogFac tory; | |
| 13 | import org .springfra mework.bea ns.factory .annotatio n.Autowire d; | |
| 14 | import org .springfra mework.ste reotype.Se rvice; | |
| 15 | ||
| 16 | import gov .va.med.cc ht.persist ent.Termin ologyDAO; | |
| 17 | import gov .va.med.cc ht.service .common.Te rminologyE xception; | |
| 18 | import gov .va.med.cc ht.service .common.Te rminologyS ervice; | |
| 19 | import gov .va.med.fw .model.loo kup.Abstra ctLookup; | |
| 20 | import gov .va.med.fw .model.loo kup.Lookup ; | |
| 21 | import gov .va.med.fw .service.A bstractCom ponent; | |
| 22 | import gov .va.med.fw .util.Stop WatchLogge r; | |
| 23 | ||
| 24 | /** | |
| 25 | * IHTA IH TA_common Jun 26, 20 10 | |
| 26 | * | |
| 27 | * @author DN S
|
|
| 28 | */ | |
| 29 | @Service | |
| 30 | public cla ss Termino logyServic eImpl exte nds Abstra ctComponen t implemen ts Termino logyServic e { | |
| 31 | ||
| 32 | @A utowired | |
| 33 | pr ivate Term inologyDAO terminolo gyDAO; | |
| 34 | ||
| 35 | pu blic Termi nologyServ iceImpl() { | |
| 36 | ||
| 37 | } | |
| 38 | ||
| 39 | pu blic Termi nologyServ iceImpl(Te rminologyD AO TermDao ) { | |
| 40 | ||
| 41 | term inologyDAO = TermDao ; | |
| 42 | } | |
| 43 | ||
| 44 | /* | |
| 45 | * (non-Java doc) | |
| 46 | * | |
| 47 | * @see | |
| 48 | * gov.va.me d.IHTA.ser vice.commo n.Terminol ogyService #findAll(j ava.lang.C lass | |
| 49 | * ) | |
| 50 | * / | |
| 51 | @S uppressWar nings("unc hecked") | |
| 52 | pu blic List findAll(St ring termi nologyType ) throws T erminology Exception { | |
| 53 | /* | |
| 54 | * F irst check to see if we are re questing a n enum cla ss that al so | |
| 55 | * i mplements Lookup - C PB | |
| 56 | */ | |
| 57 | Clas s<?> clazz ; | |
| 58 | try { | |
| 59 | clazz = Class.fo rName(term inologyTyp e); | |
| 60 | if (cl azz.isEnum () && Look up.class.i sAssignabl eFrom(claz z)) | |
| 61 | return A rrays.asLi st(clazz.g etEnumCons tants()); | |
| 62 | } ca tch (Class NotFoundEx ception ig nored) { | |
| 63 | } | |
| 64 | ||
| 65 | /* O therwise, return val ues from t he databas e */ | |
| 66 | try { | |
| 67 | return terminolo gyDAO.find All(termin ologyType) ; | |
| 68 | } ca tch (Excep tion ex) { | |
| 69 | throw new Termin ologyExcep tion("Erro r while lo oking up " + termino logyType, ex); | |
| 70 | } | |
| 71 | } | |
| 72 | ||
| 73 | pu blic <T ex tends Look up> List<T > findAll( Class<T> t erminology Type) thro ws Termino logyExcept ion { | |
| 74 | /* | |
| 75 | * F irst check to see if we are re questing a n enum cla ss that al so | |
| 76 | * i mplements Lookup - C PB | |
| 77 | */ | |
| 78 | if ( terminolog yType.isEn um() && Lo okup.class .isAssigna bleFrom(te rminologyT ype)) | |
| 79 | return (List<T>) Arrays.as List(termi nologyType .getEnumCo nstants()) ; | |
| 80 | ||
| 81 | try { | |
| 82 | return terminolo gyDAO.find All(termin ologyType) ; | |
| 83 | } ca tch (Excep tion ex) { | |
| 84 | throw new Termin ologyExcep tion("Erro r while lo oking up " + termino logyType, ex); | |
| 85 | } | |
| 86 | } | |
| 87 | ||
| 88 | /* | |
| 89 | * (non-Java doc) | |
| 90 | * | |
| 91 | * @see | |
| 92 | * gov.va.me d.IHTA.ser vice.commo n.Terminol ogyService #findAll(j ava.lang.C lass | |
| 93 | * ) | |
| 94 | * / | |
| 95 | pu blic <T ex tends Look up> List<T > findAllA ctive(Clas s<T> termi nologyType ) | |
| 96 | throws Terminolo gyExceptio n { | |
| 97 | /* | |
| 98 | * F irst check to see if we are re questing a n enum cla ss that al so | |
| 99 | * i mplements Lookup - C PB | |
| 100 | */ | |
| 101 | if ( terminolog yType.isEn um() && Lo okup.class .isAssigna bleFrom(te rminologyT ype)) | |
| 102 | return (List<T>) Arrays.as List(termi nologyType .getEnumCo nstants()) ; | |
| 103 | ||
| 104 | try { | |
| 105 | return terminolo gyDAO.find AllActive( terminolog yType); | |
| 106 | } ca tch (Excep tion ex) { | |
| 107 | throw new Termin ologyExcep tion("Erro r while lo oking up " + termino logyType.g etName(), | |
| 108 | ex); | |
| 109 | } | |
| 110 | } | |
| 111 | ||
| 112 | /* | |
| 113 | * (non-Java doc) | |
| 114 | * | |
| 115 | * @see | |
| 116 | * gov.va.me d.IHTA.ser vice.commo n.Terminol ogyService #getByCode (java.lang | |
| 117 | * .Class, j ava.lang.S tring) | |
| 118 | * / | |
| 119 | pu blic Looku p getByCod e(String t erminology Type, Stri ng code) t hrows Term inologyExc eption { | |
| 120 | try { | |
| 121 | StopWa tchLogger timer = ne w StopWatc hLogger("T erminology ServiceImp l.getByCod e for : " | |
| 122 | + terminol ogyType + " " + code ); | |
| 123 | timer. start(); | |
| 124 | Lookup result = null; | |
| 125 | ||
| 126 | /* | |
| 127 | * Fir st check t o see if w e are requ esting an enum class that also | |
| 128 | * imp lements Lo okup - CPB | |
| 129 | */ | |
| 130 | Class< ?> clazz = null; | |
| 131 | ||
| 132 | try { | |
| 133 | clazz = Class.forN ame(termin ologyType) ; | |
| 134 | } catc h (ClassNo tFoundExce ption igno red) { | |
| 135 | } | |
| 136 | ||
| 137 | if (cl azz != nul l && clazz .isEnum() && Lookup. class.isAs signableFr om(clazz)) { | |
| 138 | for (Obj ect o : cl azz.getEnu mConstants ()) { | |
| 139 | Lookup l = (Lookup) o; | |
| 140 | ||
| 141 | if (l.getC ode().equa ls(code)) { | |
| 142 | re sult = l; | |
| 143 | br eak; | |
| 144 | } | |
| 145 | } | |
| 146 | } else { | |
| 147 | result = terminolo gyDAO.getB yCode(term inologyTyp e, code); | |
| 148 | } | |
| 149 | ||
| 150 | timer. stopAndLog ("done", L ogFactory. getLog(Sto pWatchLogg er.class)) ; | |
| 151 | return result; | |
| 152 | } ca tch (Excep tion ex) { | |
| 153 | throw new Termin ologyExcep tion("Erro r while lo oking up " + termino logyType | |
| 154 | + " for co de = " + c ode, ex); | |
| 155 | } | |
| 156 | } | |
| 157 | ||
| 158 | pu blic <T ex tends Look up> Map<St ring, T> g etByCodes( Class<T> t erminology Type, | |
| 159 | Collec tion<Strin g> codes) throws Ter minologyEx ception { | |
| 160 | Map< String, T> results = new HashM ap<String, T>(); | |
| 161 | if ( terminolog yType.isEn um() && Lo okup.class .isAssigna bleFrom(te rminologyT ype)) { | |
| 162 | for (T l : termi nologyType .getEnumCo nstants()) { | |
| 163 | if (code s.contains (l.getCode ())) | |
| 164 | results.pu t(l.getCod e(), l); | |
| 165 | } | |
| 166 | } el se { | |
| 167 | List<T > resultLi st = termi nologyDAO. getByCodes (terminolo gyType, co des); | |
| 168 | for (T e : resul tList) | |
| 169 | if (code s.contains (e.getCode ())) | |
| 170 | results.pu t(e.getCod e(), e); | |
| 171 | } | |
| 172 | ||
| 173 | retu rn results ; | |
| 174 | } | |
| 175 | ||
| 176 | /* | |
| 177 | * (non-Java doc) | |
| 178 | * | |
| 179 | * @see | |
| 180 | * gov.va.me d.IHTA.ser vice.commo n.Terminol ogyService #getByCode (java.lang | |
| 181 | * .Class, j ava.lang.S tring) | |
| 182 | * / | |
| 183 | pu blic <T ex tends Look up> T getB yCode(Clas s<T> termi nologyType , String c ode) | |
| 184 | throws Terminolo gyExceptio n { | |
| 185 | try { | |
| 186 | StopWa tchLogger timer = ne w StopWatc hLogger("T erminology ServiceImp l.getByCod e for : " | |
| 187 | + terminol ogyType + " " + code ); | |
| 188 | timer. start(); | |
| 189 | T resu lt = null; | |
| 190 | ||
| 191 | if (te rminologyT ype.isEnum () && Look up.class.i sAssignabl eFrom(term inologyTyp e)) { | |
| 192 | for (T l : termino logyType.g etEnumCons tants()) { | |
| 193 | if (l.getC ode().equa ls(code)) { | |
| 194 | re sult = l; | |
| 195 | br eak; | |
| 196 | } | |
| 197 | } | |
| 198 | } else { | |
| 199 | result = terminolo gyDAO.getB yCode(term inologyTyp e, code); | |
| 200 | } | |
| 201 | ||
| 202 | timer. stopAndLog ("done", L ogFactory. getLog(Sto pWatchLogg er.class)) ; | |
| 203 | return result; | |
| 204 | } ca tch (Excep tion ex) { | |
| 205 | throw new Termin ologyExcep tion("Erro r while lo oking up " + termino logyType.g etName() | |
| 206 | + " for co de = " + c ode, ex); | |
| 207 | } | |
| 208 | } | |
| 209 | ||
| 210 | /* | |
| 211 | * (non-Java doc) | |
| 212 | * | |
| 213 | * @see | |
| 214 | * gov.va.me d.IHTA.ser vice.commo n.Terminol ogyService #getByName (java.lang | |
| 215 | * .Class, j ava.lang.S tring) | |
| 216 | * / | |
| 217 | pu blic <T ex tends Look up> T getB yName(Clas s<T> termi nologyType , String n ame) | |
| 218 | throws Terminolo gyExceptio n { | |
| 219 | try { | |
| 220 | T resu lt = null; | |
| 221 | ||
| 222 | if (te rminologyT ype.isEnum () && Look up.class.i sAssignabl eFrom(term inologyTyp e)) { | |
| 223 | for (T l : termino logyType.g etEnumCons tants()) { | |
| 224 | if (l.getN ame().equa ls(name)) { | |
| 225 | re sult = l; | |
| 226 | br eak; | |
| 227 | } | |
| 228 | } | |
| 229 | } else { | |
| 230 | result = terminolo gyDAO.getB yName(term inologyTyp e, name); | |
| 231 | } | |
| 232 | ||
| 233 | return result; | |
| 234 | } ca tch (Excep tion ex) { | |
| 235 | throw new Termin ologyExcep tion("Erro r while lo oking up " + termino logyType.g etName() | |
| 236 | + " for co de = " + n ame, ex); | |
| 237 | } | |
| 238 | } | |
| 239 | ||
| 240 | /* | |
| 241 | * (non-Java doc) | |
| 242 | * | |
| 243 | * @see | |
| 244 | * gov.va.me d.IHTA.ser vice.commo n.Terminol ogyService #getByName (java.lang | |
| 245 | * .String, java.lang. String) | |
| 246 | * / | |
| 247 | pu blic Looku p getByNam e(String t erminology Type, Stri ng name) t hrows Term inologyExc eption { | |
| 248 | try { | |
| 249 | Lookup result = null; | |
| 250 | ||
| 251 | /* | |
| 252 | * Fir st check t o see if w e are requ esting an enum class that also | |
| 253 | * imp lements Lo okup - CPB | |
| 254 | */ | |
| 255 | Class< ?> clazz = null; | |
| 256 | ||
| 257 | try { | |
| 258 | clazz = Class.forN ame(termin ologyType) ; | |
| 259 | } catc h (ClassNo tFoundExce ption igno red) { | |
| 260 | } | |
| 261 | ||
| 262 | if (cl azz != nul l && clazz .isEnum() && Lookup. class.isAs signableFr om(clazz)) { | |
| 263 | for (Obj ect o : cl azz.getEnu mConstants ()) { | |
| 264 | Lookup l = (Lookup) o; | |
| 265 | ||
| 266 | if (l.getN ame().equa ls(name)) { | |
| 267 | re sult = l; | |
| 268 | br eak; | |
| 269 | } | |
| 270 | } | |
| 271 | } else { | |
| 272 | result = terminolo gyDAO.getB yName(term inologyTyp e, name); | |
| 273 | } | |
| 274 | ||
| 275 | return result; | |
| 276 | } ca tch (Excep tion ex) { | |
| 277 | throw new Termin ologyExcep tion("Erro r while lo oking up " + termino logyType | |
| 278 | + " for co de = " + n ame, ex); | |
| 279 | } | |
| 280 | } | |
| 281 | ||
| 282 | pu blic <T ex tends Look up> T getB yId(Class< T> termino logyType, Long id) | |
| 283 | throws Terminolo gyExceptio n { | |
| 284 | try { | |
| 285 | return terminolo gyDAO.getB yId(termin ologyType, id); | |
| 286 | } ca tch (Excep tion e) { | |
| 287 | throw new Termin ologyExcep tion("Erro r while lo oking up " + termino logyType | |
| 288 | + " for id = " + id, e); | |
| 289 | } | |
| 290 | } | |
| 291 | ||
| 292 | pu blic Looku p getById( String ter minologyTy pe, Long i d) throws Terminolog yException { | |
| 293 | try { | |
| 294 | return terminolo gyDAO.getB yId(termin ologyType, id); | |
| 295 | } ca tch (Excep tion e) { | |
| 296 | throw new Termin ologyExcep tion("Erro r while lo oking up " + termino logyType | |
| 297 | + " for id = " + id, e); | |
| 298 | } | |
| 299 | } | |
| 300 | pu blic List< ? extends Lookup> se archTerms( String ter minologyTy pe, String searchCri teria) thr ows Termin ologyExcep tion | |
| 301 | { | |
| 302 | try { | |
| 303 | return terminolo gyDAO.sear chTerms(te rminologyT ype, searc hCriteria) ; | |
| 304 | } ca tch (Excep tion e) { | |
| 305 | throw new Termin ologyExcep tion("Erro r while lo oking up " + termino logyType | |
| 306 | + " for na me like = " + search Criteria, e); | |
| 307 | } | |
| 308 | } | |
| 309 | pu blic void save(Abstr actLookup lookup) th rows Termi nologyExce ption { | |
| 310 | try { | |
| 311 | termin ologyDAO.s ave(lookup ); | |
| 312 | } ca tch (Excep tion e) { | |
| 313 | throw new Termin ologyExcep tion("Erro r while sa ving refer ence data" ,e); | |
| 314 | } | |
| 315 | ||
| 316 | } | |
| 317 | ||
| 318 | ||
| 319 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.