Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ivaDimitrova07 committed Jan 18, 2024
1 parent 1ce03b2 commit b42ea5b
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
101 changes: 101 additions & 0 deletions static/ao/objectLocationsDates-generator.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
prefix aat: <http://vocab.getty.edu/aat/>
prefix locationRelated: <https://test.triply.cc/colonialHeritage-test/graph/Location-related_Objects_00.csv/def/>
prefix dct: <http://purl.org/dc/terms/>
prefix crm: <http://www.cidoc-crm.org/cidoc-crm/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
construct {
#DateBegin && DateEnd - check when they are present |This needs to be done because of the way in which source data is being supplied.
?objects crm:P108i_was_produced_by ?production.
?production a crm:E12_Production;
crm:P4_has_time-span ?dates;
rdfs:label ?dated.
?dates a crm:E52_Time-Span.
?dates crm:P82a_begin_of_the_begin ?newDateBeginCombined;
crm:P82b_end_of_the_end ?newDateEndCombined.
}
where {
graph <https://test.triply.cc/colonialHeritage-test/graph/graphs/objectLocations> {
$this locationRelated:ObjectNumber ?objectNumber.
bind(iri(concat(str(<https://colonial-heritage.triply.cc/nmvw/.well-known/genid/>), str(?objectNumber))) as ?objects).
#DateBegin && DateEnd - check when they are present |This needs to be done because of the way in which source data is being supplied.
# DateBegin && DateEnd are not 0
optional {
$this locationRelated:DateBegin ?dateBegin.
$this locationRelated:DateEnd ?dateEnd.
filter(?dateBegin != "0" && ?dateEnd != "0")
bind(bnode() as ?production).
bind(bnode() as ?dates).
optional {
$this locationRelated:Dated ?dated.
}
optional {
filter not exists{
$this locationRelated:Dated ?dated.
}
bind("DateBegin and DateEnd" as ?dated)
}
bind(if(strstarts(?dateBegin, "-"),concat("0", strafter(?dateBegin, "-")),?dateBegin) as ?newBeginDate)
bind(if(strlen(?newBeginDate) = 10, concat("-", ?newBeginDate),
if(strlen(?newBeginDate) = 3, concat("-0", ?newBeginDate, "-01-01"),
if(strlen(?newBeginDate) = 4,concat("-", ?newBeginDate, "-01-01"),
if(strlen(?newBeginDate) = 1, concat("-000", ?newBeginDate, "-01-01"), ?newBeginDate)
)
)
) as ?newDateBeginCombined)
bind(if(strstarts(?dateEnd, "-"),concat("0", strafter(?dateEnd, "-")),?dateEnd) as ?newEndDate)
bind(if(strlen(?newEndDate) = 10, concat("-", ?newEndDate),
if(strlen(?newEndDate) = 3, concat("-0", ?newEndDate, "-01-01"),
if(strlen(?newEndDate) = 4,concat("-", ?newEndDate, "-01-01"),
if(strlen(?newEndDate) = 1, concat("-000", ?newEndDate, "-01-01"), ?newEndDate)
)
)
) as ?newDateEndCombined)
}
# DateBegin is not 0 && DateEnd is 0
optional {
$this locationRelated:DateBegin ?dateBegin.
$this locationRelated:DateEnd ?dateEnd.
filter(?dateBegin = "0" && ?dateEnd != "0")
bind(bnode() as ?production).
bind(bnode() as ?dates).
#Check whether 'Dated' is empty or not
optional {
$this locationRelated:Dated ?dated.
}
optional {
filter not exists{
$this locationRelated:Dated ?dated.
}
bind("DateBegin and DateEnd" as ?dated)
}
bind(if(strstarts(?dateEnd, "-"),concat("0", strafter(?dateEnd, "-")),?dateEnd) as ?newEndDate)
bind(if(strlen(?newEndDate) = 10, concat("-", ?newEndDate),
if(strlen(?newEndDate) = 3, concat("-0", ?newEndDate, "-01-01"),
if(strlen(?newEndDate) = 4,concat("-", ?newEndDate, "-01-01"),
if(strlen(?newEndDate) = 1, concat("-000", ?newEndDate, "-01-01"), ?newEndDate)))) as ?newDateEndCombined)
}
# DateBegin is 0 && DateEnd is not0
optional {
$this locationRelated:DateBegin ?dateBegin.
$this locationRelated:DateEnd ?dateEnd.
filter(?dateBegin = "0" && ?dateEnd != "0")
bind(bnode() as ?production).
bind(bnode() as ?dates).
#Check whether 'Dated' is empty or not
optional {
$this locationRelated:Dated ?dated.
}
optional {
filter not exists{
$this locationRelated:Dated ?dated.
}
bind("DateBegin and DateEnd" as ?dated)
}
bind(if(strstarts(?dateEnd, "-"),concat("0", strafter(?dateEnd, "-")),?dateEnd) as ?newEndDate)
bind(if(strlen(?newEndDate) = 10, concat("-", ?newEndDate),
if(strlen(?newEndDate) = 3, concat("-0", ?newEndDate, "-01-01"),
if(strlen(?newEndDate) = 4,concat("-", ?newEndDate, "-01-01"),
if(strlen(?newEndDate) = 1, concat("-000", ?newEndDate, "-01-01"), ?newEndDate)))) as ?newDateEndCombined)
}
}
}
4 changes: 4 additions & 0 deletions static/ao/objectLocationsDates-iterator.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
prefix locationRelated: <https://test.triply.cc/colonialHeritage-test/graph/Location-related_Objects_00.csv/def/>
select * where {
?subject locationRelated:ObjectNumber ?objectNumber.
}

0 comments on commit b42ea5b

Please sign in to comment.