Skip to content

updating targetPath fails to update relationships #137

@mbjones

Description

@mbjones

The use of prov:atLocation in packages as implemented in #76 makes use of a targetPath slot on each DataObject. When an DataObject with targetPath set is added to a package with addMember(), the function knows to add a prov:atLocation relationship to the graph for that object. However, if the targetPath of the DO is later updated, the relationships in the package remain untouched, resulting in a conflicting state. Here's some example code showing how targetPath and the relationships table can be out of sync:

library(dataone)
library(datapack)

# Create a package with a DO and a targetPath
data <- charToRaw("1,2,3\n4,5,6\n")
targetPath <- "myData/time-trials/trial_data.csv"
do <- new("DataObject", "id1", dataobj=data, "text/csv", 
          "http://orcid.org/xxxx-yyyy-zzzz", "urn:node:KNB", 
          targetPath=targetPath)
do@targetPath

# Show the targetPath for the DO
dpkg <- new("DataPackage")
dpkg <- addMember(dpkg, do)
existingDO <- getMember(dpkg, "id1")
existingDO@targetPath

# Change the targetPath and show it
dpkg <- setValue(dpkg, name="targetPath", value="newdir/new_trial_data.csv", identifiers=c("id1"))
existingDO <- getMember(dpkg, "id1")
existingDO@targetPath

# Display the relationships table for the package, note the incorrect atLocation
getRelationships(dpkg)

The fix to this might be to synchronize targetPath and relationships, such that a change to one results in an update in state on the other. For example, if a prov:atLocation relationship is added via insertRelationship() (or removed), then the appropriate targetPath should be updated (assuming it can be found -- would it be an error if that entity is not in the package?). And, if targetPath is updated using setValue() then the relationships should be updated. The challenge lies in consistently determining when one or the other has been updated, especially if they get changed through other methods than those two, or if the slots are manipulated directly.

An alternate solution might be adding an updatePath(pkg, id, path), and use that in preference to the other methods discussed above. cc @jeanetteclark

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions