NIHVIVO-2316 removed unnecessary graph variables in queries
This commit is contained in:
parent
22507b11c0
commit
29ab2290b6
3 changed files with 22 additions and 40 deletions
|
@ -57,15 +57,13 @@ public class DataPropertyStatementDaoSDB extends DataPropertyStatementDaoJena
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String[] graphVars = { "?g" };
|
|
||||||
String query =
|
String query =
|
||||||
"CONSTRUCT { \n" +
|
"CONSTRUCT { \n" +
|
||||||
" <" + entity.getURI() + "> ?p ?o . \n" +
|
" <" + entity.getURI() + "> ?p ?o . \n" +
|
||||||
"} WHERE { GRAPH ?g { \n" +
|
"} WHERE { \n" +
|
||||||
" <" + entity.getURI() + "> ?p ?o . \n" +
|
" <" + entity.getURI() + "> ?p ?o . \n" +
|
||||||
" FILTER(isLiteral(?o)) \n" +
|
" FILTER(isLiteral(?o)) \n" +
|
||||||
WebappDaoFactorySDB.getFilterBlock(graphVars, datasetMode) +
|
"}" ;
|
||||||
"} }" ;
|
|
||||||
Model results = null;
|
Model results = null;
|
||||||
DatasetWrapper w = dwf.getDatasetWrapper();
|
DatasetWrapper w = dwf.getDatasetWrapper();
|
||||||
Dataset dataset = w.getDataset();
|
Dataset dataset = w.getDataset();
|
||||||
|
|
|
@ -395,8 +395,8 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
String[] graphVars = { "?g" };
|
String[] graphVars = { "?g" };
|
||||||
String queryStr =
|
String queryStr =
|
||||||
"CONSTRUCT { <"+ind.getURI()+"> <" + propertyURI + "> ?value } \n" +
|
"CONSTRUCT { <"+ind.getURI()+"> <" + propertyURI + "> ?value } \n" +
|
||||||
"WHERE { GRAPH ?g { \n" +
|
"WHERE { \n" +
|
||||||
"<" + ind.getURI() +"> <" + propertyURI + "> ?value } \n" +
|
"<" + ind.getURI() +"> <" + propertyURI + "> ?value \n" +
|
||||||
WebappDaoFactorySDB.getFilterBlock(graphVars, datasetMode) +
|
WebappDaoFactorySDB.getFilterBlock(graphVars, datasetMode) +
|
||||||
"\n} ";
|
"\n} ";
|
||||||
Query query = QueryFactory.create(queryStr);
|
Query query = QueryFactory.create(queryStr);
|
||||||
|
@ -502,14 +502,11 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
if( _hasThumb != null ){
|
if( _hasThumb != null ){
|
||||||
return _hasThumb;
|
return _hasThumb;
|
||||||
}else{
|
}else{
|
||||||
String[] graphVars = { "?g" };
|
|
||||||
String ask =
|
String ask =
|
||||||
"ASK { GRAPH ?g " +
|
"ASK { " +
|
||||||
" { <" + individualURI + "> <http://vitro.mannlib.cornell.edu/ns/vitro/public#mainImage> ?mainImage . \n" +
|
" <" + individualURI + "> <http://vitro.mannlib.cornell.edu/ns/vitro/public#mainImage> ?mainImage . \n" +
|
||||||
" ?mainImage <http://vitro.mannlib.cornell.edu/ns/vitro/public#thumbnailImage> ?thumbImage . }\n" +
|
" ?mainImage <http://vitro.mannlib.cornell.edu/ns/vitro/public#thumbnailImage> ?thumbImage . }\n" ;
|
||||||
WebappDaoFactorySDB.getFilterBlock(graphVars, datasetMode) +
|
DatasetWrapper w = getDatasetWrapper();
|
||||||
"}";
|
|
||||||
DatasetWrapper w = getDatasetWrapper();
|
|
||||||
Dataset dataset = w.getDataset();
|
Dataset dataset = w.getDataset();
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
try{
|
try{
|
||||||
|
@ -552,10 +549,8 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
Dataset dataset = w.getDataset();
|
Dataset dataset = w.getDataset();
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
try {
|
try {
|
||||||
String graphVars[] = { "?g" };
|
|
||||||
StringBuffer selectPrimaryLinkQueryBuff = new StringBuffer().append(
|
StringBuffer selectPrimaryLinkQueryBuff = new StringBuffer().append(
|
||||||
"SELECT ?url ?anchor \n" ).append(
|
"SELECT ?url ?anchor \n" ).append(" WHERE { \n").append(
|
||||||
"WHERE{ GRAPH ?g { \n " ).append(
|
|
||||||
" <" + this.individualURI + "> ").append(
|
" <" + this.individualURI + "> ").append(
|
||||||
"<" + VitroVocabulary.PRIMARY_LINK + "> " ).append(
|
"<" + VitroVocabulary.PRIMARY_LINK + "> " ).append(
|
||||||
"?link . \n").append(
|
"?link . \n").append(
|
||||||
|
@ -563,9 +558,7 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
).append(
|
).append(
|
||||||
" ?link <" + VitroVocabulary.LINK_ANCHOR + "> ?anchor . \n"
|
" ?link <" + VitroVocabulary.LINK_ANCHOR + "> ?anchor . \n"
|
||||||
).append(
|
).append(
|
||||||
"} \n")
|
"} \n");
|
||||||
.append(WebappDaoFactorySDB.getFilterBlock(graphVars, datasetMode))
|
|
||||||
.append("}");
|
|
||||||
QueryExecution qexec = QueryExecutionFactory.create(
|
QueryExecution qexec = QueryExecutionFactory.create(
|
||||||
QueryFactory.create(selectPrimaryLinkQueryBuff.toString())
|
QueryFactory.create(selectPrimaryLinkQueryBuff.toString())
|
||||||
, dataset);
|
, dataset);
|
||||||
|
@ -678,12 +671,9 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
Dataset dataset = w.getDataset();
|
Dataset dataset = w.getDataset();
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
try {
|
try {
|
||||||
String[] graphVars = { "?g" };
|
|
||||||
String valuesOfProperty =
|
String valuesOfProperty =
|
||||||
"CONSTRUCT{<" + this.individualURI + "> <" + propertyURI + "> ?object}" +
|
"CONSTRUCT{ <" + this.individualURI + "> <" + propertyURI + "> ?object }" +
|
||||||
"WHERE{ GRAPH ?g { <" + this.individualURI + "> <" + propertyURI + "> ?object} \n" +
|
"WHERE{ <" + this.individualURI + "> <" + propertyURI + "> ?object } \n";
|
||||||
WebappDaoFactorySDB.getFilterBlock(graphVars, datasetMode) +
|
|
||||||
"}";
|
|
||||||
tempModel = QueryExecutionFactory.create(QueryFactory.create(valuesOfProperty), dataset).execConstruct();
|
tempModel = QueryExecutionFactory.create(QueryFactory.create(valuesOfProperty), dataset).execConstruct();
|
||||||
ontModel.add(tempModel.listStatements());
|
ontModel.add(tempModel.listStatements());
|
||||||
Resource ontRes = ontModel.getResource(this.individualURI);
|
Resource ontRes = ontModel.getResource(this.individualURI);
|
||||||
|
@ -727,13 +717,10 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
Dataset dataset = w.getDataset();
|
Dataset dataset = w.getDataset();
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
try {
|
try {
|
||||||
String[] graphVars = { "?g" };
|
|
||||||
String valuesOfProperty =
|
String valuesOfProperty =
|
||||||
"SELECT ?object" +
|
"SELECT ?object" +
|
||||||
"WHERE{ GRAPH ?g { <" + this.individualURI + "> <" +
|
"WHERE{ <" + this.individualURI + "> <" +
|
||||||
propertyURI + "> ?object} \n" +
|
propertyURI + "> ?object } \n";
|
||||||
WebappDaoFactorySDB.getFilterBlock(graphVars, datasetMode) +
|
|
||||||
"}";
|
|
||||||
ResultSet values = QueryExecutionFactory.create(
|
ResultSet values = QueryExecutionFactory.create(
|
||||||
QueryFactory.create(valuesOfProperty), dataset)
|
QueryFactory.create(valuesOfProperty), dataset)
|
||||||
.execSelect();
|
.execSelect();
|
||||||
|
@ -767,13 +754,10 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
Dataset dataset = w.getDataset();
|
Dataset dataset = w.getDataset();
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
try {
|
try {
|
||||||
String[] graphVars = { "?g" };
|
|
||||||
String valueOfProperty =
|
String valueOfProperty =
|
||||||
"SELECT ?object " +
|
"SELECT ?object " +
|
||||||
"WHERE{ GRAPH ?g { <" + this.individualURI + "> <" +
|
"WHERE{ <" + this.individualURI + "> <" +
|
||||||
propertyURI + "> ?object} \n" +
|
propertyURI + "> ?object } \n";
|
||||||
WebappDaoFactorySDB.getFilterBlock(graphVars, datasetMode) +
|
|
||||||
"}";
|
|
||||||
QueryExecution qe = QueryExecutionFactory.create(
|
QueryExecution qe = QueryExecutionFactory.create(
|
||||||
QueryFactory.create(valueOfProperty), dataset);
|
QueryFactory.create(valueOfProperty), dataset);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -34,13 +34,13 @@
|
||||||
<c:set var="query"
|
<c:set var="query"
|
||||||
value="PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
value="PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
||||||
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||||
SELECT ?pred ?predLabel ?obj ?objLabel
|
SELECT ?pred ?predLabel ?obj ?objLabel ?graph
|
||||||
WHERE
|
WHERE
|
||||||
{
|
{
|
||||||
{ GRAPH ?g { <${entity.URI}> ?pred ?obj} }
|
{ GRAPH ?graph { <${entity.URI}> ?pred ?obj} }
|
||||||
OPTIONAL { GRAPH ?h { ?obj rdfs:label ?objLabel } }
|
OPTIONAL { GRAPH ?h { ?obj rdfs:label ?objLabel } }
|
||||||
OPTIONAL { GRAPH ?i { ?pred rdfs:label ?predLabel } }
|
OPTIONAL { GRAPH ?i { ?pred rdfs:label ?predLabel } }
|
||||||
}
|
} ORDER BY ?graph ?pred
|
||||||
limit 10000"/>
|
limit 10000"/>
|
||||||
<form action="admin/sparqlquery" method="get">
|
<form action="admin/sparqlquery" method="get">
|
||||||
<input type="hidden" name="query" value="${query}"/>
|
<input type="hidden" name="query" value="${query}"/>
|
||||||
|
@ -51,13 +51,13 @@
|
||||||
<c:set var="query"
|
<c:set var="query"
|
||||||
value="PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
value="PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
||||||
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||||
SELECT ?sub ?subL ?pred ?predLabel
|
SELECT ?sub ?subL ?pred ?predLabel ?graph
|
||||||
WHERE
|
WHERE
|
||||||
{
|
{
|
||||||
{ GRAPH ?g { ?sub ?pred <${entity.URI}> } }
|
{ GRAPH ?graph { ?sub ?pred <${entity.URI}> } }
|
||||||
OPTIONAL { GRAPH ?h { ?sub rdfs:label ?subL } }
|
OPTIONAL { GRAPH ?h { ?sub rdfs:label ?subL } }
|
||||||
OPTIONAL { GRAPH ?i { ?pred rdfs:label ?predLabel } }
|
OPTIONAL { GRAPH ?i { ?pred rdfs:label ?predLabel } }
|
||||||
}
|
} ORDER BY ?graph ?pred
|
||||||
limit 10000"/>
|
limit 10000"/>
|
||||||
<form action="admin/sparqlquery" method="get">
|
<form action="admin/sparqlquery" method="get">
|
||||||
<input type="hidden" name="query" value="${query}"/>
|
<input type="hidden" name="query" value="${query}"/>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue