Made recon process cause the client page to create facets when the recon process is done.
git-svn-id: http://google-refine.googlecode.com/svn/trunk@203 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
32c0bf08c9
commit
1d6db8fa6e
@ -113,6 +113,46 @@ public class ReconOperation extends EngineDependentOperation {
|
||||
_engineConfig = engineConfig;
|
||||
}
|
||||
|
||||
public void write(JSONWriter writer, Properties options)
|
||||
throws JSONException {
|
||||
|
||||
writer.object();
|
||||
writer.key("id"); writer.value(hashCode());
|
||||
writer.key("description"); writer.value(_description);
|
||||
writer.key("immediate"); writer.value(false);
|
||||
writer.key("status"); writer.value(_thread == null ? "pending" : (_thread.isAlive() ? "running" : "done"));
|
||||
writer.key("progress"); writer.value(_progress);
|
||||
writer.key("onDone");
|
||||
writer.array();
|
||||
writer.object();
|
||||
writer.key("action"); writer.value("createFacet");
|
||||
writer.key("facetType"); writer.value("list");
|
||||
writer.key("facetConfig");
|
||||
writer.object();
|
||||
writer.key("name"); writer.value(_columnName + ": judgment");
|
||||
writer.key("columnName"); writer.value(_columnName);
|
||||
writer.key("expression"); writer.value("cell.recon.judgment");
|
||||
writer.endObject();
|
||||
writer.key("facetOptions");
|
||||
writer.object();
|
||||
writer.key("scroll"); writer.value(false);
|
||||
writer.endObject();
|
||||
writer.endObject();
|
||||
writer.object();
|
||||
writer.key("action"); writer.value("createFacet");
|
||||
writer.key("facetType"); writer.value("range");
|
||||
writer.key("facetConfig");
|
||||
writer.object();
|
||||
writer.key("name"); writer.value(_columnName + ": best candidate's score");
|
||||
writer.key("columnName"); writer.value(_columnName);
|
||||
writer.key("expression"); writer.value("cell.recon.best.score");
|
||||
writer.key("mode"); writer.value("range");
|
||||
writer.endObject();
|
||||
writer.endObject();
|
||||
writer.endArray();
|
||||
writer.endObject();
|
||||
}
|
||||
|
||||
protected Runnable getRunnable() {
|
||||
return this;
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ abstract public class LongRunningProcess extends Process {
|
||||
throws JSONException {
|
||||
|
||||
writer.object();
|
||||
writer.key("id"); writer.value(hashCode());
|
||||
writer.key("description"); writer.value(_description);
|
||||
writer.key("immediate"); writer.value(false);
|
||||
writer.key("status"); writer.value(_thread == null ? "pending" : (_thread.isAlive() ? "running" : "done"));
|
||||
|
@ -47,6 +47,7 @@ abstract public class QuickHistoryEntryProcess extends Process {
|
||||
throws JSONException {
|
||||
|
||||
writer.object();
|
||||
writer.key("id"); writer.value(hashCode());
|
||||
writer.key("description"); writer.value(_historyEntry != null ? _historyEntry.description : _briefDescription);
|
||||
writer.key("immediate"); writer.value(true);
|
||||
writer.key("status"); writer.value(_done ? "done" : "pending");
|
||||
|
@ -27,27 +27,31 @@ ProcessWidget.prototype.update = function(updateOptions, onDone) {
|
||||
Ajax.chainGetJSON(
|
||||
"/command/get-processes?" + $.param({ project: theProject.id }), null,
|
||||
function(data) {
|
||||
self._data = data;
|
||||
self._render();
|
||||
self._render(data);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
ProcessWidget.prototype._cancelAll = function() {
|
||||
var self = this;
|
||||
$.post(
|
||||
"/command/cancel-processes?" + $.param({ project: theProject.id }),
|
||||
null,
|
||||
function(o) {},
|
||||
function(o) {
|
||||
self._data = null;
|
||||
self._runOnDones();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
};
|
||||
|
||||
ProcessWidget.prototype._render = function() {
|
||||
ProcessWidget.prototype._render = function(newData) {
|
||||
var self = this;
|
||||
var newProcessMap = {};
|
||||
|
||||
this._div.empty();
|
||||
|
||||
if (this._data.processes.length == 0) {
|
||||
if (newData.processes.length == 0) {
|
||||
this._div.hide();
|
||||
} else {
|
||||
this._div.show();
|
||||
@ -64,6 +68,7 @@ ProcessWidget.prototype._render = function() {
|
||||
.text("cancel all")
|
||||
.click(function() {
|
||||
self._cancelAll();
|
||||
|
||||
$(this).text("canceling all processes...").unbind();
|
||||
})
|
||||
.appendTo(headDiv);
|
||||
@ -79,11 +84,26 @@ ProcessWidget.prototype._render = function() {
|
||||
}
|
||||
};
|
||||
|
||||
var processes = this._data.processes;
|
||||
var processes = newData.processes;
|
||||
for (var i = 0; i < processes.length; i++) {
|
||||
renderProcess(processes[i]);
|
||||
var process = processes[i];
|
||||
renderProcess(process);
|
||||
if ("onDone" in process) {
|
||||
newProcessMap[process.id] = process;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((this._data) && this._data.processes.length > 0) {
|
||||
var oldProcesses = this._data.processes;
|
||||
for (var i = 0; i < oldProcesses.length; i++) {
|
||||
var process = oldProcesses[i];
|
||||
if ("onDone" in process && !(process.id in newProcessMap)) {
|
||||
this._perform(process.onDone);
|
||||
}
|
||||
}
|
||||
}
|
||||
this._data = newData;
|
||||
|
||||
if (this._data.processes.length > 0 && this._timerID == null) {
|
||||
this._timerID = window.setTimeout(function() {
|
||||
@ -91,7 +111,28 @@ ProcessWidget.prototype._render = function() {
|
||||
self.update();
|
||||
}, 500);
|
||||
} else {
|
||||
this._runOnDones();
|
||||
}
|
||||
};
|
||||
|
||||
ProcessWidget.prototype._perform = function(jobs) {
|
||||
for (var i = 0; i < jobs.length; i++) {
|
||||
var job = jobs[i];
|
||||
if (job.action == "createFacet") {
|
||||
try {
|
||||
ui.browsingEngine.addFacet(
|
||||
job.facetType,
|
||||
job.facetConfig,
|
||||
job.facetOptions
|
||||
);
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ProcessWidget.prototype._runOnDones = function() {
|
||||
var updateOptions = this._updateOptions;
|
||||
var onDones = this._onDones;
|
||||
|
||||
@ -107,5 +148,4 @@ ProcessWidget.prototype._render = function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -311,7 +311,7 @@ DataTableColumnHeaderUI.prototype._createMenuForColumnHeader = function(elmt) {
|
||||
ui.browsingEngine.addFacet(
|
||||
"range",
|
||||
{
|
||||
"name" : self._column.headerLabel + ": best candidate's relevance score",
|
||||
"name" : self._column.headerLabel + ": best candidate's score",
|
||||
"columnName" : self._column.headerLabel,
|
||||
"expression" : "cell.recon.best.score",
|
||||
"mode" : "range"
|
||||
|
Loading…
Reference in New Issue
Block a user