Search in sources :

Example 1 with HistoryProcess

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

the class UndoRedoCommand method doPost.

@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    if (!hasValidCSRFToken(request)) {
        respondCSRFError(response);
        return;
    }
    Project project = getProject(request);
    long lastDoneID = -1;
    String lastDoneIDString = request.getParameter("lastDoneID");
    if (lastDoneIDString != null) {
        lastDoneID = Long.parseLong(lastDoneIDString);
    } else {
        String undoIDString = request.getParameter("undoID");
        if (undoIDString != null) {
            long undoID = Long.parseLong(undoIDString);
            lastDoneID = project.history.getPrecedingEntryID(undoID);
        }
    }
    try {
        boolean done = lastDoneID == -1 || project.processManager.queueProcess(new HistoryProcess(project, lastDoneID));
        respond(response, "{ \"code\" : " + (done ? "\"ok\"" : "\"pending\"") + " }");
    } catch (Exception e) {
        respondException(response, e);
    }
}
Also used : Project(com.google.refine.model.Project) HistoryProcess(com.google.refine.history.HistoryProcess) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 2 with HistoryProcess

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

the class HistoryProcessTests method serializeHistoryProcess.

@Test
public void serializeHistoryProcess() {
    HistoryProcess process = new HistoryProcess(project, 1234L);
    TestUtils.isSerializedTo(process, "{" + "\"description\":\"Undo/redo until after first operation\"," + "\"immediate\":true," + "\"status\":\"pending\"}");
}
Also used : HistoryProcess(com.google.refine.history.HistoryProcess) RefineTest(com.google.refine.RefineTest) Test(org.testng.annotations.Test)

Aggregations

HistoryProcess (com.google.refine.history.HistoryProcess)2 RefineTest (com.google.refine.RefineTest)1 Project (com.google.refine.model.Project)1 IOException (java.io.IOException)1 ServletException (javax.servlet.ServletException)1 Test (org.testng.annotations.Test)1