Skip to content

After merge conflict where files were written over. - #17

Merged
codebyNorthsteep merged 2 commits into
mainfrom
architecture/dataModeling
Mar 31, 2026
Merged

After merge conflict where files were written over. #17
codebyNorthsteep merged 2 commits into
mainfrom
architecture/dataModeling

Conversation

@codebyNorthsteep

@codebyNorthsteep codebyNorthsteep commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

This pull request introduces a new, normalized staff role model for the system, defining clear entity relationships for staff and their specialized roles (Consultant, HR, Management). It also expands the department and role enumerations to support more granular categorization of employees. Additionally, some legacy data initialization code is removed to align with the new model.

Staff entity model and role specialization:

  • Added new JPA entities: Staff, Consultant, HR, and Management, each representing a different aspect of employee roles and responsibilities. Each specialized role is linked 1:1 with a Staff entity, supporting clear separation of concerns and extensibility. (src/main/java/org/example/cyberwatch/features/staff/model/Staff.java, Consultant.java, HR.java, Management.java) [1] [2] [3] [4]
  • All new entities use JPA annotations for persistence, and include fields for department, role, and personal information as appropriate. [1] [2] [3] [4]

Enumerations and shared model updates:

  • Expanded the Department enum to include DEVOPS, BACKEND, and FRONTEND for more detailed staff categorization. (src/main/java/org/example/cyberwatch/shared/model/enums/Department.java)
  • Introduced a new Role enum to standardize possible staff roles throughout the application. (src/main/java/org/example/cyberwatch/shared/model/enums/Role.java)

Data initialization and imports:

  • Updated imports in DataInitializer to use the new Staff entity location.
  • Removed legacy staff creation logic from DataInitializer to prevent conflicts with the new model.…R, and Management entities; update Department and Staff models

Summary by CodeRabbit

  • New Features

    • Staff now persisted as a full entity with profiles for Consultant, HR, and Management.
    • Introduced a formal Role enumeration (CEO, CTO, CONSULTANT, HR, PROJECT_MANAGER, ADMIN) and updated seed data to use it.
  • Chores

    • Department classifications updated: removed CONSULTANT, added DEVOPS, BACKEND, FRONTEND.

…R, and Management entities; update Department and Staff models
@coderabbitai

coderabbitai Bot commented Mar 31, 2026

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Introduces JPA entities for Staff, Consultant, HR, and Management; adds a shared Role enum and updates Department constants; switches repository and DataInitializer imports to the new Staff model and changes seeding code to pass Role enum constants instead of role strings.

Changes

Cohort / File(s) Summary
Staff core & role entities
src/main/java/org/example/cyberwatch/features/staff/model/Staff.java, src/main/java/org/example/cyberwatch/features/staff/model/Consultant.java, src/main/java/org/example/cyberwatch/features/staff/model/HR.java, src/main/java/org/example/cyberwatch/features/staff/model/Management.java
Added @Entity-mapped Staff with identity id, personal/contact fields, Role and Department enums, and full getters/setters. Added three role-specific entities (Consultant, HR, Management) each with generated id, required one-to-one Staff association, Department enum, constructors, and accessors.
Enums
src/main/java/org/example/cyberwatch/shared/model/enums/Department.java, src/main/java/org/example/cyberwatch/shared/model/enums/Role.java
Department enum: removed CONSULTANT, added DEVOPS, BACKEND, FRONTEND. Added new Role enum with constants CEO, CTO, CONSULTANT, HR, PROJECT_MANAGER, ADMIN.
Repository & config
src/main/java/org/example/cyberwatch/features/staff/repository/StaffRepository.java, src/main/java/org/example/cyberwatch/config/DataInitializer.java
StaffRepository import updated to new staff model package. DataInitializer import switched to the refactored Staff; seeding code adjusted to pass Role enum values to the helper (helper signature changed from String roleRole role) while preserving the existing early-return check on staffRepository.count().

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • gitnes94
  • Ericthilen
  • alicewersen-rgb

Poem

