diff --git a/src/caoscrawler/converters/rocrate.py b/src/caoscrawler/converters/rocrate.py index 8a45af753312a2bf29c1ddb9e6bcb15458c3ebde..fe40394490cb4d531929a9f7ecb6d092053945a4 100644 --- a/src/caoscrawler/converters/rocrate.py +++ b/src/caoscrawler/converters/rocrate.py @@ -196,7 +196,18 @@ class ROCrateEntityConverter(Converter): # Add the properties: for name, value in eprops.items(): - children.append(convert_basic_element(value, name)) + if isinstance(value, dict): + # This is - according to the standard - only allowed, if it's flat, i.e. + # it contains a single element with key == "@id" and the id as value which + # is supposed to be dereferenced: + if not (len(value) == 1 and "@id" in eprops): + raise RuntimeError("The JSON-LD is not flat.") + children.append( + ROCrateEntity(element.folder, element.entity.crate.dereference( + value["@id"]))) + # TODO: tests missing! + else: + children.append(convert_basic_element(value, name)) # Add the files: if isinstance(element.entity, rocrate.model.file.File): @@ -204,10 +215,14 @@ class ROCrateEntityConverter(Converter): children.append(File(name, os.path.join(element.folder, path, name))) # Parts of this entity are added as child entities: - if "hasPart" in eprops: - for p in eprops["hasPart"]: - children.append( - ROCrateEntity(element.folder, element.entity.crate.dereference( - p["@id"]))) + for sublist in ("hasPart", "variableMeasured"): + if sublist in eprops: + for p in eprops[sublist]: + children.append( + ROCrateEntity(element.folder, element.entity.crate.dereference( + p["@id"]))) + # TODO: it feels a bit strange to add (especially variableMeasured) directly, top-level + # and not in a sub-DictElement. The latter would be difficult to realize, because + # resolving the sub-references is not straight-forward. return children