Skip to content

Conversation

axlewin
Copy link
Contributor

@axlewin axlewin commented Sep 3, 2025

This removes the old Orika converters & automappers and replaces them with MapStruct mappings.

Most of the mappings just define a source & target type and let the MapStruct auto-implementations handle the rest. Where the target class is unambiguous (e.g. DTO <-> DO mappings), using these mappings is then as simple as calling map(source) (or copy(source) if the source & target classes are the same); the target class no longer needs to be specified. Where there is ambiguity in which class to map to (e.g. map(ContentDTO)), the default map method does still need to have a target class passed in to know which mapping to delegate to. In the case of mapping an object to a String (mapContentSummaryDTOtoString), the implementation is hardcoded rather than autogenerated; see mapstruct/mapstruct#584.

The mappers are split roughly according to the kind of objects they map, but the MainMapper interface is used to provide a mapper object in most cases. For consistency, one of the new mappers is called ContentMapper, hence the existing ContentMapper has been renamed (to ContentSubclassMapper).

Mappings are provided for all of the conversions that we currently need. These are not comprehensive, and there are likely other mappings that will be needed at some point that should be added now.

As discussed, there are no new unit tests introduced by this PR. The existing integration tests should cover the usage of most of the new mappings but there may be cases that are missed.

Copy link

codecov bot commented Sep 3, 2025

Codecov Report

❌ Patch coverage is 55.81395% with 57 lines in your changes missing coverage. Please review.
✅ Project coverage is 36.46%. Comparing base (09e797d) to head (0bb6673).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...a/uk/ac/cam/cl/dtg/util/mappers/ContentMapper.java 38.09% 12 Missing and 1 partial ⚠️
...cam/cl/dtg/segue/api/managers/QuestionManager.java 15.38% 11 Missing ⚠️
...java/uk/ac/cam/cl/dtg/util/mappers/UserMapper.java 33.33% 6 Missing and 4 partials ⚠️
.../cl/dtg/segue/api/managers/UserAccountManager.java 69.23% 4 Missing ⚠️
.../java/uk/ac/cam/cl/dtg/isaac/api/EventsFacade.java 66.66% 3 Missing ⚠️
...am/cl/dtg/segue/dao/content/GitContentManager.java 84.21% 3 Missing ⚠️
...tg/util/mappers/UnimplementedMappingException.java 0.00% 3 Missing ⚠️
...dtg/isaac/dao/PgQuizAttemptPersistenceManager.java 33.33% 2 Missing ⚠️
...e/configuration/SegueGuiceConfigurationModule.java 33.33% 2 Missing ⚠️
...c/cam/cl/dtg/segue/etl/ETLConfigurationModule.java 0.00% 2 Missing ⚠️
... and 4 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #720      +/-   ##
==========================================
- Coverage   37.22%   36.46%   -0.77%     
==========================================
  Files         536      530       -6     
  Lines       23706    23560     -146     
  Branches     2857     2823      -34     
==========================================
- Hits         8825     8590     -235     
- Misses      14003    14104     +101     
+ Partials      878      866      -12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This allows ContentBase types to be returned from a normal subclass mapping method without causing abstract interface errors
Since this actually handles quiz mappings too
Copy link
Contributor

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@axlewin axlewin changed the title Improvement/orika to mapstruct Replace Orika mapping with MapStruct Oct 1, 2025
@axlewin axlewin marked this pull request as ready for review October 3, 2025 12:55
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.

1 participant