diff --git a/lxltools/datacompiler.py b/lxltools/datacompiler.py index 06cabc6f0..83d184b1f 100644 --- a/lxltools/datacompiler.py +++ b/lxltools/datacompiler.py @@ -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, @@ -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) @@ -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): @@ -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] diff --git a/source/datasets/idkbse.ttl b/source/datasets/idkbse.ttl index 5e44e682b..267e07904 100644 --- a/source/datasets/idkbse.ttl +++ b/source/datasets/idkbse.ttl @@ -1,3 +1,4 @@ +prefix jsonld: prefix xsd: prefix : base @@ -82,6 +83,15 @@ base :uriSpace "/term/rda/tacnotation/" ; :created "2021-05-21T23:59:10.456Z"^^xsd:dateTime . + a :Dataset ; + jsonld:context "sys/context/kbv.jsonld" ; + :isPartOf ; + :sourceData [ :uri "build/spaterms.json.lines" ; + :sourceData [ :uri 'source/spa.ttl' ] + ] ; + :uriSpace "/term/spa/" ; + :created "2026-06-02T12:07:25Z"^^xsd:dateTime . + a :Dataset ; :isPartOf ; :sourceData [ :uri "build/swepubterms.json.lines" ; :sourceData [ a :SparqlUpdate ; diff --git a/source/spa.ttl b/source/spa.ttl new file mode 100644 index 000000000..847b7b31e --- /dev/null +++ b/source/spa.ttl @@ -0,0 +1,31 @@ +prefix : +prefix spa: + +### +# Based on +# - PART 3 Data Dictionary of Shared Print Actions Terminology +# - Controlled vocabulary (for use in $a, $i, and $l) +# See also: + +## +# ActionStatus + +spa:committed-to-retain a :ItemActionCategory ; + :sameAs ; + :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 ; + :code "ab" ; + :prefLabel "will commit to retain"@en ; + :related spa:committed-to-retain . + +spa:will-not-commit-to-retain a :ItemActionCategory ; + :sameAs ; + :code "ac" ; + :prefLabel "will not commit to retain"@en ; + :related spa:committed-to-retain . + + diff --git a/source/vocab/details.ttl b/source/vocab/details.ttl index 13fc07f94..3c74f0277 100644 --- a/source/vocab/details.ttl +++ b/source/vocab/details.ttl @@ -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 . @@ -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 . diff --git a/source/vocab/items.ttl b/source/vocab/items.ttl index 70a1220b0..feebe425c 100644 --- a/source/vocab/items.ttl +++ b/source/vocab/items.ttl @@ -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 . + +: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 diff --git a/source/vocab/relations.ttl b/source/vocab/relations.ttl index 13fc62ba7..a67d57f68 100644 --- a/source/vocab/relations.ttl +++ b/source/vocab/relations.ttl @@ -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 ;