243. EPMO Open Source Coordination Office Redaction File Detail Report

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.

243.1 Files compared

# Location File Last Modified
1 HTRE_P3_v14.5_iter_4_build_14.zip\java\gov\va\med\fw\rule\impl SimpleRuleMethod.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 SimpleRuleMethod.java Mon Jun 10 19:27:47 2019 UTC

243.2 Comparison summary

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

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

243.4 Active regular expressions

No regular expressions were active.

243.5 Comparison detail

  1   /********* ********** ********** ********** ********** ********** *********
  2    * Copyrii ght 2004 V HA. All ri ghts reser ved
  3    ********* ********** ********** ********** ********** ********** *********/
  4   package go v.va.med.f w.rule.imp l;
  5  
  6   // Java cl asses
  7   import jav a.math.Big Decimal;
  8   import jav a.text.Par seExceptio n;
  9   import jav a.text.Sim pleDateFor mat;
  10   import jav a.util.Cal endar;
  11   import jav a.util.Col lection;
  12   import jav a.util.Dat e;
  13   import jav a.util.Tim eZone;
  14  
  15   import org .apache.co mmons.lang .ObjectUti ls;
  16   import org .apache.co mmons.lang .Validate;
  17   import org .apache.co mmons.lang .time.Date Utils;
  18   import org .apache.co mmons.logg ing.Log;
  19   import org .apache.co mmons.logg ing.LogFac tory;
  20  
  21   import gov .va.med.fw .rule.Rule Exception;
  22   import gov .va.med.fw .rule.Rule Method;
  23   import gov .va.med.fw .security. SecurityCo ntext;
  24   import gov .va.med.fw .security. SecurityCo ntextHelpe r;
  25  
  26   // EDB cla sses
  27  
  28   /**
  29    * Project : Framewor k
  30    * 
  31    * @author   DN S
  32    * @versio n 1.0
  33    */
  34   public cla ss SimpleR uleMethod  implements  RuleMetho d {
  35           /* *
  36            *  An instan ce of seri alVersionU ID
  37            * /
  38           pr ivate stat ic final l ong serial VersionUID  = 8020776 5057352178 70L;
  39  
  40           /* *
  41            *  A logger  to log inf ormation
  42            * /
  43           pr otected Lo g logger =  LogFactor y.getLog(g etClass()) ;
  44  
  45           pu blic Simpl eRuleMetho d() {
  46                    supe r();
  47           }
  48  
  49           /* *
  50            *  Compares  the 2 cale ndars for  equality.  This metho d allows a  caller to
  51            *  pass in a  significa nt calenda r field to  round off  before a  comparison  of
  52            *  the 2 cal endars tak e place.
  53            *  
  54            *  @param ar g1
  55            *              A calend ar to comp are
  56            *  @param ar g2
  57            *              A calend ar to comp are
  58            *  @return T rue if 2 o bjects are  equal. Fa lse otherw ise
  59            * /
  60           pu blic boole an isCalen darEqual(C alendar ar g1, Calend ar arg2, i nt field)  throws Rul eException  {
  61                    bool ean compar e = false;
  62  
  63                    chec kCalendarF ield(field , "Invalid  calendar  field");
  64  
  65                    if ( arg1 == ar g2) {
  66                             compar e = true;
  67                    } el se if (arg 1 != null  && arg2 !=  null) {
  68  
  69                             Calend ar rounded 1 = DateUt ils.round( arg1, fiel d);
  70                             Calend ar rounded 2 = DateUt ils.round( arg2, fiel d);
  71                             compar e = rounde d1.equals( rounded2);
  72                             if (lo gger.isDeb ugEnabled( )) {
  73                                      logger.d ebug(" Arg 1: " + arg 1.getTime( ) + " Arg2 : " + arg2 .getTime() );
  74                                      logger.d ebug(" Ret urned valu e: " + com pare);
  75                             }
  76                    }
  77                    retu rn compare ;
  78           }
  79  
  80           /* *
  81            *  Compares  two object s for equa lity, wher e either o ne or both  objects m ay
  82            *  be null.  For instan ce:
  83            *  
  84            *  ObjectUti ls.equals( null, null ) = true O bjectUtils .equals(nu ll, "") =
  85            *  false Obj ectUtils.e quals("",  null) = fa lse Object Utils.equa ls("", "")  =
  86            *  true Obje ctUtils.eq uals(Boole an.TRUE, n ull) = fal se
  87            *  ObjectUti ls.equals( Boolean.TR UE, "true" ) = false
  88            *  ObjectUti ls.equals( Boolean.TR UE, Boolea n.TRUE) =  true
  89            *  ObjectUti ls.equals( Boolean.TR UE, Boolea n.FALSE) =  false
  90            *  
  91            *  @param ar g1
  92            *              An objec t to compa re
  93            *  @param ar g2
  94            *              An objec t to compa re
  95            *  @return T rue if 2 o bjects are  equal. Fa lse otherw ise
  96            * /
  97           pu blic boole an isEqual (Object ar g1, Object  arg2) {
  98                    bool ean compar e = false;
  99  
  100                    // I f 2 object s are stri ng, ignore  cases in  comparison
  101                    if ( arg1 insta nceof Stri ng && arg2  instanceo f String & & arg1 !=  null && ar g2 != null ) {
  102                             compar e = ((Stri ng) arg1). equalsIgno reCase((St ring) arg2 );
  103                    } el se if (arg 1 != null  && arg2 !=  null && D ate.class. isAssignab leFrom(arg 1.getClass ())) {
  104                             Date l hsDate = ( Date) arg1 ;
  105                             Date r hsDate = ( Date) arg2 ;
  106                             compar e = (lhsDa te.getTime () == rhsD ate.getTim e());
  107                    } el se {
  108                             compar e = Object Utils.equa ls(arg1, a rg2);
  109                    }
  110                    if ( logger.isD ebugEnable d()) {
  111                             logger .debug(" A rg1: " + ( (arg1 != n ull) ? arg 1.toString () : null)  + " Arg2:  "
  112                                               + ((arg2 ! = null) ?  arg2.toStr ing() : nu ll));
  113                             logger .debug(" R eturned va lue: " + c ompare);
  114                    }
  115                    retu rn compare ;
  116           }
  117  
  118           /* *
  119            *  Compares  a big deci mal and a  number
  120            *  
  121            *  @param ar g1
  122            *              A big de cima to co mpare
  123            *  @param ar g2
  124            *              A number  to compar e
  125            *  @return T rue if 2 o bjects are  equal. Fa lse otherw ise
  126            * /
  127           pu blic boole an isEqual (BigDecima l arg1, in t arg2) {
  128                    bool ean compar e = this.i sEqual(toI nteger(arg 1), new In teger(arg2 ));
  129  
  130                    retu rn compare ;
  131           }
  132  
  133           /* *
  134            *  Checks if  a value i s within a  range
  135            *  
  136            *  @param lo wer
  137            *              A lower  bound
  138            *  @param up per
  139            *              An upper  bound
  140            *  @return T rue if a v alue is wi thin a ran ge. false  otherwise
  141            * /
  142           pu blic boole an isInRan ge(Integer  value, in t lower, i nt upper)  {
  143                    bool ean inRang e = false;
  144                    if ( value != n ull) {
  145                             inRang e = ((lowe r <= value .intValue( ) && value .intValue( ) <= upper ) ? true :  false);
  146                    }
  147                    if ( logger.isD ebugEnable d()) {
  148                             logger .debug(" L ower bound : " + lowe r + " Uppe r bound: "  + upper);
  149                             logger .debug(" R eturned va lue: " + i nRange);
  150                    }
  151                    retu rn inRange ;
  152           }
  153  
  154           /* *
  155            *  Checks if  a value i s within a  range
  156            *  
  157            *  @param lo wer
  158            *              A lower  bound
  159            *  @param up per
  160            *              An upper  bound
  161            *  @return T rue if a v alue is wi thin a ran ge. false  otherwise
  162            * /
  163           pu blic boole an isInRan ge(BigDeci mal value,  double lo wer, doubl e upper) {
  164                    bool ean inRang e = false;
  165                    if ( value != n ull) {
  166                             inRang e = ((lowe r <= value .doubleVal ue() && va lue.double Value() <=  upper) ?  true
  167                                               : false);
  168                    }
  169                    if ( logger.isD ebugEnable d()) {
  170                             logger .debug(" L ower bound : " + lowe r + " Uppe r bound: "  + upper);
  171                             logger .debug(" R eturned va lue: " + i nRange);
  172                    }
  173                    retu rn inRange ;
  174           }
  175  
  176           /* *
  177            *  Checks if  a value i s one of t he items i n a collec tion
  178            *  
  179            *  @param va lue
  180            *              An objec t to check
  181            *  @param pa ttern
  182            *              A collec tion of va lues to co mpare
  183            *  @return T rue if an  object is  in a colle ction
  184            * /
  185           pu blic boole an isPartO f(String v alue, Stri ng pattern ) {
  186  
  187                    bool ean compar e = false;
  188                    if ( value != n ull && pat tern != nu ll) {
  189                             compar e = (patte rn.indexOf (value) !=  -1);
  190                    }
  191                    if ( logger.isD ebugEnable d()) {
  192                             logger .debug(" S tring to s earch " +  value);
  193                             logger .debug(" S tring to c ompare " +  pattern);
  194                    }
  195                    retu rn compare ;
  196           }
  197  
  198           /* *
  199            *  Checks if  a collect ion is eit her empty  or null
  200            *  
  201            *  @param co llection
  202            *              A collec tion to ch eck for em pty and nu ll
  203            *  @return T rue if a c ollection  is empty o r null
  204            * /
  205           pu blic boole an isEmpty (Collectio n collecti on) {
  206  
  207                    // i f a collec tion is nu ll, it is  considered  empty
  208                    bool ean empty  = true;
  209  
  210                    if ( collection  != null)  {
  211                             empty  = collecti on.isEmpty ();
  212                    }
  213                    retu rn empty;
  214           }
  215  
  216           /* *
  217            *  Checks if  a value i s less tha n an upper  bound
  218            *  
  219            *  @param up per
  220            *              An upper  bound
  221            *  @return T rue if a v alue is le ss than an  upper bou nd. false  otherwise
  222            * /
  223           pu blic boole an isLessT han(Intege r value, i nt upper)  {
  224                    bool ean compar e = false;
  225                    if ( value != n ull) {
  226                             compar e = (value .intValue( ) < upper  ? true : f alse);
  227                    }
  228                    if ( logger.isD ebugEnable d()) {
  229                             logger .debug(" U pper bound : " + uppe r);
  230                             logger .debug(" R eturned va lue: " + c ompare);
  231                    }
  232                    retu rn compare ;
  233           }
  234  
  235           /* *
  236            *  Checks if  a value i s greater  than a low er bound
  237            *  
  238            *  @param lo wer
  239            *              A lower  bound
  240            *  @return T rue if a v alue is gr eater than  a lower b ound. fals e otherwis e
  241            * /
  242           pu blic boole an isGreat erThan(Int eger value , int lowe r) {
  243                    bool ean compar e = false;
  244                    if ( value != n ull) {
  245                             compar e = (value .intValue( ) > lower  ? true : f alse);
  246                    }
  247                    if ( logger.isD ebugEnable d()) {
  248                             logger .debug(" L ower bound : " + lowe r);
  249                             logger .debug(" R eturned va lue: " + c ompare);
  250                    }
  251                    retu rn compare ;
  252           }
  253  
  254           /* *
  255            *  Checks if  a value i s greater  than a low er bound
  256            *  
  257            *  @param lo wer
  258            *              A lower  bound
  259            *  @return T rue if a v alue is gr eater than  a lower b ound. fals e otherwis e
  260            * /
  261           pu blic boole an isGreat erThan(Big Decimal va lue, BigDe cimal lowe r) {
  262                    bool ean compar e = false;
  263                    if ( value != n ull && low er != null ) {
  264                             compar e = value. compareTo( lower) ==  1;
  265                    }
  266                    if ( logger.isD ebugEnable d()) {
  267                             logger .debug(" L ower bound : " + lowe r);
  268                             logger .debug(" R eturned va lue: " + c ompare);
  269                    }
  270                    retu rn compare ;
  271           }
  272  
  273           /*
  274            *  @see gov. va.med.fw. rule.RuleM ethod#isDa teBetween( java.util. Date,
  275            *  java.util .Date, jav a.util.Dat e)
  276            * /
  277           pu blic boole an isDateB etween(Dat e dateToCh eck, Date  lowerDate,  Date uppe rDate) {
  278                    if ( dateToChec k == null)
  279                             return  false;
  280  
  281                    // G et the tim e to check
  282                    long  checkTime  = dateToC heck.getTi me();
  283  
  284                    // C heck the l ower date  if present
  285                    if ( lowerDate  != null) {
  286                             long l owTime = l owerDate.g etTime();
  287                             if (ch eckTime <  lowTime) {
  288                                      return f alse;
  289                             }
  290                    }
  291  
  292                    // C heck the u pper date  is present
  293                    if ( upperDate  != null) {
  294                             long u pperTime =  upperDate .getTime() ;
  295                             if (ch eckTime >  upperTime)  {
  296                                      return f alse;
  297                             }
  298                    }
  299  
  300                    // T he date is  between t he other d ates
  301                    retu rn true;
  302           }
  303  
  304           /* *
  305            *  Checks if  two dates  are of sa me day
  306            *  
  307            *  @return T rue if a d ates are s ame day. f alse other wise
  308            * /
  309           pu blic boole an isSameD ay(Date va lue1, Date  value2) {
  310                    if ( value1 !=  null && va lue2 != nu ll) {
  311                             return  DateUtils .isSameDay (value1, v alue2);
  312                    }
  313                    if ( logger.isD ebugEnable d()) {
  314                             logger .debug(" V alue 1: "  + value1);
  315                             logger .debug(" V alue 2: "  + value2);
  316                    }
  317                    retu rn false;
  318           }
  319  
  320           /* *
  321            *  Checks if  a date is  before th e specific  date
  322            *  
  323            *  @param up per
  324            *              A date t o compare
  325            *  @return T rue if a d ate is bef ore a thre shold. fal se otherwi se
  326            * /
  327           pu blic boole an isBefor e(Date val ue, Date u pper) {
  328  
  329                    bool ean compar e = false;
  330                    if ( value != n ull && upp er != null ) {
  331                             compar e = (value .before(up per) ? tru e : false) ;
  332                    }
  333                    if ( logger.isD ebugEnable d()) {
  334                             logger .debug(" U pper bound : " + uppe r);
  335                             logger .debug(" R eturned va lue: " + c ompare);
  336                    }
  337                    retu rn compare ;
  338           }
  339  
  340           /* *
  341            *  Checks if  a date is  after the  specific  date
  342            *  
  343            *  @param lo wer
  344            *              A date t o compare
  345            *  @return T rue if a d ate is aft er a thres hold. fals e otherwis e
  346            * /
  347           pu blic boole an isAfter (Date valu e, Date lo wer) {
  348  
  349                    bool ean compar e = false;
  350                    if ( value != n ull && low er != null ) {
  351                             compar e = (value .after(low er) ? true  : false);
  352                    }
  353                    if ( logger.isD ebugEnable d()) {
  354                             logger .debug(" U pper bound : " + lowe r);
  355                             logger .debug(" R eturned va lue: " + c ompare);
  356                    }
  357                    retu rn compare ;
  358           }
  359  
  360           pu blic Date  toDate(Str ing value)  throws Pa rseExcepti on {
  361                    Vali date.notNu ll(value,  "A date st ring must  not be NUL L");
  362                    Date  parsed =  toDate(val ue, Simple DateFormat .SHORT);
  363                    if ( logger.isD ebugEnable d()) {
  364                             logger .debug(" I nput date  string: "  + value);
  365                             logger .debug(" P arsed date : " + pars ed);
  366                    }
  367                    retu rn parsed;
  368           }
  369  
  370           pu blic Date  toDate(Str ing value,  int patte rn) throws  ParseExce ption {
  371                    Vali date.notNu ll(value,  "A date st ring must  not be NUL L");
  372                    Date  parsed =  SimpleDate Format.get DateInstan ce(pattern ).parse(va lue);
  373                    if ( logger.isD ebugEnable d()) {
  374                             logger .debug(" I nput date  string: "  + value);
  375                             logger .debug(" P arsed date : " + pars ed);
  376                    }
  377                    retu rn parsed;
  378           }
  379  
  380           pu blic Date  getCurrent Date() {
  381                    Date  current =  Calendar. getInstanc e().getTim e();
  382                    if ( logger.isD ebugEnable d()) {
  383                             logger .debug(" T he current  date: " +  current);
  384                    }
  385                    retu rn current ;
  386           }
  387  
  388           pu blic Strin g getLogge dInUser()  {
  389                    Secu rityContex t security Context =  SecurityCo ntextHelpe r.getSecur ityContext ();
  390                    retu rn (securi tyContext  != null) ?  securityC ontext.get UserName()  : null;
  391           }
  392  
  393           /* *
  394            *  Returns t he collect ion size.  0 if a col lection is  null.
  395            *  
  396            *  @param co llection
  397            *              A collec tion to ge t a size
  398            *  @return 0  if a coll ection is  null. Othe rwise, a s ize() is c alled
  399            * /
  400           pu blic int g etSize(Col lection co llection)  {
  401                    retu rn collect ion == nul l ? 0 : co llection.s ize();
  402           }
  403  
  404           /* *
  405            *  Converts  a date to  a calendar  using the  specific  timezone.
  406            *  
  407            *  @param da te
  408            *              A date t o convert  to calenda r
  409            *  @return C alendar A  calender f or the spe cific date
  410            *  @throws I llegalArgu mentExcept ion
  411            *               Thrown  if missing  required  date
  412            * /
  413           pu blic Calen dar toCale ndar(Date  date, Time Zone timez one) {
  414  
  415                    Vali date.notNu ll(date, " A date obj ect must n ot be NULL ");
  416  
  417                    Cale ndar calen dar = Cale ndar.getIn stance();
  418                    if ( timezone = = null) {
  419                             // Set  a default  time zone
  420                             calend ar.setTime Zone(TimeZ one.getTim eZone("GMT "));
  421                    } el se {
  422                             calend ar.setTime Zone(timez one);
  423                    }
  424                    cale ndar.setTi me(date);
  425                    cale ndar.set(C alendar.HO UR_OF_DAY,  0);
  426                    cale ndar.set(C alendar.MI NUTE, 0);
  427                    cale ndar.set(C alendar.SE COND, 0);
  428                    cale ndar.set(C alendar.MI LLISECOND,  0);
  429  
  430                    retu rn calenda r;
  431           }
  432  
  433           /* *
  434            *  Converts  a date to  a calendar  using the  default s ystem time zone.
  435            *  
  436            *  @param da te
  437            *              A date t o convert  to calenda r
  438            *  @return C alendar A  calender f or the spe cific date
  439            *  @throws I llegalArgu mentExcept ion
  440            *               Thrown  if missing  required  date
  441            * /
  442           pu blic Calen dar toCale ndar(Date  date) {
  443                    retu rn toCalen dar(date,  null);
  444           }
  445  
  446           /* *
  447            *  Converts  a Number t o an Integ er
  448            *  
  449            *  @see gov. va.med.fw. rule.RuleM ethod#toIn teger(java .lang.Numb er)
  450            * /
  451           pu blic Integ er toInteg er(Number  value) {
  452  
  453                    int  converted  = (value ! = null ? v alue.intVa lue() : 0) ;
  454                    retu rn toInteg er(convert ed);
  455           }
  456  
  457           /* *
  458            *  Converts  a Number t o an Integ er
  459            *  
  460            *  @see gov. va.med.fw. rule.RuleM ethod#toIn teger(java .lang.Numb er)
  461            * /
  462           pu blic Integ er toInteg er(int val ue) {
  463                    Inte ger conver ted = new  Integer(va lue);
  464                    retu rn convert ed;
  465           }
  466  
  467           /* *
  468            *  Throws an  IllegalAr gumentExce ption exce ption if a  field is  not a vali d
  469            *  Calendar  field.
  470            *  
  471            *  @param fi eld
  472            *              A valid  calendar f ield
  473            *  @param me ssage
  474            *              An excep tion messa ge
  475            * /
  476           pr otected vo id checkCa lendarFiel d(int fiel d, String  message) t hrows Rule Exception  {
  477                    if ( field != C alendar.SE COND && fi eld != Cal endar.MINU TE && fiel d != Calen dar.HOUR
  478                                      && field  != Calend ar.DATE &&  field !=  Calendar.M ONTH && fi eld != Cal endar.YEAR ) {
  479                             throw  new RuleEx ception(me ssage);
  480                    }
  481           }
  482   }