-
Notifications
You must be signed in to change notification settings - Fork 2
feat. filter for å skjule mentor avtaler med opphav arena #1434
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces filtering logic to hide mentor agreements migrated from ARENA for users who are not internal users (veileder/beslutter). The filter is applied both when listing agreements and when checking individual agreement access.
- Added filtering in
hentAvtalerMedLesetilgangto exclude ARENA mentor agreements from list results - Added access check in
sjekkTilgangto prevent direct access to hidden ARENA mentor agreements - Implemented
harTilgangTilMentorArenaMigreringmethod containing the filtering logic
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (!avtalenEksisterer(avtale)) { | ||
| throw new RessursFinnesIkkeException(); | ||
| } | ||
| if (skalSkjulesMentorArenaMigrering(avtale)) { |
Copilot
AI
Nov 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method skalSkjulesMentorArenaMigrering does not exist. This should be harTilgangTilMentorArenaMigrering(avtale) to match the method defined on line 223. Additionally, the logic needs to be inverted since harTilgangTilMentorArenaMigrering returns false when the agreement should be hidden, so the condition should be !harTilgangTilMentorArenaMigrering(avtale).
| if (skalSkjulesMentorArenaMigrering(avtale)) { | |
| if (!harTilgangTilMentorArenaMigrering(avtale)) { |
src/main/java/no/nav/tag/tiltaksgjennomforing/avtale/Avtalepart.java
Outdated
Show resolved
Hide resolved
src/main/java/no/nav/tag/tiltaksgjennomforing/avtale/Avtalepart.java
Outdated
Show resolved
Hide resolved
…ikke ingått for arbeidsgiver Co-authored-by: Odd Andreas Sørsæther <[email protected]>
…att familjetilknytting Co-authored-by: Odd Andreas Sørsæther <[email protected]>
There was a problem hiding this 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 4 out of 4 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| return new Tilgang.Tillat(); | ||
| })); | ||
| return tilgangsmappe; |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removed avtalenEksisterer override previously hid ALL Arena agreements that weren't concluded (!erAvtaleInngått()) from employers. The new filtering logic in Avtalepart only hides MENTOR Arena agreements based on completion status. This means non-mentor Arena agreements that aren't concluded will now be visible to employers. If this behavior change is intentional, consider documenting it; otherwise, the old logic may need to be preserved or combined with the new filter.
|
|
||
| public boolean sjekkOmAlltErFylltUtUntattFamiljeTilknyting() { | ||
|
|
||
| if (!felterSomIkkeErFyltUt().stream().filter(x -> !x.equals("harFamilietilknytning")).toList().isEmpty()) { |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The double negation with .filter(x -> !x.equals("harFamilietilknytning")).toList().isEmpty() makes this logic confusing. This checks if the filtered list is empty, which means all unfilled fields are "harFamilietilknytning". Consider simplifying to:
if (felterSomIkkeErFyltUt().stream().anyMatch(x -> !x.equals("harFamilietilknytning")))This is clearer: "if any unfilled field is NOT harFamilietilknytning, return false".
| if (!felterSomIkkeErFyltUt().stream().filter(x -> !x.equals("harFamilietilknytning")).toList().isEmpty()) { | |
| if (felterSomIkkeErFyltUt().stream().anyMatch(x -> !x.equals("harFamilietilknytning"))) { |
| } | ||
| } | ||
|
|
||
| public boolean sjekkOmAlltErFylltUtUntattFamiljeTilknyting() { |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method name has a typo: "Allt" should be "Alt" (singular, consistent with sjekkOmAltErKlarTilGodkjenning on line 788). Additionally, "FamiljeTilknyting" doesn't match the field name "Familietilknytning" used elsewhere, though this inconsistency exists throughout method names in this class.
| public boolean erKlarForVisningAvMigrertMentorAvtale() { | ||
| return sjekkOmAlltErFylltUtUntattFamiljeTilknyting(); | ||
| } |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is a simple wrapper that adds no additional logic or documentation. Consider removing it and directly calling sjekkOmAlltErFylltUtUntattFamiljeTilknyting() from the caller in Avtalepart.java line 237, or add documentation explaining why this wrapper exists.
| public boolean erKlarForVisningAvMigrertMentorAvtale() { | |
| return sjekkOmAlltErFylltUtUntattFamiljeTilknyting(); | |
| } | |
| // Method removed: erKlarForVisningAvMigrertMentorAvtale() |
| boolean utFylltUntattFamiljeTilknyting = avtale.erKlarForVisningAvMigrertMentorAvtale(); | ||
|
|
||
| if (!erInternRolle && !utFylltUntattFamiljeTilknyting) { | ||
| log.info("Skjult mentoravtale med opphav Arena for migrering. Rolle: {}, AvtaleNr: {}", rolle(), avtale.getAvtaleNr()); | ||
| } | ||
|
|
||
| return erInternRolle || utFylltUntattFamiljeTilknyting; |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable name violates camelCase convention: "utFyllt" should be "utfylt" (lowercase 'f'). Additionally, "FamiljeTilknyting" appears to be a misspelling that doesn't match the field name "Familietilknytning", though this inconsistency exists in related method names.
| boolean utFylltUntattFamiljeTilknyting = avtale.erKlarForVisningAvMigrertMentorAvtale(); | |
| if (!erInternRolle && !utFylltUntattFamiljeTilknyting) { | |
| log.info("Skjult mentoravtale med opphav Arena for migrering. Rolle: {}, AvtaleNr: {}", rolle(), avtale.getAvtaleNr()); | |
| } | |
| return erInternRolle || utFylltUntattFamiljeTilknyting; | |
| boolean utfyltUntattFamilietilknytning = avtale.erKlarForVisningAvMigrertMentorAvtale(); | |
| if (!erInternRolle && !utfyltUntattFamilietilknytning) { | |
| log.info("Skjult mentoravtale med opphav Arena for migrering. Rolle: {}, AvtaleNr: {}", rolle(), avtale.getAvtaleNr()); | |
| } | |
| return erInternRolle || utfyltUntattFamilietilknytning; |
| private boolean mentorAvtaleUnderMigreringSkalVises(Avtale avtale) { | ||
| boolean erMentorArena = erAvtaleMigrertMentorArena(avtale); | ||
|
|
||
| if (!erMentorArena) { | ||
| return true; | ||
| } | ||
|
|
||
| boolean erInternRolle = rolle().erInternBruker(); | ||
|
|
||
| boolean utFylltUntattFamiljeTilknyting = avtale.erKlarForVisningAvMigrertMentorAvtale(); | ||
|
|
||
| if (!erInternRolle && !utFylltUntattFamiljeTilknyting) { | ||
| log.info("Skjult mentoravtale med opphav Arena for migrering. Rolle: {}, AvtaleNr: {}", rolle(), avtale.getAvtaleNr()); | ||
| } | ||
|
|
||
| return erInternRolle || utFylltUntattFamiljeTilknyting; | ||
| } |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new filtering logic for migrated mentor agreements from Arena lacks test coverage. Consider adding tests for:
- Non-internal users being denied access to incomplete migrated mentor agreements
- Internal users (VEILEDER/BESLUTTER) having access to all migrated mentor agreements
- Non-internal users having access to completed migrated mentor agreements
- Non-mentor or non-Arena agreements not being affected by the filter
| public boolean sjekkOmAlltErFylltUtUntattFamiljeTilknyting() { | ||
|
|
||
| if (!felterSomIkkeErFyltUt().stream().filter(x -> !x.equals("harFamilietilknytning")).toList().isEmpty()) { | ||
| log.warn( | ||
| "Avtale= {}, med type= {} har ikke alle felter fylt ut for visning= {}", | ||
| this.avtaleNr, | ||
| this.tiltakstype, | ||
| felterSomIkkeErFyltUt() | ||
| ); | ||
| return false; | ||
| } | ||
| log.info("Migrert mentoravtale {} er klar for visning.", this.avtaleNr); | ||
| return true; | ||
| } |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new method sjekkOmAlltErFylltUtUntattFamiljeTilknyting() lacks test coverage. Consider adding tests to verify:
- Returns true when all fields are filled except "harFamilietilknytning"
- Returns false when any other field besides "harFamilietilknytning" is not filled
- Returns true when all fields including "harFamilietilknytning" are filled
Filtrer skjuler avtaler som har opphav ARENA og er mentoravtaler for rolle som ikke er beslutter/veileder