261. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 12/13/2018 10:35:26 AM Eastern 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.

261.1 Files compared

# Location File Last Modified
1 v12.5_iter_7_build 51.zip\TRM_Upgrade\src\main\java\gov\va\med\fw\io RawFileDataContainerUtils.java Fri Dec 7 17:36:20 2018 UTC
2 v12.5_iter_7_build 51.zip\TRM_Upgrade\src\main\java\gov\va\med\fw\io RawFileDataContainerUtils.java Wed Dec 12 22:26:42 2018 UTC

261.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 476
Changed 1 2
Inserted 0 0
Removed 0 0

261.3 Comparison options

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

261.4 Active regular expressions

No regular expressions were active.

261.5 Comparison detail

  1   /********* ********** ********** ********** ********** ********** *********
  2    * Copyrii ght 2006 V HA. All ri ghts reser ved
  3    ********* ********** ********** ********** ********** ********** *********/
  4  
  5   package go v.va.med.f w.io;
  6  
  7   import jav a.beans.Pr opertyDesc riptor;
  8   import jav a.util.Arr ayList;
  9   import jav a.util.Col lection;
  10   import jav a.util.Has hMap;
  11   import jav a.util.Has hSet;
  12   import jav a.util.Ite rator;
  13   import jav a.util.Lis t;
  14   import jav a.util.Map ;
  15   import jav a.util.Set ;
  16  
  17   import org .apache.co mmons.bean utils.Bean Utils;
  18   import org .apache.co mmons.bean utils.Conv ertUtils;
  19   import org .apache.co mmons.bean utils.Conv erter;
  20   import org .apache.co mmons.bean utils.Prop ertyUtils;
  21   import org .apache.co mmons.lang .StringUti ls;
  22   import org .apache.co mmons.lang .Validate;
  23  
  24   import gov .va.med.fw .model.Abs tractEntit y;
  25   import gov .va.med.fw .model.loo kup.Lookup ;
  26  
  27   /**
  28    * Utility  class for  RawFileDa taContaine r implemen tors.
  29    * 
  30    * Created  Mar 16, 2 006 4:38:2 4 PM
  31    * 
  32    * DNS
  33    */
  34   public cla ss RawFile DataContai nerUtils {
  35           pr ivate stat ic Convert er lookupC onverter;
  36  
  37           pr ivate stat ic Map con verters;
  38  
  39           pr ivate stat ic Set loo kupsToRegi ster = new  HashSet() ;
  40  
  41           pr ivate stat ic Map cla ssLoaderTo ClassesAut oRegistere d = new Ha shMap();
  42  
  43           pu blic stati c void aut oRegisterC onvertersF orClasses( Class[] cl asses) {
  44                    if ( classes !=  null) {
  45                             for (i nt i = 0;  i < classe s.length;  i++) {
  46                                      RawFileD ataContain erUtils.au toRegister Converters ForClass(c lasses[i]) ;
  47                             }
  48                    }
  49           }
  50  
  51           pu blic stati c void aut oRegisterC onvertersF orClass()  {
  52                    Stac kTraceElem ent[] elem ents = new  Exception ().getStac kTrace();
  53                    Stri ng classNa me = eleme nts[1].get ClassName( );
  54                    try  {
  55                             RawFil eDataConta inerUtils. autoRegist erConverte rsForClass (Class.for Name(class Name));
  56                    } ca tch (Excep tion e) {
  57                             throw  new Runtim eException ("Unable t o load cla ss: " + cl assName);
  58                    }
  59           }
  60  
  61           pu blic stati c void reg isterConve rterForLoo kupClass(C lass clazz ) {
  62                    if ( !Lookup.cl ass.isAssi gnableFrom (clazz))
  63                             throw  new Illega lArgumentE xception(
  64                                               "Can not r egister Lo okupConver ter for cl ass that i s not assi gnable fro m Lookup.c lass");
  65  
  66                    // s ee if ther e is a reg istered Lo okup conve rter
  67                    if ( lookupConv erter == n ull) {
  68                             lookup Converter  = ConvertU tils.looku p(Lookup.c lass);
  69                             if (lo okupConver ter == nul l) {
  70                                      lookupsT oRegister. add(clazz) ; // will  be registe red later  when
  71                                      // looku pConverter  is detect ed
  72                                      return;
  73                             }
  74                    }
  75  
  76                    Conv ertUtils.r egister(lo okupConver ter, clazz );
  77           }
  78  
  79           pu blic synch ronized st atic void  cleanUnreg isteredLoo kups(Conve rter regis teredLooku pConverter ) {
  80                    Vali date.notNu ll(registe redLookupC onverter,  "registere dLookupCon verter can  not be nu ll");
  81                    look upConverte r = regist eredLookup Converter;
  82                    if ( !lookupsTo Register.i sEmpty())  {
  83                             Iterat or itr = l ookupsToRe gister.ite rator();
  84                             while  (itr.hasNe xt()) {
  85                                      ConvertU tils.regis ter(lookup Converter,  (Class) i tr.next()) ;
  86                             }
  87                    }
  88                    look upsToRegis ter.clear( );
  89           }
  90  
  91           pu blic stati c void aut oRegisterC onvertersF orClass(Cl ass clazz)  {
  92                    // g et its pro perties an d register  "common"  converters
  93                    doAu toRegister Converters ForClass(c lazz, new  HashMap()) ;
  94           }
  95  
  96           pr ivate stat ic void do AutoRegist erConverte rsForClass (Class cla zz, Map ig noreTheseC lasses) {
  97                    if ( ignoreThes eClasses.c ontainsKey (clazz))
  98                             return ;
  99  
  100                    /*
  101                     * T his ensure s we save  overheard  across mul tiple call s to this  method.
  102                     * T racks by C lassLoader  since tha t is how B eanUtilsBe an in Comm ons
  103                     * B eanUtils d oes it.
  104                     */
  105                    Clas sLoader cu rrentClass Loader = T hread.curr entThread( ).getConte xtClassLoa der();
  106                    Set  classesAut oRegistere d = (Set)  classLoade rToClasses AutoRegist ered
  107                                      .get(cur rentClassL oader);
  108                    if ( classesAut oRegistere d == null)  {
  109                             classe sAutoRegis tered = ne w HashSet( );
  110                             classL oaderToCla ssesAutoRe gistered.p ut(current ClassLoade r, classes AutoRegist ered);
  111                    } el se if (cla ssesAutoRe gistered.c ontains(cl azz)) {
  112                             return ;
  113                    }
  114                    clas sesAutoReg istered.ad d(clazz);
  115  
  116                    igno reTheseCla sses.put(c lazz, null );
  117                    Prop ertyDescri ptor[] pro ps = Prope rtyUtils.g etProperty Descriptor s(clazz);
  118                    Conv erter well KnownConve rter = nul l;
  119                    for  (int i = 0 ; i < prop s.length;  i++) {
  120                             // rec urse (if n ecessary)
  121                             if (Ab stractEnti ty.class.i sAssignabl eFrom(prop s[i].getPr opertyType ()))
  122                                      doAutoRe gisterConv ertersForC lass(props [i].getPro pertyType( ), ignoreT heseClasse s);
  123  
  124                             // loo k for "wel l-known" c onverters  to registe r
  125                             wellKn ownConvert er = conve rters != n ull ? (Con verter) co nverters.g et(props[i ]
  126                                               .getProper tyType().g etName())  : null;
  127                             if (Lo okup.class .isAssigna bleFrom(pr ops[i].get PropertyTy pe())) {
  128                                      register ConverterF orLookupCl ass(props[ i].getProp ertyType() );
  129                             } else  if (Conve rtUtils.lo okup(props [i].getPro pertyType( )) == null
  130                                               && wellKno wnConverte r != null)  {
  131                                      ConvertU tils.regis ter(wellKn ownConvert er, props[ i].getProp ertyType() );
  132                             }
  133                    }
  134           }
  135  
  136           pu blic stati c void set ConvertedF ield(Objec t instance , String p roperty, S tring rawV alue)
  137                             throws  Exception  {
  138                    if ( StringUtil s.isNotBla nk(rawValu e)) {
  139                             // thi s allows r egistered  Converter  instances  to come in to play
  140                             BeanUt ils.copyPr operty(ins tance, pro perty, raw Value);
  141                    }
  142           }
  143  
  144           pu blic stati c Lookup c onvertToLo okup(Class  clazz, St ring code)  {
  145                    retu rn (Lookup ) lookupCo nverter.co nvert(claz z, code);
  146           }
  147  
  148           pu blic stati c Object[]  parseMult ipleValues (String ra wData, Str ing primar yDelimiter ,
  149                             String  secondary Delimiter,  int dataS ize) {
  150                    if ( StringUtil s.isBlank( rawData))
  151                             return  null;
  152  
  153                    Stri ng[] split ByPrimary  = rawData. split("\\"  + primary Delimiter) ;
  154                    Obje ct[] group edData = n ew Object[ splitByPri mary.lengt h];
  155                    if ( secondaryD elimiter = = null)
  156                             return  splitByPr imary;
  157  
  158                    Stri ng[] split BySecondar yActual =  null;
  159                    Stri ng[] split BySecondar y = null;
  160                    for  (int i = 0 ; i < spli tByPrimary .length; i ++) {
  161                             splitB ySecondary  = new Str ing[dataSi ze];
  162                             splitB ySecondary Actual = s plitByPrim ary[i].spl it("\\" +  secondaryD elimiter);
  163                             for (i nt j = 0;  j < splitB ySecondary Actual.len gth; j++)  {
  164                                      splitByS econdary[j ] = splitB ySecondary Actual[j];
  165                             }
  166                             groupe dData[i] =  splitBySe condary;
  167                    }
  168  
  169                    /*
  170                     * S ystem.out. println("o riginalDat a: " + raw Data); for (int i=0;
  171                     * i <groupedDa ta.length;  i++) { Ob ject[] dat a = (Objec t[])
  172                     * g roupedData [i]; for(i nt j=0; j<  data.leng th; j++) {
  173                     * S ystem.out. println("g roupedData  [" + i +  ", " + j +  " ]: " +
  174                     * d ata[j]); }  }
  175                     */
  176  
  177                    retu rn grouped Data;
  178           }
  179  
  180           pu blic stati c String f ormatMulti pleValues( Collection  data, Str ing delimi ter) {
  181                    Stri ngBuilder  buf = new  StringBuil der();
  182                    Iter ator itr =  data != n ull ? data .iterator( ) : null;
  183                    Obje ct obj = n ull;
  184                    whil e (itr !=  null && it r.hasNext( )) {
  185                             obj =  itr.next() ;
  186                             if (ob j instance of Lookup)
  187                                      buf.appe nd(formatL ookup((Loo kup) obj)) ;
  188                             else
  189                                      buf.appe nd(obj);
  190  
  191                             if (it r.hasNext( ))
  192                                      buf.appe nd(delimit er);
  193                    }
  194                    retu rn buf.toS tring();
  195           }
  196  
  197           pu blic stati c List par seMultiple Values(Str ing data,  String del imiter) {
  198                    List  coll = ne w ArrayLis t();
  199  
  200                    if ( StringUtil s.isBlank( data))
  201                             return  coll;
  202  
  203                    Stri ng[] token s = data.s plit("\\"  + delimite r);
  204                    for  (int j = 0 ; tokens ! = null &&  j < tokens .length; j ++)
  205                             coll.a dd(tokens[ j]);
  206                    retu rn coll;
  207           }
  208  
  209           pu blic stati c Set pars eMultipleL ookupValue s(String d ata, Strin g delimite r, Class l ookupClass ) {
  210                    Set  coll = new  HashSet() ;
  211  
  212                    if ( StringUtil s.isBlank( data))
  213                             return  coll;
  214  
  215                    Stri ng[] token s = data.s plit("\\"  + delimite r);
  216                    for  (int j = 0 ; tokens ! = null &&  j < tokens .length; j ++)
  217                             coll.a dd(convert ToLookup(l ookupClass , tokens[j ]));
  218                    retu rn coll;
  219           }
  220  
  221           pu blic stati c String f ormatLooku p(Lookup l ookup) {
  222                    retu rn lookup  != null ?  lookup.get Code() : S tringUtils .EMPTY;
  223           }
  224  
  225           /* *
  226            *  @return R eturns the  converter s.
  227            * /
  228           pu blic stati c Map getC onverters( ) {
  229                    retu rn convert ers;
  230           }
  231  
  232           /* *
  233            *  @param co nverters
  234            *              The conv erters to  set.
  235            * /
  236           pu blic stati c void set Converters (Map conve rters) {
  237                    RawF ileDataCon tainerUtil s.converte rs = conve rters;
  238           }
  239   }