Produced by Araxis Merge on 12/5/2017 12:06:36 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\CacheWeb\src\gov\va\med\cache\gui\shared | AbstractNamedVO.java | Mon Dec 4 21:34:22 2017 UTC |
| 2 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\CacheWeb\src\gov\va\med\cache\gui\shared | AbstractNamedVO.java | Mon Dec 4 21:58:02 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 548 |
| 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 | * | |
| 3 | */ | |
| 4 | package go v.va.med.c ache.gui.s hared; | |
| 5 | ||
| 6 | import jav a.io.Seria lizable; | |
| 7 | import jav a.util.Arr ayList; | |
| 8 | import jav a.util.Col lection; | |
| 9 | import jav a.util.Ite rator; | |
| 10 | import jav a.util.Lis t; | |
| 11 | import jav a.util.Sor tedSet; | |
| 12 | import org .apache.lo gging.log4 j.LogManag er; | |
| 13 | import org .apache.lo gging.log4 j.Logger; | |
| 14 | ||
| 15 | import com .google.gw t.user.cli ent.rpc.Is Serializab le; | |
| 16 | ||
| 17 | /** | |
| 18 | * @author
|
|
| 19 | * | |
| 20 | */ | |
| 21 | public abs tract clas s Abstract NamedVO | |
| 22 | implements Serializa ble, IsSer ializable, Mergable< AbstractNa medVO>, Co mparable<A bstractNam edVO> | |
| 23 | { | |
| 24 | pr ivate stat ic final l ong serialVers ionUID = 1L; | |
| 25 | ||
| 26 | pr otected tr ansient Lo gger logge r = LogMan ager.getLo gger("Abst ractNamedV O"); | |
| 27 | pr ivate Stri ng name; // the name is both th e displaye d name and the prima ry key | |
| 28 | pr ivate tran sient bool ean childr enPopulate d = false; | |
| 29 | pr ivate tran sient Abst ractNamedV O parent; // transie nt because the paren t is not | |
| 30 | // set unt il it join s the clie nt-side ca ched hiera rchy | |
| 31 | ||
| 32 | pu blic Abstr actNamedVO (){ this.n ame = null ;} | |
| 33 | pu blic Abstr actNamedVO (String na me) | |
| 34 | { | |
| 35 | this .name = na me; | |
| 36 | } | |
| 37 | ||
| 38 | pu blic Strin g getName( ) | |
| 39 | { | |
| 40 | retu rn name; | |
| 41 | } | |
| 42 | ||
| 43 | pu blic Abstr actNamedVO getParent () | |
| 44 | { | |
| 45 | retu rn parent; | |
| 46 | } | |
| 47 | ||
| 48 | pu blic void setParent( AbstractNa medVO pare nt) | |
| 49 | { | |
| 50 | this .parent = parent; | |
| 51 | } | |
| 52 | ||
| 53 | pu blic boole an isChild renPopulat ed() | |
| 54 | { | |
| 55 | retu rn childre nPopulated ; | |
| 56 | } | |
| 57 | pu blic void setChildre nPopulated (boolean c hildrenPop ulated) | |
| 58 | { | |
| 59 | this .childrenP opulated = childrenP opulated; | |
| 60 | } | |
| 61 | ||
| 62 | pu blic abstr act CacheI temPath ge tPath(); | |
| 63 | ||
| 64 | /* * | |
| 65 | * Return a count of t he total n umber of c hildren re gardless o f type. | |
| 66 | * i.e. Grou pVO includ es its chi ld groups and instan ces. | |
| 67 | * @return | |
| 68 | * / | |
| 69 | pu blic abstr act int ge tChildCoun t(); | |
| 70 | ||
| 71 | /* * | |
| 72 | * | |
| 73 | * @param na me | |
| 74 | * @return | |
| 75 | * / | |
| 76 | pu blic abstr act Abstra ctNamedVO childWithN ame(String name); | |
| 77 | ||
| 78 | /* * | |
| 79 | * | |
| 80 | * @param ch ildName | |
| 81 | * @return | |
| 82 | * / | |
| 83 | pu blic Abstr actNamedVO removeChi ld(String childName) | |
| 84 | { | |
| 85 | Abst ractNamedV O child = childWithN ame(childN ame); | |
| 86 | ||
| 87 | retu rn removeC hild(child ) ? child : null; | |
| 88 | } | |
| 89 | ||
| 90 | pr otected ab stract boo lean remov eChild(Abs tractNamed VO child); | |
| 91 | ||
| 92 | /* * | |
| 93 | * | |
| 94 | * @param <T > | |
| 95 | * @param ch ildren | |
| 96 | * @param na me | |
| 97 | * @return | |
| 98 | * / | |
| 99 | pr otected <T extends A bstractNam edVO> T se archChildC ollection( Collection <T> childr en, String name) | |
| 100 | { | |
| 101 | for( T child : children ) | |
| 102 | if( ch ild.getNam e().equals (name) ) | |
| 103 | return c hild; | |
| 104 | ||
| 105 | retu rn null; | |
| 106 | } | |
| 107 | ||
| 108 | /* * | |
| 109 | * | |
| 110 | * @param ot her | |
| 111 | * @throws M ergeExcept ion | |
| 112 | * / | |
| 113 | @O verride | |
| 114 | pu blic void merge(Abst ractNamedV O other) | |
| 115 | th rows Merge Exception | |
| 116 | { | |
| 117 | // N OTE, the n ame field is NOT mer ged becaus e they mus t be equal to do a m erge | |
| 118 | if(! this.equa ls(other)) | |
| 119 | throw new MergeE xception( | |
| 120 | "Attempt to merge unequal ob jects '" | |
| 121 | + this.g etName() | |
| 122 | + "' and '" | |
| 123 | + other. getName() | |
| 124 | + "'."); | |
| 125 | ||
| 126 | if(i sChildrenP opulated() || other. isChildren Populated( )) | |
| 127 | setChi ldrenPopul ated(true) ; | |
| 128 | } | |
| 129 | ||
| 130 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== = | |
| 131 | // | |
| 132 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== = | |
| 133 | /* * | |
| 134 | * | |
| 135 | * @param <T > | |
| 136 | * @param th isCollecti on | |
| 137 | * @param ot herCollect ion | |
| 138 | * @throws M ergeExcept ion | |
| 139 | * / | |
| 140 | pr otected <C extends A bstractNam edVO, T ex tends Abst ractNamedV O> void me rgeCollect ions( | |
| 141 | C pa rent, | |
| 142 | Coll ection<T> thisColl ection, | |
| 143 | Coll ection<T> otherCol lection) | |
| 144 | th rows Merge Exception | |
| 145 | { | |
| 146 | for( Iterator<T > otherIte r = otherC ollection. iterator() ; otherIte r.hasNext( ); ) | |
| 147 | { | |
| 148 | T othe rElement = otherIter .next(); | |
| 149 | if( th isCollecti on.contain s(otherEle ment) ) | |
| 150 | { | |
| 151 | for(T th isElement : thisColl ection) | |
| 152 | if(otherEl ement.equa ls(thisEle ment)) | |
| 153 | { | |
| 154 | ot herElement .setParent (parent); | |
| 155 | th isElement. setParent( parent); // this is a kludge !! !! | |
| 156 | th isElement. merge(othe rElement); | |
| 157 | lo gger.info( "Merged '" + otherEl ement.getN ame() + "' into '" + thisEleme nt.getName () + "', c hild of '" + parent. getName() + "'."); | |
| 158 | br eak; | |
| 159 | } | |
| 160 | } | |
| 161 | else | |
| 162 | { | |
| 163 | logger.i nfo("Addin g '" + oth erElement. getName() + "' as ch ild of '" + parent.g etName() + "'."); | |
| 164 | otherEle ment.setPa rent(paren t); | |
| 165 | thisColl ection.add (otherElem ent); | |
| 166 | } | |
| 167 | } | |
| 168 | } | |
| 169 | ||
| 170 | /* * | |
| 171 | * Get ALL o f the chil dren as on e List. | |
| 172 | * @return | |
| 173 | * / | |
| 174 | pu blic abstr act <E ext ends Abstr actNamedVO > SortedSe t<E> getCh ildren(); | |
| 175 | ||
| 176 | /* * | |
| 177 | * | |
| 178 | * @return | |
| 179 | * / | |
| 180 | pu blic List< AbstractNa medVO> get ChildrenAs List() | |
| 181 | { | |
| 182 | List <AbstractN amedVO> li st = new A rrayList<A bstractNam edVO>(); | |
| 183 | ||
| 184 | for( Iterator<A bstractNam edVO> itr = getChild ren().iter ator(); it r.hasNext( ); ) | |
| 185 | list.a dd(itr.nex t()); | |
| 186 | ||
| 187 | retu rn list; | |
| 188 | } | |
| 189 | ||
| 190 | /* * | |
| 191 | * | |
| 192 | * @param pa th | |
| 193 | * @param cu rrentDepth | |
| 194 | * / | |
| 195 | pr otected Ab stractName dVO remove Item(Cache ItemPath p ath, CACHE _POPULATIO N_DEPTH cu rrentDepth ) | |
| 196 | { | |
| 197 | Stri ng name = path.ge tNameAt(cu rrentDepth ); | |
| 198 | CACH E_POPULATI ON_DEPTH childDepth = path.ne xtDepth(cu rrentDepth ); | |
| 199 | Stri ng chil dName = ch ildDepth = = null ? n ull : path .getNameAt (childDept h); | |
| 200 | bool ean chil dIsEndOfPa th = child Depth == n ull ? fals e : path.n extDepth(c hildDepth) == null; | |
| 201 | ||
| 202 | logg er.info("r emoveItem( " + path.t oString() + "," + cu rrentDepth .toString( ) + ")"); | |
| 203 | ||
| 204 | // t he name of the item at the cur rent depth must not be null | |
| 205 | if(n ame != nul l) | |
| 206 | { | |
| 207 | // if the child name is nu ll, we som ehow went too far do wn the cha in, | |
| 208 | // thi s is an er ror | |
| 209 | if(chi ldName == null) | |
| 210 | { | |
| 211 | logger.e rror("Unab le to remo veItem(" + path.toSt ring() + " , " + curr entDepth.t oString() + "), name at child depth is n ull."); | |
| 212 | } | |
| 213 | else | |
| 214 | if(child IsEndOfPat h) | |
| 215 | { | |
| 216 | AbstractNa medVO orph anedChild = this.rem oveChild(c hildName); | |
| 217 | orphanedCh ild.setPar ent(null); | |
| 218 | logger.inf o("'" + or phanedChil d.getName( ) + "' has been dele ted."); | |
| 219 | return orp hanedChild ; | |
| 220 | } | |
| 221 | else | |
| 222 | { | |
| 223 | return c hildWithNa me(childNa me).remove Item(path, childDept h); | |
| 224 | } | |
| 225 | } | |
| 226 | else | |
| 227 | logger .error("Un able to re moveItem(" + path.to String() + ", " + cu rrentDepth .toString( ) + "), na me at curr ent depth is null.") ; | |
| 228 | ||
| 229 | retu rn null; | |
| 230 | } | |
| 231 | ||
| 232 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== == | |
| 233 | // Generated .equals a nd .hashCo de applies to all de rived clas ses, if th e names ar e the same | |
| 234 | // then the instances are the sa me. | |
| 235 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== == | |
| 236 | @O verride | |
| 237 | pu blic int h ashCode() | |
| 238 | { | |
| 239 | fina l int prim e = 31; | |
| 240 | int result = 1 ; | |
| 241 | resu lt = prime * result + ((name = = null) ? 0 : name.h ashCode()) ; | |
| 242 | retu rn result; | |
| 243 | } | |
| 244 | ||
| 245 | @O verride | |
| 246 | pu blic boole an equals( Object obj ) | |
| 247 | { | |
| 248 | if ( this == ob j) return true; | |
| 249 | if ( obj == nul l) return false; | |
| 250 | if ( getClass() != obj.ge tClass()) return fal se; | |
| 251 | Abst ractNamedV O other = (AbstractN amedVO) ob j; | |
| 252 | if ( name == nu ll) | |
| 253 | { | |
| 254 | if (ot her.name ! = null) re turn false ; | |
| 255 | } | |
| 256 | else if (!name .equals(ot her.name)) return fa lse; | |
| 257 | ||
| 258 | // t he parents must be e quals also , all the way back t o the root | |
| 259 | if(t his.getPar ent() == n ull) // i f there is no parent , then we' re at our root | |
| 260 | return true; | |
| 261 | ||
| 262 | retu rn this.ge tParent(). equals(oth er.getPare nt()); | |
| 263 | } | |
| 264 | ||
| 265 | @O verride | |
| 266 | pu blic int c ompareTo(A bstractNam edVO that) | |
| 267 | { | |
| 268 | if(t hat == nul l) | |
| 269 | return -1; | |
| 270 | ||
| 271 | retu rn this.ge tName().co mpareTo(th at.getName ()); | |
| 272 | } | |
| 273 | ||
| 274 | ||
| 275 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.