@@ -176,6 +176,80 @@ def to_fdo_person(qid: str, entity: Dict[str, Any]) -> Dict[str, Any]:
176176 }
177177
178178
179+ def to_fdo_dataset (qid : str , entity : Dict [str , Any ]) -> Dict [str , Any ]:
180+ """
181+ Build an FDO-compliant JSON-LD representation for a dataset object.
182+
183+ Produces a Digital Object record where the `digitalObjectType` is a
184+ schema.org Dataset. The resulting kernel declares a single component
185+ with componentId `"rocrate"`, pointing to a dynamically retrievable
186+ RO-Crate ZIP representation of the dataset. The object's PID (QID) is
187+ assigned as the primaryIdentifier. A minimal profile block is included
188+ using schema.org Dataset fields derived from the input entity.
189+
190+ Args:
191+ qid: PID/QID string identifying the dataset in the MaRDI Knowledge Graph.
192+ entity: Metadata extracted from the KG for the dataset (label, timestamps).
193+
194+ Returns:
195+ Dict[str, Any]: Complete FDO JSON-LD payload including:
196+ - DigitalObject envelope with context definitions
197+ - Kernel section with dataset type and component reference to RO-Crate
198+ - Profile section describing the dataset content
199+ - Provenance markers for timestamp and attribution
200+
201+ Raises:
202+ KeyError: If required fields are missing from the `entity`.
203+ """
204+ fdo_id = f"{ FDO_IRI } { qid } "
205+ created , modified = normalize_created_modified (entity )
206+
207+ kernel = {
208+ "@id" : fdo_id ,
209+ "digitalObjectType" : "https://schema.org/Dataset" ,
210+ "primaryIdentifier" : f"mardi:{ qid } " ,
211+ "kernelVersion" : KERNEL_VERSION ,
212+ "immutable" : True ,
213+ "modified" : modified ,
214+ "fdo:hasComponent" : [
215+ {
216+ "@id" : "#rocrate" ,
217+ "componentId" : "rocrate" ,
218+ "mediaType" : "application/zip"
219+ }
220+ ]
221+ }
222+ if created :
223+ kernel ["created" ] = created
224+
225+ profile = {
226+ "@context" : "https://schema.org/" ,
227+ "@type" : "Dataset" ,
228+ "@id" : f"{ fdo_id } #profile" ,
229+ "name" : entity .get ("label" , qid ),
230+ "identifier" : f"mardi:{ qid } "
231+ }
232+
233+ return {
234+ "@context" : [
235+ "https://w3id.org/fdo/context/v1" ,
236+ {
237+ "schema" : "https://schema.org/" ,
238+ "prov" : "http://www.w3.org/ns/prov#" ,
239+ "fdo" : "https://w3id.org/fdo/vocabulary/"
240+ }
241+ ],
242+ "@id" : fdo_id ,
243+ "@type" : "DigitalObject" ,
244+ "kernel" : kernel ,
245+ "profile" : profile ,
246+ "provenance" : {
247+ "prov:generatedAtTime" : modified ,
248+ "prov:wasAttributedTo" : "MaRDI Knowledge Graph"
249+ }
250+ }
251+
252+
179253
180254def to_fdo_minimal (qid : str , entity : Dict [str , Any ]) -> Dict [str , Any ]:
181255 """Transform an arbitrary entity into a minimal FDO payload.
@@ -211,6 +285,7 @@ def to_fdo_minimal(qid: str, entity: Dict[str, Any]) -> Dict[str, Any]:
211285TYPE_HANDLER_MAP = {
212286 "schema:ScholarlyArticle" : to_fdo_publication ,
213287 "schema:Person" : to_fdo_person ,
288+ "schema:Dataset" : to_fdo_dataset ,
214289}
215290
216291
0 commit comments