🐰
I hop through schemas, neat and spry,
Roles and staff now side by side,
Consultants, HR, managers too,
Departments fresh — DEVOPS, BACKEND, FRONTEND blue,
A tiny rabbit cheers this new data view! 🥕

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The PR title 'After merge conflict where files were written over' is vague and does not convey the actual changes made. The PR introduces a normalized staff role model with new JPA entities (Staff, Consultant, HR, Management), new enums (Role, updated Department), and updated initialization logic—none of which is reflected in the title. Replace the title with a more descriptive summary of the main change, such as 'Introduce normalized staff role model with JPA entities and enums' or 'Refactor staff model to use role-based JPA entities'.
✅ 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 architecture/dataModeling

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: 6

🧹 Nitpick comments (1)
src/main/java/org/example/cyberwatch/config/DataInitializer.java (1)

25-34: Remove dead createStaff(...) helper or rewire seeding to use it.

After removing seed inserts from run(...), this method is currently unused and adds maintenance noise.

Suggested cleanup
-    private Staff createStaff(String ssn, String firstName, String lastName, String email, String phone, String role) {
-        Staff staff = new Staff();
-        staff.setSocialSecurityNumber(ssn);
-        staff.setFirstName(firstName);
-        staff.setLastName(lastName);
-        staff.setEmail(email);
-        staff.setPhoneNumber(phone);
-        staff.setRole(role);
-        return staff;
-    }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/org/example/cyberwatch/config/DataInitializer.java` around
lines 25 - 34, The createStaff(...) helper in DataInitializer is now unused
after seed inserts were removed from run(...); either delete the createStaff
method to remove dead code, or rewire DataInitializer.run(...) to call
createStaff(ssn, firstName, lastName, email, phone, role) when creating seed
Staff instances so the helper is actually used—locate the DataInitializer class
and act on the createStaff method and the run method accordingly.
🤖 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/cyberwatch/config/DataInitializer.java`:
- Around line 3-4: StaffRepository is still typed to the old Staff class
location which mismatches the Staff instances created in DataInitializer; update
the import and generic type in StaffRepository to use the new model
(org.example.cyberwatch.features.staff.model.Staff) so the repository signature
and methods reference the same Staff class as DataInitializer (adjust any
references to StaffRepository, its class declaration and method signatures to
the new Staff type).

In `@src/main/java/org/example/cyberwatch/features/staff/model/Staff.java`:
- Around line 16-17: The socialSecurityNumber field in the Staff class is
persisted as plaintext; change persistence to store an encrypted or tokenized
value by implementing a JPA AttributeConverter or a `@PrePersist/`@PreUpdate hook
that uses your encryption service to transform socialSecurityNumber before save
and decrypt on read (or store a non-reversible token if decryption isn’t
needed). Update the Staff entity to use the converter (or add the lifecycle
methods) and ensure the getter/setter pair (socialSecurityNumber) interacts with
the clear-text value while persistence uses the encrypted/tokenized form; also
handle nulls and migration for existing records via a one-time migration job
using the same CryptoService. Ensure any CryptoService or key management used is
injected/available to the converter or entity listener and do not log the raw
SSN.
- Line 31: Replace the free-form String role in the Staff model with the new
Role enum: change the field type (String role -> Role role) in the Staff class,
update any constructors, getters/setters (getRole/setRole) and
equals/hashCode/toString uses to operate on Role, and update any places that
construct or populate Staff (e.g., deserializers, builders, DTO mappers) to
convert incoming strings to Role.valueOf(...) or a safe mapper that handles
invalid values; ensure imports reference the Role enum and adjust any JSON/ORM
annotations or database mappings to persist the enum appropriately.
- Around line 33-34: Staff, Management, HR, and Consultant each define their own
department field causing conflicting state; consolidate department into the base
Staff entity and remove the duplicate fields from role-specific classes
(Management.department, HR.department, Consultant.department). Keep the
`@Enumerated`(EnumType.STRING) on Staff.department, update all constructors,
getters/setters, DTOs, repository queries and any code referencing the removed
fields to use staff.getDepartment()/setDepartment(...), and if you must keep
role-specific department semantics implement a single-source delegation (e.g.,
role classes return staff.getDepartment() or a transient override) and apply a
DB migration to drop or migrate the redundant columns. Ensure JPA mappings
remain consistent after removal (adjust `@AttributeOverride/`@Column usages or
entity inheritance mappings as needed).

