Skip to content
This repository has been archived by the owner on May 31, 2019. It is now read-only.

Commit

Permalink
Optimized sparql object queries.
Browse files Browse the repository at this point in the history
  • Loading branch information
rasvaan committed Oct 30, 2016
1 parent 63c511b commit df8fc66
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
18 changes: 18 additions & 0 deletions sparql_queries
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
############### filter query ###############
PREFIX edm: <http://www.europeana.eu/schemas/edm/>
PREFIX ore: <http://www.openarchives.org/ore/terms/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT DISTINCT ?aggregation ?rights ?object ?view ?title ?creator
WHERE {
?object rdf:type edm:ProvidedCHO .
?object dc:description ?description .
FILTER ( lang(?description) = "nl" && regex(?description, " oehoe ", "i") )
?aggregation edm:aggregatedCHO ?object .
?aggregation edm:isShownBy ?view .
?aggregation edm:rights ?rights .
?object dc:title ?title .
?object dc:creator ?creatorId .
?creatorId skos:prefLabel ?creator .
}

############### annotation concept query ###############
PREFIX edm: <http://www.europeana.eu/schemas/edm/>
PREFIX ore: <http://www.openarchives.org/ore/terms/>
Expand Down
27 changes: 9 additions & 18 deletions src/helpers/objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module.exports = {
// only filter, since we have no suitable concepts to query for
let filter = (parameters.common_name_nl || parameters.common_name).toLowerCase();
const query = this.sparqlObjectQueries(filter)['edm_filter_desciption'];

console.log(query);
return tripleStore.query(platform, query.query).then((values) => {
return _this.processSparqlAggregations(values, 'dctype:Image');
}).then((aggregations) => {
Expand Down Expand Up @@ -121,6 +121,7 @@ module.exports = {

for (let i=0; i<results.length; i++) {
const result = results[i];
console.log(result);
const index = uris.indexOf(result.aggregation.value);

// see if already present in aggregations
Expand All @@ -133,6 +134,7 @@ module.exports = {
// extend information object when possible
if (result.creator) culturalObject.addCreator(result.creator.value);
if (result.title) culturalObject.addTitle(result.title.value);
if (result.description) culturalObject.addDescription(result.description.value);

let aggregation = new Aggregation(
result.aggregation.value,
Expand Down Expand Up @@ -168,15 +170,9 @@ module.exports = {
"?aggregation edm:aggregatedCHO ?object . " +
"?aggregation edm:isShownBy ?view . " +
"?aggregation edm:rights ?rights . " +
"OPTIONAL { " +
" ?object dc:title ?title . " +
" FILTER ( lang(?title) = \"en\" ) " +
"} " +
"OPTIONAL { " +
" ?object dc:creator ?creatorId . " +
" ?creatorId skos:prefLabel ?creator . " +
" FILTER ( lang(?creator) = \"en\" ) " +
"} " +
"?object dc:title ?title . " +
"?object dc:creator ?creatorId . " +
"?creatorId skos:prefLabel ?creator . " +
"} ",
"name": "description filter"
},
Expand All @@ -195,14 +191,9 @@ module.exports = {
"?aggregation edm:aggregatedCHO ?object . " +
"?aggregation edm:isShownBy ?view . " +
"?aggregation edm:rights ?rights . " +
"OPTIONAL { " +
" ?object dc:title ?title . " +
" FILTER ( lang(?title) = \"en\" ) " +
"} " +
"OPTIONAL { " +
" ?object dc:creator ?creatorId . " +
" ?creatorId skos:prefLabel ?creator . " +
" FILTER ( lang(?creator) = \"en\" ) " +
"?object dc:title ?title . " +
"?object dc:creator ?creatorId . " +
"?creatorId skos:prefLabel ?creator . " +
"} " +
"} ",
"name": "description filter"
Expand Down

0 comments on commit df8fc66

Please sign in to comment.