opencitations / oc_ocdm

Object mapping library for manipulating RDF graphs that are compliant with the OpenCitations datamodel.
https://opencitations.net/
ISC License
3 stars 3 forks source link

Enforcing the functional constraint even on entities without the preexisting_graph #27

Open iosonopersia opened 2 years ago

iosonopersia commented 2 years ago

When adding an already existing entity to a set without importing it, it is currently possible to add triples that will be inserted into the persistent graph without enforcing the single-value constraint on the functional properties (since the preexisting_graph would be empty). This should be fixed.

Example:

br = graph_set.add_br(..., res=URIRef("<existing_br_uri>"), ...)
br.hasTitle("<title>")

In the example, the existing BibliographicResource could already have a title defined for it inside the persistent graph. Synchronising the above GraphSet would add a second title to the persistent entity (unless the two literals are exactly the same), thus breaking the functional constraint.