3110. EPMO Open Source Coordination Office Redaction File Detail Report

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

3110.1 Files compared

# Location File Last Modified
1 Fri Jun 9 19:49:48 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-client\src\main\java\gov\va\nvap\service\auth ServiceAuditDAO.java Fri Apr 21 20:03:26 2017 UTC

3110.2 Comparison summary

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

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

3110.4 Active regular expressions

No regular expressions were active.

3110.5 Comparison detail

        1   /*
        2    * To chan ge this te mplate, ch oose Tools  | Templat es
        3    * and ope n the temp late in th e editor.
        4    */
        5   package go v.va.nvap. service.au th;
        6  
        7   import jav a.text.Sim pleDateFor mat;
        8   import jav a.util.Arr ayList;
        9   import jav a.util.Dat e;
        10   import jav a.util.Has hMap;
        11   import jav a.util.Lis t;
        12   import jav a.util.Map ;
        13   import jav ax.persist ence.Entit yManager;
        14   import jav ax.persist ence.NoRes ultExcepti on;
        15   import jav ax.persist ence.Persi stenceCont ext;
        16   import jav ax.persist ence.Query ;
        17  
        18   /**
        19    *
        20    * @author  564685
        21    */
        22   public cla ss Service AuditDAO {
        23       @Persi stenceCont ext(name =  "VapEntit yManager")
        24       privat e EntityMa nager em;
        25  
        26       public  void setE ntityManag er(EntityM anager ent ityManager ) {
        27           th is.em = en tityManage r;
        28       }
        29       public  Long crea te(final S erviceAudi t sa)
        30                throws E xception {
        31           tr y {
        32                this.em. persist(sa );
        33           }  catch (fin al Excepti on ex) {
        34                throw ex ;
        35           }
        36           re turn sa.ge tID();
        37       }
        38  
        39       public  ServiceAu dit findSe rviceAudit (final Lon g id) {
        40           re turn this. em.find(Se rviceAudit .class, id );
        41       }
        42  
        43       public  List<Serv iceAudit>  findServic eAuditByEx ternalServ ice(final  String cn)  {
        44           tr y {
        45                final Qu ery q = th is.em
        46                         .createNam edQuery("S erviceAudi t.findServ iceAuditBy CN");
        47                q.setPar ameter("cn ", cn);
        48                return ( List<Servi ceAudit>)  q.getResul tList();
        49           }  catch (fin al NoResul tException  nre) {
        50                return n ew ArrayLi st<Service Audit>();
        51           }
        52       }
        53       public  List<Serv iceAudit>  findServic eAuditByWe bService(f inal Strin g webservi ce) {
        54           tr y {
        55                final Qu ery q = th is.em
        56                         .createNam edQuery("S erviceAudi t.findServ iceAuditBy WebService ");
        57                q.setPar ameter("we bService",  webservic e);
        58                return ( List<Servi ceAudit>)  q.getResul tList();
        59           }  catch (fin al NoResul tException  nre) {
        60                return n ew ArrayLi st<Service Audit>();
        61           }
        62       }
        63       
        64       public  List<Stri ng> findDi stinctWebS ervices()  {
        65           tr y {
        66                final Qu ery q = th is.em.crea teNamedQue ry("Servic eAudit.fin dDistinctW ebServices ");
        67                
        68                return ( List<Strin g>) q.getR esultList( );
        69           }  catch (fin al NoResul tException  nre) {
        70                return n ew ArrayLi st<String> ();
        71           }
        72       }
        73       
        74       public  List<Stri ng> findDi stinctCall sByWebServ ice(final  String web Service) {
        75           tr y {
        76                final Qu ery q = th is.em.crea teNamedQue ry("Servic eAudit.fin dDistinctC allByWebSe rvice");
        77                q.setPar ameter("we bService",  webServic e);
        78                
        79                return ( List<Strin g>) q.getR esultList( );            
        80           }  catch (fin al NoResul tException  nre) {
        81                return n ew ArrayLi st<String> ();
        82           }
        83       }
        84       
        85       public  HashMap g etServiceA uditByWebS erviceAndC all(final  String web Service, f inal Strin g method,  final Stri ng authori zed, final  String su ccess, fin al String  duration,  final Stri ng startDa te, final  String end Date, fina l Integer  maxRows, f inal Integ er startRo w, String  sortBy, St ring sortO rder) {
        86           tr y {
        87                String q uery = "SE LECT c FRO M ServiceA udit c WHE RE 1 = 1";
        88                String c ountQuery  = "SELECT  COUNT(c.ID ) FROM Ser viceAudit  c WHERE 1  = 1";
        89                String q ueryParams  = "";
        90                
        91                // build  the query  string
        92                if (webS ervice.equ als("ALL")  && method .equals("A LL")) {
        93                    // d o nothing
        94                } else i f (method. equals("AL L")) {
        95                    quer yParams =  queryParam s + " AND  c.webServi ce = :webS ervice";
        96                } else {
        97                    quer yParams =  queryParam s + " AND  c.webServi ce = :webS ervice AND  c.call =  :method";
        98                }
        99                
        100                if (!aut horized.eq uals("ALL" )) {
        101                    quer yParams =  queryParam s + " AND  c.authoriz ed = :auth orized";
        102                }
        103                
        104                if (!suc cess.equal s("ALL"))  {
        105                    quer yParams =  queryParam s + " AND  c.success  = :success ";
        106                }
        107                
        108                if (!dur ation.equa ls("ALL"))  {
        109                    quer yParams =  queryParam s + " AND  c.duration  > :durati on";
        110                }
        111                
        112                if (star tDate.leng th() != 0  && endDate .length()  != 0) {
        113                    quer yParams =  queryParam s + " AND  eventDate  >= :startD ate AND ev entDate <=  :endDate" ;
        114                } else i f (startDa te.length( ) != 0) {
        115                    quer yParams =  queryParam s + " AND  eventDate  >= :startD ate";
        116                } else i f (endDate .length()  != 0) {
        117                    quer yParams =  queryParam s + " AND  eventDate  <= :endDat e";
        118                }
        119                
        120                //handle  the sort  by and sor t order
        121                Integer  sort = sor tBy.isEmpt y() ? 0 :  Integer.pa rseInt(sor tBy);
        122                sortOrde r = sortOr der.isEmpt y() || "DE SC".equals IgnoreCase (sortOrder ) ? " DESC " : " ASC" ;
        123                queryPar ams += " O RDER BY ";
        124                switch ( sort) {
        125                    case  0: 
        126                         queryParam s += "c.we bService"  + sortOrde r + ", c.c all ASC, c .eventDate  DESC";
        127                         break;
        128                    case  1: 
        129                         queryParam s += "c.ca ll" + sort Order + ",  c.eventDa te DESC";
        130                         break;
        131                    case  2: 
        132                         queryParam s += "c.ev entDate" +  sortOrder ;
        133                         break;
        134                    case  3: 
        135                         queryParam s += "c.ip " + sortOr der + ", c .eventDate  DESC";
        136                         break;
        137                    case  4: 
        138                         queryParam s += "c.cn " + sortOr der + ", c .eventDate  DESC";
        139                         break;
        140                    case  5: 
        141                         queryParam s += "c.au thorized"  + sortOrde r + ", c.e ventDate D ESC";
        142                         break;
        143                    case  6: 
        144                         queryParam s += "c.su ccess" + s ortOrder +  ", c.even tDate DESC ";
        145                         break;
        146                    case  7: 
        147                         queryParam s += "c.du ration" +  sortOrder  + ", c.eve ntDate DES C";
        148                         break;
        149                    defa ult: 
        150                         queryParam s += "c.ev entDate" +  sortOrder ;
        151                         break;
        152                }
        153                
        154                query =  query + qu eryParams;
        155                countQue ry = count Query + qu eryParams;
        156                
        157                Query q  = em.creat eQuery(que ry).setFir stResult(s tartRow).s etMaxResul ts(maxRows );
        158                Query cq  = em.crea teQuery(co untQuery);
        159                
        160                // build  the param eters
        161                if (webS ervice.equ als("ALL")  && method .equals("A LL")) {
        162                    // d o nothing
        163                } else i f (method. equals("AL L")) {
        164                    q.se tParameter ("webServi ce", webSe rvice);
        165                    cq.s etParamete r("webServ ice", webS ervice);
        166                } else {
        167                    q.se tParameter ("webServi ce", webSe rvice);
        168                    q.se tParameter ("method",  method);
        169                    cq.s etParamete r("webServ ice", webS ervice);
        170                    cq.s etParamete r("method" , method);
        171                }
        172                
        173                if (!aut horized.eq uals("ALL" )) {
        174                    q.se tParameter ("authoriz ed", Integ er.parseIn t(authoriz ed));
        175                    cq.s etParamete r("authori zed", Inte ger.parseI nt(authori zed));
        176                }
        177                
        178                if (!suc cess.equal s("ALL"))  {
        179                    q.se tParameter ("success" , Integer. parseInt(s uccess));
        180                    cq.s etParamete r("success ", Integer .parseInt( success));
        181                }
        182                
        183                if (!dur ation.equa ls("ALL"))  {
        184                    q.se tParameter ("duration ", Integer .parseInt( duration)) ;
        185                    cq.s etParamete r("duratio n", Intege r.parseInt (duration) );
        186                }
        187                
        188                if (star tDate.leng th() != 0  && endDate .length()  != 0) {
        189                    try  {
        190                         SimpleDate Format sdF ormatter =  new Simpl eDateForma t("MM/dd/y yyy");
        191                         Date forma ttedStartD ate = sdFo rmatter.pa rse(startD ate);
        192                        
        193                         SimpleDate Format edF ormatter =  new Simpl eDateForma t("MM/dd/y yyy HH:mm: ss");
        194                         Date forma ttedEndDat e = edForm atter.pars e(endDate  + " 23:59: 59");
        195                    
        196                         q.setParam eter("star tDate", fo rmattedSta rtDate);
        197                         q.setParam eter("endD ate", form attedEndDa te);
        198                         cq.setPara meter("sta rtDate", f ormattedSt artDate);
        199                         cq.setPara meter("end Date", for mattedEndD ate);
        200                    } ca tch (Excep tion ex) {
        201                         //can't us e the date  provided,  so don't  use it.
        202                    }
        203                } else i f (startDa te.length( ) != 0) {
        204                    try  {
        205                         SimpleDate Format sdF ormatter =  new Simpl eDateForma t("MM/dd/y yyy");
        206                         Date forma ttedStartD ate = sdFo rmatter.pa rse(startD ate);
        207                    
        208                         q.setParam eter("star tDate", fo rmattedSta rtDate);
        209                         cq.setPara meter("sta rtDate", f ormattedSt artDate);
        210                    } ca tch (Excep tion ex) {
        211                         //can't us e the date  provided,  so don't  use it.
        212                    }
        213                } else i f (endDate .length()  != 0) {
        214                    try  {
        215                         SimpleDate Format edF ormatter =  new Simpl eDateForma t("MM/dd/y yyy HH:mm: ss");
        216                         Date forma ttedEndDat e = edForm atter.pars e(endDate  + " 23:59: 59");
        217                    
        218                         q.setParam eter("endD ate", form attedEndDa te);
        219                         cq.setPara meter("end Date", for mattedEndD ate);
        220                    } ca tch (Excep tion ex) {
        221                         //can't us e the date  provided,  so don't  use it.
        222                    }
        223                }
        224                
        225                HashMap  hm = new H ashMap();
        226                hm.put(" results",  (List<Serv iceAudit>)  q.getResu ltList());
        227                hm.put(" count", (L ong) cq.ge tSingleRes ult());
        228                
        229                return h m;
        230                
        231                //return  (List<Ser viceAudit> ) q.getRes ultList();
        232           }  catch (fin al NoResul tException  nre) {
        233                return n ull;
        234           }
        235       }
        236       
        237       public  List gath erTransact ionCounts( Date start Date, Date  endDate){
        238           St ring query Template =  "SELECT E XTRACT(HOU R FROM c.e ventDate)  AS hourofd ay, "
        239                    + "S UM(CASE WH EN c.call= 'checkPoli cy' THEN 1  ELSE 0 EN D) AS exch angecount,  "
        240                    + "S UM(CASE WH EN c.webSe rvice = 'C onsentMana gementServ icePort' T HEN 1 ELSE  0 END) AS  ebenefits count "
        241                    + "F ROM Servic eAudit c W HERE c.eve ntDate BET WEEN :star tDate AND  :endDate "
        242                    + "G ROUP BY EX TRACT(HOUR  FROM c.ev entDate) "
        243                    + "O RDER BY 1" ;
        244             
        245           Qu ery query  = em.creat eQuery(que ryTemplate );
        246           
        247           qu ery.setPar ameter("st artDate",  startDate) ;
        248           qu ery.setPar ameter("en dDate", en dDate);
        249           
        250           re turn query .getResult List();
        251       }
        252   }