In `@src/main/java/org/example/cyberwatch/shared/model/enums/Role.java`:
- Line 8: The enum constant PROJEKTMANAGER in Role should be renamed to a
canonical form (e.g., PROJECT_MANAGER) to avoid mapping mismatches; update the
Role enum entry from PROJEKTMANAGER to PROJECT_MANAGER, then search and update
all references/usages (switches, DB mappings, serializers/deserializers, tests)
to the new name, and if runtime compatibility is required add a compatible
mapping (e.g., preserve old string mapping via Jackson annotations or conversion
logic) so existing persisted values still resolve correctly.
- Around line 3-10: Staff currently stores and accepts role as raw String which
bypasses the new Role enum; change Staff.role to type Role and update any
constructors/getters/setters (e.g., the Staff class's role field and
setRole/getRole methods) to use the Role enum, then update
DataInitializer.createStaff and any call sites to pass Role values (e.g.,
Role.CEO, Role.CTO, etc.) instead of Strings; ensure any persistence mapping
(ORM annotations or converters) is updated to persist enums (or add an
AttributeConverter) so invalid string roles cannot be saved.

---

Nitpick comments:
In `@src/main/java/org/example/cyberwatch/config/DataInitializer.java`:
- Around line 25-34: The createStaff(...) helper in DataInitializer is now
unused after seed inserts were removed from run(...); either delete the
createStaff method to remove dead code, or rewire DataInitializer.run(...) to
call createStaff(ssn, firstName, lastName, email, phone, role) when creating
seed Staff instances so the helper is actually used—locate the DataInitializer
class and act on the createStaff method and the run method accordingly.
🪄 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: 6da9c3b2-59dc-4e07-b0ac-4f0f6d4a2e27

📥 Commits

Reviewing files that changed from the base of the PR and between 72b7389 and fea486b.

📒 Files selected for processing (7)
  • src/main/java/org/example/cyberwatch/config/DataInitializer.java
  • src/main/java/org/example/cyberwatch/features/staff/model/Consultant.java
  • src/main/java/org/example/cyberwatch/features/staff/model/HR.java
  • src/main/java/org/example/cyberwatch/features/staff/model/Management.java
  • src/main/java/org/example/cyberwatch/features/staff/model/Staff.java
  • src/main/java/org/example/cyberwatch/shared/model/enums/Department.java
  • src/main/java/org/example/cyberwatch/shared/model/enums/Role.java

Comment on lines +3 to 4
import org.example.cyberwatch.features.staff.model.Staff;
import org.example.cyberwatch.features.staff.repository.StaffRepository;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify the Staff type bound to StaffRepository.
# Expected: StaffRepository should import org.example.cyberwatch.features.staff.model.Staff
# if the migration to the new staff model is complete.
fd StaffRepository.java --exec sed -n '1,80p' {}

Repository: ithsjava25/project-backend-super-cool-team

Length of output: 353


🏁 Script executed:

#!/bin/bash
# Check the first few lines of DataInitializer.java to verify the import statement
fd DataInitializer.java --exec head -20 {} \;

Repository: ithsjava25/project-backend-super-cool-team

Length of output: 713


🏁 Script executed:

#!/bin/bash
# Search for both Staff class definitions to verify they exist
echo "=== Checking for old Staff class at: org.example.cyberwatch.features.ticket.model.entitys.staff ==="
fd Staff.java -path "*features/ticket/model/entitys/staff*"

echo -e "\n=== Checking for new Staff class at: org.example.cyberwatch.features.staff.model ==="
fd Staff.java -path "*features/staff/model*"

Repository: ithsjava25/project-backend-super-cool-team

Length of output: 626


🏁 Script executed:

#!/bin/bash
# Check how many places reference each Staff import
echo "=== References to org.example.cyberwatch.features.ticket.model.entitys.staff.Staff ==="
rg "org\.example\.cyberwatch\.features\.ticket\.model\.entitys\.staff\.Staff" --count-matches

