Search in sources :

Example 1 with RowReorderChange

use of com.google.refine.model.changes.RowReorderChange in project OpenRefine by OpenRefine.

the class RowReorderOperation method createHistoryEntry.

@Override
protected HistoryEntry createHistoryEntry(Project project, long historyEntryID) throws Exception {
    Engine engine = new Engine(project);
    engine.setMode(_mode);
    List<Integer> rowIndices = new ArrayList<Integer>();
    if (_mode == Mode.RowBased) {
        RowVisitor visitor = new IndexingVisitor(rowIndices);
        if (_sorting != null) {
            SortingRowVisitor srv = new SortingRowVisitor(visitor);
            srv.initializeFromJSON(project, _sorting);
            if (srv.hasCriteria()) {
                visitor = srv;
            }
        }
        engine.getAllRows().accept(project, visitor);
    } else {
        RecordVisitor visitor = new IndexingVisitor(rowIndices);
        if (_sorting != null) {
            SortingRecordVisitor srv = new SortingRecordVisitor(visitor);
            srv.initializeFromJSON(project, _sorting);
            if (srv.hasCriteria()) {
                visitor = srv;
            }
        }
        engine.getAllRecords().accept(project, visitor);
    }
    return new HistoryEntry(historyEntryID, project, "Reorder rows", this, new RowReorderChange(rowIndices));
}
Also used : RowReorderChange(com.google.refine.model.changes.RowReorderChange) ArrayList(java.util.ArrayList) SortingRecordVisitor(com.google.refine.sorting.SortingRecordVisitor) HistoryEntry(com.google.refine.history.HistoryEntry) SortingRecordVisitor(com.google.refine.sorting.SortingRecordVisitor) RecordVisitor(com.google.refine.browsing.RecordVisitor) RowVisitor(com.google.refine.browsing.RowVisitor) SortingRowVisitor(com.google.refine.sorting.SortingRowVisitor) Engine(com.google.refine.browsing.Engine) SortingRowVisitor(com.google.refine.sorting.SortingRowVisitor)

Aggregations

Engine (com.google.refine.browsing.Engine)1 RecordVisitor (com.google.refine.browsing.RecordVisitor)1 RowVisitor (com.google.refine.browsing.RowVisitor)1 HistoryEntry (com.google.refine.history.HistoryEntry)1 RowReorderChange (com.google.refine.model.changes.RowReorderChange)1 SortingRecordVisitor (com.google.refine.sorting.SortingRecordVisitor)1 SortingRowVisitor (com.google.refine.sorting.SortingRowVisitor)1 ArrayList (java.util.ArrayList)1