Skip to content

Commit

Permalink
refactor: Remove unused custom mapper using MapStruct one (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
manuraf authored Sep 18, 2024
1 parent 83e588a commit f9a2d80
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 2,232 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
package it.pagopa.selfcare.mscore.model.onboarding;

import it.pagopa.selfcare.onboarding.common.InstitutionType;
import it.pagopa.selfcare.mscore.constant.TokenType;
import it.pagopa.selfcare.mscore.exception.InvalidRequestException;
import it.pagopa.selfcare.mscore.model.institution.Billing;
import it.pagopa.selfcare.mscore.model.institution.InstitutionUpdate;
import it.pagopa.selfcare.mscore.model.user.UserToOnboard;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.time.OffsetDateTime;
import java.util.List;

import static it.pagopa.selfcare.mscore.constant.GenericError.CONTRACT_PATH_ERROR;

@Data
public class OnboardingRequest {

Expand All @@ -33,12 +28,4 @@ public class OnboardingRequest {
private OffsetDateTime contractActivatedAt;
private Boolean sendCompleteOnboardingEmail;

public Contract getContract() {
if ((institutionUpdate != null && InstitutionType.PG == institutionUpdate.getInstitutionType())
|| (contract != null && StringUtils.hasText(contract.getPath()))) {
return contract;
} else {
throw new InvalidRequestException(CONTRACT_PATH_ERROR.getMessage(), CONTRACT_PATH_ERROR.getCode());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public ResponseEntity<InstitutionResponse> createInstitutionFromIpa(@RequestBody
@PostMapping(value = "/from-anac", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<InstitutionResponse> createInstitutionFromAnac(@RequestBody @Valid InstitutionRequest institution) {
CustomExceptionMessage.setCustomMessage(GenericError.CREATE_INSTITUTION_ERROR);
Institution saved = institutionService.createInstitutionFromAnac(InstitutionMapperCustom.toInstitution(institution, null));
Institution saved = institutionService.createInstitutionFromAnac(institutionResourceMapper.toInstitution(institution));
return ResponseEntity.status(HttpStatus.CREATED).body(institutionResourceMapper.toInstitutionResponse(saved));
}

Expand All @@ -163,7 +163,7 @@ public ResponseEntity<InstitutionResponse> createInstitutionFromAnac(@RequestBod
@PostMapping(value = "/from-ivass", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<InstitutionResponse> createInstitutionFromIvass(@RequestBody @Valid InstitutionRequest institution) {
CustomExceptionMessage.setCustomMessage(GenericError.CREATE_INSTITUTION_ERROR);
Institution saved = institutionService.createInstitutionFromIvass(InstitutionMapperCustom.toInstitution(institution, null));
Institution saved = institutionService.createInstitutionFromIvass(institutionResourceMapper.toInstitution(institution));
return ResponseEntity.status(HttpStatus.CREATED).body(institutionResourceMapper.toInstitutionResponse(saved));
}

Expand All @@ -183,7 +183,7 @@ public ResponseEntity<InstitutionResponse> createInstitutionFromIvass(@RequestBo
public ResponseEntity<InstitutionResponse> createInstitutionFromPda(@RequestBody @Valid PdaInstitutionRequest institutionRequest) {
CustomExceptionMessage.setCustomMessage(GenericError.CREATE_INSTITUTION_ERROR);

Institution saved = institutionService.createInstitutionFromPda(InstitutionMapperCustom.toInstitution(institutionRequest, null), institutionRequest.getInjectionInstitutionType());
Institution saved = institutionService.createInstitutionFromPda(institutionResourceMapper.toInstitution(institutionRequest), institutionRequest.getInjectionInstitutionType());
return ResponseEntity.status(HttpStatus.CREATED).body(institutionResourceMapper.toInstitutionResponse(saved));
}

Expand All @@ -203,7 +203,7 @@ public ResponseEntity<InstitutionResponse> createInstitutionFromPda(@RequestBody
public ResponseEntity<InstitutionResponse> createInstitutionFromInfocamere(@RequestBody @Valid InstitutionRequest institutionRequest) {
CustomExceptionMessage.setCustomMessage(GenericError.CREATE_INSTITUTION_ERROR);

Institution saved = institutionService.createInstitutionFromInfocamere(InstitutionMapperCustom.toInstitution(institutionRequest, null));
Institution saved = institutionService.createInstitutionFromInfocamere(institutionResourceMapper.toInstitution(institutionRequest));
return ResponseEntity.status(HttpStatus.CREATED).body(institutionResourceMapper.toInstitutionResponse(saved));
}

Expand Down Expand Up @@ -243,7 +243,7 @@ public ResponseEntity<InstitutionResponse> createInstitutionByExternalId(@ApiPar
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<InstitutionResponse> createInstitution(@RequestBody @Valid InstitutionRequest institution) {
CustomExceptionMessage.setCustomMessage(GenericError.CREATE_INSTITUTION_ERROR);
Institution saved = institutionService.createInstitution(InstitutionMapperCustom.toInstitution(institution, null));
Institution saved = institutionService.createInstitution(institutionResourceMapper.toInstitution(institution));
return ResponseEntity.status(HttpStatus.CREATED).body(institutionResourceMapper.toInstitutionResponse(saved));
}

Expand All @@ -265,7 +265,7 @@ public ResponseEntity<InstitutionResponse> createInstitutionRaw(@ApiParam("${swa
@PathVariable("externalId") String externalId,
@RequestBody @Valid InstitutionRequest institution) {
CustomExceptionMessage.setCustomMessage(GenericError.CREATE_INSTITUTION_ERROR);
Institution saved = institutionService.createInstitution(InstitutionMapperCustom.toInstitution(institution, null));
Institution saved = institutionService.createInstitution(institutionResourceMapper.toInstitution(institution));
return ResponseEntity.ok(institutionResourceMapper.toInstitutionResponse(saved));
}

Expand Down Expand Up @@ -333,7 +333,7 @@ public ResponseEntity<InstitutionResponse> updateInstitution(@ApiParam("${swagge

CustomExceptionMessage.setCustomMessage(GenericError.PUT_INSTITUTION_ERROR);
SelfCareUser selfCareUser = (SelfCareUser) authentication.getPrincipal();
Institution saved = institutionService.updateInstitution(institutionId, InstitutionMapperCustom.toInstitutionUpdate(institutionPut), selfCareUser.getId());
Institution saved = institutionService.updateInstitution(institutionId, institutionResourceMapper.toInstitutionUpdate(institutionPut), selfCareUser.getId());
return ResponseEntity.ok().body(institutionResourceMapper.toInstitutionResponse(saved));
}

Expand Down
Loading

0 comments on commit f9a2d80

Please sign in to comment.