Produced by Araxis Merge on 6/11/2019 10:54:14 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\fw\rule\impl | MatchRuleServiceImpl.java | Wed May 29 15:26:14 2019 UTC |
| 2 | HTRE_P3_v14.5_iter_4_build_14.zip\java\gov\va\med\fw\rule\impl | MatchRuleServiceImpl.java | Mon Jun 10 19:19:22 2019 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 252 |
| 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 | * Copyrii ght 2008 V HA. All ri ghts reser ved | |
| 3 | ********* ********** ********** ********** ********** ********** *********/ | |
| 4 | package go v.va.med.f w.rule.imp l; | |
| 5 | ||
| 6 | import jav a.util.Arr ayList; | |
| 7 | import jav a.util.Col lection; | |
| 8 | import jav a.util.Lis t; | |
| 9 | ||
| 10 | import org .apache.co mmons.lang .Validate; | |
| 11 | import org .springfra mework.ste reotype.Se rvice; | |
| 12 | ||
| 13 | import gov .va.med.fw .model.Abs tractEntit y; | |
| 14 | import gov .va.med.fw .model.Abs tractKeyed Entity; | |
| 15 | import gov .va.med.fw .rule.Matc h; | |
| 16 | import gov .va.med.fw .rule.Matc hRuleServi ce; | |
| 17 | import gov .va.med.fw .service.A bstractCom ponent; | |
| 18 | ||
| 19 | /** | |
| 20 | * @author DNS | |
| 21 | * | |
| 22 | */ | |
| 23 | @Service | |
| 24 | public cla ss MatchRu leServiceI mpl extend s Abstract Component implements MatchRule Service { | |
| 25 | ||
| 26 | pr ivate stat ic final l ong serial VersionUID = 7005290 8629803826 80L; | |
| 27 | ||
| 28 | /* | |
| 29 | * (non-Java doc) | |
| 30 | * | |
| 31 | * @see | |
| 32 | * gov.va.me d.fw.rule. MatchRuleS ervice#fin dMatchingE lement(gov .va.med.fw | |
| 33 | * .model.Ab stractEnti ty, java.u til.Collec tion) | |
| 34 | * / | |
| 35 | pu blic <T ex tends Abst ractEntity > T findMa tchingElem ent(T sour ce, Collec tion<T> ta rget) { | |
| 36 | Vali date.notNu ll(source, "A source to find a match mus t not be n ull"); | |
| 37 | Vali date.notNu ll(target, | |
| 38 | "A targe t collecti on in whic h a match is searche d must not be null") ; | |
| 39 | ||
| 40 | T ma tch = null ; | |
| 41 | for (T element : target) { | |
| 42 | if (ma tch(source , (Abstrac tEntity) e lement)) { | |
| 43 | match = element; | |
| 44 | break; | |
| 45 | } | |
| 46 | } | |
| 47 | retu rn match; | |
| 48 | } | |
| 49 | ||
| 50 | /* | |
| 51 | * (non-Java doc) | |
| 52 | * | |
| 53 | * @see | |
| 54 | * gov.va.me d.fw.rule. MatchRuleS ervice#mat ch(gov.va. med.fw.mod el.Abstrac tEntity | |
| 55 | * , gov.va. med.fw.mod el.Abstrac tEntity) | |
| 56 | * / | |
| 57 | pu blic <T ex tends Abst ractEntity > boolean match(T so urce, T ta rget) { | |
| 58 | Vali date.notNu ll(source, "A source must not be null"); | |
| 59 | Vali date.notNu ll(target, "A target must not be null"); | |
| 60 | // m atch by id for Abstr actKeyedEn tity | |
| 61 | if ( source ins tanceof Ab stractKeye dEntity) { | |
| 62 | Long s rcId = ((A bstractKey edEntity<? >) source) .getId(); | |
| 63 | Long t argetId = ((Abstract KeyedEntit y<?>) targ et).getId( ); | |
| 64 | if ((s rcId != nu ll && targ etId != nu ll && srcI d.equals(t argetId))) { | |
| 65 | return t rue; | |
| 66 | } | |
| 67 | } | |
| 68 | // m atch by do main conce pt for oth ers | |
| 69 | retu rn source. matchesDom ainConcept (target); | |
| 70 | } | |
| 71 | ||
| 72 | /* | |
| 73 | * (non-Java doc) | |
| 74 | * | |
| 75 | * @see gov. va.med.fw. rule.Match RuleServic e#match(ja va.util.Co llection, | |
| 76 | * java.util .Collectio n) | |
| 77 | * / | |
| 78 | pu blic <T ex tends Abst ractEntity > List<Mat ch<T>> mat ch(Collect ion<T> sou rce, | |
| 79 | Collec tion<T> ta rget) { | |
| 80 | Vali date.notNu ll(source, "A source must not be null"); | |
| 81 | Vali date.notNu ll(target, "A target must not be null"); | |
| 82 | List <Match<T>> matchList = new Arr ayList<Mat ch<T>>(); | |
| 83 | // H andle spec ial cases (delete al l, insert all) | |
| 84 | // d elete all | |
| 85 | if ( source.siz e() == 0 & & target.s ize() > 0) { | |
| 86 | for (T element : target) { | |
| 87 | matchLis t.add(new Match<T>(( T) null, e lement)); | |
| 88 | } | |
| 89 | } | |
| 90 | // i nsert all | |
| 91 | else if (sourc e.size() > 0 && targ et.size() == 0) { | |
| 92 | for (T element : source) { | |
| 93 | matchLis t.add(new Match<T>(e lement, (T ) null)); | |
| 94 | } | |
| 95 | } | |
| 96 | // G eneric cas e where so me are mod ified, add ed, delete d | |
| 97 | else { | |
| 98 | List<T > srcList = new Arra yList<T>(s ource); | |
| 99 | List<T > targetLi st = new A rrayList<T >(target); | |
| 100 | for (T element : srcList) { | |
| 101 | Match<T> match = n ull; | |
| 102 | int matc hIndex = - 1; | |
| 103 | for (int j = 0; j < targetLi st.size(); j++) { | |
| 104 | T targetEn tity = tar getList.ge t(j); | |
| 105 | if (match( element, t argetEntit y)) { | |
| 106 | ma tch = new Match<T>(e lement, ta rgetEntity ); | |
| 107 | ma tchIndex = j; | |
| 108 | } | |
| 109 | } | |
| 110 | // match found | |
| 111 | if (matc h != null) { | |
| 112 | targetList .remove(ma tchIndex); | |
| 113 | matchList. add(match) ; | |
| 114 | }// new entity | |
| 115 | else { | |
| 116 | matchList. add(new Ma tch<T>(ele ment, null )); | |
| 117 | } | |
| 118 | } | |
| 119 | // del eted entit ies | |
| 120 | for (i nt j = 0; j < target List.size( ); j++) { | |
| 121 | T target Entity = t argetList. get(j); | |
| 122 | matchLis t.add(new Match<T>(n ull, targe tEntity)); | |
| 123 | } | |
| 124 | } | |
| 125 | retu rn matchLi st; | |
| 126 | } | |
| 127 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.