From bd567a1a38f341877ea5a77e802fc21eeb8f0d44 Mon Sep 17 00:00:00 2001 From: "Kristen.Herum" Date: Wed, 30 Oct 2024 13:48:54 +0100 Subject: [PATCH] Add mapping strategy and Swagger adjustments Implemented a MapperFacade configuration to handle custom mapping strategies and converters. Improved Swagger setup by refining security configurations and customizing views. Enhanced OppdragRequest DTO with additional schema information and data types for better validation and XML support. Additionally, added basic unit tests for mapping strategies and updated dependencies in the build configuration. --- apps/oppdrag-service/build.gradle | 30 ++--- apps/oppdrag-service/settings.gradle | 3 +- .../config/ApplicationConfig.java | 3 +- .../config/MapperFacadeConfig.java | 36 ++++++ .../oppdragservice/config/OpenApiConfig.java | 28 ++-- .../oppdragservice/config/SecurityConfig.java | 23 ++-- .../consumer/OppdragConsumer.java | 4 + .../mapper/MappingStrategy.java | 19 +++ .../mapper/OppdragRequestMappingStrategy.java | 43 ++++++ .../provider/OppdragController.java | 5 +- .../service/OppdragService.java | 34 ++++- .../mapper/MapperTestUtils.java | 27 ++++ .../OppdragRequestMappingStrategyTest.java | 52 ++++++++ .../dto/oppdragservice/v1/OppdragRequest.java | 122 ++++++++++++++---- 14 files changed, 345 insertions(+), 84 deletions(-) create mode 100644 apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/config/MapperFacadeConfig.java create mode 100644 apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/mapper/MappingStrategy.java create mode 100644 apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/mapper/OppdragRequestMappingStrategy.java create mode 100644 apps/oppdrag-service/src/test/java/no/nav/testnav/oppdragservice/mapper/MapperTestUtils.java create mode 100644 apps/oppdrag-service/src/test/java/no/nav/testnav/oppdragservice/mapper/OppdragRequestMappingStrategyTest.java diff --git a/apps/oppdrag-service/build.gradle b/apps/oppdrag-service/build.gradle index 1c26638be91..deb6b04c7fa 100644 --- a/apps/oppdrag-service/build.gradle +++ b/apps/oppdrag-service/build.gradle @@ -68,28 +68,18 @@ dependencies { 'jakarta.activation:jakarta.activation-api:2.0.0', 'com.sun.xml.ws:jaxws-rt:3.0.0' - implementation 'no.nav.testnav.libs:security-core' - implementation 'no.nav.testnav.libs:servlet-core' - implementation 'no.nav.testnav.libs:servlet-security' - implementation 'no.nav.testnav.libs:data-transfer-objects' + implementation "no.nav.testnav.libs:data-transfer-objects" + implementation "no.nav.testnav.libs:servlet-core" + implementation "no.nav.testnav.libs:servlet-security" implementation "no.nav.testnav.libs:vault" - implementation 'org.springframework.cloud:spring-cloud-starter-vault-config' + implementation "org.springframework.boot:spring-boot-starter-web" + implementation "org.springframework.boot:spring-boot-starter-security" + implementation "org.springframework.boot:spring-boot-starter-oauth2-client" + implementation "org.springframework.boot:spring-boot-starter-web-services" - implementation 'net.logstash.logback:logstash-logback-encoder:7.4' + implementation "org.springdoc:springdoc-openapi-starter-webmvc-ui:$versions.springdoc" + implementation "io.swagger.core.v3:swagger-annotations-jakarta:$versions.swagger" - implementation 'org.springdoc:springdoc-openapi-starter-webflux-ui:2.3.0' - implementation 'io.swagger.core.v3:swagger-annotations-jakarta:2.2.20' - implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' - implementation 'org.springframework.boot:spring-boot-starter-security' - implementation 'org.springframework.boot:spring-boot-starter-validation' - implementation 'org.springframework.boot:spring-boot-starter-web' - implementation 'org.springframework.boot:spring-boot-starter-web-services' - implementation 'org.springframework.ws:spring-ws-security' - - implementation 'ma.glasnost.orika:orika-core:1.5.4' - annotationProcessor 'org.projectlombok:lombok' - implementation 'org.projectlombok:lombok' - - testImplementation 'org.springframework.boot:spring-boot-starter-test' + implementation "ma.glasnost.orika:orika-core:$versions.orika" } \ No newline at end of file diff --git a/apps/oppdrag-service/settings.gradle b/apps/oppdrag-service/settings.gradle index 904d9306913..1b54dd50812 100644 --- a/apps/oppdrag-service/settings.gradle +++ b/apps/oppdrag-service/settings.gradle @@ -4,10 +4,9 @@ plugins { rootProject.name = 'oppdrag-service' -includeBuild '../../libs/security-core' +includeBuild '../../libs/data-transfer-objects' includeBuild '../../libs/servlet-core' includeBuild '../../libs/servlet-security' -includeBuild '../../libs/data-transfer-objects' includeBuild '../../libs/vault' gradleEnterprise { diff --git a/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/config/ApplicationConfig.java b/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/config/ApplicationConfig.java index fa45e6cc921..b99613d9c20 100644 --- a/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/config/ApplicationConfig.java +++ b/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/config/ApplicationConfig.java @@ -6,8 +6,7 @@ import org.springframework.context.annotation.Import; @Configuration -@Import({ - ApplicationCoreConfig.class, +@Import({ApplicationCoreConfig.class, SecureOAuth2ServerToServerConfiguration.class }) public class ApplicationConfig { diff --git a/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/config/MapperFacadeConfig.java b/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/config/MapperFacadeConfig.java new file mode 100644 index 00000000000..8008cd59231 --- /dev/null +++ b/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/config/MapperFacadeConfig.java @@ -0,0 +1,36 @@ +package no.nav.testnav.oppdragservice.config; + +import ma.glasnost.orika.CustomConverter; +import ma.glasnost.orika.MapperFacade; +import ma.glasnost.orika.impl.DefaultMapperFactory; +import no.nav.testnav.oppdragservice.mapper.MappingStrategy; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.List; + +import static java.util.Objects.nonNull; + +@Configuration +@SuppressWarnings("java:S3740") +public class MapperFacadeConfig { + + @Bean + MapperFacade mapperFacade(List mappingStrategies, List customConverters) { + var mapperFactory = new DefaultMapperFactory.Builder().build(); + + if (nonNull(mappingStrategies)) { + for (var mapper : mappingStrategies) { + mapper.register(mapperFactory); + } + } + + if (nonNull(customConverters)) { + for (var converter : customConverters) { + mapperFactory.getConverterFactory().registerConverter(converter); + } + } + + return mapperFactory.getMapperFacade(); + } +} \ No newline at end of file diff --git a/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/config/OpenApiConfig.java b/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/config/OpenApiConfig.java index 22e439651d1..c5962d905d9 100644 --- a/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/config/OpenApiConfig.java +++ b/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/config/OpenApiConfig.java @@ -10,16 +10,15 @@ import no.nav.testnav.libs.servletcore.config.ApplicationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.http.HttpHeaders; -import org.springframework.web.server.ServerWebExchange; -import org.springframework.web.server.WebFilter; -import org.springframework.web.server.WebFilterChain; -import reactor.core.publisher.Mono; +import org.springframework.context.annotation.Import; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import java.util.Arrays; @Configuration -public class OpenApiConfig implements WebFilter { +@Import(ApplicationProperties.class) +public class OpenApiConfig implements WebMvcConfigurer { @Bean public OpenAPI openApi(ApplicationProperties applicationProperties) { @@ -29,7 +28,7 @@ public OpenAPI openApi(ApplicationProperties applicationProperties) { .scheme("bearer") .bearerFormat("JWT") .in(SecurityScheme.In.HEADER) - .name(HttpHeaders.AUTHORIZATION) + .name("Authorization") )) .addSecurityItem( new SecurityRequirement().addList("bearer-jwt", Arrays.asList("read", "write"))) @@ -46,20 +45,11 @@ public OpenAPI openApi(ApplicationProperties applicationProperties) { .license(new License() .name("MIT License") .url("https://opensource.org/licenses/MIT") - ) - ); + )); } @Override - public Mono filter(ServerWebExchange exchange, WebFilterChain chain) { - if (exchange.getRequest().getURI().getPath().equals("/swagger")) { - return chain - .filter(exchange.mutate() - .request(exchange.getRequest() - .mutate().path("/swagger-ui.html").build()) - .build()); - } - - return chain.filter(exchange); + public void addViewControllers(ViewControllerRegistry registry) { + registry.addViewController("/swagger").setViewName("redirect:/swagger-ui.html"); } } \ No newline at end of file diff --git a/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/config/SecurityConfig.java b/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/config/SecurityConfig.java index 718c433a892..28452a02141 100644 --- a/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/config/SecurityConfig.java +++ b/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/config/SecurityConfig.java @@ -2,36 +2,31 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; import org.springframework.security.config.Customizer; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.web.SecurityFilterChain; +import org.springframework.security.web.servlet.util.matcher.MvcRequestMatcher; +import org.springframework.web.servlet.handler.HandlerMappingIntrospector; @EnableWebSecurity @Configuration -@Profile({"prod", "dev"}) public class SecurityConfig { @Bean - public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { + public SecurityFilterChain filterChain(HttpSecurity httpSecurity, HandlerMappingIntrospector introspector) throws Exception { + + MvcRequestMatcher.Builder mvcMatcherBuilder = new MvcRequestMatcher.Builder(introspector); httpSecurity.sessionManagement(sessionConfig -> sessionConfig.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) .csrf(AbstractHttpConfigurer::disable) - .authorizeHttpRequests(authorizeConfig -> authorizeConfig.requestMatchers( - "/internal/**", - "/webjars/**", - "/swagger-resources/**", - "/v3/api-docs/**", - "/swagger-ui/**", - "/swagger", - "/error", - "/swagger-ui.html" - ).permitAll().requestMatchers("/api/**").fullyAuthenticated()) + .authorizeHttpRequests(authorizeConfig -> authorizeConfig + .requestMatchers(mvcMatcherBuilder.pattern("/api/**")).fullyAuthenticated() + .anyRequest().permitAll()) .oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(Customizer.withDefaults())); return httpSecurity.build(); } -} +} \ No newline at end of file diff --git a/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/consumer/OppdragConsumer.java b/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/consumer/OppdragConsumer.java index 54e01dc005b..67cfde505c6 100644 --- a/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/consumer/OppdragConsumer.java +++ b/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/consumer/OppdragConsumer.java @@ -4,4 +4,8 @@ @Service public class OppdragConsumer { + + public void sendOppdrag(String xmlPayload) { + + } } diff --git a/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/mapper/MappingStrategy.java b/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/mapper/MappingStrategy.java new file mode 100644 index 00000000000..fb400014104 --- /dev/null +++ b/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/mapper/MappingStrategy.java @@ -0,0 +1,19 @@ +package no.nav.testnav.oppdragservice.mapper; + +import ma.glasnost.orika.MapperFactory; + +@FunctionalInterface +public interface MappingStrategy { + + /** + * A callback for registering criteria on the provided {@link MapperFactory}. + *

+ *

{@code
+     *
+     * @Override public void register(MapperFactory factory) {
+     * factory.registerMapper(arbeidsfordelingToRestArbeidsfordeling());
+     * }
+     * }
+ */ + void register(MapperFactory factory); +} diff --git a/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/mapper/OppdragRequestMappingStrategy.java b/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/mapper/OppdragRequestMappingStrategy.java new file mode 100644 index 00000000000..f03eff9b29a --- /dev/null +++ b/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/mapper/OppdragRequestMappingStrategy.java @@ -0,0 +1,43 @@ +package no.nav.testnav.oppdragservice.mapper; + +import ma.glasnost.orika.CustomMapper; +import ma.glasnost.orika.MapperFactory; +import ma.glasnost.orika.MappingContext; +import no.nav.testnav.libs.dto.oppdragservice.v1.OppdragRequest; +import no.nav.testnav.oppdragservice.wsdl.Oppdrag; +import no.nav.testnav.oppdragservice.wsdl.SendInnOppdragRequest; +import no.nav.testnav.oppdragservice.wsdl.SendInnOppdragRequest2; +import org.springframework.stereotype.Component; + +@Component +public class OppdragRequestMappingStrategy implements MappingStrategy{ + + @Override + public void register(MapperFactory factory) { + + factory.classMap(OppdragRequest.class, SendInnOppdragRequest.class) + .customize(new CustomMapper<>() { + @Override + public void mapAtoB(OppdragRequest source, + SendInnOppdragRequest destination, + MappingContext context) { + + destination.setRequest(mapperFacade.map(source, SendInnOppdragRequest2.class, context)); + } + }) + .register(); + + factory.classMap(OppdragRequest.class, Oppdrag.class) + .customize(new CustomMapper<>() { + @Override + public void mapAtoB(OppdragRequest source, + Oppdrag destination, + MappingContext context) { + + + } + }) + .byDefault() + .register(); + } +} diff --git a/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/provider/OppdragController.java b/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/provider/OppdragController.java index c99046120b8..4a7697437fd 100644 --- a/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/provider/OppdragController.java +++ b/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/provider/OppdragController.java @@ -1,10 +1,12 @@ package no.nav.testnav.oppdragservice.provider; +import io.swagger.v3.oas.annotations.Operation; import lombok.RequiredArgsConstructor; import no.nav.testnav.libs.dto.oppdragservice.v1.OppdragRequest; import no.nav.testnav.oppdragservice.service.OppdragService; import no.nav.testnav.oppdragservice.wsdl.SendInnOppdragResponse; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -16,7 +18,8 @@ public class OppdragController { private final OppdragService oppdragService; @PostMapping - public SendInnOppdragResponse sendInnOppdrag(OppdragRequest oppdragRequest) { + @Operation(summary = "Send inn oppdrag") + public SendInnOppdragResponse sendInnOppdrag(@RequestBody OppdragRequest oppdragRequest) { return oppdragService.sendInnOppdrag(oppdragRequest); } diff --git a/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/service/OppdragService.java b/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/service/OppdragService.java index 0991380b21a..109fba28866 100644 --- a/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/service/OppdragService.java +++ b/apps/oppdrag-service/src/main/java/no/nav/testnav/oppdragservice/service/OppdragService.java @@ -1,14 +1,46 @@ package no.nav.testnav.oppdragservice.service; +import jakarta.xml.bind.JAXBContext; +import jakarta.xml.bind.JAXBException; +import lombok.SneakyThrows; +import ma.glasnost.orika.MapperFacade; import no.nav.testnav.libs.dto.oppdragservice.v1.OppdragRequest; +import no.nav.testnav.oppdragservice.consumer.OppdragConsumer; +import no.nav.testnav.oppdragservice.wsdl.SendInnOppdragRequest; import no.nav.testnav.oppdragservice.wsdl.SendInnOppdragResponse; import org.springframework.stereotype.Service; +import java.io.StringWriter; + @Service public class OppdragService { + private final JAXBContext jaxbContext; + private final OppdragConsumer oppdragConsumer; + private final MapperFacade mapperFacade; + + public OppdragService(OppdragConsumer oppdragConsumer, MapperFacade mapperFacade) throws JAXBException { + this.oppdragConsumer = oppdragConsumer; + this.mapperFacade = mapperFacade; + this.jaxbContext = JAXBContext.newInstance(SendInnOppdragRequest.class); + } + public SendInnOppdragResponse sendInnOppdrag(OppdragRequest oppdragRequest) { + var request = mapperFacade.map(oppdragRequest, SendInnOppdragRequest.class); + var xmlRequest = marshallToXml(request); + + oppdragConsumer.sendOppdrag(xmlRequest); + return null; + } + + @SneakyThrows + private String marshallToXml(SendInnOppdragRequest melding) { + + var marshaller = jaxbContext.createMarshaller(); + var writer = new StringWriter(); + marshaller.marshal(melding, writer); + return writer.toString(); } -} +} \ No newline at end of file diff --git a/apps/oppdrag-service/src/test/java/no/nav/testnav/oppdragservice/mapper/MapperTestUtils.java b/apps/oppdrag-service/src/test/java/no/nav/testnav/oppdragservice/mapper/MapperTestUtils.java new file mode 100644 index 00000000000..75c1e65a947 --- /dev/null +++ b/apps/oppdrag-service/src/test/java/no/nav/testnav/oppdragservice/mapper/MapperTestUtils.java @@ -0,0 +1,27 @@ +package no.nav.testnav.oppdragservice.mapper; + +import ma.glasnost.orika.CustomConverter; +import ma.glasnost.orika.MapperFacade; +import ma.glasnost.orika.impl.DefaultMapperFactory; + +import static java.util.Objects.nonNull; + +public class MapperTestUtils { + + public static MapperFacade createMapperFacadeForMappingStrategy(MappingStrategy... strategies) { + return createMapperFacadeForMappingStrategy(null, strategies); + } + + public static MapperFacade createMapperFacadeForMappingStrategy(CustomConverter converter, MappingStrategy... strategies) { + DefaultMapperFactory mapperFactory = new DefaultMapperFactory.Builder().build(); + + for (MappingStrategy strategy : strategies) { + strategy.register(mapperFactory); + } + + if (nonNull(converter)) { + mapperFactory.getConverterFactory().registerConverter(converter); + } + return mapperFactory.getMapperFacade(); + } +} \ No newline at end of file diff --git a/apps/oppdrag-service/src/test/java/no/nav/testnav/oppdragservice/mapper/OppdragRequestMappingStrategyTest.java b/apps/oppdrag-service/src/test/java/no/nav/testnav/oppdragservice/mapper/OppdragRequestMappingStrategyTest.java new file mode 100644 index 00000000000..d96c6b711b5 --- /dev/null +++ b/apps/oppdrag-service/src/test/java/no/nav/testnav/oppdragservice/mapper/OppdragRequestMappingStrategyTest.java @@ -0,0 +1,52 @@ +package no.nav.testnav.oppdragservice.mapper; + +import ma.glasnost.orika.MapperFacade; +import no.nav.testnav.libs.dto.oppdragservice.v1.OppdragRequest; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.util.List; + +@ExtendWith(MockitoExtension.class) +class OppdragRequestMappingStrategyTest { + + private MapperFacade mapperFacade; + + @BeforeEach + void setup() { + mapperFacade = MapperTestUtils.createMapperFacadeForMappingStrategy(new OppdragRequestMappingStrategy()); + } + + @Test + void mapOrdreOK() { + +// mapperFacade.map() + } + + private static OppdragRequest buildOppdragRequest() { + + return OppdragRequest.builder() + .bilagstype(List.of(OppdragRequest.Bilagstype.builder().typeBilag("12").build())) +// .avstemmingsnokkel() +// .ompostering() +// .oppdragslinje() +// .kodeEndring() +// .kodeStatus() +// .datoStatusFom() +// .kodeFagomraade() +// .fagsystemId() +// .oppdragsId() +// .utbetFrekvens() +// .datoForfall() +// .stonadId() +// .oppdragGjelderId() +// .datoOppdragGjelderFom() +// .saksbehId() +// .enhet() +// .belopsgrense() +// .tekst() + .build(); + } +} \ No newline at end of file diff --git a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/oppdragservice/v1/OppdragRequest.java b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/oppdragservice/v1/OppdragRequest.java index 09a973c7f3d..52afa4e35f4 100644 --- a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/oppdragservice/v1/OppdragRequest.java +++ b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/oppdragservice/v1/OppdragRequest.java @@ -11,6 +11,7 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -20,37 +21,43 @@ @Builder @NoArgsConstructor @AllArgsConstructor +@Schema(description = "Entitet Oppdrag, Referanse ID 110") public class OppdragRequest { - @Size(min = 1, max = 4) - private List bilagstype; + private List bilagstype; private List avstemmingsnokkel; private Ompostering ompostering; private List oppdragslinje; + @NotBlank private KodeEndring kodeEndring; private KodeStatus kodeStatus; private String datoStatusFom; @NotBlank + @Schema(minLength = 1, maxLength = 8) private String kodeFagomraade; + @Schema(maxLength = 30) private String fagsystemId; + @Schema(maxLength = 10) private Long oppdragsId; - private String utbetFrekvens; - private String datoForfall; + private UtbetalingFrekvensType utbetFrekvens; + private LocalDate datoForfall; + @Schema(maxLength = 10) private String stonadId; @NotBlank - @Size(min = 9, max = 11) - @Schema(description = "Fødselsnummer eller organisasjonsnummer oppdraget gjelder for") + @Schema(description = "Angir fødselsnummer eller organisasjonsnummer oppdraget gjelder for", minLength = 9, maxLength = 11) private String oppdragGjelderId; @NotBlank - private String datoOppdragGjelderFom; + private LocalDate datoOppdragGjelderFom; @NotBlank + @Schema(maxLength = 8) private String saksbehId; + private List enhet; private List belopsgrense; private List tekst; - public List getBilagstype() { + public List getBilagstype() { if (isNull(bilagstype)) { bilagstype = new ArrayList<>(); @@ -102,29 +109,46 @@ public List getTekst() { @Builder @NoArgsConstructor @AllArgsConstructor + @Schema(description = "Bilagstype, Referanse ID 113") + public static class Bilagstype { + + @Schema(description = "Kode for type av bilag", minLength = 1, maxLength = 2) + private String typeBilag; + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + @Schema(description = "Entitet nøkler til bevis informasjon, Referanse ID 115") public static class Avstemmingsnokkel { @NotBlank + @Schema(minLength = 1, maxLength = 8) private String kodeKomponent; @NotBlank + @Schema(minLength = 1, maxLength = 8) private String avstemmingsNokkel; @NotBlank - private String tidspktReg; + private LocalDateTime tidspktReg; } @Data @Builder @NoArgsConstructor @AllArgsConstructor + @Schema(description = "Ompostering, Referanse ID 116") public static class Ompostering { @NotBlank - private String omPostering; - private String datoOmposterFom; + private JaNei omPostering; + private LocalDate datoOmposterFom; + @Schema(description = "Kode for beskrivelse av feil", minLength = 0, maxLength = 1) private String feilreg; @NotBlank - private String tidspktReg; + private LocalDateTime tidspktReg; @NotBlank + @Schema(maxLength = 8) private String saksbehId; } @@ -132,55 +156,73 @@ public static class Ompostering { @Builder @NoArgsConstructor @AllArgsConstructor + @Schema(description = "Oppdragslinje, Referanse ID 115") public static class Oppdragslinje { - private RefusjonsInfo refusjonsInfo; - private List tekst; - @Schema(description = "Fra XSD: Referanse ID 120 dersom enhet på nivå oppdrag og " + - "Referanse ID 160 dersom enhet på nivå oppdragslinje") - private List enhet; - private List grad; - private List attestant; - private List valuta; @NotBlank - private String kodeEndringLinje; + private KodeEndringType kodeEndringLinje; private KodeStatusLinje kodeStatusLinje; private LocalDate datoStatusFom; + @Schema(maxLength = 10) private String vedtakId; + @Schema(maxLength = 30) private String delytelseId; - private BigInteger linjeId; + @Schema(maxLength = 5) + private Integer linjeId; @NotBlank + @Schema(minLength = 1, maxLength = 50) private String kodeKlassifik; - private String datoKlassifikFom; + private LocalDate datoKlassifikFom; @NotBlank private LocalDate datoVedtakFom; private LocalDate datoVedtakTom; @NotBlank + @Schema(description = "maximal toal lengde = 13, antall desimaler = 2") private BigDecimal sats; @NotBlank private FradragTillegg fradragTillegg; @NotBlank - private String typeSats; + private SatsType typeSats; + @Schema(description = "Angir fødselsnummer eller organisasjonsnummer på skyldneren", minLength = 9, maxLength = 11) private String skyldnerId; private LocalDate datoSkyldnerFom; + @Schema(description = "Angir fødselsnummer eller organisasjonsnummer på kravhaver", minLength = 9, maxLength = 11) private String kravhaverId; private LocalDate datoKravhaverFom; + @Schema(maxLength = 26) private String kid; private LocalDate datoKidFom; + @Schema(maxLength = 1) private String brukKjoreplan; @NotBlank + @Schema(maxLength = 8) private String saksbehId; @NotBlank + @Schema(description = "Angir fødselsnummer eller organisasjonsnummer på kravhaver", minLength = 9, maxLength = 11) private String utbetalesTilId; private LocalDate datoUtbetalesTilIdFom; @NotBlank private KodeArbeidsgiver kodeArbeidsgiver; + @Schema(maxLength = 30) private String henvisning; + @Schema(maxLength = 10) private String typeSoknad; + @Schema(maxLength = 30) private String refFagsystemId; + @Schema(maxLength = 10) private Long refOppdragsId; + @Schema(maxLength = 30) private String refDelytelseId; - private BigInteger refLinjeId; + @Schema(maxLength = 5) + private Integer refLinjeId; + private RefusjonsInfo refusjonsInfo; + private List tekst; + @Schema(description = "Fra XSD: Referanse ID 120 dersom enhet på nivå oppdrag og " + + "Referanse ID 160 dersom enhet på nivå oppdragslinje") + private List enhet; + private List grad; + private List attestant; + private List valuta; public List getTekst() { @@ -303,6 +345,11 @@ public static class Valuta { protected String feilreg; } + public enum JaNei { + J, + N; + } + public enum KodeStatusLinje { OPPH, HVIL, @@ -342,6 +389,31 @@ public enum KodeEndring { UEND } + public enum KodeEndringType { + NY, + ENDR + } + + public enum SatsType { + + DAG, + UKE, + _14DB, + MND, + AAR, + ENG, + AKTO + } + + public enum UtbetalingFrekvensType { + + DAG, + UKE, + MND, + _14DG, + ENG + } + @Data @Builder @NoArgsConstructor