Skip to content
Snippets Groups Projects
Commit 45815d65 authored by Frank Lange's avatar Frank Lange
Browse files

change the SPARQL query to find all learning resources for a given community

RDF modeling has changed from mo:hasCommunity to rec:recommender and/or bflr:supportinghost
parent 41a9b5ce
Branches
No related tags found
No related merge requests found
Pipeline #1494082 passed
......@@ -7,8 +7,8 @@ from project.dalia.api_models.api_models import Item
from project.dalia.query.communities.communities import get_metadata_for_communities
from project.dalia.query.items.metadata.items import get_metadata_for_learning_resources
from project.dalia.query.utils import query_dalia_dataset
from project.dalia.query_builder.query_builder import QueryBuilder, VALUES
from project.dalia.rdf.namespace import MoDalia, educor
from project.dalia.query_builder.query_builder import GROUP, QueryBuilder, UNION, VALUES
from project.dalia.rdf.namespace import MoDalia, bibframe_lite_relation, educor, rec
from project.dalia.rdf.prefix import COMMUNITIES_BASE_URI
......@@ -50,13 +50,21 @@ def prepare_query_for_resources_of_community(community_uri_ref: URIRef) -> str:
var_community = Variable("community")
return QueryBuilder().SELECT(
var_lr
var_lr,
distinct=True # prevents duplicates in case the same community is both rec:recommender and bflr:supportinghost
).WHERE(
VALUES(
[var_community],
[[community_uri_ref]]
),
(var_community, RDF.type, MoDalia.Community),
(var_lr, MoDalia.hasCommunity, var_community),
# This GROUP-UNION pattern is equivalent to "?lr rec:recommender|bflr:supportinghost ?community"
# (AlternativePath expression in SPARQL).
GROUP(
(var_lr, rec.recommender, var_community),
),
UNION(
(var_lr, bibframe_lite_relation.supportinghost, var_community),
),
(var_lr, RDF.type, educor.EducationalResource)
).build()
......@@ -6,7 +6,6 @@ from rdflib import URIRef
NS = "https://purl.org/ontology/modalia#"
# Properties
hasCommunity = URIRef(NS + "hasCommunity")
hasLearningType = URIRef(NS + "hasLearningType")
hasMediaType = URIRef(NS + "hasMediaType")
hasTargetGroup = URIRef(NS + "hasTargetGroup")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment