예제 #1
0
 /** Write sheet to file */
 private void writeFile(HSSFSheet sheet) throws ConQATException {
   try {
     getLogger().info("Writing measures to " + file);
     ExcelUtils.writeTo(sheet, new File(file));
   } catch (IOException e) {
     throw new ConQATException("Problems writing target file: " + e.getMessage());
   }
 }
예제 #2
0
  /** {@inheritDoc} */
  @Override
  public String process() throws ConQATException {
    HSSFSheet sheet = ExcelUtils.createSheet();

    printHeader(sheet);

    List<String[]> items = new LinkedList<String[]>();

    for (QualityModel model : models) {

      TreeIterator<EObject> i = model.eAllContents();
      while (i.hasNext()) {
        EObject eObject = i.next();
        if (eObject instanceof ManualInstrument) {
          ManualInstrument instrument = (ManualInstrument) eObject;
          Type type = instrument.getDetermines().getType();
          if (TypeUtils.isPrimitive(type)) {
            addItem(items, instrument, type);
          }
        }
      }
    }

    // sort by qualified names
    Collections.sort(
        items,
        new Comparator<String[]>() {

          @Override
          public int compare(String[] o1, String[] o2) {
            return o1[0].compareTo(o2[0]);
          }
        });

    // write excel file
    int rowNumber = 1;
    for (String[] item : items) {
      HSSFRow row = sheet.createRow(rowNumber);
      for (int i = 0; i < item.length; i++) {
        row.createCell(i).setCellValue(item[i]);
      }
      rowNumber++;
    }

    writeFile(sheet);

    return file;
  }