Skip to content

feat: implement Phase 6 – update, delete, and relationship management…#15

Merged
jfontdev merged 20 commits into
mainfrom
feat/update-delete-operations
Mar 28, 2026
Merged

feat: implement Phase 6 – update, delete, and relationship management…#15
jfontdev merged 20 commits into
mainfrom
feat/update-delete-operations

Conversation

@jfontdev
Copy link
Copy Markdown
Owner

@jfontdev jfontdev commented Mar 28, 2026

  • Add validation constraints to TrackPatchRequestDTO (@Size, @Positive, @Pattern)
  • Add @Valid to TrackController.patch() method parameter
  • Sort tags by name in TrackServiceImpl.mapToResponseDTO() for stable API responses
  • Clean up: add Comparator import and remove inline fully-qualified reference
  • Fix TrackServiceImpl class-level JavaDoc (transaction strategy)
  • Add @Size(min=1) validation to TagPatchRequestDTO.name
  • Add @Size(min=1) validation to PlaylistPatchRequestDTO.name
  • Sort tracks by title and tags by name in PlaylistServiceImpl.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.

… 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)
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 CASCADE on 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.

Comment thread src/main/java/com/jfontdev/trackstack/dto/track/TrackPatchRequestDTO.java Outdated
Comment thread src/main/java/com/jfontdev/trackstack/controller/TagController.java Outdated
Comment thread src/main/java/com/jfontdev/trackstack/controller/PlaylistController.java Outdated
Comment thread src/main/java/com/jfontdev/trackstack/dto/playlist/PlaylistPatchRequestDTO.java Outdated
Comment thread src/main/java/com/jfontdev/trackstack/service/impl/TrackServiceImpl.java Outdated
Comment thread .mvn/wrapper/maven-wrapper.properties
jfontdev and others added 3 commits March 28, 2026 22:17
….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>
@jfontdev
Copy link
Copy Markdown
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>
Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 28, 2026

@copilot add validations here too

Done in commit 40ee495:

  • TagPatchRequestDTO.name@Size(min = 1, message = "Name must not be empty if provided")
  • PlaylistPatchRequestDTO.name@Size(min = 1, message = "Name must not be empty if provided")

Both controllers already had @Valid on their patch() methods, so the constraints will be enforced immediately. Also added sorting (tracks by title, tags by name) in PlaylistServiceImpl.mapToResponseDTO() for stable API responses.

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 28, 2026

@jfontdev I've opened a new pull request, #16, to work on those changes. Once the pull request is ready, I'll request review from you.

fix: sort tracks and tags in PlaylistServiceImpl.mapToResponseDTO for deterministic responses
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 29 out of 30 changed files in this pull request and generated 8 comments.

Comment thread src/main/java/com/jfontdev/trackstack/service/impl/TrackServiceImpl.java Outdated
Comment thread src/main/java/com/jfontdev/trackstack/service/impl/TrackServiceImpl.java Outdated
Comment thread src/main/java/com/jfontdev/trackstack/service/impl/TagServiceImpl.java Outdated
Comment thread src/main/java/com/jfontdev/trackstack/service/impl/TrackServiceImpl.java Outdated
Comment thread src/main/java/com/jfontdev/trackstack/service/impl/TagServiceImpl.java Outdated
Comment thread src/main/java/com/jfontdev/trackstack/service/impl/TagServiceImpl.java Outdated
Comment thread src/main/java/com/jfontdev/trackstack/service/impl/TrackServiceImpl.java Outdated
Comment thread src/main/java/com/jfontdev/trackstack/service/impl/TrackServiceImpl.java Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 29 out of 30 changed files in this pull request and generated 3 comments.

Comment thread src/main/java/com/jfontdev/trackstack/dto/track/TrackUpdateRequestDTO.java Outdated
Comment thread src/main/java/com/jfontdev/trackstack/model/Track.java
Comment thread src/main/java/com/jfontdev/trackstack/model/Playlist.java
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 32 out of 33 changed files in this pull request and generated 6 comments.

Comment thread src/main/java/com/jfontdev/trackstack/dto/track/TrackUpdateRequestDTO.java Outdated
Comment thread src/main/java/com/jfontdev/trackstack/exception/GlobalExceptionHandler.java Outdated
Comment thread src/main/java/com/jfontdev/trackstack/dto/track/TrackRequestDTO.java Outdated
jfontdev and others added 3 commits March 28, 2026 23:39
…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>
@jfontdev jfontdev merged commit de75e9a into main Mar 28, 2026
@jfontdev jfontdev deleted the feat/update-delete-operations branch March 28, 2026 22:40
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.

3 participants