rolling back undesirable changes from r.7210, 'boatload'
This commit is contained in:
parent
8894597e7e
commit
25abfe0f32
6 changed files with 18 additions and 111 deletions
|
@ -50,19 +50,19 @@ public class ObjectPropertyStatementDaoSDB extends
|
||||||
return entity;
|
return entity;
|
||||||
else {
|
else {
|
||||||
Map<String, ObjectProperty> uriToObjectProperty = new HashMap<String,ObjectProperty>();
|
Map<String, ObjectProperty> uriToObjectProperty = new HashMap<String,ObjectProperty>();
|
||||||
//String[] graphVars = { "?g", "?h", "?i", "?j" };
|
String[] graphVars = { "?g", "?h", "?i", "?j" };
|
||||||
String query = "CONSTRUCT { \n" +
|
String query = "CONSTRUCT { \n" +
|
||||||
" <" + entity.getURI() + "> ?p ?o . \n" +
|
" <" + entity.getURI() + "> ?p ?o . \n" +
|
||||||
// " ?o a ?oType . \n" +
|
" ?o a ?oType . \n" +
|
||||||
" ?o <" + RDFS.label.getURI() + "> ?oLabel . \n" +
|
" ?o <" + RDFS.label.getURI() + "> ?oLabel . \n" +
|
||||||
" ?o <" + VitroVocabulary.MONIKER + "> ?oMoniker \n" +
|
" ?o <" + VitroVocabulary.MONIKER + "> ?oMoniker \n" +
|
||||||
"} WHERE { GRAPH <urn:x-arq:UnionGraph> { \n" +
|
"} WHERE { GRAPH ?g { \n" +
|
||||||
" <" + entity.getURI() + "> ?p ?o \n" +
|
" <" + entity.getURI() + "> ?p ?o \n" +
|
||||||
//" OPTIONAL { GRAPH ?h { ?o a ?oType } } \n" +
|
" OPTIONAL { GRAPH ?h { ?o a ?oType } } \n" +
|
||||||
// " OPTIONAL { { ?o <" + RDFS.label.getURI() + "> ?oLabel } } \n" +
|
" OPTIONAL { GRAPH ?i { ?o <" + RDFS.label.getURI() + "> ?oLabel } } \n" +
|
||||||
// " OPTIONAL { { ?o <" + VitroVocabulary.MONIKER + "> ?oMoniker } } \n" +
|
" OPTIONAL { GRAPH ?j { ?o <" + VitroVocabulary.MONIKER + "> ?oMoniker } } \n" +
|
||||||
"} \n" +
|
"} \n" +
|
||||||
//WebappDaoFactorySDB.getFilterBlock(graphVars, datasetMode) +
|
WebappDaoFactorySDB.getFilterBlock(graphVars, datasetMode) +
|
||||||
"}";
|
"}";
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
Model m = null;
|
Model m = null;
|
||||||
|
|
|
@ -204,7 +204,6 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
|
||||||
union.addSubModel(inferences);
|
union.addSubModel(inferences);
|
||||||
}
|
}
|
||||||
dataset.setDefaultModel(union);
|
dataset.setDefaultModel(union);
|
||||||
dataset.addNamedModel("urn:x-arq:UnionGraph", union);
|
|
||||||
return dataset;
|
return dataset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@ public abstract class BaseObjectPropertyDataPostProcessor implements
|
||||||
|
|
||||||
/** Postprocessing that applies to the list as a whole - reordering, removing duplicates, etc. */
|
/** Postprocessing that applies to the list as a whole - reordering, removing duplicates, etc. */
|
||||||
protected void processList(List<Map<String, String>> data) {
|
protected void processList(List<Map<String, String>> data) {
|
||||||
objectPropertyTemplateModel.removeLessSpecificSolutions(data);
|
|
||||||
objectPropertyTemplateModel.removeDuplicates(data);
|
objectPropertyTemplateModel.removeDuplicates(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -236,68 +236,6 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* For performance reasons, we've had to rewrite SPARQL queries that would
|
|
||||||
* naturally use OPTIONAL blocks to use UNIONs instead. These UNION queries
|
|
||||||
* return a superset of the solutions returned by the originals. This
|
|
||||||
* method filters out the unwanted solutions with extra null values.
|
|
||||||
*
|
|
||||||
* This operation is polynomial time in the worst case, but should be linear
|
|
||||||
* with the actual queries used for list views. The ORDER BY clauses
|
|
||||||
* should minimize the seek distance for solution elimination.
|
|
||||||
*
|
|
||||||
* @param List<Map<String, String>> data
|
|
||||||
*/
|
|
||||||
protected void removeLessSpecificSolutions(List<Map<String, String>> data) {
|
|
||||||
List<Map<String, String>> redundantSolns =
|
|
||||||
new ArrayList<Map<String, String>>();
|
|
||||||
for (int i = 0; i < data.size(); i++) {
|
|
||||||
Map<String,String> soln = data.get(i);
|
|
||||||
boolean redundantSoln = false;
|
|
||||||
// seek forward
|
|
||||||
int j = i + 1;
|
|
||||||
while (!redundantSoln && (j < data.size())) {
|
|
||||||
redundantSoln = isEqualToOrLessSpecificThan(soln, data.get(j));
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
// loop back around
|
|
||||||
j = 0;
|
|
||||||
while (!redundantSoln && (j < i)) {
|
|
||||||
redundantSoln = isEqualToOrLessSpecificThan(soln, data.get(j));
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
if (redundantSoln) {
|
|
||||||
redundantSolns.add(soln);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
data.removeAll(redundantSolns);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if soln1 is equal to or less specific (i.e., has more null
|
|
||||||
* values) than soln2
|
|
||||||
* @param List<Map<String, String>> soln1
|
|
||||||
* @param List<Map<String, String>> soln2
|
|
||||||
*/
|
|
||||||
private boolean isEqualToOrLessSpecificThan (Map<String, String> soln1,
|
|
||||||
Map<String, String> soln2) {
|
|
||||||
if (soln1.keySet().size() < soln2.keySet().size()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
for (String key : soln1.keySet()) {
|
|
||||||
String value1 = soln1.get(key);
|
|
||||||
String value2 = soln2.get(key);
|
|
||||||
if (value2 == null && value1 != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (value1 != null && value2 != null && !value1.equals(value2)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** The SPARQL query results may contain duplicate rows for a single object, if there are multiple solutions
|
/** The SPARQL query results may contain duplicate rows for a single object, if there are multiple solutions
|
||||||
* to the entire query. Remove duplicates here by arbitrarily selecting only the first row returned.
|
* to the entire query. Remove duplicates here by arbitrarily selecting only the first row returned.
|
||||||
* @param List<Map<String, String>> data
|
* @param List<Map<String, String>> data
|
||||||
|
|
|
@ -11,21 +11,9 @@
|
||||||
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||||
|
|
||||||
SELECT ?object ?name ?moniker {
|
SELECT ?object ?name ?moniker {
|
||||||
{
|
GRAPH ?g1 { ?subject ?property ?object }
|
||||||
?subject ?property ?object .
|
OPTIONAL { GRAPH ?g2 { ?object rdfs:label ?name } }
|
||||||
}
|
OPTIONAL { GRAPH ?g3 { ?object vitro:moniker ?moniker } }
|
||||||
UNION {
|
|
||||||
?subject ?property ?object .
|
|
||||||
?object rdfs:label ?name
|
|
||||||
}
|
|
||||||
UNION {
|
|
||||||
?subject ?property ?object .
|
|
||||||
?object vitro:moniker ?moniker
|
|
||||||
} UNION {
|
|
||||||
?subject ?property ?object .
|
|
||||||
?object rdfs:label ?name .
|
|
||||||
?object vitro:moniker ?moniker .
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</query-base>
|
</query-base>
|
||||||
|
|
||||||
|
@ -34,28 +22,11 @@
|
||||||
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||||
|
|
||||||
SELECT ?subclass ?object ?name ?moniker {
|
SELECT ?subclass ?object ?name ?moniker {
|
||||||
|
GRAPH ?g1 { ?subject ?property ?object
|
||||||
{
|
OPTIONAL { ?object a ?subclass }
|
||||||
?subject ?property ?object .
|
|
||||||
?object a ?subclass .
|
|
||||||
}
|
}
|
||||||
UNION {
|
OPTIONAL { GRAPH ?g2 { ?object rdfs:label ?name } }
|
||||||
?subject ?property ?object .
|
OPTIONAL { GRAPH ?g3 { ?object vitro:moniker ?moniker } }
|
||||||
?object a ?subclass .
|
|
||||||
?object rdfs:label ?name
|
|
||||||
}
|
|
||||||
UNION {
|
|
||||||
?subject ?property ?object .
|
|
||||||
?object a ?subclass .
|
|
||||||
?object vitro:moniker ?moniker
|
|
||||||
} UNION {
|
|
||||||
?subject ?property ?object .
|
|
||||||
?object a ?subclass .
|
|
||||||
?object rdfs:label ?name .
|
|
||||||
?object vitro:moniker ?moniker .
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} ORDER BY ?subclass
|
} ORDER BY ?subclass
|
||||||
</query-collated>
|
</query-collated>
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
(afn:localname(?link) AS ?linkName)
|
(afn:localname(?link) AS ?linkName)
|
||||||
?anchor
|
?anchor
|
||||||
?url WHERE {
|
?url WHERE {
|
||||||
?subject ?property ?link
|
GRAPH ?g1 { ?subject ?property ?link }
|
||||||
OPTIONAL { ?link vitro:linkAnchor ?anchor }
|
OPTIONAL { GRAPH ?g2 { ?link vitro:linkAnchor ?anchor } }
|
||||||
OPTIONAL { ?link vitro:linkURL ?url }
|
OPTIONAL { GRAPH ?g3 { ?link vitro:linkURL ?url } }
|
||||||
OPTIONAL { ?link vitro:linkDisplayRank ?rank }
|
OPTIONAL { GRAPH ?g4 { ?link vitro:linkDisplayRank ?rank } }
|
||||||
} ORDER BY ?rank
|
} ORDER BY ?rank
|
||||||
</query-base>
|
</query-base>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue