Skip to content

Conversation

@krharum
Copy link
Contributor

@krharum krharum commented Nov 28, 2025

This pull request refactors how PermisjonPermitteringId values are assigned within the Aareg bestilling logic, simplifying the handling of permission IDs and improving code maintainability. The changes remove the need to track a global maximum permission ID, instead generating IDs locally for each arbeidsforhold.

Refactoring of PermisjonPermitteringId assignment

  • The getMaxPermisjonPermitteringId method and related logic for tracking the maximum permission ID have been removed from AaregClient and AaregUtility, reducing complexity in the ID assignment process. [1] [2] [3]
  • The signature of appendArbeidsforholdId was updated to remove the AtomicInteger permisjonPermitteringId parameter, and the method now internally generates permission IDs starting from zero for each arbeidsforhold. [1] [2]
  • The logic for assigning PermisjonPermitteringId values was moved to always occur within appendArbeidsforholdId, regardless of whether the arbeidsforhold is new or existing, ensuring consistent ID assignment.
  • The code now uses a locally scoped AtomicInteger within appendPermisjonPermitteringId to assign sequential IDs, eliminating potential cross-arbeidsforhold ID conflicts and simplifying concurrency concerns.

Minor improvements

  • Added usage of Lombok's val for concise local variable declaration in AaregUtility.java.

@krharum krharum marked this pull request as ready for review November 28, 2025 10:02
@krharum krharum requested a review from a team as a code owner November 28, 2025 10:02
Copilot AI review requested due to automatic review settings November 28, 2025 10:02
Copilot finished reviewing on behalf of krharum November 28, 2025 10:05
Copy link
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

This PR fixes the ID assignment logic for permisjon/permittering (leave/furlough) records in arbeidsforhold (employment relationships). Previously, IDs were assigned using a shared global counter across all arbeidsforhold, which could lead to ID conflicts or incorrect sequencing. The fix ensures each arbeidsforhold gets its own ID sequence starting from 1.

  • Removed the global permisjonPermitteringId parameter that was shared across arbeidsforhold
  • Changed ID assignment to use a local counter per arbeidsforhold, starting from 0 (incrementing to 1, 2, etc.)
  • Removed the copying of existing permisjon/permitteringer when updating, following proper REST PUT semantics where the request contains the complete desired state

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/aareg/util/AaregUtility.java Refactored appendPermisjonPermitteringId to use a local counter per arbeidsforhold; removed the permisjonPermitteringId parameter from appendArbeidsforholdId; added import for lombok.val; removed copying of existing permisjon/permitteringer in update scenario
apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/aareg/AaregClient.java Removed the global antallPermisjonPermittering counter and its initialization; removed the parameter from calls to appendArbeidsforholdId; removed the unused import of getMaxPermisjonPermitteringId

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