Fixed Issue 14: Limiting Freebase load to starred records
git-svn-id: http://google-refine.googlecode.com/svn/trunk@853 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
3ac3feb01f
commit
d7f7d50e16
@ -15,8 +15,10 @@ Fixes:
|
|||||||
- Issue 46: "Array literals in GEL"
|
- Issue 46: "Array literals in GEL"
|
||||||
- Issue 55: "Use stable sorting for text facets sorted by count"
|
- Issue 55: "Use stable sorting for text facets sorted by count"
|
||||||
- Issue 53: "Moving the cursor inside the Text Filter box by clicking"
|
- Issue 53: "Moving the cursor inside the Text Filter box by clicking"
|
||||||
- Issue 58: "Meta facet"
|
- Issue 58: "Meta facet"
|
||||||
Supported by the function facetCount()
|
Supported by the function facetCount()
|
||||||
|
- Issue 14: "Limiting Freebase load to starred records"
|
||||||
|
We load whatever rows that are filtered through, not particularly starred rows.
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
- Row/record sorting (Issue 32)
|
- Row/record sorting (Issue 32)
|
||||||
|
@ -10,6 +10,8 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import com.metaweb.gridworks.browsing.Engine;
|
||||||
|
import com.metaweb.gridworks.browsing.FilteredRows;
|
||||||
import com.metaweb.gridworks.commands.Command;
|
import com.metaweb.gridworks.commands.Command;
|
||||||
import com.metaweb.gridworks.model.Project;
|
import com.metaweb.gridworks.model.Project;
|
||||||
import com.metaweb.gridworks.protograph.Protograph;
|
import com.metaweb.gridworks.protograph.Protograph;
|
||||||
@ -25,6 +27,8 @@ public class PreviewProtographCommand extends Command {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Project project = getProject(request);
|
Project project = getProject(request);
|
||||||
|
Engine engine = getEngine(request, project);
|
||||||
|
FilteredRows filteredRows = engine.getAllFilteredRows();
|
||||||
|
|
||||||
response.setCharacterEncoding("UTF-8");
|
response.setCharacterEncoding("UTF-8");
|
||||||
response.setHeader("Content-Type", "application/json");
|
response.setHeader("Content-Type", "application/json");
|
||||||
@ -40,7 +44,7 @@ public class PreviewProtographCommand extends Command {
|
|||||||
StringWriter stringWriter = new StringWriter();
|
StringWriter stringWriter = new StringWriter();
|
||||||
TripleLoaderTransposedNodeFactory nodeFactory = new TripleLoaderTransposedNodeFactory(stringWriter);
|
TripleLoaderTransposedNodeFactory nodeFactory = new TripleLoaderTransposedNodeFactory(stringWriter);
|
||||||
|
|
||||||
Transposer.transpose(project, protograph, protograph.getRootNode(0), nodeFactory);
|
Transposer.transpose(project, filteredRows, protograph, protograph.getRootNode(0), nodeFactory);
|
||||||
nodeFactory.flush();
|
nodeFactory.flush();
|
||||||
|
|
||||||
sb.append("\"tripleloader\" : ");
|
sb.append("\"tripleloader\" : ");
|
||||||
@ -50,7 +54,7 @@ public class PreviewProtographCommand extends Command {
|
|||||||
{
|
{
|
||||||
MqlreadLikeTransposedNodeFactory nodeFactory = new MqlreadLikeTransposedNodeFactory();
|
MqlreadLikeTransposedNodeFactory nodeFactory = new MqlreadLikeTransposedNodeFactory();
|
||||||
|
|
||||||
Transposer.transpose(project, protograph, protograph.getRootNode(0), nodeFactory);
|
Transposer.transpose(project, filteredRows, protograph, protograph.getRootNode(0), nodeFactory);
|
||||||
|
|
||||||
JSONArray results = nodeFactory.getJSON();
|
JSONArray results = nodeFactory.getJSON();
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public class TripleloaderExporter implements Exporter {
|
|||||||
|
|
||||||
TripleLoaderTransposedNodeFactory nodeFactory = new TripleLoaderTransposedNodeFactory(writer);
|
TripleLoaderTransposedNodeFactory nodeFactory = new TripleLoaderTransposedNodeFactory(writer);
|
||||||
|
|
||||||
Transposer.transpose(project, protograph, protograph.getRootNode(0), nodeFactory, -1);
|
Transposer.transpose(project, engine.getAllFilteredRows(), protograph, protograph.getRootNode(0), nodeFactory, -1);
|
||||||
nodeFactory.flush();
|
nodeFactory.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@ package com.metaweb.gridworks.protograph.transpose;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.metaweb.gridworks.browsing.FilteredRows;
|
||||||
|
import com.metaweb.gridworks.browsing.RowVisitor;
|
||||||
import com.metaweb.gridworks.expr.ExpressionUtils;
|
import com.metaweb.gridworks.expr.ExpressionUtils;
|
||||||
import com.metaweb.gridworks.model.Cell;
|
import com.metaweb.gridworks.model.Cell;
|
||||||
import com.metaweb.gridworks.model.Column;
|
import com.metaweb.gridworks.model.Column;
|
||||||
@ -23,15 +25,17 @@ import com.metaweb.gridworks.protograph.ValueNode;
|
|||||||
public class Transposer {
|
public class Transposer {
|
||||||
static public void transpose(
|
static public void transpose(
|
||||||
Project project,
|
Project project,
|
||||||
|
FilteredRows filteredRows,
|
||||||
Protograph protograph,
|
Protograph protograph,
|
||||||
Node rootNode,
|
Node rootNode,
|
||||||
TransposedNodeFactory nodeFactory
|
TransposedNodeFactory nodeFactory
|
||||||
) {
|
) {
|
||||||
transpose(project, protograph, rootNode, nodeFactory, 20);
|
transpose(project, filteredRows, protograph, rootNode, nodeFactory, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void transpose(
|
static public void transpose(
|
||||||
Project project,
|
Project project,
|
||||||
|
FilteredRows filteredRows,
|
||||||
Protograph protograph,
|
Protograph protograph,
|
||||||
Node rootNode,
|
Node rootNode,
|
||||||
TransposedNodeFactory nodeFactory,
|
TransposedNodeFactory nodeFactory,
|
||||||
@ -39,12 +43,50 @@ public class Transposer {
|
|||||||
) {
|
) {
|
||||||
Context rootContext = new Context(rootNode, null, null, limit);
|
Context rootContext = new Context(rootNode, null, null, limit);
|
||||||
|
|
||||||
for (Row row : project.rows) {
|
filteredRows.accept(project, new RowVisitor() {
|
||||||
descend(project, protograph, nodeFactory, row, rootNode, rootContext);
|
Context rootContext;
|
||||||
if (rootContext.limit > 0 && rootContext.count > rootContext.limit) {
|
Protograph protograph;
|
||||||
break;
|
Node rootNode;
|
||||||
}
|
TransposedNodeFactory nodeFactory;
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
public boolean visit(Project project, int rowIndex, Row row) {
|
||||||
|
if (rootContext.limit <= 0 || rootContext.count < rootContext.limit) {
|
||||||
|
descend(project, protograph, nodeFactory, row, rootNode, rootContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rootContext.limit > 0 && rootContext.count > rootContext.limit) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(Project project) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void end(Project project) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public RowVisitor init(
|
||||||
|
Context rootContext,
|
||||||
|
Protograph protograph,
|
||||||
|
Node rootNode,
|
||||||
|
TransposedNodeFactory nodeFactory
|
||||||
|
) {
|
||||||
|
this.rootContext = rootContext;
|
||||||
|
this.protograph = protograph;
|
||||||
|
this.rootNode = rootNode;
|
||||||
|
this.nodeFactory = nodeFactory;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}.init(rootContext, protograph, rootNode, nodeFactory));
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected void descend(
|
static protected void descend(
|
||||||
|
@ -118,7 +118,7 @@ FreebaseLoadingDialog.prototype._createDialog = function() {
|
|||||||
var show_triples = function(cont) {
|
var show_triples = function(cont) {
|
||||||
$.post(
|
$.post(
|
||||||
"/command/preview-protograph?" + $.param({ project: theProject.id }),
|
"/command/preview-protograph?" + $.param({ project: theProject.id }),
|
||||||
{ protograph: JSON.stringify(theProject.protograph) },
|
{ protograph: JSON.stringify(theProject.protograph), engine: JSON.stringify(ui.browsingEngine.getJSON()) },
|
||||||
function(data) {
|
function(data) {
|
||||||
if ("tripleloader" in data) {
|
if ("tripleloader" in data) {
|
||||||
body.html(
|
body.html(
|
||||||
@ -192,6 +192,7 @@ FreebaseLoadingDialog.prototype._load = function() {
|
|||||||
{
|
{
|
||||||
project: theProject.id,
|
project: theProject.id,
|
||||||
"graph" : (freebase) ? "otg" : "sandbox",
|
"graph" : (freebase) ? "otg" : "sandbox",
|
||||||
|
"engine" : JSON.stringify(ui.browsingEngine.getJSON()),
|
||||||
"source_name" : self._elmts.source_name.val(),
|
"source_name" : self._elmts.source_name.val(),
|
||||||
"source_id" : self._elmts.source_id.val()
|
"source_id" : self._elmts.source_id.val()
|
||||||
},
|
},
|
||||||
|
@ -257,7 +257,7 @@ SchemaAlignmentDialog.prototype.preview = function() {
|
|||||||
var protograph = this.getJSON();
|
var protograph = this.getJSON();
|
||||||
$.post(
|
$.post(
|
||||||
"/command/preview-protograph?" + $.param({ project: theProject.id }),
|
"/command/preview-protograph?" + $.param({ project: theProject.id }),
|
||||||
{ protograph: JSON.stringify(protograph) },
|
{ protograph: JSON.stringify(protograph), engine: JSON.stringify(ui.browsingEngine.getJSON()) },
|
||||||
function(data) {
|
function(data) {
|
||||||
if ("mqllike" in data) {
|
if ("mqllike" in data) {
|
||||||
$(self._previewPanes[0]).text(JSON.stringify(data.mqllike, null, 2));
|
$(self._previewPanes[0]).text(JSON.stringify(data.mqllike, null, 2));
|
||||||
|
Loading…
Reference in New Issue
Block a user