@Override
 protected long countTotalItems() {
   Integer surveyId = survey.getId();
   int count =
       survey.isWork()
           ? samplingDesignManager.countBySurveyWork(surveyId)
           : samplingDesignManager.countBySurvey(surveyId);
   return count;
 }
  @Override
  protected void execute() throws Throwable {
    if (getTotalItems() > 0) {
      Integer surveyId = survey.getId();
      boolean work = survey.isWork();

      CsvWriter writer = new CsvWriter(outputStream, OpenForisIOUtils.UTF_8, ',', '"');
      SamplingDesignSummaries summaries =
          work
              ? samplingDesignManager.loadBySurveyWork(surveyId)
              : samplingDesignManager.loadBySurvey(surveyId);

      ArrayList<String> colNames = getHeaders();
      writer.writeHeaders(colNames.toArray(new String[0]));

      List<SamplingDesignItem> items = summaries.getRecords();
      for (SamplingDesignItem item : items) {
        writeSummary(writer, item);
        incrementItemsProcessed();
      }
      writer.flush();
    }
  }