NIHVIVO-2343 Use a simpler query for the profile auto-complete to try to speed the response. Is it enough?
This commit is contained in:
parent
c5eec65693
commit
437c804432
1 changed files with 48 additions and 13 deletions
|
@ -127,29 +127,36 @@ function statusFieldUpdater(element, minLength) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var profileQuery = ""
|
var profileQuery = ""
|
||||||
+ "PREFIX fn: <http://www.w3.org/2005/xpath-functions#> \n"
|
|
||||||
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
|
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
|
||||||
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
||||||
+ "PREFIX foaf: <http://xmlns.com/foaf/0.1/> \n"
|
|
||||||
+ "PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \n"
|
|
||||||
+ "PREFIX vpublic: <http://vitro.mannlib.cornell.edu/ns/vitro/public#> \n"
|
|
||||||
+ "PREFIX auth: <http://vitro.mannlib.cornell.edu/ns/vitro/authorization#> \n"
|
|
||||||
+ "\n"
|
+ "\n"
|
||||||
+ "SELECT DISTINCT ?uri ?label ?classLabel ?imageUrl \n"
|
+ "SELECT DISTINCT ?uri ?label ?classLabel ?imageUrl \n"
|
||||||
+ "WHERE { \n"
|
+ "WHERE { \n"
|
||||||
+ " %typesUnion% \n"
|
+ " %typesUnion% \n"
|
||||||
+ " ?uri rdfs:label ?label ; \n"
|
+ " ?uri rdfs:label ?label ; \n"
|
||||||
|
+ " FILTER (REGEX(str(?label), '^%term%', 'i')) \n"
|
||||||
|
+ "} \n"
|
||||||
|
+ "ORDER BY ASC(?label) \n"
|
||||||
|
+ "LIMIT 25 \n";
|
||||||
|
|
||||||
|
var profileMoreInfoQuery = ""
|
||||||
|
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
|
||||||
|
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
||||||
|
+ "PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \n"
|
||||||
|
+ "PREFIX vpublic: <http://vitro.mannlib.cornell.edu/ns/vitro/public#> \n"
|
||||||
|
+ "\n"
|
||||||
|
+ "SELECT DISTINCT ?classLabel ?imageUrl \n"
|
||||||
|
+ "WHERE { \n"
|
||||||
+ " OPTIONAL { \n"
|
+ " OPTIONAL { \n"
|
||||||
+ " ?uri vitro:mostSpecificType ?type. \n"
|
+ " <%uri%> vitro:mostSpecificType ?type. \n"
|
||||||
+ " ?type rdfs:label ?classLabel \n"
|
+ " ?type rdfs:label ?classLabel \n"
|
||||||
+ " } \n"
|
+ " } \n"
|
||||||
+ " OPTIONAL { \n"
|
+ " OPTIONAL { \n"
|
||||||
+ " ?uri vpublic:mainImage ?imageUri. \n"
|
+ " <%uri%> vpublic:mainImage ?imageUri. \n"
|
||||||
+ " ?imageUri vpublic:thumbnailImage ?thumbUri. \n"
|
+ " ?imageUri vpublic:thumbnailImage ?thumbUri. \n"
|
||||||
+ " ?thumbUri vpublic:downloadLocation ?thumbstreamUri. \n"
|
+ " ?thumbUri vpublic:downloadLocation ?thumbstreamUri. \n"
|
||||||
+ " ?thumbstreamUri vpublic:directDownloadUrl ?imageUrl. \n"
|
+ " ?thumbstreamUri vpublic:directDownloadUrl ?imageUrl. \n"
|
||||||
+ " } \n"
|
+ " } \n"
|
||||||
+ " FILTER (REGEX(str(?label), '^%term%', 'i')) \n"
|
|
||||||
+ "} \n"
|
+ "} \n"
|
||||||
+ "ORDER BY ASC(?label) \n"
|
+ "ORDER BY ASC(?label) \n"
|
||||||
+ "LIMIT 25 \n";
|
+ "LIMIT 25 \n";
|
||||||
|
@ -170,7 +177,7 @@ var proxyQuery = ""
|
||||||
+ "ORDER BY ASC(?lastName) ASC(?firstName) \n"
|
+ "ORDER BY ASC(?lastName) ASC(?firstName) \n"
|
||||||
+ "LIMIT 25 \n";
|
+ "LIMIT 25 \n";
|
||||||
|
|
||||||
var moreInfoQuery = ""
|
var proxyMoreInfoQuery = ""
|
||||||
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
||||||
+ "PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \n"
|
+ "PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \n"
|
||||||
+ "PREFIX p.1: <http://vitro.mannlib.cornell.edu/ns/vitro/public#> \n"
|
+ "PREFIX p.1: <http://vitro.mannlib.cornell.edu/ns/vitro/public#> \n"
|
||||||
|
@ -202,8 +209,8 @@ var getAdditionalProxyInfo = function(parent, info, externalAuthId) {
|
||||||
url: proxyContextInfo.sparqlQueryUrl,
|
url: proxyContextInfo.sparqlQueryUrl,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: {
|
data: {
|
||||||
query: moreInfoQuery.replace("%matchingProperty%", proxyContextInfo.matchingProperty)
|
query: proxyMoreInfoQuery.replace(/%matchingProperty%/g, proxyContextInfo.matchingProperty)
|
||||||
.replace("%externalAuthId%", externalAuthId)
|
.replace(/%externalAuthId%/g, externalAuthId)
|
||||||
},
|
},
|
||||||
complete: function(xhr, status) {
|
complete: function(xhr, status) {
|
||||||
var results = $.parseJSON(xhr.responseText);
|
var results = $.parseJSON(xhr.responseText);
|
||||||
|
@ -236,7 +243,33 @@ var applyProfileTypes = function(rawQuery) {
|
||||||
typeClause += ' .';
|
typeClause += ' .';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rawQuery.replace("%typesUnion%", typeClause);
|
return rawQuery.replace(/%typesUnion%/g, typeClause);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function will allow a profile panel to execute another query for each profile.
|
||||||
|
*/
|
||||||
|
var getAdditionalProfileInfo = function(parent, info) {
|
||||||
|
$.ajax({
|
||||||
|
url: proxyContextInfo.sparqlQueryUrl,
|
||||||
|
dataType: 'json',
|
||||||
|
data: {
|
||||||
|
query: profileMoreInfoQuery.replace(/%uri%/g, info.uri)
|
||||||
|
},
|
||||||
|
complete: function(xhr, status) {
|
||||||
|
var results = $.parseJSON(xhr.responseText);
|
||||||
|
var parsed = sparqlUtils.parseSparqlResults(results);
|
||||||
|
if (parsed.length > 0) {
|
||||||
|
if ("classLabel" in parsed[0]) {
|
||||||
|
info.classLabel = parsed[0].classLabel;
|
||||||
|
}
|
||||||
|
if ("imageUrl" in parsed[0]) {
|
||||||
|
info.imageUrl = proxyContextInfo.baseUrl + parsed[0].imageUrl;
|
||||||
|
}
|
||||||
|
parent.displayItemData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -277,7 +310,9 @@ $(document).ready(function() {
|
||||||
query: query,
|
query: query,
|
||||||
model: ''
|
model: ''
|
||||||
}
|
}
|
||||||
this["proxyItemsPanel"] = new proxyItemsPanel(this, context);
|
var pip = new proxyItemsPanel(this, context);
|
||||||
|
pip.getAdditionalData = getAdditionalProfileInfo;
|
||||||
|
this["proxyItemsPanel"] = pip;
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue