Shorter QuickStatements preview and better export UI
This commit is contained in:
parent
035e7b82bc
commit
f763e8c6ad
@ -1,18 +1,18 @@
|
||||
/*
|
||||
ExporterManager.MenuItems.push({});//add separator
|
||||
ExporterManager.MenuItems.push(
|
||||
{
|
||||
"id" : "exportRdfXml",
|
||||
"label":"RDF as RDF/XML",
|
||||
"click": function() { RdfExporterMenuBar.exportRDF("rdf", "rdf");}
|
||||
}
|
||||
{
|
||||
"id" : "exportRdfXml",
|
||||
"label":"RDF as RDF/XML",
|
||||
"click": function() { RdfExporterMenuBar.exportRDF("rdf", "rdf");}
|
||||
}
|
||||
);
|
||||
ExporterManager.MenuItems.push(
|
||||
{
|
||||
"id" : "exportRdfTurtle",
|
||||
"label":"RDF as Turtle",
|
||||
"click": function() { RdfExporterMenuBar.exportRDF("Turtle", "ttl"); }
|
||||
}
|
||||
{
|
||||
"id" : "exportRdfTurtle",
|
||||
"label":"RDF as Turtle",
|
||||
"click": function() { RdfExporterMenuBar.exportRDF("Turtle", "ttl"); }
|
||||
}
|
||||
);
|
||||
|
||||
RdfExporterMenuBar = {};
|
||||
@ -62,12 +62,13 @@ RdfExporterMenuBar.editRdfSchema = function(reset) {
|
||||
};
|
||||
*/
|
||||
|
||||
ExporterManager.MenuItems.push({});
|
||||
ExporterManager.MenuItems.push(
|
||||
{
|
||||
"id" : "exportQuickStatements",
|
||||
"label":"QuickStatements",
|
||||
"click": function() { WikibaseExporterMenuBar.exportTo("quickstatements"); }
|
||||
}
|
||||
{
|
||||
"id" : "exportQuickStatements",
|
||||
"label":"QuickStatements",
|
||||
"click": function() { WikibaseExporterMenuBar.exportTo("quickstatements"); }
|
||||
}
|
||||
);
|
||||
|
||||
WikibaseExporterMenuBar = {};
|
||||
@ -102,18 +103,23 @@ WikibaseExporterMenuBar.exportTo = function(format) {
|
||||
//extend the column header menu
|
||||
$(function(){
|
||||
|
||||
ExtensionBar.MenuItems.push(
|
||||
{
|
||||
"id":"reconcile",
|
||||
"label": "Wikidata",
|
||||
"submenu" : [
|
||||
{
|
||||
"id": "wikidata/edit-schema",
|
||||
label: "Edit Wikibase schema...",
|
||||
click: function() { SchemaAlignmentDialog.launch(false); }
|
||||
},
|
||||
]
|
||||
}
|
||||
);
|
||||
ExtensionBar.MenuItems.push(
|
||||
{
|
||||
"id":"reconcile",
|
||||
"label": "Wikidata",
|
||||
"submenu" : [
|
||||
{
|
||||
"id": "wikidata/edit-schema",
|
||||
label: "Edit Wikibase schema...",
|
||||
click: function() { SchemaAlignmentDialog.launch(false); }
|
||||
},
|
||||
{
|
||||
"id":"wikidata/export-qs",
|
||||
"label": "Export to QuickStatements",
|
||||
"click": function() { WikibaseExporterMenuBar.exportTo("quickstatements"); }
|
||||
}
|
||||
]
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -34,8 +34,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
package org.openrefine.wikidata.commands;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.LineNumberReader;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@ -60,8 +61,6 @@ public class PreviewWikibaseSchemaCommand extends Command {
|
||||
|
||||
try {
|
||||
Project project = getProject(request);
|
||||
Engine engine = getEngine(request, project);
|
||||
FilteredRows filteredRows = engine.getAllFilteredRows();
|
||||
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
@ -79,6 +78,18 @@ public class PreviewWikibaseSchemaCommand extends Command {
|
||||
QuickStatementsExporter exporter = new QuickStatementsExporter();
|
||||
exporter.translateSchema(project, schema, stringWriter);
|
||||
|
||||
String fullQS = stringWriter.toString();
|
||||
stringWriter = new StringWriter();
|
||||
LineNumberReader reader = new LineNumberReader(new StringReader(fullQS));
|
||||
reader.setLineNumber(0);
|
||||
int maxQSLinesForPreview = 50;
|
||||
for(int i = 0; i != maxQSLinesForPreview; i++) {
|
||||
stringWriter.write(reader.readLine()+"\n");
|
||||
}
|
||||
if (reader.getLineNumber() == maxQSLinesForPreview) {
|
||||
stringWriter.write("...");
|
||||
}
|
||||
|
||||
writer.key("quickstatements");
|
||||
writer.value(stringWriter.toString());
|
||||
}
|
||||
|
@ -7,13 +7,13 @@ import org.wikidata.wdtk.datamodel.interfaces.StringValue;
|
||||
|
||||
public abstract class WbStringExpr extends WbValueExpr {
|
||||
public abstract StringValue evaluate(ExpressionContext ctxt) throws SkipStatementException;
|
||||
|
||||
|
||||
public static WbStringExpr fromJSON(JSONObject obj) throws JSONException {
|
||||
String type = obj.getString(jsonTypeKey);
|
||||
if (WbStringConstant.jsonType.equals(type)) {
|
||||
return WbStringConstant.fromJSON(obj);
|
||||
} else if (WbStringVariable.jsonType.equals(type)) {
|
||||
return WbStringVariable.fromJSON2(obj);
|
||||
return WbStringVariable.fromJSON(obj);
|
||||
} else {
|
||||
throw new JSONException("unknown type for WbItemExpr");
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class WbStringVariable extends WbStringExpr {
|
||||
writer.value(columnName);
|
||||
}
|
||||
|
||||
public static WbStringVariable fromJSON2(JSONObject obj) throws JSONException {
|
||||
public static WbStringExpr fromJSON(JSONObject obj) throws JSONException {
|
||||
return new WbStringVariable(obj.getString("columnName"));
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ public abstract class WbValueExpr extends BiJsonizable {
|
||||
} else if (WbItemVariable.jsonType.equals(type)) {
|
||||
valueExpr = WbItemVariable.fromJSON(obj);
|
||||
} else if (WbStringVariable.jsonType.equals(type)) {
|
||||
valueExpr = WbStringVariable.fromJSON2(obj);
|
||||
valueExpr = WbStringVariable.fromJSON(obj);
|
||||
} else if (WbStringConstant.jsonType.equals(type)) {
|
||||
valueExpr = WbStringConstant.fromJSON(obj);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user