4344. EPMO Open Source Coordination Office Redaction File Detail Report

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

4344.1 Files compared

# Location File Last Modified
1 Fri Jun 9 19:51:30 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\util\xls CsvExporter.java Fri Apr 21 20:03:30 2017 UTC

4344.2 Comparison summary

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

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

4344.4 Active regular expressions

No regular expressions were active.

4344.5 Comparison detail

        1   package go v.va.nvap. web.util.x ls;
        2  
        3   import gov .va.nvap.c ommon.vali dation.Nul lChecker;
        4   import gov .va.nvap.w eb.helper. report.Rep ortHelper;
        5   import jav a.io.IOExc eption;
        6   import jav a.io.Outpu tStream;
        7   import jav a.text.Sim pleDateFor mat;
        8   import jav a.util.Lin kedHashMap ;
        9   import jav a.util.Dat e;
        10   import jav a.util.Lis t;
        11   import jav a.util.Map ;
        12   import jav ax.servlet .http.Http ServletRes ponse;
        13  
        14   /**
        15    *
        16    * @author  Zachary T ubb
        17    */
        18   public cla ss CsvExpo rter {
        19  
        20       Date d ate;
        21       Simple DateFormat  df = new  SimpleDate Format("yy yyMMdd_hhm mss");
        22       String  formatted Date;
        23       
        24       public  void expo rtToCSV(fi nal HttpSe rvletRespo nse respon se, String  reportTyp e, List<Ma p<String,  Object>> r esults,
        25           Li nkedHashMa p<String,  String> re portMap) t hrows IOEx ception {
        26  
        27           Ou tputStream  outputStr eam = null ;
        28           
        29           da te = new D ate();
        30           fo rmattedDat e = df.for mat(date);
        31           
        32           re sponse.set ContentTyp e("text/cs v");
        33           re sponse.set Header("Co ntent-Disp osition",  "attachmen t; filenam e=\""
        34                + report Type + "_"  + formatt edDate + " .csv" + "\ "");
        35  
        36           tr y {
        37                StringBu ilder sbOu tput;
        38                
        39                outputSt ream = res ponse.getO utputStrea m();
        40  
        41                if (Null Checker.is NullOrEmpt y(results) ) {
        42                    sbOu tput = new  StringBui lder();
        43                    sbOu tput.appen d("No reco rds were f ound.");
        44                } else {
        45                    Simp leDateForm at dt = ne w SimpleDa teFormat(" MM/dd/yyyy ");
        46                    // A llocate st ring build er based o n the numb er of rows , but no l arger than  20MB.
        47                    if ( results.si ze() > 100 000) {
        48                         sbOutput =   new Stri ngBuilder( 20000000);
        49                    } el se {
        50                         sbOutput =   new Stri ngBuilder( results.si ze() * 200 );
        51                    }
        52  
        53                    // A ppend colu mn headers
        54                    for  (String he ading : re portMap.ke ySet()) {
        55                         sbOutput.a ppend(head ing);
        56                         sbOutput.a ppend(",") ;
        57                    }
        58                    sbOu tput.appen d("\n");
        59  
        60                    // A ppend repo rt data
        61                    for  (Map<Strin g, Object>  row : res ults) {
        62                         // Create  the row of  data
        63                         String sep arator = " ";
        64                         for (Strin g dataFiel d : report Map.values ()) {
        65                             sbOutp ut.append( separator) ;
        66                             separa tor = ",";
        67                             // Inc lude escap e characte r.
        68                             sbOutp ut.append( "\"");
        69  
        70                             if (Nu llChecker. isNullOrEm pty(row.ge t(dataFiel d))) {
        71                                 sb Output.app end("");
        72                             } else  {
        73                                 if  (dataFiel d.contains ("Date"))  {
        74                                      // Forma t dates. p atientDate Formatted  is an exce ption - co mes pre-fo rmatted
        75                                      if (data Field.equa ls("patien tDateForma tted")) {
        76                                          sbOu tput.appen d(row.get( dataField) );
        77                                      } else {
        78                                          Date  oldDate =  (Date) ro w.get(data Field);
        79                                          sbOu tput.appen d(dt.forma t(oldDate) );
        80                                      }
        81                                 }  else if (d ataField.t oLowerCase ().contain s("oid") & & !NullChe cker.isNul lOrEmpty(r ow.get(dat aField)))  {
        82                                      sbOutput .append(Re portHelper .trimOrgOi d((String) row.get(da taField))) ;
        83                                 }  else {
        84                                      // Else  print the  data as-is .
        85                                      sbOutput .append(ro w.get(data Field));
        86                                 }
        87                             }
        88                             // Inc lude closi ng escape  character.
        89                             sbOutp ut.append( "\"");
        90                         }
        91                         sbOutput.a ppend("\n" );
        92                    }
        93                }
        94  
        95                outputSt ream.write (String.va lueOf(sbOu tput).getB ytes());
        96                
        97                // Blank  out this  string bui lder so no thing is i n memory ( i.e. ssn,  other PII) . Even tho ugh sbOutp ut is scop ed to this  method
        98                // and w ill be des troyed and  set to be  garbage c ollected.
        99                sbOutput .setLength (0);
        100           }  catch (Exc eption e)  {
        101                throw ne w IOExcept ion("Error  exporting  to CSV");
        102           }  finally {
        103                if (outp utStream ! = null) {
        104                    outp utStream.f lush();
        105                    outp utStream.c lose();                  
        106                }
        107           }
        108       }
        109   }