From d303adc48e444fd599e4fd3d7b65ee03de120017 Mon Sep 17 00:00:00 2001 From: David Huynh Date: Sat, 1 May 2010 00:11:44 +0000 Subject: [PATCH] Made data upload dialog shows only limited preview of triples, but made actual uploading process and the tripleloader exporter generate all triples. Added spinner busy dialog during uploading process. git-svn-id: http://google-refine.googlecode.com/svn/trunk@582 7d457c2a-affb-35e4-300a-418c747d4874 --- .../commands/edit/UploadDataCommand.java | 2 +- .../exporters/TripleloaderExporter.java | 2 +- .../protograph/transpose/Transposer.java | 18 +++++++-- .../dialogs/freebase-loading-dialog.js | 38 ++++++++++--------- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/metaweb/gridworks/commands/edit/UploadDataCommand.java b/src/main/java/com/metaweb/gridworks/commands/edit/UploadDataCommand.java index adc1435d2..a25ffcd5c 100644 --- a/src/main/java/com/metaweb/gridworks/commands/edit/UploadDataCommand.java +++ b/src/main/java/com/metaweb/gridworks/commands/edit/UploadDataCommand.java @@ -27,7 +27,7 @@ public class UploadDataCommand extends Command { Project project = getProject(request); Engine engine = getEngine(request, project); TripleloaderExporter exporter = new TripleloaderExporter(); - StringWriter triples = new StringWriter(1024 * 10); + StringWriter triples = new StringWriter(10 * 1024 * 1024); exporter.export(project, new Properties(), engine, triples); String source_name = request.getParameter("source_name"); diff --git a/src/main/java/com/metaweb/gridworks/exporters/TripleloaderExporter.java b/src/main/java/com/metaweb/gridworks/exporters/TripleloaderExporter.java index ebfb64feb..57f556047 100644 --- a/src/main/java/com/metaweb/gridworks/exporters/TripleloaderExporter.java +++ b/src/main/java/com/metaweb/gridworks/exporters/TripleloaderExporter.java @@ -33,7 +33,7 @@ public class TripleloaderExporter implements Exporter { TripleLoaderTransposedNodeFactory nodeFactory = new TripleLoaderTransposedNodeFactory(writer); - Transposer.transpose(project, protograph, protograph.getRootNode(0), nodeFactory); + Transposer.transpose(project, protograph, protograph.getRootNode(0), nodeFactory, -1); nodeFactory.flush(); } } diff --git a/src/main/java/com/metaweb/gridworks/protograph/transpose/Transposer.java b/src/main/java/com/metaweb/gridworks/protograph/transpose/Transposer.java index 838eef7f9..c9afac828 100644 --- a/src/main/java/com/metaweb/gridworks/protograph/transpose/Transposer.java +++ b/src/main/java/com/metaweb/gridworks/protograph/transpose/Transposer.java @@ -23,11 +23,21 @@ import com.metaweb.gridworks.protograph.ValueNode; public class Transposer { static public void transpose( Project project, - Protograph protograph, - Node rootNode, - TransposedNodeFactory nodeFactory + Protograph protograph, + Node rootNode, + TransposedNodeFactory nodeFactory ) { - Context rootContext = new Context(rootNode, null, null, 20); + transpose(project, protograph, rootNode, nodeFactory, 20); + } + + static public void transpose( + Project project, + Protograph protograph, + Node rootNode, + TransposedNodeFactory nodeFactory, + int limit + ) { + Context rootContext = new Context(rootNode, null, null, limit); for (Row row : project.rows) { descend(project, protograph, nodeFactory, row, rootNode, rootContext); diff --git a/src/main/webapp/scripts/dialogs/freebase-loading-dialog.js b/src/main/webapp/scripts/dialogs/freebase-loading-dialog.js index c6614c56b..790df54bc 100644 --- a/src/main/webapp/scripts/dialogs/freebase-loading-dialog.js +++ b/src/main/webapp/scripts/dialogs/freebase-loading-dialog.js @@ -116,22 +116,11 @@ FreebaseLoadingDialog.prototype._createDialog = function() { }; var show_triples = function(cont) { - $.post("/command/export-rows", - { - project: theProject.id, - format : "tripleloader" - }, + $.post( + "/command/preview-protograph?" + $.param({ project: theProject.id }), + { protograph: JSON.stringify(theProject.protograph) }, function(data) { - if (data == null || data == "") { - body.html( - '
'+ - '

This dataset has no triples

' + - '

Have you aligned it with the Freebase schemas yet?

' + - '
' - ); - self._elmts = DOM.bind(frame); - self._end(); - } else { + if ("tripleloader" in data) { body.html( '
' + '' + '
Name this data load ¬ required
' + @@ -139,7 +128,7 @@ FreebaseLoadingDialog.prototype._createDialog = function() { '
Source ID ¬ optional
' + '
' + - '
' + data + '
' + '
' + data.tripleloader + '
' ); self._elmts = DOM.bind(frame); @@ -161,10 +150,19 @@ FreebaseLoadingDialog.prototype._createDialog = function() { }); if (typeof cont == "function") cont(); + } else { + body.html( + '
'+ + '

This dataset has no triples

' + + '

Have you aligned it with the Freebase schemas yet?

' + + '
' + ); + self._elmts = DOM.bind(frame); + self._end(); } - self._level = DialogSystem.showDialog(frame); - } + }, + "json" ); }; @@ -188,6 +186,8 @@ FreebaseLoadingDialog.prototype._load = function() { } var doLoad = function() { + var dismissBusy = DialogSystem.showBusy(); + $.post("/command/upload-data", { project: theProject.id, @@ -196,6 +196,8 @@ FreebaseLoadingDialog.prototype._load = function() { "source_id" : self._elmts.source_id.val() }, function(data) { + dismissBusy(); + var body = $(".dialog-body"); if ("status" in data && typeof data.status == "object" && "code" in data.status && data.status.code == 200) { body.html(