Produced by Araxis Merge on 12/5/2017 12:06:48 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\SiteServiceDataSourceProvider\main\src\java\gov\va\med\siteservice\siteprotocol | SiteProtocolPreferenceFactoryImpl.java | Mon Dec 4 21:34:38 2017 UTC |
| 2 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\SiteServiceDataSourceProvider\main\src\java\gov\va\med\siteservice\siteprotocol | SiteProtocolPreferenceFactoryImpl.java | Mon Dec 4 22:05:41 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 686 |
| 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.s iteservice .siteproto col; | |
| 2 | ||
| 3 | import gov .va.med.OI D; | |
| 4 | import gov .va.med.Ro utingToken ; | |
| 5 | import gov .va.med.im aging.arti factsource .ArtifactS ource; | |
| 6 | import gov .va.med.si teservice. SiteProtoc olPreferen ceFactory; | |
| 7 | ||
| 8 | import jav a.io.Seria lizable; | |
| 9 | import jav a.util.Col lection; | |
| 10 | import jav a.util.Com parator; | |
| 11 | import jav a.util.Ite rator; | |
| 12 | import jav a.util.Sor tedSet; | |
| 13 | import jav a.util.Tre eSet; | |
| 14 | ||
| 15 | import org .apache.lo gging.log4 j.LogManag er; | |
| 16 | import org .apache.lo gging.log4 j.Logger; | |
| 17 | ||
| 18 | /** | |
| 19 | * | |
| 20 | * @author
|
|
| 21 | * | |
| 22 | */ | |
| 23 | public cla ss SitePro tocolPrefe renceFacto ryImpl | |
| 24 | implements SiteProto colPrefere nceFactory | |
| 25 | { | |
| 26 | pr ivate stat ic transie nt Logger logger = L ogManager. getLogger( SiteProtoc olPreferen ceFactoryI mpl.class) ; | |
| 27 | pr ivate stat ic final l ong serial VersionUID = 1L; | |
| 28 | ||
| 29 | pr ivate fina l SortedSe t<Protocol Preference > preferen ces = new TreeSet<Pr otocolPref erence>(ne w Protocol Preference Comparator ()); | |
| 30 | ||
| 31 | /* * | |
| 32 | * The defau lt constru ctor, whic h all of t he other c onstructor s should | |
| 33 | * call firs t, include s a compar ator so th at protoco l preferen ces with w ildcards c ome | |
| 34 | * after tho se with "r eal" repos itory IDs. | |
| 35 | * / | |
| 36 | pu blic SiteP rotocolPre ferenceFac toryImpl() | |
| 37 | { | |
| 38 | supe r(); | |
| 39 | ||
| 40 | // | |
| 41 | // pref erences = new TreeSe t<Protocol Preference >(new Comp arator<Pro tocolPrefe rence>() | |
| 42 | // { | |
| 43 | // @Overr ide | |
| 44 | // public int compa re(Protoco lPreferenc e o1, Prot ocolPrefer ence o2) | |
| 45 | // { | |
| 46 | // int comm unityIdCom pare = o1. getHomeCom munityId() .compareTo (o2.getHom eCommunity Id()); | |
| 47 | // if(commu nityIdComp are != 0) | |
| 48 | // return com munityIdCo mpare; | |
| 49 | // | |
| 50 | // int repo sitoryIdCo mpare = | |
| 51 | // RoutingTok en.ROUTING _WILDCARD. equals(o1. getReposit oryId()) ? | |
| 52 | // 1 : | |
| 53 | // Ro utingToken .ROUTING_W ILDCARD.eq uals(o2.ge tRepositor yId()) ? - 1 : | |
| 54 | // o1.g etReposito ryId().com pareTo(o2. getReposit oryId()); | |
| 55 | // | |
| 56 | // return r epositoryI dCompare; | |
| 57 | // } | |
| 58 | // } | |
| 59 | // ); | |
| 60 | } | |
| 61 | ||
| 62 | ||
| 63 | ||
| 64 | /* * | |
| 65 | * Unlike re gular Set behavior, adding a P rotocolPre ference th at | |
| 66 | * already e xists repl aces an ex isting Pro tocolPrefe rence | |
| 67 | * if they a re .equals (), i.e. t he same si te number. | |
| 68 | * | |
| 69 | * @see java .util.Hash Set#add(ja va.lang.Ob ject) | |
| 70 | * / | |
| 71 | @O verride | |
| 72 | public boolean a dd(Protoco lPreferenc e e) | |
| 73 | { | |
| 74 | if (e == null ) | |
| 75 | retu rn false; | |
| 76 | ||
| 77 | Prot ocolPrefer ence exist ingPrefere nce = find BySiteNumb er(e.getSi teNumber() ); | |
| 78 | if(e xistingPre ference != null) | |
| 79 | prefer ences.remo ve(existin gPreferenc e); | |
| 80 | ||
| 81 | return p references .add(e); | |
| 82 | } | |
| 83 | ||
| 84 | public void addA ll(Collect ion<Protoc olPreferen ce> c) | |
| 85 | { | |
| 86 | fo r(Protocol Preference preferenc e : c) | |
| 87 | add( preference ); | |
| 88 | } | |
| 89 | ||
| 90 | /* * | |
| 91 | * Clear all except th e default ProtocolPr eference | |
| 92 | * @see java .util.Hash Set#clear( ) | |
| 93 | * / | |
| 94 | @Overr ide | |
| 95 | public void clea r() | |
| 96 | { | |
| 97 | Prot ocolPrefer ence defau ltPreferen ce = findD efaultSite (); | |
| 98 | preferen ces.clear( ); | |
| 99 | add(defa ultPrefere nce); | |
| 100 | } | |
| 101 | ||
| 102 | /* * | |
| 103 | * A remove( ) that dis allows rem oval of th e default ProtocolPr eference | |
| 104 | * | |
| 105 | * @see java .util.Hash Set#remove (java.lang .Object) | |
| 106 | * / | |
| 107 | public boolean r emove(Prot ocolPrefer ence proto colPrefere nce) | |
| 108 | { | |
| 109 | if(p rotocolPre ference in stanceof P rotocolPre ference) | |
| 110 | if( (( ProtocolPr eference)p rotocolPre ference).g etSiteNumb er() == nu ll ) | |
| 111 | return f alse; | |
| 112 | ||
| 113 | return p references .remove(pr otocolPref erence); | |
| 114 | } | |
| 115 | ||
| 116 | /* (non-Java doc) | |
| 117 | * @see gov. va.med.sit eservice.S iteProtoco lPreferenc eFactory#r emove(gov. va.med.OID , java.lan g.String) | |
| 118 | * / | |
| 119 | @O verride | |
| 120 | pu blic void remove(OID homeCommu nityId, St ring repos itoryId) | |
| 121 | { | |
| 122 | Prot ocolPrefer ence deadM an = null; | |
| 123 | for( ProtocolPr eference p rotocolPre ference : preference s) | |
| 124 | if( pr otocolPref erence.get HomeCommun ityId().eq uals(homeC ommunityId ) && | |
| 125 | protocol Preference .getReposi toryId().e quals(repo sitoryId) ) | |
| 126 | { | |
| 127 | deadMan = protocol Preference ; | |
| 128 | break; | |
| 129 | } | |
| 130 | if(d eadMan != null) | |
| 131 | prefer ences.remo ve(deadMan ); | |
| 132 | } | |
| 133 | ||
| 134 | ||
| 135 | @O verride | |
| 136 | public String[] getPreferr edProtocol s(String s iteNumber) | |
| 137 | { | |
| 138 | Prot ocolPrefer ence proto colPrefere nce = find BySiteNumb er(siteNum ber); | |
| 139 | if(p rotocolPre ference == null) | |
| 140 | protoc olPreferen ce = findD efaultSite (); | |
| 141 | ||
| 142 | Stri ng[] prefe rredProtoc ols = prot ocolPrefer ence.getPr efererredP rotocols() ; | |
| 143 | retu rn preferr edProtocol s == null ? null : p referredPr otocols.cl one(); | |
| 144 | } | |
| 145 | ||
| 146 | @O verride | |
| 147 | pu blic Strin g[] getPre ferredProt ocols(Arti factSource artifactS ource) | |
| 148 | { | |
| 149 | if(a rtifactSou rce == nul l) | |
| 150 | return null; | |
| 151 | ||
| 152 | retu rn getPref erredProto cols(artif actSource. getHomeCom munityId() , artifact Source.get Repository Id()); | |
| 153 | } | |
| 154 | ||
| 155 | /* (non-Java doc) | |
| 156 | * @see gov. va.med.sit eservice.S iteProtoco lPreferenc eFactory#g etPreferre dProtocols (gov.va.me d.OID, jav a.lang.Str ing) | |
| 157 | * / | |
| 158 | @O verride | |
| 159 | pu blic Strin g[] getPre ferredProt ocols(OID homeCommun ityId, Str ing reposi toryId) | |
| 160 | { | |
| 161 | if(h omeCommuni tyId == nu ll || repo sitoryId = = null) | |
| 162 | return null; | |
| 163 | ||
| 164 | for( ProtocolPr eference p rotocolPre ference : preference s) | |
| 165 | if( pr otocolPref erence.get HomeCommun ityId().eq uals(homeC ommunityId ) && | |
| 166 | protocol Preference .getReposi toryId().e quals(repo sitoryId) ) | |
| 167 | return pro tocolPrefe rence.getP refererred Protocols( ).clone(); | |
| 168 | ||
| 169 | Prot ocolPrefer ence defau ltProtocol Preference = (getDef aultPrefer redProtoco ls(homeCom munityId)) ; | |
| 170 | ||
| 171 | retu rn default ProtocolPr eference = = null ? n ull : defa ultProtoco lPreferenc e.getPrefe rerredProt ocols().cl one(); | |
| 172 | } | |
| 173 | ||
| 174 | ||
| 175 | /* * | |
| 176 | * @param ar tifactSour ce | |
| 177 | * @return | |
| 178 | * / | |
| 179 | pr ivate Prot ocolPrefer ence getDe faultPrefe rredProtoc ols(Artifa ctSource a rtifactSou rce) | |
| 180 | { | |
| 181 | if(a rtifactSou rce == nul l) | |
| 182 | return null; | |
| 183 | retu rn getDefa ultPreferr edProtocol s(artifact Source.get HomeCommun ityId()); | |
| 184 | } | |
| 185 | ||
| 186 | /* * | |
| 187 | * | |
| 188 | * @param ho meCommunit yId | |
| 189 | * @return | |
| 190 | * / | |
| 191 | pr ivate Prot ocolPrefer ence getDe faultPrefe rredProtoc ols(OID ho meCommunit yId) | |
| 192 | { | |
| 193 | if(h omeCommuni tyId == nu ll) | |
| 194 | return null; | |
| 195 | ||
| 196 | for( ProtocolPr eference p rotocolPre ference : preference s) | |
| 197 | if( pr otocolPref erence.isW ildcardRep ository() && | |
| 198 | protocol Preference .getHomeCo mmunityId( ).equals(h omeCommuni tyId) ) | |
| 199 | return pro tocolPrefe rence; | |
| 200 | ||
| 201 | retu rn null; | |
| 202 | } | |
| 203 | ||
| 204 | @O verride | |
| 205 | public boolean i sSiteAlien (String si teNumber) | |
| 206 | { | |
| 207 | Prot ocolPrefer ence proto colPrefere nce = find BySiteNumb er(siteNum ber); | |
| 208 | ||
| 209 | return p rotocolPre ference == null ? fa lse : prot ocolPrefer ence.isSit eAlien(); | |
| 210 | } | |
| 211 | ||
| 212 | @O verride | |
| 213 | public boolean i sSiteLocal (String si teNumber) | |
| 214 | { | |
| 215 | Prot ocolPrefer ence proto colPrefere nce = find BySiteNumb er(siteNum ber); | |
| 216 | ||
| 217 | return p rotocolPre ference == null ? fa lse : prot ocolPrefer ence.isSit eLocal(); | |
| 218 | } | |
| 219 | ||
| 220 | @O verride | |
| 221 | pu blic boole an isSiteE nabled(Str ing siteNu mber) | |
| 222 | { | |
| 223 | Prot ocolPrefer ence proto colPrefere nce = find BySiteNumb er(siteNum ber); | |
| 224 | ||
| 225 | return p rotocolPre ference == null ? tr ue : proto colPrefere nce.isEnab led(); | |
| 226 | } | |
| 227 | ||
| 228 | ||
| 229 | ||
| 230 | /* * | |
| 231 | * Find the protocol p references by site n umber if a site is e ither exce ptional or | |
| 232 | * local, el se return null. | |
| 233 | * @param si teNumber | |
| 234 | * @return | |
| 235 | * / | |
| 236 | pr ivate Prot ocolPrefer ence findB ySiteNumbe r(String s iteNumber) | |
| 237 | { | |
| 238 | if(s iteNumber == null) | |
| 239 | return null; | |
| 240 | ||
| 241 | for( ProtocolPr eference p rotocolPre ference : preference s) | |
| 242 | if( pr otocolPref erence.isV aRepositor y() && sit eNumber.eq uals(proto colPrefere nce.getSit eNumber()) ) | |
| 243 | return p rotocolPre ference; | |
| 244 | retu rn null; | |
| 245 | } | |
| 246 | ||
| 247 | /* * | |
| 248 | * return th e protocol preferenc es where t he site nu mber is nu ll. | |
| 249 | * | |
| 250 | * @return | |
| 251 | * / | |
| 252 | pr ivate Prot ocolPrefer ence findD efaultSite () | |
| 253 | { | |
| 254 | for( ProtocolPr eference p rotocolPre ference : preference s) | |
| 255 | if( pr otocolPref erence.isV aRepositor y() && pro tocolPrefe rence.isWi ldcardRepo sitory() ) | |
| 256 | return pro tocolPrefe rence; | |
| 257 | retu rn null; | |
| 258 | } | |
| 259 | ||
| 260 | @O verride | |
| 261 | pu blic int h ashCode() | |
| 262 | { | |
| 263 | fina l int prim e = 31; | |
| 264 | int result = 1 ; | |
| 265 | resu lt = prime * result + ((this.p references == null) ? 0 : this .preferenc es.hashCod e()); | |
| 266 | retu rn result; | |
| 267 | } | |
| 268 | ||
| 269 | /* * | |
| 270 | * This meth od is a co mbination of generat ed and han d-written code, don' t | |
| 271 | * regenerat e it! | |
| 272 | * / | |
| 273 | @O verride | |
| 274 | pu blic boole an equals( Object obj ) | |
| 275 | { | |
| 276 | if ( this == ob j) | |
| 277 | return true; | |
| 278 | if ( obj == nul l) | |
| 279 | return false; | |
| 280 | if ( getClass() != obj.ge tClass()) | |
| 281 | return false; | |
| 282 | fina l SiteProt ocolPrefer enceFactor yImpl othe r = (SiteP rotocolPre ferenceFac toryImpl) obj; | |
| 283 | if ( this.prefe rences == null) | |
| 284 | { | |
| 285 | if (ot her.prefer ences != n ull) | |
| 286 | return f alse; | |
| 287 | } | |
| 288 | else if( this. preference s.size() ! = other.pr eferences. size() ) | |
| 289 | return false; | |
| 290 | ||
| 291 | Iter ator<Proto colPrefere nce> thisP references Iter = pre ferences.i terator(); | |
| 292 | Iter ator<Proto colPrefere nce> other Preference sIter = pr eferences. iterator() ; | |
| 293 | ||
| 294 | // i t is a sor ted set so the membe rs must be in the sa me order | |
| 295 | whil e(thisPref erencesIte r.hasNext( ) && other Preference sIter.hasN ext()) | |
| 296 | if( ! thisPrefer encesIter. next().equ als(otherP references Iter.next( )) ) | |
| 297 | return f alse; | |
| 298 | ||
| 299 | retu rn true; | |
| 300 | } | |
| 301 | ||
| 302 | /* (non-Java doc) | |
| 303 | * @see java .lang.Obje ct#toStrin g() | |
| 304 | * / | |
| 305 | @O verride | |
| 306 | pu blic Strin g toString () | |
| 307 | { | |
| 308 | Stri ngBuilder sb = new S tringBuild er(); | |
| 309 | ||
| 310 | sb.a ppend("Has hSetProtoc olPreferen ceFactory \n"); | |
| 311 | for( ProtocolPr eference p rotocolPre ference : this.prefe rences) | |
| 312 | sb.app end(protoc olPreferen ce.toStrin g() + "\n" ); | |
| 313 | ||
| 314 | retu rn sb.toSt ring(); | |
| 315 | } | |
| 316 | ||
| 317 | ||
| 318 | cl ass Protoc olPreferen ceComparat or | |
| 319 | im plements C omparator< ProtocolPr eference>, Serializab le | |
| 320 | { | |
| 321 | priv ate static final lon g serialVe rsionUID = -39728109 9891976760 5L; | |
| 322 | ||
| 323 | @Ove rride | |
| 324 | publ ic int com pare(Proto colPrefere nce o1, Pr otocolPref erence o2) | |
| 325 | { | |
| 326 | int co mmunityIdC ompare = o 1.getHomeC ommunityId ().compare To(o2.getH omeCommuni tyId()); | |
| 327 | if(com munityIdCo mpare != 0 ) | |
| 328 | return c ommunityId Compare; | |
| 329 | ||
| 330 | int re positoryId Compare = | |
| 331 | RoutingT oken.ROUTI NG_WILDCAR D.equals(o 1.getRepos itoryId()) ? | |
| 332 | 1 : | |
| 333 | RoutingTok en.ROUTING _WILDCARD. equals(o2. getReposit oryId()) ? -1 : | |
| 334 | o1 .getReposi toryId().c ompareTo(o 2.getRepos itoryId()) ; | |
| 335 | ||
| 336 | return repositor yIdCompare ; | |
| 337 | } | |
| 338 | } | |
| 339 | ||
| 340 | } | |
| 341 | ||
| 342 | ||
| 343 | ||
| 344 |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.