156. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 7/10/2017 1:01:47 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.

156.1 Files compared

# Location File Last Modified
1 C:\AraxisMergeCompare\Pri_un\IV-ehmp_cif\VistaImagingDataSourceProvider\main\src\java\gov\va\med\imaging\protocol\vista VistaImagingParser.java Thu Jun 29 17:22:03 2017 UTC
2 C:\AraxisMergeCompare\Pri_re\IV-ehmp_cif\VistaImagingDataSourceProvider\main\src\java\gov\va\med\imaging\protocol\vista VistaImagingParser.java Thu Jul 6 15:05:59 2017 UTC

156.2 Comparison summary

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

156.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

156.4 Active regular expressions

No regular expressions were active.

156.5 Comparison detail

  1   /**
  2    * 
  3    */
  4   package go v.va.med.i maging.pro tocol.vist a;
  5  
  6   import jav a.util.Arr ayList;
  7   import jav a.util.Ite rator;
  8   import jav a.util.Lis t;
  9   import org .apache.lo g4j.Logger ;
  10  
  11   /**
  12    * Parse t he lines r ead from a  Vista int o a hierar chy as def ined by th e tag
  13    * delimit er keys. T he first l ine is ski pped. Exam ple: lines  = 8 NEXT_ STUDY||712
  14    * STUDY_I EN|712 STU DY_PAT|101 1|92171036 63V710366| IMAGPATIEN T1011,1011
  15    * NEXT_SE RIES SERIE S_IEN|712  NEXT_IMAGE  IMAGE_IEN |713
  16    * IMAGE_I NFO|B2^713 ^\\isw-wer felj-lt\im age1$\DM\0 0\07\DM000 713.TGA^\\ isw-werfel j-lt\image 1$\DM\00\0 7\DM000713 .ABS^04060 0-28
  17    * CHEST S INGLE
  18    * VIEW^30 00406.1349 ^3^CR^04/0 6/2000^^M^ A^^^1^1^SL C^^^1011^I MAGPATIENT 1011,1011^ CLIN^^^^
  19    * and ont ologyDelim iterKeys =  NEXT_STUD Y, NEXT_SE RIES, NEXT _IMAGE
  20    * 
  21    * would r eturn a li st: Parsed VistaLine  with key=" NEXT_STUDY " and valu es="",
  22    * "712" a nd propert ies: Parse dVistaLine  with key= "STUDY_IEN " and valu es="712"
  23    * ParsedV istaLine w ith key="S TUDY_PAT"  and values ="1011", " 9217103663 V710366",
  24    * IMAGPAT IENT1011,1 011 and ch ildren: Pa rsedVistaL ine with k ey="NEXT_S ERIES" and
  25    * values=  and prope rties: Par sedVistaLi ne with ke y="SERIES_ IEN" and
  26    * values= "712" and  children:  ParsedVist aLine with  key="NEXT _IMAGE" an d values=
  27    * and pro perties: P arsedVista Line with  key="IMAGE _IEN" and  values="71 3"
  28    * ParsedV istaLine w ith key="I MAGE_INFO"  and
  29    * values= "B2^713^\\ isw-werfel j-lt\image 1$\DM\00\0 7\DM000713 .TGA^\\isw -werfelj-l t\image1$\ DM\00\07\D M000713.AB S^040600-2 8
  30    * CHEST S INGLE
  31    * VIEW^30 00406.1349 ^3^CR^04/0 6/2000^^M^ A^^^1^1^SL C^^^1011^I MAGPATIENT 1011,1011^ CLIN^^^^"
  32    * 
  33    * 
  34    * 
  35    * @param  lines
  36    * @param  delimiterK eys -
  37    *             A list  of key va lues that  define the  start of  each seria lized
  38    *             object . The orde r of the d elimiter k eys IS SIG NIFICANT.  Later,
  39    *             numeri cally high er index,  delimiter  keys are c onsidered  children
  40    *             of ear lier keys.  The retur ned List w ill consis t entirely  of
  41    *             Parsed VistaLine  where the  key is the  first del imiterKeys  member.
  42    *             Each o f those Pa rsedVistaL ine will h ave childr en with a  key value
  43    *             of the  second de limiterKey s member,  etc ...
  44    * 
  45    * @return
  46    * @author  vhaiswbec kec
  47    * 
  48    */
  49   public cla ss VistaIm agingParse r
  50   {
  51           pr ivate Onto logyDelimi terKey[] o ntologyDel imiterKeys ;
  52           pr ivate Logg er logger  = Logger.g etLogger(t his.getCla ss());
  53           
  54           Vi staImaging Parser(Ont ologyDelim iterKey[]  ontologyDe limiterKey s)
  55           {
  56                    this .ontologyD elimiterKe ys = new O ntologyDel imiterKey[ ontologyDe limiterKey s.length];
  57                    Syst em.arrayco py(ontolog yDelimiter Keys, 0, t his.ontolo gyDelimite rKeys, 0,  ontologyDe limiterKey s.length);
  58           }
  59  
  60           /* *
  61            *  
  62            *  @param li nes
  63            *  @param di scardUnkno wnRootLine s
  64            *  @return
  65            * /
  66           pu blic List< ParsedVist aLine> par se(String[ ] lines, b oolean dis cardUnknow nRootLines )
  67           {
  68  
  69                    // p arameter c hecking, t he ontolog y delimite r keys mus t be provi ded
  70                    if ( ontologyDe limiterKey s == null  || ontolog yDelimiter Keys.lengt h <= 0)
  71                             throw  new Illega lArgumentE xception(" The delimi ter keys m ust not be  null or a n empty ar ray.");
  72  
  73                    for  (OntologyD elimiterKe y ontology DelimiterK ey : ontol ogyDelimit erKeys)
  74                             if (on tologyDeli miterKey = = null ||  ontologyDe limiterKey .getKey()  == null
  75                                      || ontol ogyDelimit erKey.getK ey().lengt h() <= 0)
  76                                      throw ne w IllegalA rgumentExc eption(
  77                                               "All keys  in the del imiter key s must not  be null o r an empty  String.") ;
  78  
  79                    List <ParsedVis taLine> pa rsedLines  = new Arra yList<Pars edVistaLin e>();
  80                    // i f no lines  given the n return a n empty li st
  81                    if ( lines == n ull || lin es.length  <= 1)
  82                             return  parsedLin es;
  83  
  84                    logg er.info("P arsing " +  lines.len gth + " li nes using  " + ontolo gyDelimite rKeys.leng th + " key s.");
  85  
  86                    // A n array of  ParsedVis taLine ins tances tha t define t he current  path
  87                    // i n the resu lting hier archy. New  instances  of Parsed VistaLine,  as they
  88                    // a re parsed,  are added  to the cu rrent path , unless t hey are de limiter
  89                    // k eys, in wh ich case t hey change  the curre nt path.
  90                    Pars edVistaLin e[] curren tHierarchy Path = new  ParsedVis taLine[ont ologyDelim iterKeys.l ength];
  91                    for  (int index  = 0; inde x < curren tHierarchy Path.lengt h; ++index )
  92                             curren tHierarchy Path[index ] = null;
  93                    // t he depth i nto the hi erarchy th at we are  currently  adding to
  94                    // t his is als o the inde x into cur rentHierar chyPath of  the "acti ve"
  95                    // e lement
  96                    int  currentHie rarchyDept h = 0;
  97  
  98                    for  (String li ne : lines )
  99                    {
  100                             if (li ne == null ) // shoul d never ha ppen, but  ...
  101                                      continue ;
  102                             line =  line.trim (); // rem ove traili ng whitesp ace
  103  
  104                             //logg er.debug(" Parsing li ne '" + li ne + "'.") ;
  105  
  106                             // giv en a line  like "NEXT _STUDY||71 2" get the  parts "NE XT_STUDY",
  107                             // "",  "712"
  108                             String  parts[] =  line.spli t("\\|", - 1); // Str ingUtils.S plit(line,
  109                                                                                                                     // Str ingUtils.S TICK);
  110                             String  key = par ts[0].trim ();
  111                             String [] values  = parts.le ngth > 1 ?  new Strin g[parts.le ngth - 1]  : null;
  112                             if (va lues != nu ll)
  113                                      System.a rraycopy(p arts, 1, v alues, 0,  parts.leng th - 1);
  114                             // at  this point  the examp le line sh ould end u p like:
  115                             // key  = "NEXT_S TUDY"
  116                             // val ues = "",  "712"
  117  
  118                             // sim ply see if  the key i s an ontol ogy delimi ter, its h e index va lue we'll  be looking  at later
  119                             int on tologyKeyI ndex;
  120                             for (o ntologyKey Index = 0;  ontologyK eyIndex <  ontologyDe limiterKey s.length;  ++ontology KeyIndex)
  121                                      if (onto logyDelimi terKeys[on tologyKeyI ndex].getK ey().equal s(key))
  122                                               break;
  123                             
  124                             int pa rentKeyInd ex = -1;
  125                             if (on tologyKeyI ndex >= on tologyDeli miterKeys. length)
  126                             {
  127                                      ontology KeyIndex =  -1;
  128                                      // if th e current  key is not  a ontolog y key, che ck to see  if the
  129                                      // curre nt key
  130                                      // is a  exceptiona l key for  an ontolog y. if so w e will add  this
  131                                      // prope rty to tha t key
  132                                      for (par entKeyInde x = ontolo gyDelimite rKeys.leng th - 1; pa rentKeyInd ex >= 0; - -parentKey Index)
  133                                      {
  134                                               if (ontolo gyDelimite rKeys[pare ntKeyIndex ].contains Exceptiona lKey(key))
  135                                               {
  136                                                       br eak;
  137                                               }
  138                                      }
  139                             }
  140  
  141                             // if  the new li ne is a ro ot line
  142                             if (on tologyKeyI ndex == 0)
  143                             {
  144                                      logger.d ebug("Root  line dete cted '" +  line + "'. ");
  145  
  146                                      ParsedVi staLine ro ot = new P arsedVista Line(key,  values);
  147                                      parsedLi nes.add(ro ot);
  148                                      currentH ierarchyDe pth = 0;
  149                                      currentH ierarchyPa th[current HierarchyD epth] = ro ot;
  150                             }
  151  
  152                             // if  the new li ne is just  a propert y
  153                             else i f (ontolog yKeyIndex  == -1)
  154                             {
  155                                      logger.d ebug("Prop erty line  detected ' " + line +  "'.");
  156                                      ParsedVi staLine pa rent = nul l;
  157                                      // if th e parent k ey index i s not -1,  then there  is a pare nt key
  158                                      // index  to use, n ot the cur rent one
  159                                      if (pare ntKeyIndex  >= 0)
  160                                      {
  161                                               parent = c urrentHier archyPath[ parentKeyI ndex];
  162                                      }
  163                                      else
  164                                      {
  165                                               parent = c urrentHier archyPath[ currentHie rarchyDept h];
  166                                      }
  167                                      if (pare nt != null )
  168                                               parent.add Property(k ey, values );
  169                                      else
  170                                      {
  171                                               if (discar dUnknownRo otLines)
  172                                                       lo gger.warn( "There is  no current  line to a dd unknown  line '" +  line + "'  to, disca rding.");
  173                                               else
  174                                                       pa rsedLines. add(new Pa rsedVistaL ine(key, v alues));
  175                                      }
  176                             }
  177  
  178                             // if  the key is  a delimit er at the  current hi erarchy le vel
  179                             // and  it is not  the root  level (whi ch we addr essed in t he
  180                             // pre ceeding 'i f' block)
  181                             // cre ate a new  ParsedVist aLine as a  sibling o f the curr ent
  182                             // and  make the  new elemen t the curr ently acti ve element
  183                             else i f (ontolog yKeyIndex  == current HierarchyD epth)
  184                             {
  185                                      logger.d ebug("Sibl ing delimi ter line d etected '"  + line +  "'.");
  186  
  187                                      ParsedVi staLine pa rent = cur rentHierar chyPath[on tologyKeyI ndex - 1];
  188                                      currentH ierarchyPa th[ontolog yKeyIndex]  = parent. addChild(k ey, values );
  189                             }
  190  
  191                             // if  the key is  a delimit er at the  child hier erchy leve l
  192                             // cre ate a new  ParsedVist aLine as a  child of  the curren t
  193                             // mak e the new  element th e currentl y active e lement
  194                             // set  the curre nt depth t o the new  deeper lev el
  195                             else i f (ontolog yKeyIndex  > currentH ierarchyDe pth)
  196                             {
  197                                      logger.d ebug("Desc endent del imiter lin e detected  '" + line  + "'.");
  198  
  199                                      ParsedVi staLine pa rent = cur rentHierar chyPath[cu rrentHiera rchyDepth] ;
  200                                      currentH ierarchyPa th[ontolog yKeyIndex]  = parent. addChild(k ey, values );
  201                                      currentH ierarchyDe pth = onto logyKeyInd ex;
  202                             }
  203  
  204                             // if  the key is  a delimit er at an a ncestor hi ererchy le vel
  205                             // cre ate a new  ParsedVist aLine
  206                             // mak e the new  element th e currentl y active e lement
  207                             // set  the curre nt depth t o the new  shallower  level
  208                             else i f (ontolog yKeyIndex  < currentH ierarchyDe pth)
  209                             {
  210                                      logger.d ebug("Ance stor delim iter line  detected ' " + line +  "'.");
  211  
  212                                      ParsedVi staLine pa rent = cur rentHierar chyPath[on tologyKeyI ndex - 1];
  213                                      currentH ierarchyPa th[ontolog yKeyIndex]  = parent. addChild(k ey, values );
  214                                      currentH ierarchyDe pth = onto logyKeyInd ex;
  215                             }
  216                    }
  217  
  218                    retu rn parsedL ines;
  219           }
  220  
  221           /* *
  222            *  A class t hat contai ns parsed  lines from  Vista wit h no seman tics appli ed,
  223            *  other tha n recogniz ing "NEXT_ XXX" as a  start deli miter.
  224            *  
  225              * @author        
BECKEC
  226            *  
  227            * /
  228           pu blic stati c class Pa rsedVistaL ine
  229           {
  230                    priv ate Logger  logger =  Logger.get Logger(thi s.getClass ());
  231                    
  232                    priv ate final  String key ;
  233                    priv ate final  List<Strin g> values;
  234                    priv ate final  List<Parse dVistaLine > properti es;
  235                    priv ate final  List<Parse dVistaLine > children ;
  236  
  237                    Pars edVistaLin e(String k ey, String [] values)
  238                    {
  239                             this.k ey = key;
  240                             this.v alues = ne w ArrayLis t<String>( );
  241                             if (va lues != nu ll)
  242                                      for (Str ing value  : values)
  243                                               this.value s.add(valu e);
  244                             this.p roperties  = new Arra yList<Pars edVistaLin e>();
  245                             this.c hildren =  new ArrayL ist<Parsed VistaLine> ();
  246                    }
  247  
  248                    /**
  249                     * A  Child is  a line who se type in dicates an  inferior  position i n the
  250                     * d efined hie rarchy.
  251                     * 
  252                     * @ param key
  253                     * @ param valu es
  254                     * @ return
  255                     */
  256                    Pars edVistaLin e addChild (String ke y, String[ ] values)
  257                    {
  258                             Parsed VistaLine  child = ne w ParsedVi staLine(ke y, values) ;
  259                             childr en.add(chi ld);
  260  
  261                             return  child;
  262                    }
  263  
  264                    /**
  265                     * A  Property  is a line  whose type  indicates  an equiva lent posit ion in
  266                     * t he defined  hierarchy .
  267                     * 
  268                     * @ param key
  269                     * @ param valu es
  270                     * @ return
  271                     */
  272                    Pars edVistaLin e addPrope rty(String  key, Stri ng[] value s)
  273                    {
  274                             Parsed VistaLine  property =  new Parse dVistaLine (key, valu es);
  275                             proper ties.add(p roperty);
  276  
  277                             return  property;
  278                    }
  279  
  280                    Stri ng getKey( )
  281                    {
  282                             return  key;
  283                    }
  284  
  285                    Iter ator<Strin g> valuesI terator()
  286                    {
  287                             return  values.it erator();
  288                    }
  289  
  290                    Iter ator<Parse dVistaLine > property Iterator()
  291                    {
  292                             return  propertie s.iterator ();
  293                    }
  294  
  295                    Iter ator<Parse dVistaLine > childIte rator()
  296                    {
  297                             return  children. iterator() ;
  298                    }
  299  
  300                    Stri ng getValu eAtIndex(i nt index)
  301                    {
  302                             return  values.ge t(index);
  303                    }
  304  
  305                    bool ean isValu eAtIndexEx ists(int i ndex)
  306                    {
  307                             if (in dex < 0)
  308                                      return f alse;
  309                             if (in dex >= val ues.size() )
  310                                      return f alse;
  311                             return  true;
  312                    }
  313  
  314                    Pars edVistaLin e getPrope rtyAtIndex (int index )
  315                    {
  316                             return  propertie s.get(inde x);
  317                    }
  318  
  319                    Pars edVistaLin e getChild AtIndex(in t index)
  320                    {
  321                             return  children. get(index) ;
  322                    }
  323  
  324                    Pars edVistaLin e getPrope rty(String  key)
  325                    {
  326                             for (I terator<Pa rsedVistaL ine> iter  = property Iterator() ; iter.has Next();)
  327                             {
  328                                      ParsedVi staLine pr operty = i ter.next() ;
  329                                      if (key. equals(pro perty.getK ey()))
  330                                               return pro perty;
  331                             }
  332  
  333                             return  null;
  334                    }
  335  
  336                    /**
  337                     * T he keys mu st match a nd the pro perties an d children  must also  be
  338                     * e quals and  in the sam e order.
  339                     * 
  340                     * @ see java.l ang.Object #equals(ja va.lang.Ob ject)
  341                     */
  342                    @Ove rride
  343                    publ ic boolean  equals(Ob ject obj)
  344                    {
  345                             if (ob j instance of ParsedV istaLine)
  346                             {
  347                                      ParsedVi staLine th at = (Pars edVistaLin e) obj;
  348  
  349                                      if (this .getKey()  == null &&  that.getK ey() != nu ll || this .getKey()  != null &&  that.getK ey() == nu ll
  350                                               || !this.g etKey().eq uals(that. getKey()))
  351                                      {
  352                                               logger.inf o("this.ke y '" + thi s.getKey()  + "' is n ot equal t o that.key  '" + that .getKey()  + "'.");
  353                                               return fal se;
  354                                      }
  355  
  356                                      if (this .values.si ze() != th at.values. size())
  357                                      {
  358                                               logger.inf o("this.va lues.size  '" + this. values.siz e() + "' i s not equa l to that. values.siz e '"
  359                                                       +  that.value s.size() +  "'.");
  360                                               return fal se;
  361                                      }
  362  
  363                                      Iterator <String> t hisValueIt erator = t his.values Iterator() ;
  364                                      Iterator <String> t hatValueIt erator = t hat.values Iterator() ;
  365                                      for (; t hisValueIt erator.has Next() &&  thatValueI terator.ha sNext();)
  366                                      {
  367                                               String thi sValue = t hisValueIt erator.nex t();
  368                                               String tha tValue = t hatValueIt erator.nex t();
  369                                               if (!thisV alue.equal s(thatValu e))
  370                                               {
  371                                                       lo gger.info( "this(" +  this.getKe y() + ").v alue '" +  thisValue  + "' is no t equal to  that("
  372                                                                + th at.getKey( ) + ").val ue '" + th atValue +  "'.");
  373                                                       re turn false ;
  374                                               }
  375                                      }
  376  
  377                                      if (this .propertie s.size() ! = that.pro perties.si ze())
  378                                      {
  379                                               logger.inf o("this.pr operties.s ize '" + t his.proper ties.size( )
  380                                                       +  "' is not  equal to t hat.proper ties.size  '" + that. properties .size() +  "'.");
  381                                               return fal se;
  382                                      }
  383  
  384                                      Iterator <ParsedVis taLine> th isProperty Iterator =  this.prop ertyIterat or();
  385                                      Iterator <ParsedVis taLine> th atProperty Iterator =  that.prop ertyIterat or();
  386                                      for (; t hisPropert yIterator. hasNext()  && thatPro pertyItera tor.hasNex t();)
  387                                      {
  388                                               ParsedVist aLine this Property =  thisPrope rtyIterato r.next();
  389                                               ParsedVist aLine that Property =  thatPrope rtyIterato r.next();
  390                                               if (!thisP roperty.eq uals(thatP roperty))
  391                                                       re turn false ;
  392                                      }
  393  
  394                                      if (this .children. size() !=  that.child ren.size() )
  395                                      {
  396                                               logger.inf o("this.ch ildren.siz e '" + thi s.children .size()
  397                                                       +  "' is not  equal to t hat.childr en.size '"  + that.ch ildren.siz e() + "'." );
  398                                               return fal se;
  399                                      }
  400  
  401                                      Iterator <ParsedVis taLine> th isChildIte rator = th is.childIt erator();
  402                                      Iterator <ParsedVis taLine> th atChildIte rator = th at.childIt erator();
  403                                      for (; t hisChildIt erator.has Next() &&  thatChildI terator.ha sNext();)
  404                                      {
  405                                               ParsedVist aLine this Child = th isChildIte rator.next ();
  406                                               ParsedVist aLine that Child = th atChildIte rator.next ();
  407                                               if (!thisC hild.equal s(thatChil d))
  408                                                       re turn false ;
  409                                      }
  410  
  411                                      return t rue;
  412                             }
  413  
  414                             return  false;
  415                    }
  416  
  417                    @Ove rride
  418                    publ ic String  toString()
  419                    {
  420                             String Builder sb  = new Str ingBuilder ();
  421  
  422                             sb.app end("Parse dVistaLine  \r");
  423  
  424                             sb.app end("\tKey  :'");
  425                             sb.app end(key);
  426                             sb.app end("'\r") ;
  427  
  428                             sb.app end("\tVal ues :'");
  429                             for (S tring valu e : values )
  430                                      sb.appen d(value +  " ");
  431                             sb.app end("'\r") ;
  432  
  433                             return  sb.toStri ng();
  434                    }
  435           }
  436  
  437           /* *
  438            *  Represent s an ontol ogy key in  the study , series,  instance h ierearchy
  439            *  
  440            *  @author v haiswwerfe j
  441            *  
  442            * /
  443           st atic class  OntologyD elimiterKe y
  444           {
  445                    priv ate final  String key ;
  446                    priv ate final  String[] e xceptional Keys;
  447  
  448                    /**
  449                     * C reate an o ntology de limiter ke y with no  exceptiona l keys
  450                     * 
  451                     * @ param key
  452                     */
  453                    Onto logyDelimi terKey(Str ing key)
  454                    {
  455                             this.k ey = key;
  456                             except ionalKeys  = null;
  457                    }
  458  
  459                    /**
  460                     * C reate an o ntology de limiter ke y with exc eptional k eys
  461                     * 
  462                     * @ param key
  463                     * @ param exce ptionalKey s
  464                     */
  465                    Onto logyDelimi terKey(Str ing key, S tring[] ex ceptionalK eys)
  466                    {
  467                             this.k ey = key;
  468                             this.e xceptional Keys = exc eptionalKe ys;
  469                    }
  470  
  471                    /**
  472                     * @ return the  key
  473                     */
  474                    publ ic String  getKey()
  475                    {
  476                             return  key;
  477                    }
  478  
  479                    /**
  480                     * @ return the  exception alKeys
  481                     */
  482                    publ ic String[ ] getExcep tionalKeys ()
  483                    {
  484                             return  exception alKeys;
  485                    }
  486  
  487                    publ ic boolean  containsE xceptional Key(String  searchExc eptionalKe y)
  488                    {
  489                             if (ex ceptionalK eys == nul l)
  490                                      return f alse;
  491                             if (se archExcept ionalKey = = null)
  492                                      return f alse;
  493                             for (S tring exce ptionalKey  : excepti onalKeys)
  494                             {
  495                                      if (exce ptionalKey .equals(se archExcept ionalKey))
  496                                               return tru e;
  497                             }
  498                             return  false;
  499                    }
  500           }
  501   }