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
@ -98,10 +98,10 @@ public class ReconOperation extends EngineDependentOperation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class ReconProcess extends LongRunningProcess implements Runnable {
|
public class ReconProcess extends LongRunningProcess implements Runnable {
|
||||||
final protected Project _project;
|
final protected Project _project;
|
||||||
final protected JSONObject _engineConfig;
|
final protected JSONObject _engineConfig;
|
||||||
protected List<ReconEntry> _entries;
|
protected List<ReconEntry> _entries;
|
||||||
protected int _cellIndex;
|
protected int _cellIndex;
|
||||||
|
|
||||||
public ReconProcess(
|
public ReconProcess(
|
||||||
Project project,
|
Project project,
|
||||||
@ -113,6 +113,46 @@ public class ReconOperation extends EngineDependentOperation {
|
|||||||
_engineConfig = engineConfig;
|
_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() {
|
protected Runnable getRunnable() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import org.json.JSONException;
|
|||||||
import org.json.JSONWriter;
|
import org.json.JSONWriter;
|
||||||
|
|
||||||
abstract public class LongRunningProcess extends Process {
|
abstract public class LongRunningProcess extends Process {
|
||||||
final protected String _description;
|
final protected String _description;
|
||||||
protected ProcessManager _manager;
|
protected ProcessManager _manager;
|
||||||
protected Thread _thread;
|
protected Thread _thread;
|
||||||
protected int _progress; // out of 100
|
protected int _progress; // out of 100
|
||||||
@ -27,6 +27,7 @@ abstract public class LongRunningProcess extends Process {
|
|||||||
throws JSONException {
|
throws JSONException {
|
||||||
|
|
||||||
writer.object();
|
writer.object();
|
||||||
|
writer.key("id"); writer.value(hashCode());
|
||||||
writer.key("description"); writer.value(_description);
|
writer.key("description"); writer.value(_description);
|
||||||
writer.key("immediate"); writer.value(false);
|
writer.key("immediate"); writer.value(false);
|
||||||
writer.key("status"); writer.value(_thread == null ? "pending" : (_thread.isAlive() ? "running" : "done"));
|
writer.key("status"); writer.value(_thread == null ? "pending" : (_thread.isAlive() ? "running" : "done"));
|
||||||
|
@ -47,6 +47,7 @@ abstract public class QuickHistoryEntryProcess extends Process {
|
|||||||
throws JSONException {
|
throws JSONException {
|
||||||
|
|
||||||
writer.object();
|
writer.object();
|
||||||
|
writer.key("id"); writer.value(hashCode());
|
||||||
writer.key("description"); writer.value(_historyEntry != null ? _historyEntry.description : _briefDescription);
|
writer.key("description"); writer.value(_historyEntry != null ? _historyEntry.description : _briefDescription);
|
||||||
writer.key("immediate"); writer.value(true);
|
writer.key("immediate"); writer.value(true);
|
||||||
writer.key("status"); writer.value(_done ? "done" : "pending");
|
writer.key("status"); writer.value(_done ? "done" : "pending");
|
||||||
|
@ -27,27 +27,31 @@ ProcessWidget.prototype.update = function(updateOptions, onDone) {
|
|||||||
Ajax.chainGetJSON(
|
Ajax.chainGetJSON(
|
||||||
"/command/get-processes?" + $.param({ project: theProject.id }), null,
|
"/command/get-processes?" + $.param({ project: theProject.id }), null,
|
||||||
function(data) {
|
function(data) {
|
||||||
self._data = data;
|
self._render(data);
|
||||||
self._render();
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
ProcessWidget.prototype._cancelAll = function() {
|
ProcessWidget.prototype._cancelAll = function() {
|
||||||
|
var self = this;
|
||||||
$.post(
|
$.post(
|
||||||
"/command/cancel-processes?" + $.param({ project: theProject.id }),
|
"/command/cancel-processes?" + $.param({ project: theProject.id }),
|
||||||
null,
|
null,
|
||||||
function(o) {},
|
function(o) {
|
||||||
|
self._data = null;
|
||||||
|
self._runOnDones();
|
||||||
|
},
|
||||||
"json"
|
"json"
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
ProcessWidget.prototype._render = function() {
|
ProcessWidget.prototype._render = function(newData) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
var newProcessMap = {};
|
||||||
|
|
||||||
this._div.empty();
|
this._div.empty();
|
||||||
|
|
||||||
if (this._data.processes.length == 0) {
|
if (newData.processes.length == 0) {
|
||||||
this._div.hide();
|
this._div.hide();
|
||||||
} else {
|
} else {
|
||||||
this._div.show();
|
this._div.show();
|
||||||
@ -64,6 +68,7 @@ ProcessWidget.prototype._render = function() {
|
|||||||
.text("cancel all")
|
.text("cancel all")
|
||||||
.click(function() {
|
.click(function() {
|
||||||
self._cancelAll();
|
self._cancelAll();
|
||||||
|
|
||||||
$(this).text("canceling all processes...").unbind();
|
$(this).text("canceling all processes...").unbind();
|
||||||
})
|
})
|
||||||
.appendTo(headDiv);
|
.appendTo(headDiv);
|
||||||
@ -79,33 +84,68 @@ ProcessWidget.prototype._render = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var processes = this._data.processes;
|
var processes = newData.processes;
|
||||||
for (var i = 0; i < processes.length; i++) {
|
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) {
|
if (this._data.processes.length > 0 && this._timerID == null) {
|
||||||
this._timerID = window.setTimeout(function() {
|
this._timerID = window.setTimeout(function() {
|
||||||
self._timerID = null;
|
self._timerID = null;
|
||||||
self.update();
|
self.update();
|
||||||
}, 500);
|
}, 500);
|
||||||
} else {
|
} else {
|
||||||
|
this._runOnDones();
|
||||||
var updateOptions = this._updateOptions;
|
|
||||||
var onDones = this._onDones;
|
|
||||||
|
|
||||||
this._updateOptions = {};
|
|
||||||
this._onDones = [];
|
|
||||||
|
|
||||||
Gridworks.update(updateOptions, function() {
|
|
||||||
for (var i = 0; i < onDones.length; i++) {
|
|
||||||
try {
|
|
||||||
onDones[i]();
|
|
||||||
} catch (e) {
|
|
||||||
Gridworks.reportException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
this._updateOptions = {};
|
||||||
|
this._onDones = [];
|
||||||
|
|
||||||
|
Gridworks.update(updateOptions, function() {
|
||||||
|
for (var i = 0; i < onDones.length; i++) {
|
||||||
|
try {
|
||||||
|
onDones[i]();
|
||||||
|
} catch (e) {
|
||||||
|
Gridworks.reportException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
@ -311,7 +311,7 @@ DataTableColumnHeaderUI.prototype._createMenuForColumnHeader = function(elmt) {
|
|||||||
ui.browsingEngine.addFacet(
|
ui.browsingEngine.addFacet(
|
||||||
"range",
|
"range",
|
||||||
{
|
{
|
||||||
"name" : self._column.headerLabel + ": best candidate's relevance score",
|
"name" : self._column.headerLabel + ": best candidate's score",
|
||||||
"columnName" : self._column.headerLabel,
|
"columnName" : self._column.headerLabel,
|
||||||
"expression" : "cell.recon.best.score",
|
"expression" : "cell.recon.best.score",
|
||||||
"mode" : "range"
|
"mode" : "range"
|
||||||
|
Loading…
Reference in New Issue
Block a user