Skip to content

Commit

Permalink
Updated rdf extension: added vocabulary force import option
Browse files Browse the repository at this point in the history
  • Loading branch information
sparkica committed Mar 25, 2013
1 parent 696e644 commit 74d599a
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<div class="note" bind="uri_note"></div>
</td>
</tr>
<tr><td>Force input:</td><td><input type="checkbox" bind="forceImport"></td></tr>
</table>
<div bind="fetching_options_table">
<fieldset class="rdf-reconcile-fieldset">
Expand Down
47 changes: 36 additions & 11 deletions extensions/rdf-extension/module/scripts/menu-bar-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ ExporterManager.MenuItems.push(
}
);

ExporterManager.MenuItems.push(
{
"id" : "exportRdfVirtuoso",
"label":"Upload RDF to Sparql endpoint ",
"click": function() { RdfExporterMenuBar.exportRDF("Virtuoso", ""); }
}
);


RdfExporterMenuBar = {};

RdfExporterMenuBar.exportRDF = function(format, ext) {
Expand All @@ -22,10 +31,25 @@ RdfExporterMenuBar.exportRDF = function(format, ext) {
"You haven't done any RDF schema alignment yet!"
);
} else {
RdfExporterMenuBar.rdfExportRows(format, ext);
if(format === "Virtuoso") {
RdfExporterMenuBar.rdfExportTriples();
}
else {
RdfExporterMenuBar.rdfExportRows(format, ext);
}
}
};

RdfExporterMenuBar.rdfExportTriples = function() {

//TODO: create a form for entering SPARQL endpoint
//and setting a default graph (or create a new one)
//TODO: dealing with authentication via OAuth

alert("Uploading triples to Virtuoso");
};


RdfExporterMenuBar.rdfExportRows = function(format, ext) {
var name = $.trim(theProject.metadata.name.replace(/\W/g, ' ')).replace(/\s+/g, '-');
var form = document.createElement("form");
Expand Down Expand Up @@ -136,10 +160,10 @@ function ReconciliationStanbolServiceDialog() {
$.each(data, function(i, obj) {
//check issue #579: http:https://code.google.com/p/google-refine/issues/detail?id=579
if (ReconciliationManager.getServiceFromUrl(obj.uri)) {
self.printAddedService(registering, obj, false)
self.printAddedService(registering, obj, false);
} else {
ReconciliationManager.registerStandardService(obj.uri, function(index) {
self.printAddedService(registering, obj, true)
self.printAddedService(registering, obj, true);
});
}
});
Expand All @@ -152,7 +176,7 @@ function ReconciliationStanbolServiceDialog() {
} else {
inputUri.addClass("error");
inputUri.after($('<img src="extension/rdf-extension/images/no.png" width="16" height="16" alt="invalid" class="validation" id="validation-img" />'));
alert("Not valid URI")
alert("Not a valid URI");
}
});

