Added "cancel processes" command, not hooked up yet.
git-svn-id: http://google-refine.googlecode.com/svn/trunk@171 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
2741d54984
commit
ad7671508f
@ -43,6 +43,7 @@ import com.metaweb.gridworks.commands.recon.ReconJudgeOneCellCommand;
|
|||||||
import com.metaweb.gridworks.commands.recon.ReconJudgeSimilarCellsCommand;
|
import com.metaweb.gridworks.commands.recon.ReconJudgeSimilarCellsCommand;
|
||||||
import com.metaweb.gridworks.commands.recon.ReconMatchSpecificTopicCommand;
|
import com.metaweb.gridworks.commands.recon.ReconMatchSpecificTopicCommand;
|
||||||
import com.metaweb.gridworks.commands.recon.ReconcileCommand;
|
import com.metaweb.gridworks.commands.recon.ReconcileCommand;
|
||||||
|
import com.metaweb.gridworks.commands.util.CancelProcessesCommand;
|
||||||
import com.metaweb.gridworks.commands.util.GetExpressionLanguageInfoCommand;
|
import com.metaweb.gridworks.commands.util.GetExpressionLanguageInfoCommand;
|
||||||
import com.metaweb.gridworks.commands.util.GuessTypesOfColumnCommand;
|
import com.metaweb.gridworks.commands.util.GuessTypesOfColumnCommand;
|
||||||
import com.metaweb.gridworks.commands.util.PreviewExpressionCommand;
|
import com.metaweb.gridworks.commands.util.PreviewExpressionCommand;
|
||||||
@ -68,6 +69,7 @@ public class GridworksServlet extends HttpServlet {
|
|||||||
|
|
||||||
_commands.put("undo-redo", new UndoRedoCommand());
|
_commands.put("undo-redo", new UndoRedoCommand());
|
||||||
_commands.put("apply-operations", new ApplyOperationsCommand());
|
_commands.put("apply-operations", new ApplyOperationsCommand());
|
||||||
|
_commands.put("cancel-processes", new CancelProcessesCommand());
|
||||||
|
|
||||||
_commands.put("compute-facets", new ComputeFacetsCommand());
|
_commands.put("compute-facets", new ComputeFacetsCommand());
|
||||||
_commands.put("do-text-transform", new DoTextTransformCommand());
|
_commands.put("do-text-transform", new DoTextTransformCommand());
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
package com.metaweb.gridworks.commands.util;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.metaweb.gridworks.commands.Command;
|
||||||
|
import com.metaweb.gridworks.model.Project;
|
||||||
|
|
||||||
|
public class CancelProcessesCommand extends Command {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||||
|
throws ServletException, IOException {
|
||||||
|
|
||||||
|
try {
|
||||||
|
Project project = getProject(request);
|
||||||
|
project.processManager.cancelAll();
|
||||||
|
|
||||||
|
response.setCharacterEncoding("UTF-8");
|
||||||
|
response.setHeader("Content-Type", "application/json");
|
||||||
|
response.getWriter().write("{ \"code\" : \"ok\" }");
|
||||||
|
} catch (Exception e) {
|
||||||
|
respondException(response, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -56,6 +56,15 @@ public class ProcessManager implements Jsonizable {
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void cancelAll() {
|
||||||
|
for (Process p : _processes) {
|
||||||
|
if (!p.isImmediate() && p.isRunning()) {
|
||||||
|
p.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_processes.clear();
|
||||||
|
}
|
||||||
|
|
||||||
protected void update() {
|
protected void update() {
|
||||||
while (_processes.size() > 0) {
|
while (_processes.size() > 0) {
|
||||||
Process p = _processes.get(0);
|
Process p = _processes.get(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user