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

Persist ActionHistory entities in separate action-history context #88

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

palagdan
Copy link
Collaborator

@palagdan palagdan commented Dec 25, 2024

@palagdan palagdan requested a review from blcham December 25, 2024 13:05
Copy link

@blcham blcham left a 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);
Copy link

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.

Copy link

@blcham blcham Dec 27, 2024

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

Copy link
Collaborator Author

@palagdan palagdan Dec 29, 2024

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.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@palagdan

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:

  1. ActionHistory besides "author" entity is persisted to separate context ..../action-history
  2. 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.

Copy link
Collaborator Author

@palagdan palagdan Jan 8, 2025

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);

Copy link

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

@palagdan palagdan changed the title Persist ActionHistory entity in separate Person context Persist ActionHistory entity in separate Action context Dec 29, 2024
@palagdan palagdan force-pushed the 82-action-history-context branch 2 times, most recently from 05d1cf0 to 499e7a5 Compare December 29, 2024 18:28
@palagdan palagdan changed the title Persist ActionHistory entity in separate Action context Persist ActionHistory entities in separate Action context Dec 29, 2024
@palagdan palagdan force-pushed the 82-action-history-context branch from 499e7a5 to 428022b Compare December 29, 2024 18:45
@palagdan palagdan changed the title Persist ActionHistory entities in separate Action context Persist ActionHistory entities in separate action-history context Dec 29, 2024
@blcham blcham merged commit 0c5b6cc into main Jan 7, 2025
2 checks passed
@blcham blcham deleted the 82-action-history-context branch January 7, 2025 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Action history should be saved to separate context
2 participants