SHARE
TWEET

Untitled

a guest Dec 13th, 2018 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public void exportData() throws IOException {
  2.  
  3.     FacesContext facesContext = FacesContext.getCurrentInstance();
  4.     ExternalContext externalContext = facesContext.getExternalContext();
  5.     externalContext.setResponseContentType("text/csv");
  6.     externalContext.setResponseHeader("Content-Disposition", "attachment; filename="all_files.csv"");
  7.  
  8.     OutputStream out = externalContext.getResponseOutputStream();
  9.     Writer writer = new OutputStreamWriter(out);
  10.  
  11.     String sql = "SELECT"
  12.             + "     job_class_cd "JOB CLASS","
  13.             + "     pay_grade "PAY GRADE","
  14.             + "     job_class_title,"
  15.             + "     mou,"
  16.             + "     mou_description,"
  17.             + "     nvl(REGEXP_REPLACE(minimum_annual, '\.[0-9]*', ''), ' ') "MINIMUM ANNUAL","
  18.             + "     nvl(REGEXP_REPLACE(maximum_annual, '\.[0-9]*', ''), ' ') "MAXIMUM ANNUAL","
  19.             + "     nvl(salary_range || CASE WHEN min_step IS NULL THEN '' ELSE ' ('  || to_char(MIN_STEP) || ')' END, ' ') "SALARY RANGE (MIN STEP)","
  20.             + "     nvl(rate_type, ' ') "RATE TYPE","
  21.             + "     nvl(flat_rate, ' ') "FLAT RATE","
  22.             + "     nvl(per_event_rate, ' ') "PER EVENT RATE","
  23.             + "     step_1,"
  24.             + "     step_2,"
  25.             + "     step_3,"
  26.             + "     step_4,"
  27.             + "     step_5,"
  28.             + "     step_6,"
  29.             + "     step_7,"
  30.             + "     step_8,"
  31.             + "     step_9,"
  32.             + "     step_10,"
  33.             + "     step_11,"
  34.             + "     step_12,"
  35.             + "     step_13,"
  36.             + "     step_14,"
  37.             + "     step_15"
  38.             + " FROM myApp.st_s_spay"
  39.             + "       ORDER BY job_class_title, job_class_cd, pay_grade, rate_type desc";
  40.  
  41.     // MARK: CSV content header
  42.     try {
  43.  
  44.         writer.write("JOB CLASS,PAY GRADE,JOB_CLASS_TITLE");
  45.         writer.write("PAY GRADE, JOB_CLASS_TITLE");
  46.         writer.write(", MOU,MOU_DESCRIPTION");
  47.         writer.write(", MINIMUM ANNUAL,MAXIMUM ANNUAL");
  48.         writer.write(", SALARY RANGE, RATE TYPE");
  49.         writer.write(", FLAT RATE, PER EVENT RATE");
  50.         writer.write(",STEP_1, STEP_2");
  51.         writer.write(",STEP_3, STEP_4");
  52.         writer.write(",STEP_5, STEP_6");
  53.         writer.write(",STEP_7, STEP_8");
  54.         writer.write(",STEP_9, STEP_10");
  55.         writer.write(",STEP_11, STEP_12");
  56.         writer.write(",STEP_13, STEP_14");
  57.         writer.write(",STEP_15");
  58.  
  59.     } finally {
  60.         if (writer != null) {
  61.  
  62.             // MARK: Close and flush the  OutputStream
  63.             writer.close();
  64.         }
  65.     }
  66.  
  67.     facesContext.responseComplete();
  68. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top