예제 #1
0
 @Test
 public void nonBlankCell() {
   Row row = new Row(5);
   row.setCell(0, new Cell("I'm not empty", null));
   Assert.assertFalse(row.isCellBlank(0));
   row.setCell(3, new Cell("I'm not empty", null));
   Assert.assertFalse(row.isCellBlank(3));
 }
예제 #2
0
 @Test
 public void toStringTest() {
   Row row = new Row(5);
   row.setCell(0, new Cell(1, null));
   row.setCell(1, new Cell(2, null));
   row.setCell(2, new Cell(3, null));
   row.setCell(3, new Cell(4, null));
   row.setCell(4, new Cell(5, null));
   Assert.assertEquals(row.toString(), "1,2,3,4,5,");
 }
예제 #3
0
 @Test
 public void saveRow() {
   Row row = new Row(5);
   row.setCell(0, new Cell("I'm not empty", null));
   row.save(writer, options);
   Assert.assertEquals(
       writer.getBuffer().toString(),
       "{\"flagged\":false,\"starred\":false,\"cells\":[{\"v\":\"I'm not empty\"}]}");
 }
예제 #4
0
 @Test
 public void saveRowWithRecordIndex() {
   Row row = new Row(5);
   row.setCell(0, new Cell("I'm not empty", null));
   when(options.containsKey("rowIndex")).thenReturn(true);
   when(options.get("rowIndex")).thenReturn(0);
   when(options.containsKey("recordIndex")).thenReturn(true);
   when(options.get("recordIndex")).thenReturn(1);
   row.save(writer, options);
   Assert.assertEquals(
       writer.getBuffer().toString(),
       "{\"flagged\":false,\"starred\":false,\"cells\":[{\"v\":\"I'm not empty\"}],\"i\":0,\"j\":1}");
 }
예제 #5
0
  protected static void addImportRecordToProject(ImportRecord record, Project project) {
    if (record.rows.size() > 0) {
      for (List<Cell> row : record.rows) {
        Row realRow = new Row(row.size());
        int cellCount = 0;

        for (int c = 0; c < row.size(); c++) {
          Cell cell = row.get(c);
          if (cell != null) {
            realRow.setCell(c, cell);
            cellCount++;
          }
        }

        if (cellCount > 0) {
          project.rows.add(realRow);
        }
      }
    }
  }
  protected void extendRow(
      Row row, DataExtension dataExtension, int extensionRowIndex, Map<String, Recon> reconMap) {
    Object[] values = dataExtension.data[extensionRowIndex];
    for (int c = 0; c < values.length; c++) {
      Object value = values[c];
      Cell cell = null;

      if (value instanceof ReconCandidate) {
        ReconCandidate rc = (ReconCandidate) value;
        Recon recon;
        if (reconMap.containsKey(rc.id)) {
          recon = reconMap.get(rc.id);
        } else {

          if (rc.id.equals("")) {
            cell = new Cell(rc.name, null);
          } else {

            recon =
                new DBpediaDataExtensionReconConfig(new DBpediaType(rc.name, rc.id))
                    .createNewRecon(_historyEntryID);
            recon.addCandidate(rc);
            recon.service = "dbpedia-extension";
            recon.match = rc;
            recon.matchRank = 0;
            recon.judgment = Judgment.Matched;
            recon.judgmentAction = "auto";
            recon.judgmentBatchSize = 1;

            reconMap.put(rc.id, recon);
            cell = new Cell(rc.name, recon);
          }
        }

      } else {
        cell = new Cell((Serializable) value, null);
      }

      row.setCell(_firstNewCellIndex + c, cell);
    }
  }
  protected void extendRow(
      Row row, DataExtension dataExtension, int extensionRowIndex, Map<String, Recon> reconMap) {
    Object[] values = dataExtension.data[extensionRowIndex];
    for (int c = 0; c < values.length; c++) {
      Object value = values[c];
      Cell cell = null;

      if (value instanceof ReconCandidate) {
        ReconCandidate rc = (ReconCandidate) value;
        Recon recon;
        if (reconMap.containsKey(rc.id)) {
          recon = reconMap.get(rc.id);
        } else {
          if (rc.id.equals("")) {
            cell = new Cell(rc.name, null);
          } else {
            // TODO: maybe zemanta type will be needed
            // what if there are many types? - preview links?
            // maybe recon fields have to be populated with data from results
            recon = new ZemantaDataExtensionReconConfig().createNewRecon(_historyEntryID);
            recon.addCandidate(rc);
            recon.service = "zemanta";
            recon.match = rc;
            recon.matchRank = 0;
            recon.judgment = Judgment.Matched;
            recon.judgmentAction = "auto";
            recon.judgmentBatchSize = 1;

            reconMap.put(rc.id, recon);
            cell = new Cell(rc.name, recon);
          }
        }
      } else {
        cell = new Cell((Serializable) value, null);
      }

      row.setCell(_firstNewCellIndex + c, cell);
    }
  }
예제 #8
0
 @Test
 public void notEmptyRow() {
   Row row = new Row(1);
   row.setCell(0, new Cell("I'm not empty", null));
   Assert.assertFalse(row.isEmpty());
 }