Exemplo n.º 1
0
  public SheetDiff determineChanges(SheetDiff sheetDiff) {
    // 559deb3dd4c6da20f74e6fc0-559deb3dd4c6da20f74e6fc0
    Sheet baseSheet = sheetDAO.find(sheetDiff.getBaseSheetId(), false);
    Sheet compareSheet = sheetDAO.find(sheetDiff.getCompareSheetId(), true);

    String[][] baseData = baseSheet.getData();
    String[][] compareData = compareSheet.getData();

    List<String[]> changeSet = new ArrayList<String[]>();
    int rowCount = (baseData.length > compareData.length) ? compareData.length : baseData.length;
    int colCount = baseData[0].length;

    for (int row = 0; row < rowCount; row++) {
      for (int col = 0; col < colCount; col++) {
        if (!baseData[row][col].equals(compareData[row][col])) {
          changeSet.add(new String[] {row + "", col + "", compareData[row][col], DIFF_EDIT});
        }
      }
    }

    if (baseData.length > compareData.length) {
      changeSet.add(
          new String[] {
            "[" + (compareData.length + 1) + "," + baseData.length + "]", "-1", "", DIFF_ADD
          });
    } else if (baseData.length < compareData.length) {
      changeSet.add(
          new String[] {
            "[" + (baseData.length + 1) + "," + compareData.length + "]", "-1", "", DIFF_DELETE
          });
    }

    sheetDiff.setChangeSet(changeSet);

    return sheetDiff;
  }
Exemplo n.º 2
0
 public String saveSheet(Sheet sheet) {
   System.out.println("hello");
   sheet.setData(Arrays.copyOf(sheet.getData(), sheet.getData().length - 1));
   sheetDAO.save(sheet);
   return null;
 }