Skip to content

Feature/ticket mapper - #10

Closed
simonforsberg wants to merge 6 commits into
mainfrom
feature/ticket-mapper
Closed

Feature/ticket mapper#10
simonforsberg wants to merge 6 commits into
mainfrom
feature/ticket-mapper

Conversation

@simonforsberg

@simonforsberg simonforsberg commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Added ticket creation via a web form with title/description fields and validation feedback.
    • Submitted tickets are now persisted and returned as viewable ticket entries.
    • Ticket listings include core details (ID, title, description, status, creation date) and show an assigned investigator when present.

@coderabbitai

coderabbitai Bot commented Apr 9, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c5da1509-1437-4baf-85c7-3726ded0d999

📥 Commits

Reviewing files that changed from the base of the PR and between 343ea3c and f601843.

📒 Files selected for processing (2)
  • src/main/java/org/example/alfs/controllers/TicketController.java
  • src/main/java/org/example/alfs/services/TicketService.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/java/org/example/alfs/services/TicketService.java
  • src/main/java/org/example/alfs/controllers/TicketController.java

📝 Walkthrough

Walkthrough

Adds ticket creation flow: a Spring MVC controller with GET/POST endpoints, a service that persists tickets and maps entities to DTOs, and a mapper component converting Ticket entities to TicketViewDTOs.

Changes

Cohort / File(s) Summary
Controller
src/main/java/org/example/alfs/controllers/TicketController.java
New Spring MVC controller exposing GET /create (adds empty TicketCreateDTO to model) and POST /create (validates TicketCreateDTO, on success calls service and redirects to /home).
Service & Mapper
src/main/java/org/example/alfs/services/TicketService.java, src/main/java/org/example/alfs/mapper/TicketMapper.java
New TicketService that constructs and saves Ticket entities via TicketRepository and returns TicketViewDTO; new TicketMapper converts TicketTicketViewDTO, conditionally setting investigator ID.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Controller as "TicketController"
    participant Service as "TicketService"
    participant Repo as "TicketRepository"
    participant Mapper as "TicketMapper"

    User->>Controller: GET /create
    Controller-->>User: 200 (render create view with empty TicketCreateDTO)

    User->>Controller: POST /create (form data)
    Controller->>Controller: validate TicketCreateDTO
    alt validation fails
        Controller-->>User: 200 (render create view with errors)
    else validation succeeds
        Controller->>Service: createNewTicket(dto)
        Service->>Repo: save(new Ticket)
        Repo-->>Service: persisted Ticket
        Service->>Mapper: entityToViewDTO(persisted Ticket)
        Mapper-->>Service: TicketViewDTO
        Service-->>Controller: TicketViewDTO
        Controller-->>User: 302 Redirect to /home
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Feature/dto #3: Introduces TicketCreateDTO and TicketViewDTO types that are consumed by the new controller, service, and mapper.

Suggested reviewers

  • addee1

Poem

🐰 I hopped in code where tickets grow and sprout,
A form to fill, a service to route,
The mapper nibbles fields with gentle care,
Saved and returned—a redirect in the air,
Hooray for small classes scurrying about!

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'Feature/ticket mapper' is only partially related to the changeset. While a TicketMapper class is added, the primary changes include a new TicketController and TicketService, making the title too narrow and not capturing the main scope of the feature. Revise the title to reflect the complete feature scope, such as 'Add ticket creation feature with controller, service, and mapper' or 'Implement ticket creation endpoints and service layer'.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/ticket-mapper

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/main/java/org/example/alfs/services/TicketService.java (1)

30-32: Use a clearer variable name for the persisted entity.

Line 30 uses save, which reads like an action. A name like savedTicket improves readability.

♻️ Suggested cleanup
-        Ticket save = ticketRepository.save(ticket);
-
-        return ticketMapper.entityToViewDTO(save);
+        Ticket savedTicket = ticketRepository.save(ticket);
+        return ticketMapper.entityToViewDTO(savedTicket);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/org/example/alfs/services/TicketService.java` around lines 30 -
32, In TicketService, rename the local variable that holds the persisted entity
from save to a clearer name like savedTicket where ticketRepository.save(ticket)
is called and then passed into ticketMapper.entityToViewDTO; update both the
assignment and the subsequent reference so the code reads e.g. Ticket
savedTicket = ticketRepository.save(ticket); return
ticketMapper.entityToViewDTO(savedTicket);
src/main/java/org/example/alfs/controllers/TicketController.java (1)

19-24: Prefer private final for injected dependencies.

Since constructor injection is already used, making ticketService immutable improves encapsulation and prevents accidental reassignment.

🔧 Suggested refactor
-    TicketService ticketService;
+    private final TicketService ticketService;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/org/example/alfs/controllers/TicketController.java` around
lines 19 - 24, The injected TicketService field should be made immutable and
encapsulated: change the TicketController's ticketService field to "private
final TicketService ticketService" and keep the existing constructor
TicketController(TicketService ticketService) to assign it; update any direct
field access if present to use the private field (no other constructor changes
needed). Ensure the class compiles after marking the field final and that there
are no reassignment sites for ticketService.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/java/org/example/alfs/controllers/TicketController.java`:
- Around line 31-39: The POST handler createNewTicket in TicketController is
using an unnamed `@ModelAttribute` so it binds as "ticketCreateDTO" while the GET
handler adds the form model as "ticket"; update the POST to use the same
attribute name by changing the `@ModelAttribute` to explicitly use "ticket" (or
alternatively ensure you re-add model.addAttribute("ticket", ticketCreateDTO)
before returning on validation errors) so the create view and validation errors
render against the same attribute name.

---

Nitpick comments:
In `@src/main/java/org/example/alfs/controllers/TicketController.java`:
- Around line 19-24: The injected TicketService field should be made immutable
and encapsulated: change the TicketController's ticketService field to "private
final TicketService ticketService" and keep the existing constructor
TicketController(TicketService ticketService) to assign it; update any direct
field access if present to use the private field (no other constructor changes
needed). Ensure the class compiles after marking the field final and that there
are no reassignment sites for ticketService.

In `@src/main/java/org/example/alfs/services/TicketService.java`:
- Around line 30-32: In TicketService, rename the local variable that holds the
persisted entity from save to a clearer name like savedTicket where
ticketRepository.save(ticket) is called and then passed into
ticketMapper.entityToViewDTO; update both the assignment and the subsequent
reference so the code reads e.g. Ticket savedTicket =
ticketRepository.save(ticket); return ticketMapper.entityToViewDTO(savedTicket);
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 73c3b789-959a-46d3-bd1a-335ce73ac03e

📥 Commits

Reviewing files that changed from the base of the PR and between 8d9a5ff and 343ea3c.

📒 Files selected for processing (3)
  • src/main/java/org/example/alfs/controllers/TicketController.java
  • src/main/java/org/example/alfs/mapper/TicketMapper.java
  • src/main/java/org/example/alfs/services/TicketService.java

Comment thread src/main/java/org/example/alfs/controllers/TicketController.java
…cketService` final, adjust method annotations, and improve variable naming.
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.

2 participants