use of com.google.refine.browsing.Engine in project OpenRefine by OpenRefine.
the class EngineDependentMassCellOperation method createHistoryEntry.
@Override
protected HistoryEntry createHistoryEntry(Project project, long historyEntryID) throws Exception {
Engine engine = createEngine(project);
Column column = project.columnModel.getColumnByName(_columnName);
if (column == null) {
throw new Exception("No column named " + _columnName);
}
List<CellChange> cellChanges = new ArrayList<CellChange>(project.rows.size());
FilteredRows filteredRows = engine.getAllFilteredRows();
try {
filteredRows.accept(project, createRowVisitor(project, cellChanges, historyEntryID));
} catch (Exception e) {
e.printStackTrace();
}
String description = createDescription(column, cellChanges);
return new HistoryEntry(historyEntryID, project, description, this, createChange(project, column, cellChanges));
}
use of com.google.refine.browsing.Engine in project OpenRefine by OpenRefine.
the class EngineDependentOperation method createEngine.
protected Engine createEngine(Project project) throws Exception {
Engine engine = new Engine(project);
engine.initializeFromJSON(getEngineConfig());
return engine;
}
use of com.google.refine.browsing.Engine in project OpenRefine by OpenRefine.
the class CommandTests method getEngineRegressionTest.
@Test
public void getEngineRegressionTest() {
// TODO refactor getEngine to use dependency injection, so a mock Engine
// object can be used.
Engine engine = null;
when(request.getParameter("engine")).thenReturn("{\"hello\":\"world\"}");
try {
engine = SUT.wrapGetEngine(request, project);
Assert.assertNotNull(engine);
} catch (Exception e) {
Assert.fail();
}
verify(request, times(1)).getParameter("engine");
// JSON configuration doesn't have 'facets' key or 'INCLUDE_DEPENDENT'
// key, so there should be no further action
// Engine._facets is protected so can't test that it is of zero length.
}
use of com.google.refine.browsing.Engine in project OpenRefine by OpenRefine.
the class RowRemovalOperation method createHistoryEntry.
@Override
protected HistoryEntry createHistoryEntry(Project project, long historyEntryID) throws Exception {
Engine engine = createEngine(project);
List<Integer> rowIndices = new ArrayList<Integer>();
FilteredRows filteredRows = engine.getAllFilteredRows();
filteredRows.accept(project, createRowVisitor(project, rowIndices));
return new HistoryEntry(historyEntryID, project, "Remove " + rowIndices.size() + " rows", this, new RowRemovalChange(rowIndices));
}
use of com.google.refine.browsing.Engine 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));
}
Aggregations