4276. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 6/9/2017 3:51:25 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.

4276.1 Files compared

# Location File Last Modified
1 Fri Jun 9 19:51:25 2017 UTC
2 eHealth_Exch (eHealth Exchange Enhancements) Build 3 docs & code_May_2017.zip\VAP_CIF_CODE0502.zip\VAP_CIF_CODE0502\VAP_CIF_CODE0502\nvap-web\src\main\java\gov\va\nvap\web\dao UserDocumentDAO.java Fri Apr 21 20:03:30 2017 UTC

4276.2 Comparison summary

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

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

4276.4 Active regular expressions

No regular expressions were active.

4276.5 Comparison detail

        1   package go v.va.nvap. web.dao;
        2  
        3   import gov .va.nvap.s vc.consent mgmt.jpa.e xceptions. Nonexisten tEntityExc eption;
        4   import gov .va.nvap.s vc.consent mgmt.jpa.e xceptions. Preexistin gEntityExc eption;
        5   import gov .va.nvap.w eb.user.do cument.Use rDocument;
        6   import jav a.util.Arr ayList;
        7   import jav a.util.Cal endar;
        8  
        9   import jav a.util.Col lection;
        10   import jav a.util.Dat e;
        11   import jav a.util.Has hMap;
        12   import jav a.util.Lis t;
        13   import jav a.util.log ging.Level ;
        14   import jav a.util.log ging.Logge r;
        15  
        16   import jav ax.persist ence.Entit yManager;
        17   import jav ax.persist ence.Entit yNotFoundE xception;
        18   import jav ax.persist ence.Persi stenceCont ext;
        19   import jav ax.persist ence.Query ;
        20   import org .springfra mework.tra nsaction.a nnotation. Transactio nal;
        21  
        22   /**
        23    *
        24    * @author  Zack Pete rson
        25    */
        26   public cla ss UserDoc umentDAO {
        27  
        28           @P ersistence Context
        29           pr ivate Enti tyManager  em;
        30  
        31       /**
        32        * Set  the entit y manager  (Injected  by Spring) .
        33        * @pa ram em
        34        */
        35       public  void setE ntityManag er(final E ntityManag er em) {
        36           th is.em = em ;
        37       }
        38  
        39       @Trans actional
        40           pu blic void  create(fin al UserDoc ument user Document)
        41                             throws  Preexisti ngEntityEx ception, E xception {
        42                    try  {
        43                             this.e m.persist( userDocume nt);
        44                    } ca tch (final  Exception  ex) {
        45                             if (th is.findUse rDocument( userDocume nt.getDocu mentId())  != null) {
        46                                      throw ne w Preexist ingEntityE xception(" UserDocume nt "
        47                                                       +  userDocume nt + " alr eady exist s.", ex);
        48                             }
        49                             throw  ex;
        50                    }
        51           }
        52  
        53       @Trans actional
        54           pu blic void  destroy(fi nal Long i d) throws  Nonexisten tEntityExc eption {
        55                    User Document u serDocumen t;
        56                    try  {
        57                             userDo cument = t his.em.get Reference(
        58                                               UserDocume nt.class,  id);
        59                             userDo cument.get DocumentId ();
        60                    } ca tch (final  EntityNot FoundExcep tion enfe)  {
        61                             throw  new Nonexi stentEntit yException ("The user Document w ith id "
        62                                               + id + " n o longer e xists.", e nfe);
        63                    }
        64                    this .em.remove (userDocum ent);
        65           }
        66  
        67       @Trans actional
        68           pu blic void  edit(UserD ocument us erDocument )
        69                             throws  Nonexiste ntEntityEx ception, E xception {
        70                    try  {
        71                             this.e m.merge(us erDocument );
        72                    } ca tch (final  Exception  ex) {
        73                             final  String msg  = ex.getL ocalizedMe ssage();
        74                             if ((m sg == null ) || (msg. length() = = 0)) {
        75                                      final Lo ng id = us erDocument .getDocume ntId();
        76                                      if (this .findUserD ocument(id ) == null)  {
        77                                               throw new  Nonexisten tEntityExc eption(
        78                                                                "The  userDocum ent with i d " + id
        79                                                                                  + " no l onger exis ts.");
        80                                      }
        81                             }
        82                             throw  ex;
        83                    }
        84           }
        85       
        86       @Trans actional
        87       public  void remo veUserDocu ments() {
        88           Ca lendar cal  = Calenda r.getInsta nce();
        89           ca l.add(Cale ndar.MONTH , -1);
        90           Da te expired Date = cal .getTime() ;
        91           
        92           fi nal Query  q = this.e m.createNa medQuery(" UserDocume nt.findByB eforeDate" );
        93           q. setParamet er("cutoff Date", exp iredDate);
        94           
        95           Ar rayList<Us erDocument > docs = ( ArrayList< UserDocume nt>)q.getR esultList( );
        96           
        97           fo r (UserDoc ument doc  : docs) {
        98                this.em. remove(doc );
        99           }
        100           Lo gger.getLo gger(UserD ocumentDAO .class.get Name()).lo g(Level.IN FO, "Sched uled expor ts created  before "  + expiredD ate.toLoca leString()  + " remov ed.");
        101       }
        102  
        103           pu blic UserD ocument fi ndUserDocu ment(final  Long id)  {
        104                    retu rn this.em .find(User Document.c lass, id);
        105           }
        106  
        107           pr ivate List <UserDocum ent> findU serDocumen tEntities(
        108                             final  boolean al l, final i nt maxResu lts, final  int first Result) {
        109                    fina l Query q  = this.em
        110                                      .createN amedQuery( "UserDocum ent.findAl l");
        111                    if ( !all) {
        112                             q.setM axResults( maxResults );
        113                             q.setF irstResult (firstResu lt);
        114                    }
        115                    retu rn q.getRe sultList() ;
        116           }
        117  
        118           pu blic List< UserDocume nt> findUs erDocument Entities(
        119                             final  EntityMana ger em) {
        120                    retu rn this.fi ndUserDocu mentEntiti es(true, - 1, -1);
        121           }
        122  
        123           pu blic List< UserDocume nt> findUs erDocument Entities(
        124                             final  int maxRes ults, fina l int firs tResult) {
        125                    retu rn this.fi ndUserDocu mentEntiti es(false,  maxResults , firstRes ult);
        126           }
        127  
        128           pu blic HashM ap findByU serId(fina l String u serId, fin al String  sortBy, St ring sortO rder, fina l Integer  maxRows, f inal Integ er startRo w) {
        129  
        130           St ring query  = "SELECT  d FROM Us erDocument  d WHERE d .userId =  :userId";
        131           St ring count Query = "S ELECT COUN T(d.docume ntId) FROM  UserDocum ent d WHER E d.userId  = :userId ";
        132           St ring query Params = " ";
        133           In teger sort  = sortBy. isEmpty()  ? 1 : Inte ger.parseI nt(sortBy) ;
        134           
        135           sw itch (sort ) {
        136                case 0:
        137                    quer yParams +=  " ORDER B Y d.title" ;
        138                    brea k;
        139                case 1:
        140                    quer yParams +=  " ORDER B Y d.format ";
        141                    brea k;
        142                case 2: 
        143                    quer yParams +=  " ORDER B Y d.creati onDate";
        144                    brea k; 
        145                case 3: 
        146                    quer yParams +=  " ORDER B Y d.status ";
        147                    brea k; 
        148                default:
        149                    quer yParams +=  " ORDER B Y d.creati onDate";
        150                    brea k;
        151           }
        152           
        153           so rtOrder =  sortOrder. isEmpty()  ? " DESC"  : " " + so rtOrder;
        154           qu eryParams  = queryPar ams + sort Order;
        155  
        156           qu ery = quer y + queryP arams;
        157           Qu ery q = em .createQue ry(query). setFirstRe sult(start Row);
        158  
        159           if ( maxRows  != -1 ) // set the ma x rows if  we have it
        160           {
        161                q.setMax Results(ma xRows);
        162           } 
        163           
        164                    q.se tParameter ("userId",  userId);
        165           
        166           Qu ery cq = e m.createQu ery(countQ uery);
        167           cq .setParame ter("userI d", userId );
        168           
        169           Ha shMap hm =  new HashM ap();
        170           hm .put("resu lts", (Lis t<UserDocu ment>) q.g etResultLi st());
        171           hm .put("coun t", (Long)  cq.getSin gleResult( ));
        172           
        173           re turn hm;
        174           }
        175  
        176           pu blic Colle ction<User Document>  findByTitl e(
        177                             final  String tit le) {
        178                    fina l Query q  = this.em
        179                                      .createN amedQuery( "UserDocum ent.findBy Title");
        180                    q.se tParameter ("title",  title);
        181                    retu rn q.getRe sultList() ;
        182           }
        183  
        184           pu blic Colle ction<User Document>  findByUser IdAndTitle (
        185                             final  String use rId, final  String ti tle) {
        186                    fina l Query q  = this.em
        187                                      .createN amedQuery( "UserDocum ent.findBy UserIdAndT itle");
        188                    q.se tParameter ("userId",  userId);
        189           q. setParamet er("title" , title);
        190                    retu rn q.getRe sultList() ;
        191           }
        192  
        193       public  UserDocum ent findBy CreationDa te(final D ate date)  {
        194                    fina l Query q  = this.em. createName dQuery("Us erDocument .findByCre ationDate" );
        195                    q.se tParameter ("creation Date", dat e);
        196                    retu rn (UserDo cument) q. getSingleR esult();
        197           }
        198  
        199           pu blic int g etUserDocu mentCount( final Enti tyManager  em) {
        200                    fina l Query q  = em.creat eQuery("se lect count (ud.*) fro m UserDocu ment ud");
        201                    retu rn ((Long)  q.getSing leResult() ).intValue ();
        202           }
        203   }