echo -e "\n=== References to org.example.cyberwatch.features.staff.model.Staff ==="
rg "org\.example\.cyberwatch\.features\.staff\.model\.Staff" --count-matches

Repository: ithsjava25/project-backend-super-cool-team

Length of output: 398


🏁 Script executed:

#!/bin/bash
# Search for Staff class definitions in both locations
echo "=== Searching for Staff class in old location (features/ticket/model/entitys/staff) ==="
find . -name "Staff.java" -exec grep -l "class Staff" {} \; 2>/dev/null

echo -e "\n=== Directory structure check ==="
find . -type d -name "ticket" -o -type d -name "staff" 2>/dev/null | head -20

Repository: ithsjava25/project-backend-super-cool-team

Length of output: 549


🏁 Script executed:

#!/bin/bash
# More targeted search for Staff class files
rg "^class Staff" --type java -B 2

Repository: ithsjava25/project-backend-super-cool-team

Length of output: 68


🏁 Script executed:

#!/bin/bash
# Compare the two Staff classes to see if they're identical or different
echo "=== New Staff class (features/staff/model/Staff.java) ==="
head -30 ./src/main/java/org/example/cyberwatch/features/staff/model/Staff.java

echo -e "\n=== Old Staff class (features/ticket/model/entitys/staff/Staff.java) ==="
head -30 ./src/main/java/org/example/cyberwatch/features/ticket/model/entitys/staff/Staff.java

Repository: ithsjava25/project-backend-super-cool-team

Length of output: 2046


🏁 Script executed:

#!/bin/bash
# Check all files that use StaffRepository to see if they import Staff and which version
echo "=== Files that import or reference StaffRepository ==="
rg "StaffRepository" --type java -l

echo -e "\n=== Check what Staff type is used alongside StaffRepository in other files ==="
rg -A 2 -B 2 "StaffRepository" --type java

Repository: ithsjava25/project-backend-super-cool-team

Length of output: 2172


Fix StaffRepository to use the new Staff model location.

StaffRepository imports org.example.cyberwatch.features.ticket.model.entitys.staff.Staff, but DataInitializer imports and uses org.example.cyberwatch.features.staff.model.Staff. This type mismatch will cause errors when DataInitializer attempts to save Staff instances—it's creating objects of the new Staff class while the repository is typed to the old one. Update StaffRepository to import from the new location: org.example.cyberwatch.features.staff.model.Staff.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/org/example/cyberwatch/config/DataInitializer.java` around
lines 3 - 4, StaffRepository is still typed to the old Staff class location
which mismatches the Staff instances created in DataInitializer; update the
import and generic type in StaffRepository to use the new model
(org.example.cyberwatch.features.staff.model.Staff) so the repository signature
and methods reference the same Staff class as DataInitializer (adjust any
references to StaffRepository, its class declaration and method signatures to
the new Staff type).

Comment on lines +16 to +17
@Column(name = "social_security_number", nullable = false, unique = true)
String socialSecurityNumber;

@coderabbitai coderabbitai Bot Mar 31, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Plaintext SSN storage is a compliance/privacy risk.

socialSecurityNumber is stored directly as plain text. This should be protected (encryption/tokenization) before persisting to reduce PII exposure risk.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/org/example/cyberwatch/features/staff/model/Staff.java` around
lines 16 - 17, The socialSecurityNumber field in the Staff class is persisted as
plaintext; change persistence to store an encrypted or tokenized value by
implementing a JPA AttributeConverter or a `@PrePersist/`@PreUpdate hook that uses
your encryption service to transform socialSecurityNumber before save and
decrypt on read (or store a non-reversible token if decryption isn’t needed).
Update the Staff entity to use the converter (or add the lifecycle methods) and
ensure the getter/setter pair (socialSecurityNumber) interacts with the
clear-text value while persistence uses the encrypted/tokenized form; also
handle nulls and migration for existing records via a one-time migration job
using the same CryptoService. Ensure any CryptoService or key management used is
injected/available to the converter or entity listener and do not log the raw
SSN.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This will be implemented further ahead

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@codebyNorthsteep, understood! Since this is a security-sensitive item (PII/compliance), would you like me to open a GitHub issue to track the SSN encryption/tokenization work for a future PR? That way it won't get lost.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
gh issue create \
  --repo ithsjava25/project-backend-super-cool-team \
  --title "Encrypt/tokenize socialSecurityNumber before persisting Staff entity" \
  --assignee codebyNorthsteep \
  --body "## Overview

The \`socialSecurityNumber\` field in the \`Staff\` entity (\`src/main/java/org/example/cyberwatch/features/staff/model/Staff.java\`) is currently stored as plaintext. This poses a compliance and privacy risk (PII exposure).

## Context

- Raised during code review in PR `#17` (comment: https://github.com/ithsjava25/project-backend-super-cool-team/pull/17#discussion_r3016058753)
- Requested by `@codebyNorthsteep` to be tracked for a future PR.

