Arches is a web platform for creating, managing, & visualizing geospatial data. Arches was inspired by the needs of the Cultural Heritage community, particularly the widespread need of organizations to build & manage cultural heritage inventories
GNU Affero General Public License v3.0
212
stars
143
forks
source link
ConceptList's from_rdf() should check list vs dict before iterating #4554
The resolve_node_ids() function iterates through values in its descent through the tree.
ConceptList also tries to iterate values, even if there is only one given to it. This results in iterating over a dict's keys, rather than the entries in a list.
Which then proceeds to iterate over the keys, and pass rdfs:label to ConceptDataType.from_rdf.
This fails to work, unsurprisingly.
Proposed Solution
Type check the value coming into ConceptListDatatype to see if it's a list or not:
def from_rdf(self, json_ld_node):
# returns a list of concept ids
ctype = ConceptDataType()
if isinstance(json_ld_node, list):
return [ctype.from_rdf(item) for item in json_ld_node]
else:
return ctype.from_rdf(json_ld_node)
Describe the bug
The resolve_node_ids() function iterates through values in its descent through the tree. ConceptList also tries to iterate values, even if there is only one given to it. This results in iterating over a dict's keys, rather than the entries in a list.
To Reproduce
The following JSON-LD is imported:
Resulting in
resolve_node_ids
passing this to ConceptListDatatype.from_rdf:Which then proceeds to iterate over the keys, and pass
rdfs:label
to ConceptDataType.from_rdf.This fails to work, unsurprisingly.
Proposed Solution
Type check the value coming into ConceptListDatatype to see if it's a list or not: