-
Notifications
You must be signed in to change notification settings - Fork 2
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
Persist ActionHistory entities in separate action-history context #88
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The files looks perfectly fine, but i do not understand
- commit title
- this PR title
Both of them contains "separate Person context". Which is confusing as i thought that you would persist actionhistory per each person separately. Did you mean:
"separate ActionHistory context"
If so i would only rename both commit title and PR title to:
Persist ActionHistory entities into separate context
Note entity --> entities, as it is not clear weather we have context per each instance or per type.
BTW, great job that you included the screenshot ... so now i am quite confident that you just accidentally copied bad title
private Descriptor getDescriptor(URI ctx){ | ||
Descriptor descriptor = new EntityDescriptor(ctx); | ||
EntityType<ActionHistory> et = em.getMetamodel().entity(ActionHistory.class); | ||
descriptor.addAttributeContext(et.getAttribute("author"), null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just FYI, to be honest I have trouble of understanding this line of code why this is needed if we do not have cascades for the "author" attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I leave it open question for me :) so just resolve it as soon as you read it :) unless you know what to answer here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@blcham
Yes, I accidentally overlooked the commit message. Thanks for pointing it out.
I've renamed the commit.
Without removing the author attribute from the descriptor, I get the following error:
The following instances were neither persisted nor marked as cascade for persist: [Admin Administratorowitch<http://onto.fel.cvut.cz/ontologies/record-manager/Admin-Administratorowitch-1486>]
I have also a trouble of understanding it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code descriptor.addAttributeContext(et.getAttribute("author"), null);
means that retrieve-ing or persisting data would be taken from default context which is union of all contexts within GraphDB database.
It works as follows:
- ActionHistory besides "author" entity is persisted to separate context
..../action-history
- when processing "author" attribute, since there is no cascade on PERSIST operation, it is just searched in default context if it exists. Since it exists there, it does not throw any error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! But if the author is in the User context, should we write the following?
descriptor.addAttributeContext(et.getAttribute("author"), Vocabulary.s_c_person);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the soultion with null
will work even if we put authors to different context ....
The soultion with Vocabulary.s_c_person
is more precise/correct if we do not want to upload data to db-server manually ... could be very little faster since it takes data from concrete context ...
anyway for now i do not care which one we use
05d1cf0
to
499e7a5
Compare
499e7a5
to
428022b
Compare
Resolve kbss-cvut/record-manager-ui#248