-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/entities #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
02a9056
Initial entity model
FionaSprinkles 1b0bc2b
Update .gitignore
FionaSprinkles 1cbf5fd
chore: remove IntelliJ project files from repository
FionaSprinkles 7abc014
Initial README
FionaSprinkles 3d94f79
add data jpa dependency
FionaSprinkles fd03ed2
ci: ensure jte directory exists for CI build
FionaSprinkles 673f5cb
refactor: rename SystemUser to User
FionaSprinkles c145935
chore: resolve merge conflict remove .idea
FionaSprinkles 0791b1b
add prePersist on TicketComment
FionaSprinkles a213d26
refactor: replace lombok @Data with @Getter and @Setter in entities
FionaSprinkles 980a4da
Edit README: adjust heading levels
simonforsberg bce8087
Update `AuditLog` entity: add column constraints, lazy fetching, and …
simonforsberg 42c24e9
Update `Ticket` entity: add column constraints, improve mapping for a…
simonforsberg 680c915
Update `User` entity: replace `role` with `Role` enum, rename `passwo…
simonforsberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # The ALFS Whistleblower Ticket System | ||
|
|
||
| ## A secure case management system built with Spring Boot for handling whistleblower reports. | ||
| The system allows anonymous reporting, secure file uploads, role-based access control, and full audit logging. | ||
|
|
||
| ### Logs should look like this: | ||
| ```text | ||
| action = HANDLER_ASSIGNED | ||
| fieldName = assignedHandler | ||
| oldValue = null | ||
| newValue = userId:5 | ||
| createdAt = 2026-03-27 | ||
| ``` | ||
|
|
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package org.example.alfs; | ||
|
|
||
| public enum Role { | ||
| REPORTER, | ||
| INVESTIGATOR, | ||
| ADMIN | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package org.example.alfs.entities; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import lombok.*; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| /* | ||
| Represent a file uploaded with Ticket. | ||
| Stores metadata about the file and the file reference s3key. | ||
| */ | ||
| @Entity | ||
| @Getter | ||
| @Setter | ||
| @AllArgsConstructor | ||
| @NoArgsConstructor | ||
| public class Attachment { | ||
|
|
||
| @Id | ||
| @GeneratedValue | ||
| private Long id; | ||
|
|
||
| private String fileName; | ||
|
|
||
| private String s3Key; | ||
|
|
||
| private LocalDateTime uploadedAt; | ||
|
|
||
| @PrePersist | ||
| public void prePersist() { | ||
| uploadedAt = LocalDateTime.now(); | ||
| } | ||
|
|
||
| @ManyToOne | ||
| private Ticket ticket; | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package org.example.alfs.entities; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import lombok.*; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| /* | ||
| Represents audit log for Ticket. | ||
| Logs all events such as status change, assignment and comments. | ||
| Should be written automatically. | ||
| */ | ||
| @Entity | ||
| @Table(name = "audit_log") | ||
| @Getter | ||
| @Setter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public class AuditLog { | ||
|
|
||
| @Id | ||
| @GeneratedValue | ||
| private Long id; | ||
|
|
||
| private String action; | ||
|
|
||
| private String fieldName; | ||
|
|
||
| @Column(length = 4000) | ||
| private String oldValue; | ||
|
|
||
| @Column(length = 4000) | ||
| private String newValue; | ||
|
|
||
| private LocalDateTime createdAt; | ||
|
|
||
| @PrePersist | ||
| public void prePersist() { | ||
| createdAt = LocalDateTime.now(); | ||
| } | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "ticket_id") | ||
| private Ticket ticket; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "user_id") | ||
| private User user; | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| package org.example.alfs.entities; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import lombok.*; | ||
|
|
||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.List; | ||
|
|
||
| /* | ||
| Representing a whistleblower report. | ||
| The ticket can be followed by the anonymous reporter by using the reporterToken. | ||
| */ | ||
|
|
||
| @Entity | ||
| @Table(name = "ticket") | ||
| @Getter | ||
| @Setter | ||
| @AllArgsConstructor | ||
| @NoArgsConstructor | ||
| public class Ticket { | ||
|
|
||
| @Id | ||
| @GeneratedValue | ||
| private Long id; | ||
|
|
||
| private String title; | ||
|
|
||
| private String description; | ||
|
|
||
| private String status; | ||
|
|
||
| @Column(nullable = false, unique = true, length = 128, updatable = false) | ||
| private String reporterToken; | ||
|
|
||
| private LocalDateTime createdAt; | ||
|
|
||
| @PrePersist | ||
| public void prePersist() { | ||
| createdAt = LocalDateTime.now(); | ||
| } | ||
|
|
||
| @OneToMany(mappedBy = "ticket", cascade = CascadeType.ALL, orphanRemoval = true) | ||
| private List<Attachment> attachments; | ||
|
|
||
| @ManyToOne | ||
| private User assignedHandler; | ||
| } |
39 changes: 39 additions & 0 deletions
39
src/main/java/org/example/alfs/entities/TicketComment.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package org.example.alfs.entities; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import lombok.*; | ||
|
|
||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| /* | ||
| Represents comment on a ticket. | ||
| The comments are written by a User. | ||
| */ | ||
| @Entity | ||
| @Table(name="ticket_comment") | ||
| @Getter | ||
| @Setter | ||
| @AllArgsConstructor | ||
| @NoArgsConstructor | ||
| public class TicketComment { | ||
|
|
||
| @Id | ||
| @GeneratedValue | ||
| private Long id; | ||
|
|
||
| private String message; | ||
|
|
||
| private LocalDateTime createdAt; | ||
|
|
||
| @PrePersist | ||
| public void prePersist() { | ||
| createdAt = LocalDateTime.now(); | ||
| } | ||
|
|
||
| @ManyToOne | ||
| private Ticket ticket; | ||
|
|
||
| @ManyToOne | ||
| private User author; | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package org.example.alfs.entities; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import lombok.*; | ||
| import org.example.alfs.Role; | ||
|
|
||
| /* | ||
| Represents a system user. | ||
| Users have different roles such as admin or investigator. | ||
| */ | ||
| @Entity | ||
| @Table(name = "users") | ||
| @Getter | ||
| @Setter | ||
| @AllArgsConstructor | ||
| @NoArgsConstructor | ||
| public class User { | ||
|
|
||
| @GeneratedValue | ||
| @Id | ||
| private Long id; | ||
|
|
||
| private String username; | ||
|
|
||
| @Column(name = "password_hash", nullable = false, length = 255) | ||
| private String passwordHash; | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| private Role role; | ||
|
|
||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| <%-- This is a placeholder jte file for CI test --%> |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.