Skip to content

Commit

Permalink
convert to new library version
Browse files Browse the repository at this point in the history
  • Loading branch information
hknots committed Oct 3, 2024
1 parent 2b26d29 commit b356559
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 28 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ dependencies {

implementation 'io.netty:netty-resolver-dns-native-macos:4.1.86.Final:osx-aarch_64'

implementation 'no.fintlabs:fint-core-infra-models:1.1.2'
implementation 'no.fintlabs:fint-core-adapter-common:0.1.3-rc-1'
implementation 'no.fintlabs:fint-core-infra-models:2.0.0-rc-9'
implementation 'no.fintlabs:fint-core-adapter-common:0.1.6-rc-2'
implementation "no.fint:fint-personvern-resource-model-java:${apiVersion}"
implementation "no.fint:fint-felles-resource-model-java:${apiVersion}"
implementation 'no.fint:fint-event-model:3.0.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import lombok.extern.slf4j.Slf4j;
import no.fint.model.resource.personvern.kodeverk.BehandlingsgrunnlagResource;
import no.fintlabs.adapter.events.WriteableResourceRepository;
import no.fintlabs.adapter.models.RequestFintEvent;
import no.fintlabs.adapter.models.event.RequestFintEvent;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import no.fintlabs.adapter.config.AdapterProperties;
import no.fintlabs.adapter.datasync.ResourceSubscriber;
import no.fintlabs.adapter.models.AdapterCapability;
import no.fintlabs.adapter.models.SyncPageEntry;
import no.fintlabs.adapter.models.sync.SyncPageEntry;
import no.fintlabs.adapter.validator.ValidatorService;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
Expand All @@ -14,18 +14,17 @@
@Service
public class BehandlingsgrunnlagSubscriber extends ResourceSubscriber<BehandlingsgrunnlagResource, BehandlingsgrunnlagPublisher> {

protected BehandlingsgrunnlagSubscriber(WebClient webClient, AdapterProperties props, BehandlingsgrunnlagPublisher publisher, ValidatorService<BehandlingsgrunnlagResource> validatorService) {
protected BehandlingsgrunnlagSubscriber(WebClient webClient, AdapterProperties props, BehandlingsgrunnlagPublisher publisher, ValidatorService validatorService) {
super(webClient, props, publisher, validatorService);
}

@Override
protected AdapterCapability getCapability() {

return adapterProperties.getCapabilities().get("behandlingsgrunnlag");
}

@Override
protected SyncPageEntry<BehandlingsgrunnlagResource> createSyncPageEntry(BehandlingsgrunnlagResource resource) {
protected SyncPageEntry createSyncPageEntry(BehandlingsgrunnlagResource resource) {
String identificationValue = resource.getSystemId().getIdentifikatorverdi();
return SyncPageEntry.of(identificationValue, resource);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
package no.fintlabs.model.personopplysning;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import no.fint.model.resource.personvern.kodeverk.PersonopplysningResource;
import no.fintlabs.adapter.events.WriteableResourceRepository;
import no.fintlabs.adapter.models.RequestFintEvent;
import no.fintlabs.adapter.models.event.RequestFintEvent;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Repository
@RequiredArgsConstructor
public class PersonopplysningRepository implements WriteableResourceRepository<PersonopplysningResource> {

private PersonopplysningJpaRepository personopplysningJpaRepository;

private PersonopplysningMappingService personopplysningMappingService;

public PersonopplysningRepository(PersonopplysningJpaRepository personopplysningJpaRepository, PersonopplysningMappingService personopplysningMappingService) {
this.personopplysningJpaRepository = personopplysningJpaRepository;
this.personopplysningMappingService = personopplysningMappingService;
}
private final PersonopplysningJpaRepository personopplysningJpaRepository;
private final PersonopplysningMappingService personopplysningMappingService;

@Override
public List<PersonopplysningResource> getResources() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import no.fintlabs.adapter.config.AdapterProperties;
import no.fintlabs.adapter.datasync.ResourceSubscriber;
import no.fintlabs.adapter.models.AdapterCapability;
import no.fintlabs.adapter.models.SyncPageEntry;
import no.fintlabs.adapter.models.sync.SyncPageEntry;
import no.fintlabs.adapter.validator.ValidatorService;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
Expand All @@ -15,7 +15,7 @@
public class PersonopplysningSubscriber extends ResourceSubscriber<PersonopplysningResource, PersonopplysningPublisher> {


protected PersonopplysningSubscriber(WebClient webClient, AdapterProperties props, PersonopplysningPublisher publisher, ValidatorService<PersonopplysningResource> validatorService) {
protected PersonopplysningSubscriber(WebClient webClient, AdapterProperties props, PersonopplysningPublisher publisher, ValidatorService validatorService) {
super(webClient, props, publisher, validatorService);
}

Expand All @@ -25,7 +25,7 @@ protected AdapterCapability getCapability() {
}

@Override
protected SyncPageEntry<PersonopplysningResource> createSyncPageEntry(PersonopplysningResource resource) {
protected SyncPageEntry createSyncPageEntry(PersonopplysningResource resource) {
String identificationValue = resource.getSystemId().getIdentifikatorverdi();
return SyncPageEntry.of(identificationValue, resource);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import no.fint.model.resource.personvern.kodeverk.PersonopplysningResource;
import no.fintlabs.adapter.config.AdapterProperties;
import no.fintlabs.adapter.events.EventPublisher;
import no.fintlabs.adapter.models.OperationType;
import no.fintlabs.adapter.models.RequestFintEvent;
import no.fintlabs.adapter.models.ResponseFintEvent;
import no.fintlabs.adapter.models.SyncPageEntry;
import no.fintlabs.adapter.models.event.RequestFintEvent;
import no.fintlabs.adapter.models.event.ResponseFintEvent;
import no.fintlabs.adapter.models.sync.SyncPageEntry;
import no.fintlabs.adapter.operation.OperationType;
import no.fintlabs.model.personopplysning.PersonopplysningJpaRepository;
import no.fintlabs.model.personopplysning.PersonopplysningRepository;
import no.fintlabs.model.personopplysning.PersonopplysningResourceValidator;
Expand All @@ -21,10 +21,12 @@
public class PersonopplysningEventPublisher extends EventPublisher<PersonopplysningResource> {

private final PersonopplysningResourceValidator personopplysningResourceValidator;
private final ObjectMapper objectMapper;

protected PersonopplysningEventPublisher(WebClient webClient, AdapterProperties adapterProperties, PersonopplysningRepository repository, ObjectMapper objectMapper, PersonopplysningResourceValidator personopplysningResourceValidator, PersonopplysningJpaRepository personopplysningJpaRepository) {
super("personopplysning", PersonopplysningResource.class, webClient, adapterProperties, repository, objectMapper);
this.personopplysningResourceValidator = personopplysningResourceValidator;
this.objectMapper = objectMapper;
}

@Override
Expand All @@ -35,11 +37,11 @@ public void doCheckForNewEvents() {

@Override
protected void handleEvent(RequestFintEvent requestFintEvent, PersonopplysningResource personopplysningResource) {
ResponseFintEvent<PersonopplysningResource> response = createResponse(requestFintEvent);
ResponseFintEvent response = createResponse(requestFintEvent);
response.setOperationType(OperationType.CREATE);
response.setValue(createSyncpageEntry(personopplysningResource));
if (personopplysningResourceValidator.isResourceValid(personopplysningResource)) {
PersonopplysningResource savedResource = repository.saveResources(response.getValue().getResource(), requestFintEvent);
PersonopplysningResource savedResource = repository.saveResources(objectMapper.convertValue(response.getValue().getResource(), PersonopplysningResource.class), requestFintEvent);
response.setValue(createSyncpageEntry(savedResource));
submit(response);
} else {
Expand All @@ -50,7 +52,7 @@ protected void handleEvent(RequestFintEvent requestFintEvent, PersonopplysningRe
log.info(response.getCorrId());
}

private SyncPageEntry<PersonopplysningResource> createSyncpageEntry(PersonopplysningResource savedResource) {
private SyncPageEntry createSyncpageEntry(PersonopplysningResource savedResource) {
return SyncPageEntry.of(savedResource.getSystemId().getIdentifikatorverdi(), savedResource);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import no.fint.model.resource.personvern.kodeverk.PersonopplysningResource;
import no.fintlabs.adapter.config.AdapterProperties;
import no.fintlabs.adapter.events.EventSubscriber;
import no.fintlabs.adapter.models.ResponseFintEvent;
import no.fintlabs.adapter.models.event.ResponseFintEvent;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
Expand All @@ -19,7 +19,7 @@ protected PersonopplysningEventSubscriber(WebClient webClient, AdapterProperties
}

@Override
protected void responsePostingEvent(ResponseEntity<Void> responseEntity, ResponseFintEvent<PersonopplysningResource> responseFintEvent) {
protected void responsePostingEvent(ResponseEntity<Void> responseEntity, ResponseFintEvent responseFintEvent) {
log.info("Posting response for event: {} status code: {} ", responseFintEvent.getCorrId(), responseEntity.getStatusCode());
}
}

0 comments on commit b356559

Please sign in to comment.