18. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 3/24/2017 5:17:18 PM 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.

18.1 Files compared

# Location File Last Modified
1 MHV_2017.2.0.0 Code In Flight.zip\National Portal\mhv_rxrefill\mhv-rx-refill-portal-main\src\main\java\gov\va\med\domain\model\validation BaseRawVO.java Thu Feb 11 17:10:22 2016 UTC
2 MHV_2017.2.0.0 Code In Flight.zip\National Portal\mhv_rxrefill\mhv-rx-refill-portal-main\src\main\java\gov\va\med\domain\model\validation BaseRawVO.java Fri Mar 24 20:30:22 2017 UTC

18.2 Comparison summary

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

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

18.4 Active regular expressions

No regular expressions were active.

18.5 Comparison detail

  1   package go v.va.med.d omain.mode l.validati on;
  2  
  3   import jav a.text.Par seExceptio n;
  4   import jav a.text.Sim pleDateFor mat;
  5   import jav a.util.Arr ayList;
  6   import jav a.util.Dat e;
  7   import jav a.util.Lis t;
  8  
  9   import gov .va.med.do main.model .DtoListPa yload;
  10   import gov .va.med.fr amework.be an.Abstrac tVO;
  11  
  12   /**
  13    * Supercl ass for Ra w Value Ob jects that  can valid ate and bu ild a targ et DTO.
  14    * Subclas ses are wr itten to p opulate a  DtoListPay load with  either 
  15    * a valid  DTO or an  errant DT O with ass ociated er rors in th e buildAnd Validate m ethod.   
  16    * <P>
  17    * These o bjects gen erally con tain untyp ed values  against wh ich busine ss rules
  18    * are app lied inclu ding but n ot limited  to:
  19    * <UL>
  20    * <LI>typ e/conversi on checks
  21    * <LI>req uired fiel d checks
  22    * <LI>ref erantial f ield check s
  23    * <LI>val ue in rang e or enume rated list  checks
  24    * <LI>etc
  25    * </UL>
  26    * 
  27    * @author   PII
  28    * @versio n $Id: Bas eRawVO.jav a,v 1.5 20 05/09/16 2 1:43:08 ye .jin Exp $
  29    * @since  MHV 2.0 <b r>
  30    *         Jul 2, 200 5
  31    */
  32   public abs tract clas s BaseRawV O extends  AbstractVO  {
  33  
  34       List e rrors;
  35  
  36       /**
  37        * Sub classes do  not need  to overrid e this meh tod. 
  38        * It  is a templ ate method  for the m ain proces sing for a ll subclas ses.
  39        * <P>
  40        * It  provides c onsistent  handling o f the DtoL istPayload  and calls  out to <B R>
  41        * fin er-grained  methods t o create,  populate a nd validat e the DTO.  
  42        * The  result of  this meth od is:
  43        * <OL >
  44        * <LI >A new DTO  is bulit
  45        * <LI >If the ne w DTO has  validation  errors it  is added  to the
  46        * Dto ListPayloa d's errors  with the  DTO as the  key and t he resulti ng error
  47        * lis t as the v alue. fals e is then  returned
  48        * <LI >If the DT O is valid , it is ad ded to the  to the Dt oListPaylo ad's dtos
  49        * lis t true is  then retur ned
  50        * </O L>
  51        * 
  52        * @pa ram dtoLis t
  53        *             th e list to  be populat ed with ei ther a val id or erra nt dto
  54        * @re turn true  is valid,   false if  an error w as detecte d
  55        */
  56       public  boolean b uildAndVal idate(DtoL istPayload  dtoList)  {
  57           
  58           Ob ject dto =  createDto ();
  59           po pulateAndV alidate(dt o);
  60           
  61           if  (!hasErro rs()) {
  62                dtoList. addDto(dto );
  63                return t rue;
  64           }
  65           
  66           dt oList.addE rrorList(d to, getErr ors());
  67           se tErrors(ne w ArrayLis t());
  68           re turn false ;
  69       }
  70  
  71       /**
  72        * Cre ates the i nstance of  the targe t DTO to b e populate d
  73        * 
  74        * @re turn a new  instance  of the tar get of thi s RawVO
  75        */
  76       public  abstract  Object cre ateDto();
  77  
  78       /**
  79        * Che cks variab les in thi s RawVO an d moves, c onverts th em as dict ated by
  80        * the  business  rules to t he target  Dto passed  in.
  81        * <P>
  82        * If  any of the  fields vi olate busi ness rules , error ob jects of t ype
  83        * Val idationErr or are add ed to the  the errors  variable.  
  84        * <P>
  85        * Hel per conver sions and  validation  methods a re provide d for comm on
  86        * con versions a nd validat ions.  
  87        * 
  88        * @pa ram dto th e target o bject to p opulate
  89        */
  90       public  abstract  void popul ateAndVali date(Objec t dto);
  91  
  92       /**
  93        * Ret urns a Dat e from the  value pas sed if val id.  
  94        * If  invalid, a dds Invali d date err or and ret urns null.
  95        * 
  96        * @pa ram value  to be vali dated and  converted
  97        * @pa ram fieldN ame name t o use if a n error oc curs
  98        * @re turn conve rted Date
  99        */
  100       public  Date vali dateDate(S tring valu e, String  fieldName)  {
  101           tr y {
  102                return s tringToDat e(value); 
  103           } 
  104           ca tch (Parse Exception  e) {
  105                addError (Validatio nError.INV ALID_DATE_ ERROR, fie ldName, va lue);
  106                return n ull;
  107           }
  108       }
  109       /**
  110        * Ret urns an In teger from  the value  passed if  valid.  
  111        * If  invalid, a dds invali d number e rror and r eturns nul l.
  112        * 
  113        * @pa ram value  to be vali dated and  converted
  114        * @pa ram fieldN ame name t o use if a n error oc curs
  115        * @re turn conve rted Integ er
  116        */
  117       public  Integer v alidateInt eger(Strin g value, S tring fiel dName){
  118           tr y {
  119                return s tringToInt eger(value ); 
  120           } 
  121           ca tch (Excep tion e) {
  122                addError (Validatio nError.INV ALID_NUMBE R_ERROR, f ieldName,  value);
  123                return n ull;
  124           }
  125       }
  126       
  127       /**
  128        * Ret urns an Fl oat from t he value p assed if v alid.  
  129        * If  invalid, a dds invali d number e rror and r eturns nul l.
  130        * 
  131        * @pa ram value  to be vali dated and  converted
  132        * @pa ram fieldN ame name t o use if a n error oc curs
  133        * @re turn conve rted Integ er
  134        */
  135       public  Float val idateFloat (String va lue, Strin g fieldNam e){
  136           tr y {
  137                    if ( isNull(val ue)) {
  138                    retu rn null;
  139                }
  140                return n ew Float(v alue);
  141                    
  142                
  143           } 
  144           ca tch (Excep tion e) {
  145                addError (Validatio nError.INV ALID_NUMBE R_ERROR, f ieldName,  value);
  146                return n ull;
  147           }
  148       }
  149       /**
  150        * Sam e as valid ateInteger  but first  checks to  see if no t null or  "empty".
  151        * If  null, adds  missing f ield error  and retur ns null.
  152        * 
  153        * @pa ram value  to be vali dated and  converted
  154        * @pa ram fieldN ame name t o use if a n error oc curs
  155        * @re turn conve rted Integ er
  156        */
  157       public  Integer v alidateNon NullIntege r(String v alue, Stri ng fieldNa me) {
  158           if  (validate NotNull(va lue, field Name) == n ull) {
  159                return n ull;
  160           }        
  161           re turn valid ateInteger (value, fi eldName);
  162       }
  163       
  164       
  165       /**
  166        * Sam e as valid ateInteger  but first  checks to  see if no t null or  "empty".
  167        * If  null, adds  missing f ield error  and retur ns null.
  168        * 
  169        * @pa ram value  to be vali dated and  converted
  170        * @pa ram fieldN ame name t o use if a n error oc curs
  171        * @re turn conve rted Integ er
  172        */
  173       public  Float val idateNonNu llFloat(St ring value , String f ieldName)  {
  174           if  (validate NotNull(va lue, field Name) == n ull) {
  175                return n ull;
  176           }        
  177           re turn valid ateFloat(v alue, fiel dName);
  178       }
  179       /**
  180        * Sam e as valid ateDate bu t first ch ecks to se e if not n ull or "em pty".
  181        * If  null, adds  missing f ield error  and retur ns null.
  182        * 
  183        * @pa ram value  to be vali dated and  converted
  184        * @pa ram fieldN ame name t o use if a n error oc curs
  185        * @re turn conve rted Date
  186        */
  187       public  Date vali dateNonNul lDate(Stri ng value,  String fie ldName) {
  188           if  (validate NotNull(va lue, field Name) == n ull) {
  189                return n ull;
  190           }        
  191           re turn valid ateDate(va lue, field Name);
  192       }
  193  
  194       /**
  195        * Che cks if nul l or "empt y" value a nd adds a  missing fi eld error 
  196        * or  the value  passed in  if not.  
  197        * 
  198        * @pa ram value  to be vali dated and  converted
  199        * @pa ram fieldN ame name t o use if a n error oc curs
  200        * @re turn conve rted Integ er
  201        */
  202       public  String va lidateNotN ull(String  value, St ring field Name){
  203           if  (isNull(v alue)) {
  204                addError (Validatio nError.MIS SING_FIELD _ERROR, fi eldName);
  205                         return nul l;
  206           }
  207           re turn value ;
  208       }
  209       
  210       /**
  211        * Che cks for nu ll or a lo gically em pty string .
  212        * Cal led by all  methods t hat valida te for nul l. 
  213        * If  your subcl ass has a  diffferent  rule for  this check , override
  214        * thi s method.    
  215        */
  216       public  boolean i sNull(Stri ng value)  {
  217           re turn  valu e==null ||  value.tri m().length ()==0 || v alue.trim( ).equals(" \"\"");
  218       }
  219       
  220       /**
  221        * Con verts the  String to  an Integer  or null i f the valu e is null  or "empty"
  222        * @pa ram rawNum ber the va lue to con vert
  223        * @th rows Numbe rFormatExc eption if  the raw nu mber is no t a valid  integer
  224        */                                    
  225       public  Integer s tringToInt eger(Strin g rawNumbe r) {
  226           if  (exists(r awNumber))  {
  227                return n ull;
  228           }
  229           re turn parse ToInteger( rawNumber) ;
  230       }
  231       
  232       /**
  233        * Con verts the  String to  a Date or  null if th e value is  null or " empty". 
  234        * @pa ram rawDat e the valu e to conve rt
  235        * @th rows Parse Exception  if the raw  date cann ot be conv erted to a  valid Dat e
  236        */      
  237       public  Date stri ngToDate(S tring rawD ate) throw s ParseExc eption {
  238           if  (exists(r awDate)) {
  239                return n ull;
  240           }
  241           re turn parse ToDate(raw Date);
  242       }
  243       
  244       public  Integer p arseToInte ger(String  value) {
  245           re turn new I nteger(val ue);
  246       }
  247       
  248       public  Date pars eToDate(St ring value ) throws P arseExcept ion {
  249           Si mpleDateFo rmat sdf =  new Simpl eDateForma t("yyyyMMd d");
  250           re turn sdf.p arse(value );
  251       }
  252       
  253       /**
  254        * Use d to decid e if field  value is  usable for  field con version.
  255        * By  Default, u ses isNull () but can  be overri dden. 
  256        */
  257       public  boolean e xists(Stri ng value)  {
  258           re turn isNul l(value);
  259       }
  260  
  261       /**
  262        * Con venience m ethod to a dd an erro r to the e rrors list
  263        * @pa ram key th e error ke y
  264        * @pa ram fieldN ame the er rant field  name
  265        */
  266       public  void addE rror(Strin g key, Str ing fieldN ame) {
  267               addError( key, field Name, null );
  268       }
  269       
  270       /**
  271        * Con venience m ethod to a dd an erro r to the e rrors list
  272        * @pa ram key th e error ke y
  273        * @pa ram fieldN ame the er rant field  name
  274        * @pa ram value  the errant  value add ed a entry  in the er ror's Para meters
  275        */
  276       public  void addE rror(Strin g key, Str ing fieldN ame, Strin g value) {
  277                Validati onError er ror = new  Validation Error();
  278                error.se tFieldName (fieldName );
  279                error.se tErrorKey( key);
  280                if (valu e != null)  {
  281                         error.setP arameters( new Object [] {value} );
  282                }
  283                getError s().add(er ror);
  284       }
  285       
  286       public  boolean h asErrors()  {
  287           re turn !getE rrors().is Empty();
  288       }
  289       
  290       public  List getE rrors() {
  291           if  (errors = = null) {
  292                errors =  new Array List();
  293           }
  294           re turn error s;
  295       }
  296  
  297       public  void setE rrors(List  errors) {
  298           th is.errors  = errors;
  299       }
  300   }