Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix (webapi): Update a resource's lastModificationDate when one of its values is changed #31

Merged
merged 3 commits into from
Feb 9, 2016

Conversation

benjamingeer
Copy link

Fixes issue #9.

Benjamin Geer added 3 commits February 8, 2016 17:16
…s values is changed.

- Fix bug in createValue.scala.txt.
- Add tests.
- Add string constants to ValuesResponderV1Spec.
…s values is changed.

- Don't add lastModificationDate to a new resource, it's unnecessary.
@benjamingeer benjamingeer added the bug something isn't working label Feb 8, 2016
@benjamingeer benjamingeer added this to the On Deck milestone Feb 8, 2016
@benjamingeer
Copy link
Author

While doing this, I realised that if a resource has more than one lastModificationDate (which should never happen), it can cause SPARQL updates to insert duplicate data. I opened another issue for this, #32.

@tobiasschweizer
Copy link
Contributor

In the SPARQL templates that handle adding values or new versions of values to a resource, you delete (Delete clause) and recreate (Insert clause) the resource's lastModificationDate so it reflects the time when the last modification has been made (as the name suggests) :-)

Why does this have to be included in the Where-clause of the templates? It is optional, so it won't affect the matching to a specific resource.

 @* Get the resource's last modification date, if it has one, so we can update it. *@

    OPTIONAL {
        ?resource knora-base:lastModificationDate ?resourceLastModificationDate .
    }

@benjamingeer
Copy link
Author

The WHERE clause binds variables that are used in the DELETE and INSERT clauses. If a variable is unbound, any statement in the DELETE clause that uses that variable will have no effect. We have to delete any existing lastModificationDate before we can insert a new one. Therefore we need to know the current lastModificationDate so it can be deleted.

benjamingeer pushed a commit that referenced this pull request Feb 9, 2016
fix (webapi): Update a resource's lastModificationDate when one of its values is changed
@benjamingeer benjamingeer merged commit 3d047a0 into develop Feb 9, 2016
@benjamingeer benjamingeer deleted the wip/last-modification-date branch February 9, 2016 14:52
@benjamingeer benjamingeer mentioned this pull request Jul 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants