feat: implement Phase 6 – update, delete, and relationship management…#15
Merged
Conversation
… operations Complete the CRUD cycle with PUT, PATCH, DELETE endpoints for Track, Tag, and Playlist entities. Add relationship management endpoints for adding/removing tags from tracks and tracks from playlists. Key changes: - Entity update() methods for controlled mutation, HashSet initialization - V5 Flyway migration: ON DELETE CASCADE on join table foreign keys - Update/Patch request DTOs with validation per entity - Enriched response DTOs (tracks include tags, playlists include tracks) - @transactional on writes, @transactional(readOnly=true) on reads - @CacheEvict(allEntries=true) on all write operations - DataIntegrityViolationException handler (409 Conflict) - Integration tests for all new endpoints (27 tests, all passing) - Fix Testcontainers port conflict (random ports instead of fixed)
Contributor
There was a problem hiding this comment.
Pull request overview
Implements Phase 6 of the project plan by completing CRUD (PUT/PATCH/DELETE) for Track/Tag/Playlist and adding relationship-management endpoints (Track↔Tag, Playlist↔Track), plus DB support for safe deletes via join-table cascade behavior.
Changes:
- Added PUT/PATCH/DELETE endpoints and corresponding service methods (with caching + transaction boundaries).
- Enriched response DTOs to include relationships (tracks include tags; playlists include tracks (+ tags)).
- Added Flyway migration for
ON DELETE CASCADEon join-table FKs and expanded integration test coverage.
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/com/jfontdev/trackstack/TrackControllerIntegrationTest.java | Expands integration tests to cover update/patch/delete and tag relationship management for tracks. |
| src/test/java/com/jfontdev/trackstack/TagControllerIntegrationTest.java | Expands integration tests to cover update/patch/delete and 409 conflict behavior for tags. |
| src/test/java/com/jfontdev/trackstack/PlaylistControllerIntegrationTest.java | Expands integration tests to cover update/patch/delete, track relationship management, and cascade-delete behavior. |
| src/test/java/com/jfontdev/trackstack/TestcontainersConfiguration.java | Switches Postgres container to random host ports to avoid port conflicts. |
| src/main/resources/db/migration/V5__add_cascade_delete_to_join_tables.sql | Adds ON DELETE CASCADE to join-table foreign keys to support deletes without FK violations. |
| src/main/java/com/jfontdev/trackstack/service/impl/TrackServiceImpl.java | Adds update/patch/delete + tag relationship ops, DTO mapping including tags, caching eviction, and transaction annotations. |
| src/main/java/com/jfontdev/trackstack/service/impl/TagServiceImpl.java | Adds update/patch/delete operations with caching eviction and transaction annotations. |
| src/main/java/com/jfontdev/trackstack/service/impl/PlaylistServiceImpl.java | Adds update/patch/delete + track relationship ops and DTO mapping including nested tracks/tags. |
| src/main/java/com/jfontdev/trackstack/service/TrackService.java | Extends service contract to include update/patch/delete and tag relationship methods with JavaDoc. |
| src/main/java/com/jfontdev/trackstack/service/TagService.java | Extends service contract to include update/patch/delete with JavaDoc. |
| src/main/java/com/jfontdev/trackstack/service/PlaylistService.java | Extends service contract to include update/patch/delete and track relationship methods with JavaDoc. |
| src/main/java/com/jfontdev/trackstack/model/Track.java | Adds controlled mutation (update), relationship helpers, and initializes relationship sets. |
| src/main/java/com/jfontdev/trackstack/model/Tag.java | Adds controlled mutation (update) and initializes relationship set. |
| src/main/java/com/jfontdev/trackstack/model/Playlist.java | Adds controlled mutation (update), relationship helpers, and initializes tracks set. |
| src/main/java/com/jfontdev/trackstack/exception/GlobalExceptionHandler.java | Adds 409 mapping for DataIntegrityViolationException and improves handler documentation. |
| src/main/java/com/jfontdev/trackstack/dto/track/TrackUpdateRequestDTO.java | Introduces PUT request DTO for tracks with required-field validation. |
| src/main/java/com/jfontdev/trackstack/dto/track/TrackResponseDTO.java | Enriches track responses to include tags. |
| src/main/java/com/jfontdev/trackstack/dto/track/TrackPatchRequestDTO.java | Introduces PATCH request DTO for tracks (nullable fields). |
| src/main/java/com/jfontdev/trackstack/dto/tag/TagUpdateRequestDTO.java | Introduces PUT request DTO for tags with required-field validation. |
| src/main/java/com/jfontdev/trackstack/dto/tag/TagPatchRequestDTO.java | Introduces PATCH request DTO for tags (nullable fields). |
| src/main/java/com/jfontdev/trackstack/dto/playlist/PlaylistUpdateRequestDTO.java | Introduces PUT request DTO for playlists with required-field validation. |
| src/main/java/com/jfontdev/trackstack/dto/playlist/PlaylistResponseDTO.java | Enriches playlist responses to include tracks. |
| src/main/java/com/jfontdev/trackstack/dto/playlist/PlaylistPatchRequestDTO.java | Introduces PATCH request DTO for playlists (nullable fields). |
| src/main/java/com/jfontdev/trackstack/controller/TrackController.java | Adds PUT/PATCH/DELETE and tag relationship endpoints for tracks. |
| src/main/java/com/jfontdev/trackstack/controller/TagController.java | Adds PUT/PATCH/DELETE endpoints for tags. |
| src/main/java/com/jfontdev/trackstack/controller/PlaylistController.java | Adds PUT/PATCH/DELETE and track relationship endpoints for playlists. |
| docs/project-plan.md | Marks Phase 06 complete and advances “Current Phase” to Phase 07. |
| .mvn/wrapper/maven-wrapper.properties | Updates Maven wrapper distribution/wrapper URLs. |
… fixes n+1 on some of the queries
…atch method in TrackController
…ng deterministic API responses
Agent-Logs-Url: https://github.com/jfontdev/TrackStack/sessions/6983bc94-1827-4fac-ab42-1d52ee178a62 Co-authored-by: jfontdev <62617184+jfontdev@users.noreply.github.com>
….java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…oller.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…eImpl.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Owner
Author
|
@copilot add validations here too |
…uestDTO; sort tracks/tags in PlaylistServiceImpl Agent-Logs-Url: https://github.com/jfontdev/TrackStack/sessions/f2297d8a-ece4-405a-be99-16af291f6da6 Co-authored-by: jfontdev <62617184+jfontdev@users.noreply.github.com>
Contributor
Done in commit
Both controllers already had |
Contributor
fix: sort tracks and tags in PlaylistServiceImpl.mapToResponseDTO for deterministic responses
…questDTO for improved data integrity
…ack entities for better encapsulation
…nHandler.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…uestDTO.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…O.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TrackPatchRequestDTO(@Size,@Positive,@Pattern)@ValidtoTrackController.patch()method parameterTrackServiceImpl.mapToResponseDTO()for stable API responsesComparatorimport and remove inline fully-qualified referenceTrackServiceImplclass-level JavaDoc (transaction strategy)@Size(min=1)validation toTagPatchRequestDTO.name@Size(min=1)validation toPlaylistPatchRequestDTO.namePlaylistServiceImpl.mapToResponseDTO()✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.