Beispiel #1
0
 public boolean hasData(Company company, GroupEntry ge, Map<String, DataDto> dataLookup) {
   for (FormDisplayCell cell : cells) {
     if (null != cell) {
       if (cell.getCellType().equals(CellType.COPYCELL)
           || cell.getCellType().equals(CellType.INPUT)) {
         DataKey key = new DataKey(cell.getCellContents()); // for
         // data
         // cells
         // getCellContents()
         // is
         // the
         // key.
         key.setCompanyId(company.getId());
         if (null != ge) {
           key.setGroupEntryId(ge.getId());
         }
         if (key.isCg()) {
           key.setCg(false);
           DataDto dto = dataLookup.get(key.getKey(true));
           if (null != dto && !dto.getConfidenceGrade().isEmpty()) {
             return true;
           }
         } else {
           DataDto dto = dataLookup.get(key.getKey(true));
           if (null != dto && !dto.getValue().isEmpty()) {
             return true;
           }
         }
       }
     }
   }
   return false;
 }
Beispiel #2
0
 public boolean hasCalcCells() {
   for (FormDisplayCell cell : cells) {
     if (null != cell) {
       if (cell.getCellType().equals(CellType.CALC)) {
         return true;
       }
     }
   }
   return false;
 }
Beispiel #3
0
 public boolean hasDataCells() {
   for (FormDisplayCell cell : cells) {
     if (null != cell) {
       if (cell.getCellType().equals(CellType.COPYCELL)
           || cell.getCellType().equals(CellType.INPUT)) {
         return true;
       }
     }
   }
   return false;
 }
Beispiel #4
0
 public boolean newSection(Row row, PageSection nextSection) {
   for (PageForm form : nextSection.getPageForms()) {
     FormDisplayCell[][] cellGrid = form.getCellGrid();
     for (FormDisplayCell[] line : cellGrid) {
       int colIdx = 0;
       for (FormDisplayCell cell : line) {
         if (null != cell) {
           //							System.out.println("Model: '" + cell.getCellContents() + "' Spreadsheet: '" +
           // row.getCell(colIdx) + "'");
           switch (cell.getCellType()) {
             case EMPTY:
               colIdx++;
               break;
             case COL_HEADING:
               Cell spreadsheetCell = row.getCell(colIdx);
               // Check that the spreadsheet cell content is the same as the model.
               if (null == spreadsheetCell) {
                 // The spreadsheetCell can be null as long as there is nothing in the model cell.
                 if (!cell.getCellContents().isEmpty()) {
                   return false;
                 }
               } else {
                 try {
                   if (!cell.getCellContents().equals(spreadsheetCell.getStringCellValue())) {
                     // The next section and the current row are not the same.
                     //												System.out.println("Not a new section");
                     return false;
                   }
                 } catch (Exception e) {
                   //											System.out.println("Not a new section (not a String cell)");
                   return false;
                 }
               }
               colIdx++;
               break;
             case ROW_HEADING_NON_REPEAT:
             case ROW_HEADING:
             case CALC:
             case COPYCELL:
             case INPUT:
               colIdx++;
               break;
           }
         }
       }
     }
   }
   System.out.println("Is a new section at row " + row.getRowNum() + 1);
   return true;
 }
Beispiel #5
0
 protected DataKey makeKey(GroupEntry groupEntry, Company company, FormDisplayCell cell) {
   DataKey key = new DataKey(cell.getCellContents()); // for data cells
   // getCellContents()
   // is the key.
   key.setCompanyId(company.getId());
   key.setGroupEntryId(groupEntry.getId());
   return key;
 }
Beispiel #6
0
 public boolean isSectionHeader(Row row) {
   boolean isSectionHeader = true;
   for (FormDisplayCell cell : cells) {
     if (null != cell) {
       switch (cell.getCellType()) {
         case EMPTY:
         case COL_HEADING:
         case ROW_HEADING_NON_REPEAT:
         case ROW_HEADING:
           break;
         case CALC:
         case COPYCELL:
         case INPUT:
           isSectionHeader = false;
           break;
       }
     }
   }
   return isSectionHeader;
 }
Beispiel #7
0
  public void readUnchangableCell(Row row, int cellIdx, FormDisplayCell tableCell, DataDto dto) {
    Cell cell = row.getCell(cellIdx);
    if (null == cell) {
      log.warn(
          "Table import. Table "
              + metaData.getTableName()
              + " Cell at row: "
              + (row.getRowNum() + 1)
              + " col: "
              + (cellIdx + 1)
              + " current value: "
              + dto.getValue()
              + " cell is null.");
    }
    if (cell.getCellType() != Cell.CELL_TYPE_NUMERIC
        && cell.getCellType() != Cell.CELL_TYPE_FORMULA) {
      log.warn(
          "Table import. Table "
              + metaData.getTableName()
              + " Cell at row: "
              + (row.getRowNum() + 1)
              + " col: "
              + (cellIdx + 1)
              + " current value: "
              + dto.getValue()
              + " cell is is not numeric.");
    }

    double editedValue = cell.getNumericCellValue();
    if ("0.00%".equals(cell.getCellStyle().getDataFormatString())) {
      // Percent
      editedValue = editedValue * 100;
    }
    String editedValueString = formatter.formatValueToAtLeastDP(dto, editedValue);

    if (!editedValueString.equals(dto.getValue()) && !editedValueString.isEmpty()) {
      // value has changed so log a warning
      metaData.addWarning(
          row.getRowNum(),
          cellIdx,
          dto.getValue(),
          editedValueString,
          "This is a " + tableCell.getCellType().name() + " cell. It cannot be changed.");
    }
  }