DSpace
DSpace copied to clipboard
Move service-dependent methods out of database entity classes
References
- Fixes https://github.com/DSpace/DSpace/issues/9027
Description
This PR removes all database entity methods that used the corresponding Service, in order to improve separation of concerns & clarity.
- Many of the cases were remnants of the service refactor, but some others were added later
- Most of the methods in question were dealing with DSpaceObject metadata
- If similar methods are added in the future, they should be added to the service instead of the entity itself
- In general: if you find that you need to inject a service in a new entity method, you should move the whole method to the service instead
One of the most impactful changes is the removal of the DSpaceObject.getName method
- Since most DSO implementations depend on metadata for their name, this method cannot be part of the general interface for DSO entities
- Instead, the corresponding
DSpaceObjectService.getNameshould be used - The only exception to this is
Group, which stores its name as a dedicated column
Instructions for Reviewers
Confirm that the refactor is sensible and that everything works as it did before. I've added some comments to highlight test fixes that may indicate more fundamental issues that we may want to investigate in more detail.
Checklist
This checklist provides a reminder of what we are going to look for when reviewing your PR. You need not complete this checklist prior to creating your PR (draft PRs are always welcome). However, reviewers may request that you complete any actions in this list if you have not done so. If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!
- [x] My PR is created against the
mainbranch of code (unless it is a backport or is fixing an issue specific to an older branch). - [ ] My PR is small in size (e.g. less than 1,000 lines of code, not including comments & integration tests). Exceptions may be made if previously agreed upon.
- The refactoring performed in this PR touches a significant portion of the codebase
- [x] My PR passes Checkstyle validation based on the Code Style Guide.
- [x] My PR includes Javadoc for all new (or modified) public methods and classes. It also includes Javadoc for large or complex private methods.
- [x] My PR passes all tests and includes new/updated Unit or Integration Tests based on the Code Testing Guide.
- [x] My PR includes details on how to test it. I've provided clear instructions to reviewers on how to successfully test this fix or feature.
- [x] If my PR includes new libraries/dependencies (in any
pom.xml), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation. - [x] If my PR modifies REST API endpoints, I've opened a separate REST Contract PR related to this change.
- [x] If my PR includes new configurations, I've provided basic technical documentation in the PR itself.
- [x] If my PR fixes an issue ticket, I've linked them together.
Hi @ybnd, Conflicts have been detected against the base branch. Please resolve these conflicts as soon as you can. Thanks!
Hi @ybnd, Conflicts have been detected against the base branch. Please resolve these conflicts as soon as you can. Thanks!
~~As far as I can tell the new IT failure that comes up is unrelated to this PR; I've opened a separate PR for it: https://github.com/DSpace/DSpace/pull/9811~~ scratch that, covered by #9807 instead
This refactor looks great. @ybnd feel free to request review from me once you are ready for it (note you will need to rebase and push to get the IT to pass now that we fixed those issues)
Hi @ybnd, Conflicts have been detected against the base branch. Please resolve these conflicts as soon as you can. Thanks!