Skip to content

Commit

Permalink
Refactor service name and change access modifier #deploy-oppsummering…
Browse files Browse the repository at this point in the history
…sdokument-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.
  • Loading branch information
krharum committed Feb 23, 2024
1 parent b67bb36 commit df6658f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> getAllOpplysningspliktig(
Expand All @@ -34,7 +35,7 @@ public ResponseEntity<String> 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)
Expand All @@ -59,7 +60,7 @@ public ResponseEntity<String> getAllOpplysningspliktig(
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_XML_VALUE)
public ResponseEntity<String> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {

Expand Down Expand Up @@ -129,7 +120,7 @@ public List<Oppsummeringsdokument> 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());
Expand Down

0 comments on commit df6658f

Please sign in to comment.