diff --git a/openapi/p4pa-pu-bff.openapi.yaml b/openapi/p4pa-pu-bff.openapi.yaml index 7f827a5..a3a2903 100644 --- a/openapi/p4pa-pu-bff.openapi.yaml +++ b/openapi/p4pa-pu-bff.openapi.yaml @@ -86,7 +86,9 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/CollectionModelTaxonomyOrganizationTypeDTO' + type: array + items: + $ref: '#/components/schemas/TaxonomyOrganizationTypeDTO' '401': description: Unauthorized - Missing or invalid token '403': @@ -107,9 +109,11 @@ paths: '200': description: OK content: - application/hal+json: + application/json: schema: - $ref: '#/components/schemas/CollectionModelTaxonomyMacroAreaCodeDTO' + type: array + items: + $ref: '#/components/schemas/TaxonomyMacroAreaCodeDTO' '401': description: Unauthorized - Missing or invalid token '403': @@ -134,9 +138,11 @@ paths: '200': description: OK content: - application/hal+json: + application/json: schema: - $ref: '#/components/schemas/CollectionModelTaxonomyServiceTypeCodeDTO' + type: array + items: + $ref: '#/components/schemas/TaxonomyServiceTypeCodeDTO' '401': description: Unauthorized - Missing or invalid token '403': @@ -165,9 +171,11 @@ paths: '200': description: OK content: - application/hal+json: + application/json: schema: - $ref: '#/components/schemas/CollectionModelTaxonomyCollectionReasonDTO' + type: array + items: + $ref: '#/components/schemas/TaxonomyCollectionReasonDTO' '401': description: Unauthorized - Missing or invalid token '403': @@ -200,9 +208,11 @@ paths: '200': description: OK content: - application/hal+json: + application/json: schema: - $ref: '#/components/schemas/CollectionModelTaxonomyCodeDTO' + type: array + items: + $ref: '#/components/schemas/TaxonomyCodeDTO' security: - bearerAuth: [ ] components: @@ -212,10 +222,6 @@ components: scheme: bearer bearerFormat: JWT schemas: - CollectionModelTaxonomyCodeDTO: - type: array - items: - $ref: '#/components/schemas/TaxonomyCodeDTO' TaxonomyCodeDTO: type: object properties: @@ -239,10 +245,6 @@ components: type: string taxonomyCode: type: string - CollectionModelTaxonomyCollectionReasonDTO: - type: array - items: - $ref: '#/components/schemas/TaxonomyCollectionReasonDTO' TaxonomyCollectionReasonDTO: type: object properties: @@ -264,10 +266,6 @@ components: type: string collectionReason: type: string - CollectionModelTaxonomyServiceTypeCodeDTO: - type: array - items: - $ref: '#/components/schemas/TaxonomyServiceTypeCodeDTO' TaxonomyServiceTypeCodeDTO: type: object properties: @@ -287,10 +285,6 @@ components: type: string serviceTypeDescription: type: string - CollectionModelTaxonomyMacroAreaCodeDTO: - type: array - items: - $ref: '#/components/schemas/TaxonomyMacroAreaCodeDTO' TaxonomyMacroAreaCodeDTO: type: object properties: @@ -304,10 +298,6 @@ components: type: string macroAreaDescription: type: string - CollectionModelTaxonomyOrganizationTypeDTO: - type: array - items: - $ref: '#/components/schemas/TaxonomyOrganizationTypeDTO' TaxonomyOrganizationTypeDTO: type: object properties: diff --git a/src/main/java/it/gov/pagopa/pu/bff/exception/GlobalExceptionHandler.java b/src/main/java/it/gov/pagopa/pu/bff/exception/GlobalExceptionHandler.java index ebf1060..7c71620 100644 --- a/src/main/java/it/gov/pagopa/pu/bff/exception/GlobalExceptionHandler.java +++ b/src/main/java/it/gov/pagopa/pu/bff/exception/GlobalExceptionHandler.java @@ -14,10 +14,5 @@ public ResponseEntity handleInvalidOperatorRoleException(InvalidOperat return new ResponseEntity<>(errorDTO, HttpStatus.INTERNAL_SERVER_ERROR); } - @ExceptionHandler(UnparsableEntityException.class) - public ResponseEntity handleUnparsableEntityException(UnparsableEntityException e){ - ErrorDTO errorDTO = new ErrorDTO("GENERIC_ERROR", e.getMessage()); - return new ResponseEntity<>(errorDTO, HttpStatus.INTERNAL_SERVER_ERROR); - } } diff --git a/src/main/java/it/gov/pagopa/pu/bff/exception/UnparsableEntityException.java b/src/main/java/it/gov/pagopa/pu/bff/exception/UnparsableEntityException.java deleted file mode 100644 index 50aec20..0000000 --- a/src/main/java/it/gov/pagopa/pu/bff/exception/UnparsableEntityException.java +++ /dev/null @@ -1,8 +0,0 @@ -package it.gov.pagopa.pu.bff.exception; - -public class UnparsableEntityException extends RuntimeException{ - - public UnparsableEntityException (String message){ - super(message); - } -} diff --git a/src/main/java/it/gov/pagopa/pu/bff/mapper/TaxonomyCodeMapper.java b/src/main/java/it/gov/pagopa/pu/bff/mapper/TaxonomyCodeMapper.java index 9388fe2..114af90 100644 --- a/src/main/java/it/gov/pagopa/pu/bff/mapper/TaxonomyCodeMapper.java +++ b/src/main/java/it/gov/pagopa/pu/bff/mapper/TaxonomyCodeMapper.java @@ -1,28 +1,25 @@ package it.gov.pagopa.pu.bff.mapper; import it.gov.pagopa.pu.bff.dto.generated.TaxonomyCodeDTO; -import it.gov.pagopa.pu.p4pa_organization.dto.generated.CollectionModelTaxonomyCodeDTOEmbedded; -import java.util.List; import org.springframework.stereotype.Component; @Component public class TaxonomyCodeMapper { - public List map(CollectionModelTaxonomyCodeDTOEmbedded input) { - return input.getTaxonomyCodeDTOes().stream().map(taxonomyCodeDTO -> { - TaxonomyCodeDTO element = new TaxonomyCodeDTO(); - element.setOrganizationTypeDescription(taxonomyCodeDTO.getOrganizationTypeDescription()); - element.setOrganizationType(taxonomyCodeDTO.getOrganizationType()); - element.setMacroAreaCode(taxonomyCodeDTO.getMacroAreaCode()); - element.setMacroAreaName(taxonomyCodeDTO.getMacroAreaName()); - element.setMacroAreaDescription(taxonomyCodeDTO.getMacroAreaDescription()); - element.setServiceTypeCode(taxonomyCodeDTO.getServiceTypeCode()); - element.setServiceType(taxonomyCodeDTO.getServiceType()); - element.setServiceTypeDescription(taxonomyCodeDTO.getServiceTypeDescription()); - element.setCollectionReason(taxonomyCodeDTO.getCollectionReason()); - element.setTaxonomyCode(taxonomyCodeDTO.getTaxonomyCode()); - return element; - }).toList(); + public TaxonomyCodeDTO map( + it.gov.pagopa.pu.p4pa_organization.dto.generated.TaxonomyCodeDTO input) { + TaxonomyCodeDTO dto = new TaxonomyCodeDTO(); + dto.setOrganizationTypeDescription(input.getOrganizationType()+". "+input.getOrganizationTypeDescription()); + dto.setOrganizationType(input.getOrganizationType()); + dto.setMacroAreaCode(input.getMacroAreaCode()); + dto.setMacroAreaName(input.getMacroAreaCode()+". "+input.getMacroAreaName()); + dto.setMacroAreaDescription(input.getMacroAreaDescription()); + dto.setServiceTypeCode(input.getServiceTypeCode()); + dto.setServiceType(input.getServiceTypeCode()+". "+input.getServiceType()); + dto.setServiceTypeDescription(input.getServiceTypeDescription()); + dto.setCollectionReason(input.getCollectionReason()); + dto.setTaxonomyCode(input.getTaxonomyCode()); + return dto; } } diff --git a/src/main/java/it/gov/pagopa/pu/bff/mapper/TaxonomyCollectionReasonMapper.java b/src/main/java/it/gov/pagopa/pu/bff/mapper/TaxonomyCollectionReasonMapper.java index 6c3a48a..5709fa4 100644 --- a/src/main/java/it/gov/pagopa/pu/bff/mapper/TaxonomyCollectionReasonMapper.java +++ b/src/main/java/it/gov/pagopa/pu/bff/mapper/TaxonomyCollectionReasonMapper.java @@ -1,28 +1,23 @@ package it.gov.pagopa.pu.bff.mapper; import it.gov.pagopa.pu.bff.dto.generated.TaxonomyCollectionReasonDTO; -import it.gov.pagopa.pu.p4pa_organization.dto.generated.CollectionModelTaxonomyCollectionReasonDTOEmbedded; -import java.util.List; import org.springframework.stereotype.Component; @Component public class TaxonomyCollectionReasonMapper { - public List map(CollectionModelTaxonomyCollectionReasonDTOEmbedded input) { - return input.getTaxonomyCollectionReasonDTOes().stream() - .map(taxonomyCodeDTO -> { - TaxonomyCollectionReasonDTO dto = new TaxonomyCollectionReasonDTO(); - dto.setOrganizationTypeDescription(taxonomyCodeDTO.getOrganizationTypeDescription()); - dto.setOrganizationType(taxonomyCodeDTO.getOrganizationType()); - dto.setMacroAreaCode(taxonomyCodeDTO.getMacroAreaCode()); - dto.setMacroAreaName(taxonomyCodeDTO.getMacroAreaName()); - dto.setMacroAreaDescription(taxonomyCodeDTO.getMacroAreaDescription()); - dto.setServiceTypeCode(taxonomyCodeDTO.getServiceTypeCode()); - dto.setServiceType(taxonomyCodeDTO.getServiceType()); - dto.setServiceTypeDescription(taxonomyCodeDTO.getServiceTypeDescription()); - dto.setCollectionReason(taxonomyCodeDTO.getCollectionReason()); - return dto; - }) - .toList(); + public TaxonomyCollectionReasonDTO map( + it.gov.pagopa.pu.p4pa_organization.dto.generated.TaxonomyCollectionReasonDTO input) { + TaxonomyCollectionReasonDTO dto = new TaxonomyCollectionReasonDTO(); + dto.setOrganizationTypeDescription(input.getOrganizationType()+". "+input.getOrganizationTypeDescription()); + dto.setOrganizationType(input.getOrganizationType()); + dto.setMacroAreaCode(input.getMacroAreaCode()); + dto.setMacroAreaName(input.getMacroAreaCode()+". "+input.getMacroAreaName()); + dto.setMacroAreaDescription(input.getMacroAreaDescription()); + dto.setServiceTypeCode(input.getServiceTypeCode()); + dto.setServiceType(input.getServiceTypeCode()+". "+input.getServiceType()); + dto.setServiceTypeDescription(input.getServiceTypeDescription()); + dto.setCollectionReason(input.getCollectionReason()); + return dto; } } diff --git a/src/main/java/it/gov/pagopa/pu/bff/mapper/TaxonomyMacroAreaCodeMapper.java b/src/main/java/it/gov/pagopa/pu/bff/mapper/TaxonomyMacroAreaCodeMapper.java index 675a409..0a96384 100644 --- a/src/main/java/it/gov/pagopa/pu/bff/mapper/TaxonomyMacroAreaCodeMapper.java +++ b/src/main/java/it/gov/pagopa/pu/bff/mapper/TaxonomyMacroAreaCodeMapper.java @@ -1,23 +1,18 @@ package it.gov.pagopa.pu.bff.mapper; import it.gov.pagopa.pu.bff.dto.generated.TaxonomyMacroAreaCodeDTO; -import it.gov.pagopa.pu.p4pa_organization.dto.generated.CollectionModelTaxonomyMacroAreaCodeDTOEmbedded; -import java.util.List; import org.springframework.stereotype.Component; @Component public class TaxonomyMacroAreaCodeMapper { - public List map(CollectionModelTaxonomyMacroAreaCodeDTOEmbedded input) { - return input.getTaxonomyMacroAreaCodeDTOes().stream() - .map(taxonomyCodeDTO -> { - TaxonomyMacroAreaCodeDTO dto = new TaxonomyMacroAreaCodeDTO(); - dto.setOrganizationTypeDescription(taxonomyCodeDTO.getOrganizationTypeDescription()); - dto.setOrganizationType(taxonomyCodeDTO.getOrganizationType()); - dto.setMacroAreaCode(taxonomyCodeDTO.getMacroAreaCode()); - dto.setMacroAreaName(taxonomyCodeDTO.getMacroAreaName()); - dto.setMacroAreaDescription(taxonomyCodeDTO.getMacroAreaDescription()); - return dto; - }) - .toList(); + public TaxonomyMacroAreaCodeDTO map( + it.gov.pagopa.pu.p4pa_organization.dto.generated.TaxonomyMacroAreaCodeDTO input) { + TaxonomyMacroAreaCodeDTO dto = new TaxonomyMacroAreaCodeDTO(); + dto.setOrganizationTypeDescription(input.getOrganizationType()+". "+input.getOrganizationTypeDescription()); + dto.setOrganizationType(input.getOrganizationType()); + dto.setMacroAreaCode(input.getMacroAreaCode()); + dto.setMacroAreaName(input.getMacroAreaCode()+". "+input.getMacroAreaName()); + dto.setMacroAreaDescription(input.getMacroAreaDescription()); + return dto; } } diff --git a/src/main/java/it/gov/pagopa/pu/bff/mapper/TaxonomyOrganizationTypeMapper.java b/src/main/java/it/gov/pagopa/pu/bff/mapper/TaxonomyOrganizationTypeMapper.java index ab29f6b..76ea256 100644 --- a/src/main/java/it/gov/pagopa/pu/bff/mapper/TaxonomyOrganizationTypeMapper.java +++ b/src/main/java/it/gov/pagopa/pu/bff/mapper/TaxonomyOrganizationTypeMapper.java @@ -1,21 +1,16 @@ package it.gov.pagopa.pu.bff.mapper; import it.gov.pagopa.pu.bff.dto.generated.TaxonomyOrganizationTypeDTO; -import it.gov.pagopa.pu.p4pa_organization.dto.generated.CollectionModelTaxonomyOrganizationTypeDTOEmbedded; -import java.util.List; import org.springframework.stereotype.Component; @Component public class TaxonomyOrganizationTypeMapper { - public List map(CollectionModelTaxonomyOrganizationTypeDTOEmbedded input) { - return input.getTaxonomyOrganizationTypeDTOes().stream() - .map(taxonomyCodeDTO -> { - TaxonomyOrganizationTypeDTO dto = new TaxonomyOrganizationTypeDTO(); - dto.setOrganizationTypeDescription(taxonomyCodeDTO.getOrganizationTypeDescription()); - dto.setOrganizationType(taxonomyCodeDTO.getOrganizationType()); - return dto; - }) - .toList(); + public TaxonomyOrganizationTypeDTO map( + it.gov.pagopa.pu.p4pa_organization.dto.generated.TaxonomyOrganizationTypeDTO input) { + TaxonomyOrganizationTypeDTO dto = new TaxonomyOrganizationTypeDTO(); + dto.setOrganizationTypeDescription(input.getOrganizationType()+". "+input.getOrganizationTypeDescription()); + dto.setOrganizationType(input.getOrganizationType()); + return dto; } } diff --git a/src/main/java/it/gov/pagopa/pu/bff/mapper/TaxonomyServiceTypeCodeMapper.java b/src/main/java/it/gov/pagopa/pu/bff/mapper/TaxonomyServiceTypeCodeMapper.java index 8716d4b..761246c 100644 --- a/src/main/java/it/gov/pagopa/pu/bff/mapper/TaxonomyServiceTypeCodeMapper.java +++ b/src/main/java/it/gov/pagopa/pu/bff/mapper/TaxonomyServiceTypeCodeMapper.java @@ -1,27 +1,22 @@ package it.gov.pagopa.pu.bff.mapper; import it.gov.pagopa.pu.bff.dto.generated.TaxonomyServiceTypeCodeDTO; -import it.gov.pagopa.pu.p4pa_organization.dto.generated.CollectionModelTaxonomyServiceTypeCodeDTOEmbedded; -import java.util.List; import org.springframework.stereotype.Component; @Component public class TaxonomyServiceTypeCodeMapper { - public List map(CollectionModelTaxonomyServiceTypeCodeDTOEmbedded input) { - return input.getTaxonomyServiceTypeCodeDTOes().stream() - .map(taxonomyCodeDTO -> { - TaxonomyServiceTypeCodeDTO dto = new TaxonomyServiceTypeCodeDTO(); - dto.setOrganizationTypeDescription(taxonomyCodeDTO.getOrganizationType()+". "+taxonomyCodeDTO.getOrganizationTypeDescription()); - dto.setOrganizationType(taxonomyCodeDTO.getOrganizationType()); - dto.setMacroAreaCode(taxonomyCodeDTO.getMacroAreaCode()); - dto.setMacroAreaName(taxonomyCodeDTO.getMacroAreaName()); - dto.setMacroAreaDescription(taxonomyCodeDTO.getMacroAreaDescription()); - dto.setServiceTypeCode(taxonomyCodeDTO.getServiceTypeCode()); - dto.setServiceType(taxonomyCodeDTO.getServiceType()); - dto.setServiceTypeDescription(taxonomyCodeDTO.getServiceTypeDescription()); - return dto; - }) - .toList(); + public TaxonomyServiceTypeCodeDTO map( + it.gov.pagopa.pu.p4pa_organization.dto.generated.TaxonomyServiceTypeCodeDTO input) { + TaxonomyServiceTypeCodeDTO dto = new TaxonomyServiceTypeCodeDTO(); + dto.setOrganizationTypeDescription(input.getOrganizationType()+". "+input.getOrganizationTypeDescription()); + dto.setOrganizationType(input.getOrganizationType()); + dto.setMacroAreaCode(input.getMacroAreaCode()); + dto.setMacroAreaName(input.getMacroAreaCode()+". "+input.getMacroAreaName()); + dto.setMacroAreaDescription(input.getMacroAreaDescription()); + dto.setServiceTypeCode(input.getServiceTypeCode()); + dto.setServiceType(input.getServiceTypeCode()+". "+input.getServiceType()); + dto.setServiceTypeDescription(input.getServiceTypeDescription()); + return dto; } } diff --git a/src/main/java/it/gov/pagopa/pu/bff/service/taxonomy/TaxonomyServiceImpl.java b/src/main/java/it/gov/pagopa/pu/bff/service/taxonomy/TaxonomyServiceImpl.java index 667c1cb..16bc1a7 100644 --- a/src/main/java/it/gov/pagopa/pu/bff/service/taxonomy/TaxonomyServiceImpl.java +++ b/src/main/java/it/gov/pagopa/pu/bff/service/taxonomy/TaxonomyServiceImpl.java @@ -40,28 +40,43 @@ public TaxonomyServiceImpl(TaxonomyClient taxonomyClient, public List getCollectionReason ( String organizationType, String macroAreaCode, String serviceTypeCode, String accessToken){ - return taxonomyCollectionReasonMapper.map(taxonomyClient.getCollectionReason(organizationType,macroAreaCode,serviceTypeCode,accessToken).getEmbedded()); + return taxonomyClient.getCollectionReason(organizationType, macroAreaCode, serviceTypeCode, accessToken) + .getEmbedded().getTaxonomyCollectionReasonDTOes() + .stream() + .map(taxonomyCollectionReasonMapper::map) + .toList(); } @Override public List getMacroArea ( String organizationType, String accessToken) { - return taxonomyMacroAreaCodeMapper.map(taxonomyClient.getMacroArea(organizationType,accessToken).getEmbedded()); + return taxonomyClient.getMacroArea(organizationType,accessToken).getEmbedded() + .getTaxonomyMacroAreaCodeDTOes() + .stream() + .map(taxonomyMacroAreaCodeMapper::map) + .toList(); } @Override public List getOrganizationTypes ( String accessToken) { - return taxonomyOrganizationTypeMapper - .map(taxonomyClient.getOrganizationType(accessToken).getEmbedded()); + return taxonomyClient.getOrganizationType(accessToken).getEmbedded() + .getTaxonomyOrganizationTypeDTOes() + .stream() + .map(taxonomyOrganizationTypeMapper::map) + .toList(); } @Override public List getServiceType ( String organizationType, String macroAreaCode, String accessToken) { - return taxonomyServiceTypeCodeMapper.map(taxonomyClient.getServiceType(organizationType,macroAreaCode,accessToken).getEmbedded()); + return taxonomyClient.getServiceType(organizationType,macroAreaCode,accessToken).getEmbedded() + .getTaxonomyServiceTypeCodeDTOes() + .stream() + .map(taxonomyServiceTypeCodeMapper::map) + .toList(); } @Override @@ -69,6 +84,10 @@ public List getTaxonomyCode ( String organizationType, String macroAreaCode, String serviceTypeCode, String collectionReason, String accessToken) { - return taxonomyCodeMapper.map(taxonomyClient.getTaxonomyCode(organizationType,macroAreaCode,serviceTypeCode,collectionReason,accessToken).getEmbedded()); + return taxonomyClient.getTaxonomyCode(organizationType,macroAreaCode,serviceTypeCode,collectionReason,accessToken).getEmbedded() + .getTaxonomyCodeDTOes() + .stream() + .map(taxonomyCodeMapper::map) + .toList(); } } diff --git a/src/test/java/it/gov/pagopa/pu/bff/mapper/OrganizationDTOMapperTest.java b/src/test/java/it/gov/pagopa/pu/bff/mapper/OrganizationDTOMapperTest.java index 334cebd..57b1dd1 100644 --- a/src/test/java/it/gov/pagopa/pu/bff/mapper/OrganizationDTOMapperTest.java +++ b/src/test/java/it/gov/pagopa/pu/bff/mapper/OrganizationDTOMapperTest.java @@ -24,7 +24,7 @@ void testMapToOrganizationDTO_ValidRoles() { organization.setOrganizationId(123L); organization.setIpaCode("testIpaCode"); organization.setOrgName("Test Organization"); - organization.setOrgLogoDesc("base64LogoString"); + organization.setOrgLogo("base64LogoString"); List roles = Collections.singletonList("ROLE_ADMIN"); OrganizationDTO result = mapper.mapToOrganizationDTO(organization, roles);