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);
}
}
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\"}");
}
Aggregations