88
88
import no .nav .vedtak .sikkerhet .abac .TilpassetAbacAttributt ;
89
89
import no .nav .vedtak .sikkerhet .abac .beskyttet .ActionType ;
90
90
91
- @ OpenAPIDefinition (tags = { @ Tag (name = "iay-grunnlag" ) })
91
+ @ OpenAPIDefinition (tags = {@ Tag (name = "iay-grunnlag" )})
92
92
@ Path ("/iay/grunnlag/v1" )
93
93
@ ApplicationScoped
94
94
@ Transactional
@@ -113,12 +113,12 @@ public GrunnlagRestTjeneste(InntektArbeidYtelseTjeneste iayTjeneste,
113
113
@ Consumes (MediaType .APPLICATION_JSON )
114
114
@ Produces (MediaType .APPLICATION_JSON )
115
115
@ Operation (description = "Hent ett enkelt IAY Grunnlag for angitt spesifikasjon. Spesifikasjonen kan angit hvilke data som ønskes" , tags = "iay-grunnlag" , responses = {
116
- @ ApiResponse (description = "InntektArbeidYtelseGrunnlagDto" , content = @ Content (mediaType = "application/json" , schema = @ Schema (implementation = InntektArbeidYtelseGrunnlagDto .class ))),
117
- @ ApiResponse (responseCode = "204" , description = "Det finnes ikke et grunnlag for forespørselen" ),
118
- @ ApiResponse (responseCode = "304" , description = "Grunnlaget har ikke endret seg i henhold til det fagsystemet allerede kjenner" )
116
+ @ ApiResponse (description = "InntektArbeidYtelseGrunnlagDto" , content = @ Content (mediaType = "application/json" , schema = @ Schema (implementation = InntektArbeidYtelseGrunnlagDto .class ))),
117
+ @ ApiResponse (responseCode = "204" , description = "Det finnes ikke et grunnlag for forespørselen" ),
118
+ @ ApiResponse (responseCode = "304" , description = "Grunnlaget har ikke endret seg i henhold til det fagsystemet allerede kjenner" )
119
119
})
120
120
@ BeskyttetRessurs (actionType = ActionType .READ , resource = GRUNNLAG )
121
- @ SuppressWarnings ({ "findsecbugs:JAXRS_ENDPOINT" , "resource" })
121
+ @ SuppressWarnings ({"findsecbugs:JAXRS_ENDPOINT" , "resource" })
122
122
public Response hentIayGrunnlag (@ NotNull @ Valid InntektArbeidYtelseGrunnlagRequestAbacDto spesifikasjon ) {
123
123
Response response ;
124
124
@@ -153,12 +153,12 @@ public Response hentIayGrunnlag(@NotNull @Valid InntektArbeidYtelseGrunnlagReque
153
153
@ Path ("/arbeidsforhold-referanser" )
154
154
@ Produces (MediaType .APPLICATION_JSON )
155
155
@ Operation (description = "Hent aktivt arbeidsforholdinformasjon grunnlag for angitt kobling" , tags = "iay-grunnlag" , responses = {
156
- @ ApiResponse (description = "ArbeidsforholdInformasjon" , content = @ Content (mediaType = "application/json" , schema = @ Schema (implementation = ArbeidsforholdInformasjon .class ))),
157
- @ ApiResponse (responseCode = "204" , description = "Det finnes ikke et arbeidsforhold grunnlag for forespørselen" ),
158
- @ ApiResponse (responseCode = "304" , description = "Grunnlaget har ikke endret seg i henhold til det fagsystemet allerede kjenner" )
156
+ @ ApiResponse (description = "ArbeidsforholdInformasjon" , content = @ Content (mediaType = "application/json" , schema = @ Schema (implementation = ArbeidsforholdInformasjon .class ))),
157
+ @ ApiResponse (responseCode = "204" , description = "Det finnes ikke et arbeidsforhold grunnlag for forespørselen" ),
158
+ @ ApiResponse (responseCode = "304" , description = "Grunnlaget har ikke endret seg i henhold til det fagsystemet allerede kjenner" )
159
159
})
160
160
@ BeskyttetRessurs (actionType = ActionType .READ , resource = GRUNNLAG )
161
- @ SuppressWarnings ({ "findsecbugs:JAXRS_ENDPOINT" })
161
+ @ SuppressWarnings ({"findsecbugs:JAXRS_ENDPOINT" })
162
162
public Response hentArbeidsforholdInformasjon (@ NotNull @ Valid @ QueryParam ("ytelseType" ) YtelseType ytelseType ,
163
163
@ NotNull @ Valid @ TilpassetAbacAttributt (supplierClass = AbacDataSupplier .class ) @ Pattern (regexp = "^[A-Za-z0-9_\\ .\\ -:]+$" , message = "[${validatedValue}] matcher ikke tillatt pattern '{value}'" ) String saksnummer ,
164
164
@ NotNull @ Valid @ QueryParam ("kobling" ) UUID koblingReferanse ,
@@ -203,12 +203,12 @@ public Response hentArbeidsforholdInformasjon(@NotNull @Valid @QueryParam("ytels
203
203
@ GET
204
204
@ Produces (MediaType .APPLICATION_JSON )
205
205
@ Operation (description = "Hent aktivt IAY grunnlag grunnlag for angitt kobling" , tags = "iay-grunnlag" , responses = {
206
- @ ApiResponse (description = "InntektArbeidYtelseGrunnlagDto" , content = @ Content (mediaType = "application/json" , schema = @ Schema (implementation = ArbeidsforholdInformasjon .class ))),
207
- @ ApiResponse (responseCode = "204" , description = "Det finnes ikke et arbeidsforhold grunnlag for forespørselen" ),
208
- @ ApiResponse (responseCode = "304" , description = "Grunnlaget har ikke endret seg i henhold til det fagsystemet allerede kjenner" )
206
+ @ ApiResponse (description = "InntektArbeidYtelseGrunnlagDto" , content = @ Content (mediaType = "application/json" , schema = @ Schema (implementation = ArbeidsforholdInformasjon .class ))),
207
+ @ ApiResponse (responseCode = "204" , description = "Det finnes ikke et arbeidsforhold grunnlag for forespørselen" ),
208
+ @ ApiResponse (responseCode = "304" , description = "Grunnlaget har ikke endret seg i henhold til det fagsystemet allerede kjenner" )
209
209
})
210
210
@ BeskyttetRessurs (actionType = ActionType .READ , resource = GRUNNLAG )
211
- @ SuppressWarnings ({ "findsecbugs:JAXRS_ENDPOINT" })
211
+ @ SuppressWarnings ({"findsecbugs:JAXRS_ENDPOINT" })
212
212
public Response hentSisteIayGrunnlag (@ NotNull @ Valid @ QueryParam ("ytelseType" ) YtelseType ytelseType ,
213
213
@ TilpassetAbacAttributt (supplierClass = AbacDataSupplier .class ) @ NotNull @ Valid @ Pattern (regexp = "^[A-Za-z0-9_\\ .\\ -:]+$" , message = "[${validatedValue}] matcher ikke tillatt pattern '{value}'" ) String saksnummer ,
214
214
@ NotNull @ Valid @ QueryParam ("kobling" ) UUID koblingReferanse ,
@@ -250,7 +250,7 @@ public Response hentSisteIayGrunnlag(@NotNull @Valid @QueryParam("ytelseType") Y
250
250
@ Consumes (MediaType .APPLICATION_JSON )
251
251
@ Produces (MediaType .APPLICATION_JSON )
252
252
@ Operation (description = "Lagrer siste versjon" , tags = "iay-grunnlag" , responses = {
253
- @ ApiResponse (responseCode = "200" , description = "Mottatt grunnlaget" )
253
+ @ ApiResponse (responseCode = "200" , description = "Mottatt grunnlaget" )
254
254
})
255
255
@ BeskyttetRessurs (actionType = ActionType .UPDATE , resource = GRUNNLAG )
256
256
@ SuppressWarnings ("findsecbugs:JAXRS_ENDPOINT" )
@@ -271,13 +271,15 @@ public Response oppdaterOgLagreOverstyring(@NotNull @Valid OverstyrtInntektArbei
271
271
return Response .ok ().build ();
272
272
}
273
273
274
- /** @deprecated bytt til {@link #oppdaterOgLagreOverstyring(OverstyrtInntektArbeidYtelseDto)} . */
274
+ /**
275
+ * @deprecated bytt til {@link #oppdaterOgLagreOverstyring(OverstyrtInntektArbeidYtelseDto)} .
276
+ */
275
277
@ Deprecated (forRemoval = true )
276
278
@ PUT
277
279
@ Consumes (MediaType .APPLICATION_JSON )
278
280
@ Produces (MediaType .APPLICATION_JSON )
279
281
@ Operation (description = "Lagrer siste versjon" , tags = "iay-grunnlag" , responses = {
280
- @ ApiResponse (responseCode = "200" , description = "Mottatt grunnlaget" )
282
+ @ ApiResponse (responseCode = "200" , description = "Mottatt grunnlaget" )
281
283
})
282
284
@ BeskyttetRessurs (actionType = ActionType .UPDATE , resource = GRUNNLAG )
283
285
@ SuppressWarnings ("findsecbugs:JAXRS_ENDPOINT" )
@@ -305,7 +307,7 @@ public Response oppdaterOgLagreGrunnlag(@NotNull @Valid InntektArbeidYtelseGrunn
305
307
@ Consumes (MediaType .APPLICATION_JSON )
306
308
@ Produces (MediaType .APPLICATION_JSON )
307
309
@ Operation (description = "Hent IAY Grunnlag for angitt søke spesifikasjon" , tags = "iay-grunnlag" , responses = {
308
- @ ApiResponse (description = "Grunnlaget for saken" , content = @ Content (mediaType = "application/json" , schema = @ Schema (implementation = InntektArbeidYtelseGrunnlagSakSnapshotDto .class )))
310
+ @ ApiResponse (description = "Grunnlaget for saken" , content = @ Content (mediaType = "application/json" , schema = @ Schema (implementation = InntektArbeidYtelseGrunnlagSakSnapshotDto .class )))
309
311
})
310
312
@ BeskyttetRessurs (actionType = ActionType .READ , resource = GRUNNLAG )
311
313
@ SuppressWarnings ("findsecbugs:JAXRS_ENDPOINT" )
@@ -400,20 +402,21 @@ private Kobling oppdaterKobling(@NotNull @Valid KopierGrunnlagRequest dto) {
400
402
}
401
403
}
402
404
}
403
- // Oppdater kobling
404
- Periode opplysningsperiode = dto .getOpplysningsperiode ();
405
- if (opplysningsperiode != null ) {
406
- kobling .setOpplysningsperiode (IntervallEntitet .fraOgMedTilOgMed (opplysningsperiode .getFom (), opplysningsperiode .getTom ()));
407
- }
408
- Periode opptjeningsperiode = dto .getOpptjeningsperiode ();
409
- if (opptjeningsperiode != null ) {
410
- kobling .setOpptjeningsperiode (IntervallEntitet .fraOgMedTilOgMed (opptjeningsperiode .getFom (), opptjeningsperiode .getTom ()));
411
- }
405
+ // Oppdater kobling med perioder
406
+ mapPeriodeTilIntervall (dto .getOpplysningsperiode ()).ifPresent (kobling ::setOpplysningsperiode );
407
+ mapPeriodeTilIntervall (dto .getOpplysningsperiodeSkattegrunnlag ()).ifPresent (kobling ::setOpplysningsperiodeSkattegrunnlag );
408
+ mapPeriodeTilIntervall (dto .getOpptjeningsperiode ()).ifPresent (kobling ::setOpptjeningsperiode );
409
+
412
410
// Diff & log endringer
413
411
koblingTjeneste .lagre (kobling );
414
412
return kobling ;
415
413
}
416
414
415
+ private Optional <IntervallEntitet > mapPeriodeTilIntervall (Periode periode ) {
416
+ return Optional .ofNullable (periode == null ? null :
417
+ IntervallEntitet .fraOgMedTilOgMed (periode .getFom (), periode .getTom ()));
418
+ }
419
+
417
420
private KoblingReferanse getKoblingReferanse (AktørId aktørId , UUID koblingRef , UUID grunnlagRef ) {
418
421
KoblingReferanse koblingReferanse ;
419
422
if (koblingRef != null ) {
0 commit comments