Search in sources :

Example 6 with Change

use of com.google.refine.history.Change in project OpenRefine by OpenRefine.

the class RowStarOperation method createHistoryEntry.

@Override
protected HistoryEntry createHistoryEntry(Project project, long historyEntryID) throws Exception {
    Engine engine = createEngine(project);
    List<Change> changes = new ArrayList<Change>(project.rows.size());
    FilteredRows filteredRows = engine.getAllFilteredRows();
    filteredRows.accept(project, createRowVisitor(project, changes));
    return new HistoryEntry(historyEntryID, project, (_starred ? "Star" : "Unstar") + " " + changes.size() + " rows", this, new MassChange(changes, false));
}
Also used : MassChange(com.google.refine.model.changes.MassChange) ArrayList(java.util.ArrayList) HistoryEntry(com.google.refine.history.HistoryEntry) RowStarChange(com.google.refine.model.changes.RowStarChange) Change(com.google.refine.history.Change) MassChange(com.google.refine.model.changes.MassChange) FilteredRows(com.google.refine.browsing.FilteredRows) Engine(com.google.refine.browsing.Engine)

Example 7 with Change

use of com.google.refine.history.Change in project OpenRefine by OpenRefine.

the class MassChangeTests method testWrongReverseOrder.

/**
     * Test case for #914 - Demonstrates MassChange revert doesn't work by
     * adding two columns to a project with a MassChange and then reverting.
     * Without the fix, column "a" will be removed before column "b", causing
     * column "b" removal to fail because it won't be found at index 1 as
     * expected.
     */
@Test
public void testWrongReverseOrder() throws Exception {
    List<Change> changes = new ArrayList<Change>();
    changes.add(new ColumnAdditionChange("a", 0, new ArrayList<CellAtRow>()));
    changes.add(new ColumnAdditionChange("b", 1, new ArrayList<CellAtRow>()));
    MassChange massChange = new MassChange(changes, false);
    massChange.apply(project);
    massChange.revert(project);
    assertTrue(project.columnModel.columns.isEmpty());
}
Also used : MassChange(com.google.refine.model.changes.MassChange) ColumnAdditionChange(com.google.refine.model.changes.ColumnAdditionChange) ArrayList(java.util.ArrayList) Change(com.google.refine.history.Change) ColumnAdditionChange(com.google.refine.model.changes.ColumnAdditionChange) MassChange(com.google.refine.model.changes.MassChange) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) RefineTest(com.google.refine.tests.RefineTest)

Aggregations

Change (com.google.refine.history.Change)7 HistoryEntry (com.google.refine.history.HistoryEntry)5 ArrayList (java.util.ArrayList)5 Engine (com.google.refine.browsing.Engine)4 FilteredRows (com.google.refine.browsing.FilteredRows)4 Column (com.google.refine.model.Column)3 MassChange (com.google.refine.model.changes.MassChange)3 JSONException (org.json.JSONException)3 ColumnAdditionChange (com.google.refine.model.changes.ColumnAdditionChange)2 RowVisitor (com.google.refine.browsing.RowVisitor)1 CellAtRow (com.google.refine.model.changes.CellAtRow)1 ColumnRemovalChange (com.google.refine.model.changes.ColumnRemovalChange)1 ColumnSplitChange (com.google.refine.model.changes.ColumnSplitChange)1 RowFlagChange (com.google.refine.model.changes.RowFlagChange)1 RowStarChange (com.google.refine.model.changes.RowStarChange)1 RefineTest (com.google.refine.tests.RefineTest)1 Serializable (java.io.Serializable)1 List (java.util.List)1 Pattern (java.util.regex.Pattern)1 BeforeTest (org.testng.annotations.BeforeTest)1