Added command to browse to the data load page on the Gridworks QA dashboard.
Save the data load job name and fill it in the next time the Load into Freebase dialog is opened. git-svn-id: http://google-refine.googlecode.com/svn/trunk@1220 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
bd3ce8e36d
commit
baa4e0db8c
@ -17,11 +17,13 @@ import com.google.gridworks.browsing.Engine;
|
||||
import com.google.gridworks.commands.Command;
|
||||
import com.google.gridworks.exporters.ProtographTransposeExporter.TripleLoaderExporter;
|
||||
import com.google.gridworks.model.Project;
|
||||
import com.google.gridworks.preference.PreferenceStore;
|
||||
import com.google.gridworks.util.FreebaseUtils;
|
||||
import com.google.gridworks.util.ParsingUtilities;
|
||||
|
||||
public class UploadDataCommand extends Command {
|
||||
final static public String s_dataLoadJobIDPref = "core/freebaseDataLoadJobID";
|
||||
final static public String s_dataLoadJobIDPref = "freebase.load.jobID";
|
||||
final static public String s_dataLoadJobNamePref = "freebase.load.jobName";
|
||||
|
||||
@Override
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
@ -31,6 +33,8 @@ public class UploadDataCommand extends Command {
|
||||
try {
|
||||
Project project = getProject(request);
|
||||
Engine engine = getEngine(request, project);
|
||||
PreferenceStore preferenceStore = project.getMetadata().getPreferenceStore();
|
||||
|
||||
TripleLoaderExporter exporter = new TripleLoaderExporter();
|
||||
StringWriter triples = new StringWriter(10 * 1024 * 1024);
|
||||
exporter.export(project, new Properties(), engine, triples);
|
||||
@ -40,8 +44,10 @@ public class UploadDataCommand extends Command {
|
||||
String graph = request.getParameter("graph");
|
||||
String mdo_id = null;
|
||||
|
||||
preferenceStore.put(s_dataLoadJobNamePref, source_name);
|
||||
|
||||
try {
|
||||
Integer jobID = (Integer) project.getMetadata().getPreferenceStore().get(s_dataLoadJobIDPref);
|
||||
Integer jobID = (Integer) preferenceStore.get(s_dataLoadJobIDPref);
|
||||
if (jobID != null) {
|
||||
URL url = new URL("http://gridworks-loads.freebaseapps.com/job_id_to_mdo?job=" + jobID);
|
||||
String s = ParsingUtilities.inputStreamToString(url.openConnection().getInputStream());
|
||||
|
@ -126,6 +126,16 @@ FreebaseLoadingDialog.prototype._createDialog = function() {
|
||||
make_topic(val, "/dataworld/information_source");
|
||||
});
|
||||
|
||||
$.getJSON(
|
||||
"/command/core/get-preference?" + $.param({ project: theProject.id, name: "freebase.load.jobName" }),
|
||||
null,
|
||||
function(data) {
|
||||
if (data.value != null) {
|
||||
self._elmts.source_name[0].value = data.value;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (typeof cont == "function") cont();
|
||||
} else {
|
||||
body.html(
|
||||
@ -159,7 +169,7 @@ FreebaseLoadingDialog.prototype._load = function() {
|
||||
var freebase = self._elmts.freebase.attr("checked");
|
||||
|
||||
var get_peacock_url = function(url) {
|
||||
return "http://gridworks-loads.freebaseapps.com/job/" + url.split("/").slice(-1)[0];
|
||||
return "http://gridworks-loads.freebaseapps.com/load/" + url.split("/").slice(-1)[0];
|
||||
};
|
||||
|
||||
var doLoad = function() {
|
||||
|
@ -101,6 +101,11 @@ MenuBar.MenuItems = [
|
||||
label: "Load into Freebase ...",
|
||||
click: function() { MenuBar.handlers.loadIntoFreebase(); }
|
||||
},
|
||||
{
|
||||
"id" : "core/browse-load",
|
||||
label: "Browse to Data Load ...",
|
||||
click: function() { MenuBar.handlers.browseToDataLoad(); }
|
||||
},
|
||||
{
|
||||
"id" : "core/import-qa-data",
|
||||
label: "Import QA Data",
|
||||
@ -326,6 +331,35 @@ MenuBar.handlers.loadIntoFreebase = function() {
|
||||
new FreebaseLoadingDialog();
|
||||
};
|
||||
|
||||
MenuBar.handlers.browseToDataLoad = function() {
|
||||
// The form has to be created as part of the click handler. If you create it
|
||||
// inside the getJSON success handler, it won't work.
|
||||
|
||||
var form = document.createElement("form");
|
||||
$(form)
|
||||
.css("display", "none")
|
||||
.attr("method", "GET")
|
||||
.attr("target", "dataload");
|
||||
|
||||
document.body.appendChild(form);
|
||||
var w = window.open("about:blank", "dataload");
|
||||
|
||||
$.getJSON(
|
||||
"/command/core/get-preference?" + $.param({ project: theProject.id, name: "freebase.load.jobID" }),
|
||||
null,
|
||||
function(data) {
|
||||
if (data.value == null) {
|
||||
alert("You have not tried to load the data in this project into Freebase yet.");
|
||||
} else {
|
||||
$(form).attr("action", "http://gridworks-loads.freebaseapps.com/load/" + data.value);
|
||||
form.submit();
|
||||
w.focus();
|
||||
}
|
||||
document.body.removeChild(form);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
MenuBar.handlers.importQAData = function() {
|
||||
Gridworks.postCoreProcess(
|
||||
"import-qa-data",
|
||||
|
Loading…
Reference in New Issue
Block a user