From 0bb9d09815d9bf7f1eaa45b36388310dcf68b6e2 Mon Sep 17 00:00:00 2001 From: brianjlowe Date: Tue, 12 Feb 2013 16:40:30 -0500 Subject: [PATCH] modifications to SPARQL queries to allow data to be in the unnamed graph --- .../vitro/webapp/dao/jena/IndividualDaoSDB.java | 6 +++++- .../vitro/webapp/dao/jena/VClassDaoSDB.java | 2 -- webapp/web/templates/edit/specific/ents_edit.jsp | 14 ++++++++++---- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoSDB.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoSDB.java index 7b7ec4281..388a69078 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoSDB.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoSDB.java @@ -438,13 +438,17 @@ public class IndividualDaoSDB extends IndividualDaoJena { final List list = new LinkedList(); - // get all labeled resources from any non-tbox and non-metadata graphs. + // get all labeled resources from any non-tbox and non-metadata graphs, + // as well as the unnamed graph (first pattern below) String query = "SELECT DISTINCT ?ind WHERE { \n" + + " { ?ind <" + RDFS.label.getURI() + "> ?label } " + + " UNION { " + " GRAPH ?g { ?ind <" + RDFS.label.getURI() + "> ?label } \n" + " FILTER (?g != <" + JenaDataSourceSetupBase .JENA_APPLICATION_METADATA_MODEL + "> " + " && !regex(str(?g),\"tbox\")) \n " + + " } " + "}"; Query q = QueryFactory.create(query); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassDaoSDB.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassDaoSDB.java index 3ce03edca..c177161fa 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassDaoSDB.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassDaoSDB.java @@ -139,10 +139,8 @@ public class VClassDaoSDB extends VClassDaoJena { try { String queryText = "SELECT COUNT( DISTINCT ?instance ) WHERE { \n" + - " GRAPH { \n" + " ?class <"+VitroVocabulary.IN_CLASSGROUP+"> <"+vcg.getURI() +"> .\n" + " ?instance a ?class . \n" + - " } \n" + "} \n" ; Query countQuery = QueryFactory.create(queryText, Syntax.syntaxARQ); diff --git a/webapp/web/templates/edit/specific/ents_edit.jsp b/webapp/web/templates/edit/specific/ents_edit.jsp index cc5df1e7f..3377c525e 100644 --- a/webapp/web/templates/edit/specific/ents_edit.jsp +++ b/webapp/web/templates/edit/specific/ents_edit.jsp @@ -37,9 +37,12 @@ SELECT ?pred ?predLabel ?obj ?objLabel ?graph WHERE { + { <${entity.URI}> ?pred ?obj + MINUS { GRAPH ?g { <${entity.URI}> ?pred ?obj } } } + UNION { GRAPH ?graph { <${entity.URI}> ?pred ?obj} } - OPTIONAL { GRAPH ?h { ?obj rdfs:label ?objLabel } } - OPTIONAL { GRAPH ?i { ?pred rdfs:label ?predLabel } } + OPTIONAL { ?obj rdfs:label ?objLabel } + OPTIONAL { ?pred rdfs:label ?predLabel } } ORDER BY ?graph ?pred limit 10000"/>
@@ -54,9 +57,12 @@ SELECT ?sub ?subL ?pred ?predLabel ?graph WHERE { + { ?sub ?pred <${entity.URI}> + MINUS { GRAPH ?g { ?sub ?pred <${entity.URI}> } } } + UNION { GRAPH ?graph { ?sub ?pred <${entity.URI}> } } - OPTIONAL { GRAPH ?h { ?sub rdfs:label ?subL } } - OPTIONAL { GRAPH ?i { ?pred rdfs:label ?predLabel } } + OPTIONAL { ?sub rdfs:label ?subL } + OPTIONAL { ?pred rdfs:label ?predLabel } } ORDER BY ?graph ?pred limit 10000"/>