## Acceptance Criteria

- [ ] Implement a JPA \`AttributeConverter\` (or \`@PrePersist\`/\`@PreUpdate\` lifecycle hooks) that encrypts or tokenizes \`socialSecurityNumber\` before saving and decrypts/resolves on read.
- [ ] The \`Staff\` entity getter/setter pair should continue to work with the clear-text value; only the persisted column should store the encrypted/tokenized form.
- [ ] A \`CryptoService\` (or equivalent key management solution) should be used and injected into the converter or entity listener — never hardcoded.
- [ ] Do **not** log the raw SSN at any point.
- [ ] Handle \`null\` values gracefully.
- [ ] Provide a one-time migration job (using the same \`CryptoService\`) to re-encrypt any existing plaintext records.

## References

- [JPA AttributeConverter docs](https://jakarta.ee/specifications/persistence/3.1/apidocs/jakarta.persistence/jakarta/persistence/AttributeConverter.html)
- [OWASP - Protecting PII](https://owasp.org/www-project-top-ten/)
"

Length of output: 71


@codebyNorthsteep, done! I've opened issue #18 to track this work: #18

It's assigned to you and includes the following acceptance criteria:

  • Implement a JPA AttributeConverter (or @PrePersist/@PreUpdate hooks) for encryption/tokenization of the SSN column.
  • Keep getter/setter working with clear-text; only the DB column stores the encrypted form.
  • Use an injected CryptoService — no hardcoded keys.
  • Never log the raw SSN.
  • Handle null values gracefully.
  • Provide a one-time migration job for any existing plaintext records.

Comment thread src/main/java/org/example/cyberwatch/features/staff/model/Staff.java Outdated
Comment on lines +33 to +34
@Enumerated(EnumType.STRING)
Department department;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Inspect all staff-role entities carrying a Department field.
# Expected: one source of truth for department, or explicit sync mechanism.
rg -n -C2 'Department\s+department|setDepartment\s*\(' -g '*.java'

Repository: ithsjava25/project-backend-super-cool-team

Length of output: 9100


🏁 Script executed:

#!/bin/bash
# Check the class hierarchy - are Management, HR, Consultant subclasses of Staff?
# Look at the class definitions
for file in src/main/java/org/example/cyberwatch/features/staff/model/*.java; do
  echo "=== $file ==="
  head -20 "$file" | grep -E "^(public|private|protected)?\s*(abstract\s+)?class|extends|implements"
done

Repository: ithsjava25/project-backend-super-cool-team

Length of output: 595


🏁 Script executed:

#!/bin/bash
# Check the full Staff.java to understand structure
cat src/main/java/org/example/cyberwatch/features/staff/model/Staff.java

Repository: ithsjava25/project-backend-super-cool-team

Length of output: 2370


🏁 Script executed:

#!/bin/bash
# Check Management.java to see if it extends Staff
cat src/main/java/org/example/cyberwatch/features/staff/model/Management.java

Repository: ithsjava25/project-backend-super-cool-team

Length of output: 1126


🏁 Script executed:

#!/bin/bash
# Check HR and Consultant full definitions
cat src/main/java/org/example/cyberwatch/features/staff/model/HR.java

Repository: ithsjava25/project-backend-super-cool-team

Length of output: 1122


🏁 Script executed:

#!/bin/bash
cat src/main/java/org/example/cyberwatch/features/staff/model/Consultant.java

Repository: ithsjava25/project-backend-super-cool-team

Length of output: 1132


🏁 Script executed:

#!/bin/bash
# Check if there are any lifecycle listeners or event handlers for sync
rg -n '@PreUpdate|@PostUpdate|@PrePersist|@PostPersist|@PreRemove|PostRemove' -g '*.java' src/main/java/org/example/cyberwatch/features/staff/model/

Repository: ithsjava25/project-backend-super-cool-team

Length of output: 68


Staff and role-specific entities have duplicate, unsynchronized department fields.

Staff.department, Management.department, HR.department, and Consultant.department are independent fields with no synchronization mechanism. A single staff member can have conflicting department values across these entities (e.g., IT in Staff but HR in Management), violating single source of truth.

Consider consolidating the department field into the base Staff entity and removing it from role-specific classes, or implementing a synchronization mechanism if role-specific departments serve a distinct purpose.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/org/example/cyberwatch/features/staff/model/Staff.java` around
lines 33 - 34, Staff, Management, HR, and Consultant each define their own
department field causing conflicting state; consolidate department into the base
Staff entity and remove the duplicate fields from role-specific classes
(Management.department, HR.department, Consultant.department). Keep the
`@Enumerated`(EnumType.STRING) on Staff.department, update all constructors,
getters/setters, DTOs, repository queries and any code referencing the removed
fields to use staff.getDepartment()/setDepartment(...), and if you must keep
role-specific department semantics implement a single-source delegation (e.g.,
role classes return staff.getDepartment() or a transient override) and apply a
DB migration to drop or migrate the redundant columns. Ensure JPA mappings
remain consistent after removal (adjust `@AttributeOverride/`@Column usages or
entity inheritance mappings as needed).

