Beispiel #1
0
 /** Adds an item to the list. */
 private void addItem(List<String[]> items, ManualInstrument instrument, Type type)
     throws AssertionError {
   items.add(
       new String[] {
         instrument.getQualifiedName(),
         type.toString(),
         instrument.getDescription(),
         TypeUtils.defaultValue(type).toString()
       });
 }
Beispiel #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;
  }