Expand Down Expand Up @@ -180,7 +204,7 @@ function ReconciliationSindiceServiceDialog(){
var frame = DialogSystem.createDialog();
frame.width("400px");

var header = $('<div></div>').addClass("dialog-header").text("Add reconciliation service").appendTo(frame);
$('<div></div>').addClass("dialog-header").text("Add reconciliation service").appendTo(frame);
var body = $('<div class="grid-layout layout-full"></div>').addClass("dialog-body").appendTo(frame);
var footer = $('<div></div>').addClass("dialog-footer").appendTo(frame);

Expand Down Expand Up @@ -252,8 +276,8 @@ function ReconciliationRdfServiceDialog(){

frame.width("600px");

var header = $('<div></div>').addClass("dialog-header").text("Add file-based reconciliation service").appendTo(frame);
var body = $('<div></div>').addClass("dialog-body").append(dialog).appendTo(frame);
$('<div></div>').addClass("dialog-header").text("Add file-based reconciliation service").appendTo(frame);
$('<div></div>').addClass("dialog-body").append(dialog).appendTo(frame);
var footer = $('<div></div>').addClass("dialog-footer").appendTo(frame);

this._level = DialogSystem.showDialog(frame);
Expand Down Expand Up @@ -294,7 +318,8 @@ ReconciliationRdfServiceDialog.prototype._footer = function(footer){
return;
}

var services = ReconciliationManager.getAllServices();
//var services = ;
ReconciliationManager.getAllServices();

$.post("command/rdf-extension/addService",
{"datasource":"file_url","name":name,"url":file_url,properties:prop_uris, "file_format":file_format},
Expand Down Expand Up @@ -341,8 +366,8 @@ function ReconciliationSparqlServiceDialog(){

frame.width("600px");

var header = $('<div></div>').addClass("dialog-header").text("Add SPARQL-based reconciliation service").appendTo(frame);
var body = $('<div></div>').addClass("dialog-body").append(dialog).appendTo(frame);
$('<div></div>').addClass("dialog-header").text("Add SPARQL-based reconciliation service").appendTo(frame);
$('<div></div>').addClass("dialog-body").append(dialog).appendTo(frame);
var footer = $('<div></div>').addClass("dialog-footer").appendTo(frame);

this._level = DialogSystem.showDialog(frame);
Expand All @@ -355,7 +380,7 @@ ReconciliationSparqlServiceDialog.prototype._footer = function(footer){
$('<button></button>').addClass('button').html("&nbsp;&nbsp;OK&nbsp;&nbsp;").click(function() {
self._dismissBusy = DialogSystem.showBusy('Adding new reconciliation service');
var name = self._elmts.service_name.val();
var endpoint = self._elmts.endpoint_url.val()
var endpoint = self._elmts.endpoint_url.val();
var graph_uri = self._elmts.graph_uri.val();
if(name.trim()===""){
alert("Name is required");
Expand Down
46 changes: 0 additions & 46 deletions extensions/rdf-extension/module/scripts/new-prefix-widget.html

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RdfDataTableView.previewUrisOnVisibleRows = function(column, title, expression,
RdfDataTableView.previewOnVisibleRows = function(isLiteral,column, title, expression, isRowNumberCell, baseUri, onDone) {
var o = DataTableView.sampleVisibleRows(column);

var self = this;
//var self = this;

function f () {}

Expand Down Expand Up @@ -38,7 +38,7 @@ RdfDataTableView.previewOnVisibleRows = function(isLiteral,column, title, expres
var frame = DialogSystem.createDialog();
frame.width("700px");

var header = $('<div></div>').addClass("dialog-header").text(title).appendTo(frame);
$('<div></div>').addClass("dialog-header").text(title).appendTo(frame);
var body = $('<div></div>').addClass("dialog-body").appendTo(frame);
var footer = $('<div></div>').addClass("dialog-footer").appendTo(frame);
var html = $(self.generateWidgetHtmlOnlyGrel()).appendTo(body);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RdfSchemaAlignmentDialog.UILink = function(dialog, link, table, options, parentU
this._parentUINode = parentUINode;

// Make sure target node is there
this._link.target = this._link.target || { nodeType: "cell-as-literal" }
this._link.target = this._link.target || { nodeType: "cell-as-literal" };

this._tr = table.insertRow(table.rows.length);
this._tdMain = this._tr.insertCell(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RdfSchemaAlignmentDialog.UINode = function(dialog, node, table, options) {

this._linkUIs = [];
this._detailsRendered = false;

this._tr = table.insertRow(table.rows.length);
this._tdMain = this._tr.insertCell(0);
this._tdToggle = this._tr.insertCell(1);
Expand Down Expand Up @@ -261,7 +261,7 @@ RdfSchemaAlignmentDialog.UINode.prototype._showNodeConfigDialog = function(){

frame.width("610px");

var header = $('<div></div>').addClass("dialog-header").text("RDF Node").appendTo(frame);
$('<div></div>').addClass("dialog-header").text("RDF Node").appendTo(frame);
var body = $('<div class="grid-layout layout-full"></div>').addClass("dialog-body rdf-schema").appendTo(frame);
var footer = $('<div></div>').addClass("dialog-footer").appendTo(frame);

Expand Down Expand Up @@ -386,7 +386,7 @@ RdfSchemaAlignmentDialog.UINode.prototype._showNodeConfigDialog = function(){

var makeRowIndexChoice = function(checked) {
var tr = tableColumns.insertRow(tableColumns.rows.length);
var radio = $('<input />')
$('<input />')
.attr("type", "radio")
.attr("checked", checked)
.attr("value","")
Expand All @@ -405,7 +405,7 @@ RdfSchemaAlignmentDialog.UINode.prototype._showNodeConfigDialog = function(){

var makeConstantValueChoice = function(checked,value){
var tr = tableColumns.insertRow(tableColumns.rows.length);
var radio = $('<input />')
$('<input />')
.attr("type", "radio")
.attr("checked", checked)
.attr("value","")
Expand Down Expand Up @@ -615,7 +615,7 @@ RdfSchemaAlignmentDialog.UINode.prototype._showNodeConfigDialog = function(){
node.rdfTypes = cloneDeep(self._node.rdfTypes);
}

DialogSystem.dismissUntil(level - 1);
DialogSystem.dismissUntil(self._level - 1);

self._node = node;
/*if('columnIndex' in node){
Expand All @@ -631,15 +631,15 @@ RdfSchemaAlignmentDialog.UINode.prototype._showNodeConfigDialog = function(){
}).appendTo(footer);

$('<button></button>').addClass('button').text("Cancel").click(function() {
DialogSystem.dismissUntil(level - 1);
DialogSystem.dismissUntil(self._level - 1);
}).appendTo(footer);


var level = DialogSystem.showDialog(frame);
self._level = DialogSystem.showDialog(frame);
};

RdfSchemaAlignmentDialog.UINode.prototype._preview = function(expr,columnName,isUri){
var self = this;
//var self = this;
if(isUri){
RdfDataTableView.previewUrisOnVisibleRows(
{
Expand Down Expand Up @@ -854,7 +854,7 @@ RdfSchemaAlignmentDialog.NewRdfResourceDialog = function(elmt,defaultVal,onDone)
});
};
RdfSchemaAlignmentDialog.RdfResourceDialog = function(elmt,lookFor,projectId,parent,prefixesManager,onDone){
var self = this;
//var self = this;
var menu = MenuSystem.createMenu().width('250px');
menu.html('<div class="schema-alignment-link-menu-type-search">' +
'<span>Search for ' + lookFor + ':</span>' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ RdfSchemaAlignmentDialog.prototype._constructBody = function(body) {

self._elmts.add_another_root_node.click(function(e){
e.preventDefault();
var newRootNode = RdfSchemaAlignment.createNewRootNode(false)
var newRootNode = RdfSchemaAlignment.createNewRootNode(false);
self._schema.rootNodes.push(newRootNode);
self._nodeUIs.push(new RdfSchemaAlignmentDialog.UINode(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ ManageVocabsWidget.prototype.renderBody = function(){
}
}
);
}
};
};

var getRefreshHandler = function(name,uri){
Expand All @@ -92,7 +92,7 @@ ManageVocabsWidget.prototype.renderBody = function(){
}
});
}
}
};
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ NewPrefixWidget.prototype.show = function(msg,def_prefix, onDone){
return;
}

var force_import = (self._elmts.forceImport.attr('checked') !== undefined);

var dismissBusy;

if(fetchOption === 'file'){
Expand All @@ -51,6 +53,7 @@ NewPrefixWidget.prototype.show = function(msg,def_prefix, onDone){
if (data.code === 'error')
{
alert("Error: " + data.message);

} else {
if(onDone){
onDone(name,uri);
Expand All @@ -72,13 +75,18 @@ NewPrefixWidget.prototype.show = function(msg,def_prefix, onDone){
uri:uri,
"fetch-url":uri,
project: theProject.id,
"force-import": force_import,
fetch:fetchOption
},
function(data)
{
dismissBusy();
if (data.code === "error"){
alert('Error:' + data.message)
alert('Error:' + data.message);
//todo: add force input option
console.log("Force import...");
console.log(force_import);

}else{
if(onDone){
onDone(name,uri);
Expand All @@ -105,7 +113,7 @@ NewPrefixWidget.prototype.show = function(msg,def_prefix, onDone){
self._elmts.fetching_options_table.show();
$('#advanced_options_button').hide();
$('#advanced_options_button').attr("disabled", "true");
})
});

self._elmts.fetching_options_table
.hide()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.deri.grefine.rdf.vocab.PrefixExistException;
import org.deri.grefine.rdf.vocab.VocabularyImportException;
import org.deri.grefine.rdf.vocab.VocabularyImporter;
import org.json.JSONException;

public class AddPrefixCommand extends RdfCommand{

Expand All @@ -23,6 +24,8 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) thr
String uri = request.getParameter("uri").trim();
String projectId = request.getParameter("project");
String fetchOption = request.getParameter("fetch");
Boolean forceImport = Boolean.valueOf(request.getParameter("force-import"));

try {

if(fetchOption.equals("web")){
Expand All @@ -38,15 +41,26 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) thr


} catch (PrefixExistException e) {
//in case something went wrong importing the prefix, remove it from manager
//in case something went wrong importing the prefix, remove it from manager
getRdfSchema(request).removePrefix(name);
respondException(response, e);

} catch (VocabularyImportException e) {
//respondException(response, e);
logger.warn("Vocabulary import exception: " + e.getLocalizedMessage());
getRdfSchema(request).removePrefix(name);
respondException(response,e);
//logger.warning("Vocabulary import exception: " + e.getLocalizedMessage());
//TODO: if force import was checked, respond with OK, do not remove it from manager

if(forceImport) {
try {
respond(response,"ok", "Vocabulary added, but not imported.");
} catch (JSONException e1) {
respondException(response,e1);
}

}
else {
getRdfSchema(request).removePrefix(name);
respondException(response,e);
}
}
catch (Exception e1){
logger.warn("General exception");
Expand Down
Loading

0 comments on commit 74d599a

Please sign in to comment.