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