Produced by Araxis Merge on 12/5/2017 12:06:38 PM Central 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 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\CoreValueObjects\main\src\java\gov\va\med\imaging\exchange\configuration | ProcedureFilterTerms.java | Mon Dec 4 21:35:00 2017 UTC |
| 2 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\CoreValueObjects\main\src\java\gov\va\med\imaging\exchange\configuration | ProcedureFilterTerms.java | Mon Dec 4 21:58:55 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 3 | 860 |
| Changed | 2 | 4 |
| 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 | * | |
| 3 | Package: MAG - Vis tA Imaging | |
| 4 | WARNING: Per VHA D irective 2 004-038, t his routin e should n ot be modi fied. | |
| 5 | Date Cre ated: Dec 01, 2007 | |
| 6 | Site Nam e: Washin gton OI Fi eld Office , Silver S pring, MD | |
| 7 | Developer:
|
|
| 8 | Descript ion: | |
| 9 | ||
| 10 | ;; +-------- ---------- ---------- ---------- ---------- ---------- ---------- + | |
| 11 | ;; Property of the US Government . | |
| 12 | ;; No permis sion to co py or redi stribute t his softwa re is give n. | |
| 13 | ;; Use of un released v ersions of this soft ware requi res the us er | |
| 14 | ;; to execu te a writt en test ag reement wi th the Vis tA Imaging | |
| 15 | ;; Developm ent Office of the De partment o f Veterans Affairs, | |
| 16 | ;; telephon e (301) 73 4-0100. | |
| 17 | ;; | |
| 18 | ;; The Food and Drug A dministrat ion classi fies this software a s | |
| 19 | ;; a Class I I medical device. A s such, it may not b e changed | |
| 20 | ;; in any wa y. Modifi cations to this soft ware may r esult in a n | |
| 21 | ;; adulterat ed medical device un der 21CFR8 20, the us e of which | |
| 22 | ;; is consid ered to be a violati on of US F ederal Sta tutes. | |
| 23 | ;; +-------- ---------- ---------- ---------- ---------- ---------- ---------- + | |
| 24 | ||
| 25 | */ | |
| 26 | package go v.va.med.i maging.exc hange.conf iguration; | |
| 27 | ||
| 28 | import gov .va.med.im aging.core .interface s.IAppConf iguration; | |
| 29 | import gov .va.med.im aging.core .interface s.IProcedu reFilterTe rms; | |
| 30 | import gov .va.med.im aging.core .interface s.exceptio ns.Applica tionConfig urationExc eption; | |
| 31 | import gov .va.med.im aging.core .interface s.exceptio ns.Procedu reFilterTe rmsExcepti on; | |
| 32 | ||
| 33 | import jav a.beans.Be anInfo; | |
| 34 | import jav a.beans.In trospectio nException ; | |
| 35 | import jav a.beans.In trospector ; | |
| 36 | import jav a.beans.Pr opertyDesc riptor; | |
| 37 | import jav a.beans.XM LDecoder; | |
| 38 | import jav a.beans.XM LEncoder; | |
| 39 | import jav a.io.Buffe redInputSt ream; | |
| 40 | import jav a.io.Buffe redOutputS tream; | |
| 41 | import jav a.io.File; | |
| 42 | import jav a.io.FileI nputStream ; | |
| 43 | import jav a.io.FileN otFoundExc eption; | |
| 44 | import jav a.io.FileO utputStrea m; | |
| 45 | import jav a.util.Abs tractList; | |
| 46 | import jav a.util.Arr ayList; | |
| 47 | ||
| 48 | import jav a.util.con current.lo cks.Lock; | |
| 49 | import jav a.util.con current.lo cks.Reentr antReadWri teLock; | |
| 50 | import org .apache.lo gging.log4 j.LogManag er; | |
| 51 | import org .apache.lo gging.log4 j.Logger; | |
| 52 | ||
| 53 | /** | |
| 54 | * @author
|
|
| 55 | * | |
| 56 | */ | |
| 57 | public abs tract clas s Procedur eFilterTer ms impleme nts IProce dureFilter Terms | |
| 58 | { | |
| 59 | // public st atic | |
| 60 | pu blic stati c boolean loadFilter TermsfromF ile = true ; // for u se by unit tests - n ot product ion code | |
| 61 | // protected | |
| 62 | pr otected St ring proce dureFilter TermsFiles pec = null ; | |
| 63 | // private | |
| 64 | pr ivate IApp Configurat ion appCon figuration = null; | |
| 65 | pr ivate fina l Logger l ogger = Lo gManager.g etLogger(t his.getCla ss()); | |
| 66 | privat e final Re entrantRea dWriteLock rwl = new Reentrant ReadWriteL ock(); | |
| 67 | privat e final Lo ck readLoc k = rwl.re adLock(); | |
| 68 | privat e final Lo ck writeLo ck = rwl.w riteLock() ; | |
| 69 | privat e Abstract List<Strin g> filterT erms = new ArrayList <String>() ; | |
| 70 | ||
| 71 | // ---------- ---------- ---------- ----- | |
| 72 | // construct or | |
| 73 | // ---------- ---------- ---------- ----- | |
| 74 | ||
| 75 | pu blic Proce dureFilter Terms() | |
| 76 | { | |
| 77 | } | |
| 78 | ||
| 79 | pu blic Proce dureFilter Terms(IApp Configurat ion appCon figuration ) | |
| 80 | { | |
| 81 | this .appConfig uration = appConfigu ration; | |
| 82 | } | |
| 83 | ||
| 84 | // ---------- ---------- ---------- ----- | |
| 85 | // IProcedur eFilterTer ms public properties | |
| 86 | // ---------- ---------- ---------- ----- | |
| 87 | ||
| 88 | /* (non-Java doc) | |
| 89 | * @see gov. va.med.ima ging.excha nge.interf aces.IProc edureFilte rTerms#get FilterTerm s() | |
| 90 | * / | |
| 91 | pu blic Abstr actList<St ring> getF ilterTerms () | |
| 92 | { | |
| 93 | this .readLock. lock(); | |
| 94 | try | |
| 95 | { | |
| 96 | return new Array List<Strin g>(this.fi lterTerms) ; | |
| 97 | } | |
| 98 | fina lly {this. readLock.u nlock();} | |
| 99 | } | |
| 100 | ||
| 101 | /* (non-Java doc) | |
| 102 | * @see gov. va.med.ima ging.excha nge.interf aces.IProc edureFilte rTerms#set FilterTerm s(java.uti l.Collecti on) | |
| 103 | * / | |
| 104 | pu blic void setFilterT erms(Abstr actList<St ring> filt erTerms) | |
| 105 | { | |
| 106 | this .writeLock .lock(); | |
| 107 | try | |
| 108 | { | |
| 109 | this.f ilterTerms .clear(); | |
| 110 | this.f ilterTerms .addAll(fi lterTerms) ; | |
| 111 | this.v alidateAnd ReduceFilt erTerms(); | |
| 112 | } | |
| 113 | fina lly {this. writeLock. unlock();} | |
| 114 | } | |
| 115 | ||
| 116 | pu blic void setFilterT erm(String filterTer m) | |
| 117 | { | |
| 118 | this .writeLock .lock(); | |
| 119 | try | |
| 120 | { | |
| 121 | if (fi lterTerm ! = null && filterTerm .length() > 0 && !th is.filterT erms.conta ins(filter Term)) | |
| 122 | { | |
| 123 | this.fil terTerms.a dd(filterT erm); | |
| 124 | } | |
| 125 | } | |
| 126 | fina lly {this. writeLock. unlock();} | |
| 127 | } | |
| 128 | ||
| 129 | // ---------- ---------- ---------- ----- | |
| 130 | // IProcedur eFilterTer ms methods | |
| 131 | // ---------- ---------- ---------- ----- | |
| 132 | ||
| 133 | /* (non-Java doc) | |
| 134 | * @see gov. va.med.ima ging.excha nge.interf aces.IProc edureFilte rTerms#loa dProcedure FilterTerm sFromFile( ) | |
| 135 | * / | |
| 136 | pu blic boole an loadPro cedureFilt erTermsFro mFile() | |
| 137 | { | |
| 138 | bool ean succes s = false; | |
| 139 | Stri ng filespe c = null; | |
| 140 | ||
| 141 | this .readLock. lock(); | |
| 142 | try {filespec = this.pro cedureFilt erTermsFil espec;} | |
| 143 | fina lly {this. readLock.u nlock();} | |
| 144 | succ ess = this .loadProce dureFilter TermsFromF ile(filesp ec); | |
| 145 | retu rn success ; | |
| 146 | } | |
| 147 | ||
| 148 | /* (non-Java doc) | |
| 149 | * @see gov. va.med.ima ging.excha nge.interf aces.IProc edureFilte rTerms#sav eProcedure FilterTerm sToFile() | |
| 150 | * / | |
| 151 | pu blic boole an savePro cedureFilt erTermsToF ile() | |
| 152 | { | |
| 153 | bool ean succes s = false; | |
| 154 | Stri ng filespe c = null; | |
| 155 | ||
| 156 | this .readLock. lock(); | |
| 157 | try {filespec = this.pro cedureFilt erTermsFil espec;} | |
| 158 | fina lly {this. readLock.u nlock();} | |
| 159 | succ ess = this .saveProce dureFilter TermsToFil e(filespec ); | |
| 160 | retu rn success ; | |
| 161 | } | |
| 162 | ||
| 163 | // ---------- ---------- ---------- ----- | |
| 164 | // public me thods | |
| 165 | // ---------- ---------- ---------- ----- | |
| 166 | ||
| 167 | /* * | |
| 168 | * @param se t the full y qualifie d file nam e that spe cifies whe re the per sisted sta te of this object is stored | |
| 169 | * / | |
| 170 | pu blic void setProcedu reFilterTe rmsFilespe c(String f ileSpec) { | |
| 171 | this .writeLock .lock(); | |
| 172 | try {this.proc edureFilte rTermsFile spec = fil eSpec;} | |
| 173 | fina lly {this. writeLock. unlock();} | |
| 174 | } | |
| 175 | ||
| 176 | /* * | |
| 177 | * @return t he fully q ualified f ile that c ontains th e persiste d state of this obje ct | |
| 178 | * / | |
| 179 | pu blic Strin g getProce dureFilter TermsFiles pec() | |
| 180 | { | |
| 181 | Stri ng fileSpe c = null; | |
| 182 | this .readLock. lock(); | |
| 183 | try {fileSpec = this.pro cedureFilt erTermsFil espec;} | |
| 184 | fina lly {this. readLock.u nlock();} | |
| 185 | retu rn fileSpe c; | |
| 186 | } | |
| 187 | ||
| 188 | /* * | |
| 189 | * @param te rms - the ProcedureF ilterTerms object th at contain s the stat e to use | |
| 190 | * This publ ic method takes the state of t he passed terms para m and over lays it on to the cur rent insta nce | |
| 191 | * Note: tra nsient pro perties do not parti cipate | |
| 192 | * / | |
| 193 | pu blic void assignStat e(Procedur eFilterTer ms terms) | |
| 194 | { | |
| 195 | if ( terms != n ull) | |
| 196 | { | |
| 197 | this.w riteLock.l ock(); | |
| 198 | terms. readLock.l ock(); | |
| 199 | try | |
| 200 | { | |
| 201 | this.fil terTerms.c lear(); | |
| 202 | this.fil terTerms.a ddAll(term s.filterTe rms); | |
| 203 | } | |
| 204 | finall y | |
| 205 | { | |
| 206 | this.wri teLock.unl ock(); | |
| 207 | terms.re adLock.unl ock(); | |
| 208 | } | |
| 209 | } | |
| 210 | } | |
| 211 | ||
| 212 | /* | |
| 213 | * The follo wing metho d was gene rated by E clipse. If you regen erate this method, n ote that: | |
| 214 | * tran sient prop erty filte rTermsFile name does not partic ipate. | |
| 215 | * lock ing must b e added ba ck in manu ally | |
| 216 | * (non-Java doc) | |
| 217 | * @see java .lang.Obje ct#hashCod e() | |
| 218 | * / | |
| 219 | @O verride | |
| 220 | pu blic int h ashCode() | |
| 221 | { | |
| 222 | fina l int prim e = 31; | |
| 223 | int result = 1 ; | |
| 224 | this .readLock. lock(); | |
| 225 | try | |
| 226 | { | |
| 227 | result = prime * result | |
| 228 | + ((filter Terms == n ull) ? 0 : filterTer ms.hashCod e()); | |
| 229 | } | |
| 230 | fina lly {this. readLock.u nlock();} | |
| 231 | retu rn result; | |
| 232 | } | |
| 233 | ||
| 234 | /* | |
| 235 | * The follo wing metho d was gene rated by E clipse. If you regen erate this method, n ote that: | |
| 236 | * tran sient prop erty filte rTermsFile name does not partic ipate. | |
| 237 | * lock ing must b e added ba ck in manu ally | |
| 238 | * (non-Java doc) | |
| 239 | * @see java .lang.Obje ct#equals( java.lang. Object) | |
| 240 | * / | |
| 241 | @O verride | |
| 242 | pu blic boole an equals( Object obj ) | |
| 243 | { | |
| 244 | this .readLock. lock(); | |
| 245 | try | |
| 246 | { | |
| 247 | if (th is == obj) | |
| 248 | return t rue; | |
| 249 | if (ob j == null) | |
| 250 | return f alse; | |
| 251 | if (ge tClass() ! = obj.getC lass()) | |
| 252 | return f alse; | |
| 253 | final ProcedureF ilterTerms other = ( ProcedureF ilterTerms ) obj; | |
| 254 | if (fi lterTerms == null) | |
| 255 | { | |
| 256 | if (othe r.filterTe rms != nul l) | |
| 257 | return fal se; | |
| 258 | } | |
| 259 | else i f (!filter Terms.equa ls(other.f ilterTerms )) | |
| 260 | return f alse; | |
| 261 | return true; | |
| 262 | } | |
| 263 | fina lly {this. readLock.u nlock();} | |
| 264 | } | |
| 265 | ||
| 266 | // ---------- ---------- ---------- ----- | |
| 267 | // protected methods | |
| 268 | // ---------- ---------- ---------- ----- | |
| 269 | ||
| 270 | /* * | |
| 271 | * Derived c lasses cal l this fro m their Sp ring init method | |
| 272 | * @throws P rocedureFi lterTermsE xception | |
| 273 | * / | |
| 274 | pr otected vo id init() throws Pro cedureFilt erTermsExc eption | |
| 275 | { | |
| 276 | this .markPrope rtyAsTrans ient("proc edureFilte rTermsFile spec"); // determined at run ti me from de rived clas s | |
| 277 | } | |
| 278 | ||
| 279 | pr otected St ring getPr ocedureFil terTermFil espec(Stri ng filenam e) | |
| 280 | { | |
| 281 | Stri ng fileSpe c = null; | |
| 282 | try | |
| 283 | { | |
| 284 | fileSp ec = this. appConfigu ration.get VixConfigu rationDire ctory(); | |
| 285 | } | |
| 286 | catc h (Applica tionConfig urationExc eption ex) | |
| 287 | { | |
| 288 | fileSp ec = Syste m.getenv(" vixconfig" ); | |
| 289 | if (fi leSpec == null) | |
| 290 | { | |
| 291 | fileSpec = "c:/Vix Config"; | |
| 292 | } | |
| 293 | } | |
| 294 | // a dd the tra iling file separator character if necess ary | |
| 295 | if ( !fileSpec. endsWith(" \\") || !f ileSpec.en dsWith("/" )) | |
| 296 | { | |
| 297 | fileSp ec += "/"; | |
| 298 | } | |
| 299 | file Spec += fi lename; | |
| 300 | ||
| 301 | retu rn fileSpe c; | |
| 302 | } | |
| 303 | ||
| 304 | /* * | |
| 305 | * Initializ e the list of proced ure filter terms. Th is method is called from the d erived cla sses init method | |
| 306 | * if the fi lter terms cannot be loaded fr om file. | |
| 307 | * / | |
| 308 | pr otected ab stract voi d initProc edureFilte rTermsFrom Code(); | |
| 309 | ||
| 310 | // ---------- ---------- ---------- ----- | |
| 311 | // private m ethods | |
| 312 | // ---------- ---------- ---------- ----- | |
| 313 | ||
| 314 | pu blic boole an loadPro cedureFilt erTermsFro mFile(Stri ng fileSpe c) { | |
| 315 | bool ean succes s = false; | |
| 316 | XMLD ecoder xml Decoder = null; | |
| 317 | Proc edureFilte rTerms ter ms = null; | |
| 318 | ||
| 319 | if ( fileSpec ! = null) | |
| 320 | { | |
| 321 | File f ilterTermF ile = new File(fileS pec); | |
| 322 | if (fi lterTermFi le.exists( )) | |
| 323 | { | |
| 324 | try | |
| 325 | { | |
| 326 | xmlDecoder = new XML Decoder(ne w Buffered InputStrea m(new File InputStrea m(fileSpec ))); // th rows FileN otFoundExc eption | |
| 327 | terms = (P rocedureFi lterTerms) xmlDecode r.readObje ct(); | |
| 328 | if (terms != null) | |
| 329 | { | |
| 330 | th is.assignS tate(terms ); // this method ob tains a wr ite lock | |
| 331 | lo gger.info( this.getCl ass().getS impleName( ) + " load ed from " + fileSpec ); | |
| 332 | su ccess = tr ue; | |
| 333 | } | |
| 334 | } | |
| 335 | catch (F ileNotFoun dException ex) | |
| 336 | { | |
| 337 | logger.err or(ex.getM essage()); | |
| 338 | } | |
| 339 | catch (A rrayIndexO utOfBounds Exception ex) | |
| 340 | { | |
| 341 | logger.err or("Proced ureFilterT erms.loadP rocedureFi lterTermsF romFile: A rrayIndexO utOfBounds Exception : " + ex.g etMessage( )); | |
| 342 | } | |
| 343 | finally | |
| 344 | { | |
| 345 | if (xmlDec oder != nu ll) | |
| 346 | { | |
| 347 | xm lDecoder.c lose(); | |
| 348 | } | |
| 349 | } | |
| 350 | } | |
| 351 | } | |
| 352 | retu rn success ; | |
| 353 | } | |
| 354 | ||
| 355 | pu blic boole an savePro cedureFilt erTermsToF ile(String fileSpec) { | |
| 356 | bool ean succes s = false; | |
| 357 | XMLE ncoder xml Encoder = null; | |
| 358 | ||
| 359 | this .readLock. lock(); | |
| 360 | try | |
| 361 | { | |
| 362 | xmlEnc oder = new XMLEncode r(new Buff eredOutput Stream(new FileOutpu tStream(fi leSpec))); | |
| 363 | xmlEnc oder.write Object(thi s); | |
| 364 | logger .info(this .getClass( ).getSimpl eName() + " saved to : " + file Spec); | |
| 365 | succes s = true; | |
| 366 | } | |
| 367 | catc h (FileNot FoundExcep tion ex) | |
| 368 | { | |
| 369 | logger .error("Pr ocedureFil terTerms.s aveProcedu reFilterTe rmsToFile: " + ex.ge tMessage() ); | |
| 370 | } | |
| 371 | fina lly | |
| 372 | { | |
| 373 | this.r eadLock.un lock(); | |
| 374 | if (xm lEncoder ! = null) | |
| 375 | { | |
| 376 | xmlEncod er.close() ; | |
| 377 | } | |
| 378 | } | |
| 379 | ||
| 380 | retu rn success ; | |
| 381 | } | |
| 382 | ||
| 383 | ||
| 384 | /* * | |
| 385 | * Mark a be an propert y as trans ient so th at the Xml Encoder wi ll not inc lude it as part of t he | |
| 386 | * persisted state. | |
| 387 | * @param pr opertyName - the pro perty to m ark as tra nsient | |
| 388 | * @throws P rocedureFi lterTermsE xception | |
| 389 | * / | |
| 390 | pr ivate void markPrope rtyAsTrans ient(Strin g property Name) thro ws Procedu reFilterTe rmsExcepti on | |
| 391 | { | |
| 392 | Bean Info info = null; | |
| 393 | bool ean proper tySet = fa lse; | |
| 394 | ||
| 395 | try { | |
| 396 | info = Introspec tor.getBea nInfo(this .getClass( )); | |
| 397 | Proper tyDescript or[] prope rtyDescrip tors = inf o.getPrope rtyDescrip tors(); | |
| 398 | for (i nt i = 0; i < proper tyDescript ors.length ; ++i) | |
| 399 | { | |
| 400 | Property Descriptor pd = prop ertyDescri ptors[i]; | |
| 401 | if (pd.g etName().e quals(prop ertyName)) | |
| 402 | { | |
| 403 | pd.setValu e("transie nt", Boole an.TRUE); | |
| 404 | propertySe t = true; | |
| 405 | break; | |
| 406 | } | |
| 407 | } | |
| 408 | if (!p ropertySet ) | |
| 409 | { | |
| 410 | throw ne w Procedur eFilterTer msExceptio n("markPro pertyAsTra nsient: pr operty not found : " + propert yName); | |
| 411 | } | |
| 412 | } | |
| 413 | catc h (Introsp ectionExce ption ex) { | |
| 414 | throw new Proced ureFilterT ermsExcept ion(ex.get Message()) ; | |
| 415 | } | |
| 416 | } | |
| 417 | ||
| 418 | /* * | |
| 419 | * Validate each filte r term to ensure it is not the empty str ing. Remov e any filt er terms t hat are. | |
| 420 | * Note: thi s method s hould only be called within th e scope of a write l ock | |
| 421 | * / | |
| 422 | pr ivate void validateA ndReduceFi lterTerms( ) | |
| 423 | { | |
| 424 | for (int i = t his.filter Terms.size () - 1 ; i >= 0 ; i- -) | |
| 425 | { | |
| 426 | if (th is.filterT erms.get(i ).length() == 0) | |
| 427 | { | |
| 428 | this.fil terTerms.r emove(i); | |
| 429 | } | |
| 430 | } | |
| 431 | } | |
| 432 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.