From df6658f6f3f111c122c0bea6533a67dfece3895e Mon Sep 17 00:00:00 2001 From: kristenhaerum Date: Fri, 23 Feb 2024 13:39:11 +0100 Subject: [PATCH] Refactor service name and change access modifier #deploy-oppsummeringsdokument-service Renamed 'adapter' to 'oppsummeringsdokumentService' to boost code clarity and avoid confusion. Also, the access modifier of the method 'getAllCurrentDocumentsBy' was changed to public in the 'OppsummeringsdokumentService' class. --- .../OppsummeringsdokumentetRawController.java | 7 ++++--- .../service/OppsummeringsdokumentService.java | 11 +---------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/apps/oppsummeringsdokument-service/src/main/java/no/nav/testnav/apps/oppsummeringsdokumentservice/controller/OppsummeringsdokumentetRawController.java b/apps/oppsummeringsdokument-service/src/main/java/no/nav/testnav/apps/oppsummeringsdokumentservice/controller/OppsummeringsdokumentetRawController.java index 3ceb9d391cb..b15caa1ecb7 100644 --- a/apps/oppsummeringsdokument-service/src/main/java/no/nav/testnav/apps/oppsummeringsdokumentservice/controller/OppsummeringsdokumentetRawController.java +++ b/apps/oppsummeringsdokument-service/src/main/java/no/nav/testnav/apps/oppsummeringsdokumentservice/controller/OppsummeringsdokumentetRawController.java @@ -23,7 +23,8 @@ public class OppsummeringsdokumentetRawController { private static final String NUMBER_OF_ELEMENTS_HEADER = "Number-Of-Elements"; private static final String ELEMENT_ID_HEADER = "Element-Id"; - private final OppsummeringsdokumentService adapter; + private final OppsummeringsdokumentService oppsummeringsdokumentService + ; @GetMapping(produces = MediaType.APPLICATION_XML_VALUE) public ResponseEntity getAllOpplysningspliktig( @@ -34,7 +35,7 @@ public ResponseEntity getAllOpplysningspliktig( @RequestParam(value = "fom", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fom, @RequestParam(value = "tom", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate tom) { - var response = adapter.getAllCurrentDocumentsBy(QueryRequest.builder() + var response = oppsummeringsdokumentService.getAllCurrentDocumentsBy(QueryRequest.builder() .miljo(miljo) .fom(fom) .tom(tom) @@ -59,7 +60,7 @@ public ResponseEntity getAllOpplysningspliktig( @GetMapping(value = "/{id}", produces = MediaType.APPLICATION_XML_VALUE) public ResponseEntity getItem(@PathVariable("id") String id) { - var document = adapter.getCurrentDocumentsBy(id); + var document = oppsummeringsdokumentService.getCurrentDocumentsBy(id); return document.map(value -> ResponseEntity.ok().body(value.toXml())) .orElseGet(() -> ResponseEntity.notFound().build()); diff --git a/apps/oppsummeringsdokument-service/src/main/java/no/nav/testnav/apps/oppsummeringsdokumentservice/service/OppsummeringsdokumentService.java b/apps/oppsummeringsdokument-service/src/main/java/no/nav/testnav/apps/oppsummeringsdokumentservice/service/OppsummeringsdokumentService.java index 4a17b587a81..182fe14585e 100644 --- a/apps/oppsummeringsdokument-service/src/main/java/no/nav/testnav/apps/oppsummeringsdokumentservice/service/OppsummeringsdokumentService.java +++ b/apps/oppsummeringsdokument-service/src/main/java/no/nav/testnav/apps/oppsummeringsdokumentservice/service/OppsummeringsdokumentService.java @@ -11,7 +11,6 @@ import no.nav.testnav.apps.oppsummeringsdokumentservice.domain.QueryResponse; import no.nav.testnav.apps.oppsummeringsdokumentservice.repository.OppsummeringsdokumentRepository; import no.nav.testnav.apps.oppsummeringsdokumentservice.repository.model.OppsummeringsdokumentModel; -import no.nav.testnav.libs.dto.oppsummeringsdokumentservice.v2.Populasjon; import org.opensearch.action.search.SearchRequest; import org.opensearch.action.search.SearchResponse; import org.opensearch.client.RequestOptions; @@ -50,14 +49,6 @@ public class OppsummeringsdokumentService { @Value("${open.search.index}") private String DOCUMENT_INDEX; - public void deleteAllBy(String miljo, Populasjon populasjon) { - repository.deleteAllByMiljoAndPopulasjon(miljo, populasjon); - } - - public void deleteAllBy(String miljo) { - repository.deleteAllByMiljo(miljo); - } - @SneakyThrows public String save(Oppsummeringsdokument oppsummeringsdokument, String miljo, String origin) { @@ -129,7 +120,7 @@ public List getAllCurrentDocumentsBy(String miljo, String .getDokumenter(); } - private QueryResponse getAllCurrentDocumentsBy(QueryRequest request) { + public QueryResponse getAllCurrentDocumentsBy(QueryRequest request) { var query = prepareQuery(request); var response = execQuery(query, request.getPage(), request.getPageSize());