Search in sources :

Example 1 with CellDependency

use of com.google.refine.model.RecordModel.CellDependency in project OpenRefine by OpenRefine.

the class DenormalizeOperation method createHistoryEntry.

@Override
protected HistoryEntry createHistoryEntry(Project project, long historyEntryID) throws Exception {
    List<Row> newRows = new ArrayList<Row>();
    List<Row> oldRows = project.rows;
    for (int r = 0; r < oldRows.size(); r++) {
        Row oldRow = oldRows.get(r);
        Row newRow = null;
        RowDependency rd = project.recordModel.getRowDependency(r);
        if (rd.cellDependencies != null) {
            newRow = oldRow.dup();
            for (CellDependency cd : rd.cellDependencies) {
                if (cd != null) {
                    int contextRowIndex = cd.rowIndex;
                    int contextCellIndex = cd.cellIndex;
                    if (contextRowIndex >= 0 && contextRowIndex < oldRows.size()) {
                        Row contextRow = oldRows.get(contextRowIndex);
                        Cell contextCell = contextRow.getCell(contextCellIndex);
                        newRow.setCell(contextCellIndex, contextCell);
                    }
                }
            }
        }
        newRows.add(newRow != null ? newRow : oldRow);
    }
    return new HistoryEntry(historyEntryID, project, getBriefDescription(project), DenormalizeOperation.this, new MassRowChange(newRows));
}
Also used : MassRowChange(com.google.refine.model.changes.MassRowChange) CellDependency(com.google.refine.model.RecordModel.CellDependency) ArrayList(java.util.ArrayList) HistoryEntry(com.google.refine.history.HistoryEntry) Row(com.google.refine.model.Row) RowDependency(com.google.refine.model.RecordModel.RowDependency) Cell(com.google.refine.model.Cell)

Aggregations

HistoryEntry (com.google.refine.history.HistoryEntry)1 Cell (com.google.refine.model.Cell)1 CellDependency (com.google.refine.model.RecordModel.CellDependency)1 RowDependency (com.google.refine.model.RecordModel.RowDependency)1 Row (com.google.refine.model.Row)1 MassRowChange (com.google.refine.model.changes.MassRowChange)1 ArrayList (java.util.ArrayList)1