archesproject / arches

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

Repeated nodes to cardinality 1 branch incorrectly error #5687

Closed azaroth42 closed 4 years ago

azaroth42 commented 4 years ago

Describe the bug

Although the export works as expected when created by hand, if there is a concept-list that has multiple values, and then has a concept with cardinality 1 associated, then the second instance in the concept-list will cause an error, when the import attempts to re-add the same value into the concept.

To Reproduce

ValueError: Attempt to add a value to cardinality 1, non-list node http://www.cidoc-crm.org/cidoc-crm/P2_has_type http://www.cidoc-crm.org/cidoc-crm/E55_Type:
 {'@id': 'http://vocab.getty.edu/aat/300435443', '@type': ['http://www.cidoc-crm.org/cidoc-crm/E55_Type']}

Expected behavior

Given discussions and experiments to date, we didn't encounter this issue!

What would be good to happen is that it checks the current values to determine if the value is already there and does not re-add it, and thus does not trigger the error.

azaroth42 commented 4 years ago

The fix:

in rdffile.py, in data_walk()

                    elif branch[0]["cardinality"] != "n":
                        # Determine if the value is the same as the current value
                        # If so, then no-op
                        bnode = result[bnodeid][0]
                        if node_value == bnode['tile'].data[bnodeid]:
                            pass
                        else:
                            raise ValueError(f"Attempt to add a value to cardinality 1, non-list node {k} {clss}:\n {vi}")
azaroth42 commented 4 years ago

Fixed in v5.

apeters commented 4 years ago

fixed in the latest