Exemplo n.º 1
0
 public FacetResult(AbstractResultSearch<?> result, String field) {
   terms = new ArrayList<FacetFieldItem>();
   FacetList facetList = result.getFacetList();
   fieldName = field;
   for (FacetItem facet : facetList.getByField(field.trim()))
     terms.add(new FacetFieldItem(facet.getCount(), facet.getTerm()));
 }
 @Command
 public void onExportReport() throws SearchLibException, IOException {
   PrintWriter pw = null;
   try {
     File tempFile = File.createTempFile("OSS_Query_Reports", "csv");
     pw = new PrintWriter(tempFile);
     for (FacetItem facetItem : reportSet) {
       pw.print('"');
       pw.print(facetItem.getTerm().replaceAll("\"", "\"\""));
       pw.print('"');
       pw.print(',');
       pw.println(facetItem.getCount());
     }
     pw.close();
     pw = null;
     Filedownload.save(
         new FileInputStream(tempFile), "text/csv; charset-UTF-8", "OSS_Query_Reports.csv");
   } finally {
     IOUtils.close(pw);
   }
 }