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
This commit is contained in:
David Huynh 2010-05-01 00:11:44 +00:00
parent b6ed5a3df5
commit d303adc48e
4 changed files with 36 additions and 24 deletions

View File

@ -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");

View File

@ -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();
}
}

View File

@ -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);

View File

@ -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(
'<div class="freebase-loading-tripleloader-message">'+
'<h2>This dataset has no triples</h2>' +
'<p>Have you aligned it with the Freebase schemas yet?</p>' +
'</div>'
);
self._elmts = DOM.bind(frame);
self._end();
} else {
if ("tripleloader" in data) {
body.html(
'<div class="freebase-loading-tripleloader-info"><table><tr>' +
'<td><div>Name this data load &not; <sup style="color: red">required</sup></div>' +
@ -139,7 +128,7 @@ FreebaseLoadingDialog.prototype._createDialog = function() {
'<td><div>Source ID &not; <sup style="color: #888">optional</sup></div>' +
'<input type="text" size="60" id="freebase-loading-source-id" bind="source_id"></td>' +
'</tr></table></div>' +
'<div class="freebase-loading-tripleloader-data">' + data + '</div>'
'<div class="freebase-loading-tripleloader-data">' + data.tripleloader + '</div>'
);
self._elmts = DOM.bind(frame);
@ -161,10 +150,19 @@ FreebaseLoadingDialog.prototype._createDialog = function() {
});
if (typeof cont == "function") cont();
} else {
body.html(
'<div class="freebase-loading-tripleloader-message">'+
'<h2>This dataset has no triples</h2>' +
'<p>Have you aligned it with the Freebase schemas yet?</p>' +
'</div>'
);
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(