Comment on lines +3 to +10
public enum Role {
CEO,
CTO,
CONSULTANT,
HR,
PROJEKTMANAGER,
ADMIN
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Role standardization is incomplete and currently unenforced

Role is defined here, but Staff and DataInitializer still persist/assign roles as raw String values (Staff.role and createStaff(..., String role)), so invalid role values can still be saved. This breaks the stated normalization goal and risks inconsistent data at runtime.

Suggested direction
// Staff.java
- private String role;
+ `@Enumerated`(EnumType.STRING)
+ private Role role;

- public String getRole() { return role; }
- public void setRole(String role) { this.role = role; }
+ public Role getRole() { return role; }
+ public void setRole(Role role) { this.role = role; }

// DataInitializer.java
- private Staff createStaff(..., String role) {
+ private Staff createStaff(..., Role role) {
    ...
    staff.setRole(role);
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/org/example/cyberwatch/shared/model/enums/Role.java` around
lines 3 - 10, Staff currently stores and accepts role as raw String which
bypasses the new Role enum; change Staff.role to type Role and update any
constructors/getters/setters (e.g., the Staff class's role field and
setRole/getRole methods) to use the Role enum, then update
DataInitializer.createStaff and any call sites to pass Role values (e.g.,
Role.CEO, Role.CTO, etc.) instead of Strings; ensure any persistence mapping
(ORM annotations or converters) is updated to persist enums (or add an
AttributeConverter) so invalid string roles cannot be saved.

CTO,
CONSULTANT,
HR,
PROJEKTMANAGER,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Consider renaming PROJEKTMANAGER to a canonical enum style

Line 8 uses PROJEKTMANAGER, which is likely a typo/localized variant. If other layers expect PROJECT_MANAGER (or PROJECTMANAGER), this can create mapping/filter bugs later. Prefer one canonical spelling now.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/org/example/cyberwatch/shared/model/enums/Role.java` at line 8,
The enum constant PROJEKTMANAGER in Role should be renamed to a canonical form
(e.g., PROJECT_MANAGER) to avoid mapping mismatches; update the Role enum entry
from PROJEKTMANAGER to PROJECT_MANAGER, then search and update all
references/usages (switches, DB mappings, serializers/deserializers, tests) to
the new name, and if runtime compatibility is required add a compatible mapping
(e.g., preserve old string mapping via Jackson annotations or conversion logic)
so existing persisted values still resolve correctly.

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