-
Notifications
You must be signed in to change notification settings - Fork 3
MODLD-873: LdImportOutputEvent Listener and Handler introduced #352
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
base: master
Are you sure you want to change the base?
Conversation
| var existed = resourceRepository.existsById(resource.getId()); | ||
| var entity = resourceModelMapper.toEntity(resource); | ||
| var saveGraphResult = resourceGraphService.saveMergingGraph(entity); | ||
| if (existed) { |
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.
Not sure if we need to check for existence of a resource.
On one hand, this allows us to choose between CREATE and UPDATE events, but on the other hand, it definitely degrades performance.
Let's discuss 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.
Actually, we can check in "newResources" array of "saveGraphResult" to determine if entity is already existing or not.
var existed = !saveGraphResult.newResources().contains(entity);
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.
Oh actually a saveGraphResult already contains distinguished info regarding created and updated resources, right?
So why do we need to manually decide if create or update events should be sent.. I will refactor ResourceEventsPublisher to do it automatically
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.
When the work / instance is edited via UI, we delete the original work / instance and create a new one.
So, the new work (which replaced the original work) will be always present in the newResources() array.
So, we manually invoke emitEventsForUpdate from PUT method and emitEventsForCreate from POST method.
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.
In the case you described we also have or do NOT have the oldResource object and this lets us distinguish the type of the process happening
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.
You are right. Good idea.
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.
Can we make a small change in saveMergingGraph method? At present, we only search in createdResources array for persistedRootResource. The persistedRootResource could be in updatedResources also.
So, maybe we have to change as follows
var persistedRootResource = filterResources(result, r -> r.resource().getId().equals(resource.getId()))
.stream()
.findFirst()
.orElse(resource);
|



No description provided.