Skip to content
15 changes: 7 additions & 8 deletions lxltools/datacompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@ def handler(self, func):
def path(self, pth):
return self.base_dir / pth

def to_jsonld(self, graph):
def to_jsonld(self, graph, context=None):
context = (context or self.context)
return ldutil.to_jsonld(graph,
"../" + self.context,
self.load_json(self.context))
"../" + context,
self.load_json(context))

def _compile_datasets(self, names):
self._create_dataset_description(self.dataset_id,
Expand Down Expand Up @@ -151,9 +152,6 @@ def _compile_dataset(self, name, result):
ds_created_ms = timeutil.w3c_dtz_to_ms(created_time)
ds_modified_ms = last_modified_ms(self.current_ds_resources)

if isinstance(data, Graph):
data = self.to_jsonld(data)

ds_url = urljoin(self.dataset_id, name)
self._create_dataset_description(ds_url, ds_created_ms, ds_modified_ms)

Expand Down Expand Up @@ -380,7 +378,7 @@ def load_json(self, fpathref):
def read_csv(self, fpath, **kws):
return _read_csv(self.path(fpath), **kws)

def construct(self, sources, query=None):
def construct(self, sources, query=None, context=None):
return _construct(self, sources, query)

def _handlers_from_datasets_description(self, description_path):
Expand All @@ -402,9 +400,10 @@ def dataset_handler():
sources=source.get('source', []),
query=source.get('query')
)
data = compiler.to_jsonld(graph, ds.get('jsonld:context'))

ztime = ds['created']['@value'].replace('+00:00', 'Z')
return ds.get('uriSpace'), ztime, graph
return ds.get('uriSpace'), ztime, data

dataset_handler.__name__ = ds['@id'].rsplit('/', 1)[-1]

Expand Down
10 changes: 10 additions & 0 deletions source/datasets/idkbse.ttl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
prefix jsonld: <http://www.w3.org/ns/json-ld#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix : <https://id.kb.se/vocab/>
base <https://id.kb.se/dataset/>
Expand Down Expand Up @@ -82,6 +83,15 @@ base <https://id.kb.se/dataset/>
:uriSpace "/term/rda/tacnotation/" ;
:created "2021-05-21T23:59:10.456Z"^^xsd:dateTime .

<spaterms> a :Dataset ;
jsonld:context "sys/context/kbv.jsonld" ;
:isPartOf <common> ;
:sourceData [ :uri "build/spaterms.json.lines" ;
:sourceData [ :uri 'source/spa.ttl' ]
] ;
:uriSpace "/term/spa/" ;
:created "2026-06-02T12:07:25Z"^^xsd:dateTime .

<swepubterms> a :Dataset ;
:isPartOf <common> ;
:sourceData [ :uri "build/swepubterms.json.lines" ; :sourceData [ a :SparqlUpdate ;
Expand Down
31 changes: 31 additions & 0 deletions source/spa.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
prefix : <https://id.kb.se/vocab/>
prefix spa: <https://id.kb.se/term/spa/>

###
# Based on <https://wordpress.clir.org/wp-content/uploads/sites/62/Shared-Print-Actions_-Terminology-for-MARC-21-Field-583-April-2024.pdf>
# - PART 3 Data Dictionary of Shared Print Actions Terminology
# - Controlled vocabulary (for use in $a, $i, and $l)
# See also: <https://sharedprint.org/>

##
# ActionStatus

spa:committed-to-retain a :ItemActionCategory ;
:sameAs <aa> ;
:code "aa" ;
:prefLabel "committed to retain"@en, "åtagande att bevara"@sv ;
:definition "Commitment by the institution to retain the materials for a given shared print program (or multiple programs) for the duration stipulated by the shared print program(s)."@en .

spa:will-commit-to-retain a :ItemActionCategory ;
:sameAs <ab> ;
:code "ab" ;
:prefLabel "will commit to retain"@en ;
:related spa:committed-to-retain .

spa:will-not-commit-to-retain a :ItemActionCategory ;
:sameAs <ac> ;
:code "ac" ;
:prefLabel "will not commit to retain"@en ;
:related spa:committed-to-retain .


5 changes: 3 additions & 2 deletions source/vocab/details.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@

:date a owl:DatatypeProperty;
#rdfs:domain :Resource ?;
sdo:domainIncludes :Agent, :Capture, :Title, :ProvisionActivity, :Dissertation ;
sdo:domainIncludes :Agent, :Capture, :Title, :ProvisionActivity, :Dissertation, :ItemAction ;
rdfs:label "datum"@sv;
rdfs:comment "Oformaterad uppgift om datum/årtal/tidsperiod."@sv;
owl:equivalentProperty bf2:date, dc:date .
Expand All @@ -1382,11 +1382,12 @@
rdfs:comment "Formatera årtalet med fyra siffror eller 'u' för okänd del."@sv .

:startDate a owl:DatatypeProperty;
sdo:domainIncludes :ItemAction ;
rdfs:label "start date"@en,"startdatum"@sv;
rdfs:subPropertyOf :date .

:endDate a owl:DatatypeProperty;
sdo:domainIncludes :Embargo;
sdo:domainIncludes :Embargo , :ItemAction ;
rdfs:label "end date"@en, "slutdatum"@sv;
rdfs:subPropertyOf :date .

Expand Down
22 changes: 21 additions & 1 deletion source/vocab/items.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,31 @@
skos:prefLabel "Active shelf label"@en, "Aktiv signumsvit"@sv .
# TODO: description ?

:nextShelfControlNumber a :DatatypeProperty ;
:nextShelfControlNumber a owl:DatatypeProperty ;
rdfs:label "Next shelf control Number"@en, "Nästa löpnummer"@sv ;
rdfs:domain :ShelfMarkSequence ;
rdfs:range xsd:positiveInteger .

##
# SHARED PRINT ACTIONS

:hasItemAction a owl:ObjectProperty ;
rdfs:label "has item action"@en, "har beståndsåtgärd"@sv ;
rdfs:domain :Item ;
rdfs:range :ItemAction ;
skos:related <http://id.loc.gov/vocabulary/mnotetype/action> .

:ItemAction a owl:Class ;
rdfs:label "Beståndsåtgärd" ;
rdfs:subClassOf [ a owl:ObjectProperty ;
owl:onProperty :category ;
owl:allValuesFrom :ItemActionCategory ] .

:ItemActionCategory a owl:Class ;
rdfs:subClassOf :Category ;
rdfs:label "Item action category"@en, "Kategori för beståndsåtgärd"@sv .


##
# OTHER ITEM PROPERTIES AND CLASSES

Expand Down
2 changes: 1 addition & 1 deletion source/vocab/relations.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@
rdfs:label "agent"@sv;
rdfs:subPropertyOf :object ;
owl:equivalentProperty bf2:agent, prov:agent;
sdo:domainIncludes :Contribution, :Event, :AdministrativeAction;
sdo:domainIncludes :Contribution, :Event, :AdministrativeAction , :ItemAction ;
rdfs:range :Agent .

:agentOf a owl:ObjectProperty ;
Expand Down