Skip to content

Commit

Permalink
adding sparql queries to address #48
Browse files Browse the repository at this point in the history
  • Loading branch information
iannesbitt committed Aug 17, 2024
1 parent b2ab6d5 commit b12e74b
Showing 1 changed file with 91 additions and 0 deletions.
91 changes: 91 additions & 0 deletions src/main/resources/application-context-schema-org.xml
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,97 @@
</constructor-arg>
</bean>

<!-- This query extracts the name from a creator field that uses no list when there is a single creator,
and also nests creator fields with @type definitions.
{
"@context": {
"@vocab": "https://schema.org/"
},
"@graph": {
"creator": {
"@type": "Role",
"creator": {
"@type": "Person",
...
"name": "..."
}
}
}
}
-->
<bean id="schema_org_creator_role_name" class="org.dataone.cn.indexer.annotation.SparqlField">
<constructor-arg name="name" value="origin" />
<constructor-arg name="query">
<value>
<![CDATA[
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX list: <http://jena.hpl.hp.com/ARQ/list#>
PREFIX SO: <http://schema.org/>
SELECT (?name as ?origin)
WHERE {
?dsId rdf:type SO:Dataset .
?dsId SO:creator $creator .
$creator SO:creator ?role .
$role SO:name ?name .
}
]]>
</value>
</constructor-arg>
</bean>

<!-- This query extracts the names from a creator field that uses ordered list syntax when there are multiple creators,
and also nests creator fields with @type definitions.
{
"@context": {
"@vocab": "https://schema.org/"
},
"@graph": {
"creator": [
{
"@type": "Role",
"creator": {
"@type": "Person",
...
"name": "Person 1"
}
},
{
"@type": "Role",
"creator": {
"@type": "Person",
...
"name": "Person 2"
}
}
]
}
}
-->
<bean id="schema_org_creator_list_role_name" class="org.dataone.cn.indexer.annotation.SparqlField">
<constructor-arg name="name" value="origin" />
<constructor-arg name="query">
<value>
<![CDATA[
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX list: <http://jena.hpl.hp.com/ARQ/list#>
PREFIX SO: <http://schema.org/>
SELECT (?name as ?origin)
WHERE {
?dsId rdf:type SO:Dataset .
?dsId SO:creator ?creatorList .
?creatorList list:member ?creator .
?creatorList list:index ?pos .
?creator SO:creator ?role .
?role SO:name ?name .
}
order by (?pos)
]]>
</value>
</constructor-arg>
</bean>

<bean id="schema_org_prov_hadDerivation" class="org.dataone.cn.indexer.annotation.SparqlField">
<constructor-arg name="name" value="prov_hasDerivations" />
<constructor-arg name="query">
Expand Down

0 comments on commit b12e74b

Please sign in to comment.