From 0e3a953b3bdf25341b233d246c4173f71b381c52 Mon Sep 17 00:00:00 2001 From: oleksiybozhykntt Date: Thu, 19 Dec 2024 16:33:00 +0100 Subject: [PATCH 01/20] updated entity --- .../controller/TaxonomyController.java | 26 +++++++++++ .../dto/DistinctCollectionReasonDTO.java | 12 ++++++ .../dto/DistinctMacroAreaDTO.java | 8 ++++ .../dto/DistinctOrganizationTypeDTO.java | 11 +++++ .../dto/DistinctServiceTypeDTO.java | 11 +++++ .../dto/DistinctTaxonomyCodeDTO.java | 13 ++++++ .../pu/organization/model/Taxonomy.java | 43 +++++++++++++++++++ .../repository/TaxonomyRepository.java | 27 ++++++++++++ .../organization/service/TaxonomyService.java | 19 ++++++++ 9 files changed, 170 insertions(+) create mode 100644 src/main/java/it/gov/pagopa/pu/organization/controller/TaxonomyController.java create mode 100644 src/main/java/it/gov/pagopa/pu/organization/dto/DistinctCollectionReasonDTO.java create mode 100644 src/main/java/it/gov/pagopa/pu/organization/dto/DistinctMacroAreaDTO.java create mode 100644 src/main/java/it/gov/pagopa/pu/organization/dto/DistinctOrganizationTypeDTO.java create mode 100644 src/main/java/it/gov/pagopa/pu/organization/dto/DistinctServiceTypeDTO.java create mode 100644 src/main/java/it/gov/pagopa/pu/organization/dto/DistinctTaxonomyCodeDTO.java create mode 100644 src/main/java/it/gov/pagopa/pu/organization/model/Taxonomy.java create mode 100644 src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java create mode 100644 src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java diff --git a/src/main/java/it/gov/pagopa/pu/organization/controller/TaxonomyController.java b/src/main/java/it/gov/pagopa/pu/organization/controller/TaxonomyController.java new file mode 100644 index 0000000..1257f93 --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/organization/controller/TaxonomyController.java @@ -0,0 +1,26 @@ +package it.gov.pagopa.pu.organization.controller; + +import it.gov.pagopa.pu.organization.dto.DistinctOrganizationTypeDTO; +import it.gov.pagopa.pu.organization.service.TaxonomyService; +import java.util.List; +import org.springframework.http.HttpStatusCode; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class TaxonomyController { + + TaxonomyService taxonomyService; + + public TaxonomyController(TaxonomyService taxonomyService){ + this.taxonomyService = taxonomyService; + } + + @GetMapping("/taxonomy") + public ResponseEntity> getDistinctOrgType(){ + return new ResponseEntity<>(taxonomyService.getDistinctOrganizationType(), + HttpStatusCode.valueOf(200)); + } + +} diff --git a/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctCollectionReasonDTO.java b/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctCollectionReasonDTO.java new file mode 100644 index 0000000..88cd558 --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctCollectionReasonDTO.java @@ -0,0 +1,12 @@ +package it.gov.pagopa.pu.organization.dto; + +public interface DistinctCollectionReasonDTO { + String getOrganizationType(); + String getOrganizationTypeDescription(); + String getMacroAreaCode(); + String getMacroAreaName(); + String getServiceTypeCode(); + String getServiceType(); + String getServiceTypeDescription(); + String getCollectionReason(); +} diff --git a/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctMacroAreaDTO.java b/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctMacroAreaDTO.java new file mode 100644 index 0000000..ebe2d79 --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctMacroAreaDTO.java @@ -0,0 +1,8 @@ +package it.gov.pagopa.pu.organization.dto; + +public interface DistinctMacroAreaDTO { + String getOrganizationType(); + String getOrganizationTypeDescription(); + String getMacroAreaCode(); + String getMacroAreaName(); +} diff --git a/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctOrganizationTypeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctOrganizationTypeDTO.java new file mode 100644 index 0000000..9cd4900 --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctOrganizationTypeDTO.java @@ -0,0 +1,11 @@ +package it.gov.pagopa.pu.organization.dto; + +import it.gov.pagopa.pu.organization.model.Taxonomy; +import org.springframework.data.rest.core.config.Projection; + +@Projection(name = "distinctOrganizationType", types = { Taxonomy.class }) +public interface DistinctOrganizationTypeDTO { + String getOrganizationType(); + String getOrganizationTypeDescription(); + +} diff --git a/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctServiceTypeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctServiceTypeDTO.java new file mode 100644 index 0000000..02ad835 --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctServiceTypeDTO.java @@ -0,0 +1,11 @@ +package it.gov.pagopa.pu.organization.dto; + +public interface DistinctServiceTypeDTO { + String getOrganizationType(); + String getOrganizationTypeDescription(); + String getMacroAreaCode(); + String getMacroAreaName(); + String getServiceTypeCode(); + String getServiceType(); + String getServiceTypeDescription(); +} diff --git a/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctTaxonomyCodeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctTaxonomyCodeDTO.java new file mode 100644 index 0000000..13b0ff8 --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctTaxonomyCodeDTO.java @@ -0,0 +1,13 @@ +package it.gov.pagopa.pu.organization.dto; + +public interface DistinctTaxonomyCodeDTO { + String getOrganizationType(); + String getOrganizationTypeDescription(); + String getMacroAreaCode(); + String getMacroAreaName(); + String getServiceTypeCode(); + String getServiceType(); + String getServiceTypeDescription(); + String getCollectionReason(); + String getTaxonomyCode(); +} diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/Taxonomy.java b/src/main/java/it/gov/pagopa/pu/organization/model/Taxonomy.java new file mode 100644 index 0000000..8fa2ca6 --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/organization/model/Taxonomy.java @@ -0,0 +1,43 @@ +package it.gov.pagopa.pu.organization.model; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.SequenceGenerator; +import jakarta.persistence.Table; +import java.io.Serializable; +import java.sql.Timestamp; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Entity +@Table(name = "taxonomy") +@AllArgsConstructor +@NoArgsConstructor +@Data +public class Taxonomy implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "taxonomy_generator") + @SequenceGenerator(name = "taxonomy_generator", sequenceName = "taxonomy_seq", allocationSize = 1) + private Long taxonomyId; + private Long version; + private String organizationType; + private String organizationTypeDescription; + private String macroAreaCode; + private String macroAreaName; + private String macroAreaDescription; + private String serviceTypeCode; + private String serviceType; + private String serviceTypeDescription; + private String collectionReason; + private Timestamp startDateValidity; + private Timestamp endDateOfValidity; + private String taxonomyCode; + private Timestamp creationDate; + private Timestamp lastModifiedDate; + private Long versionMyPay; + +} diff --git a/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java b/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java new file mode 100644 index 0000000..dbc9e8a --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java @@ -0,0 +1,27 @@ +package it.gov.pagopa.pu.organization.repository; + +import it.gov.pagopa.pu.organization.dto.DistinctCollectionReasonDTO; +import it.gov.pagopa.pu.organization.dto.DistinctMacroAreaDTO; +import it.gov.pagopa.pu.organization.dto.DistinctOrganizationTypeDTO; +import it.gov.pagopa.pu.organization.dto.DistinctServiceTypeDTO; +import it.gov.pagopa.pu.organization.dto.DistinctTaxonomyCodeDTO; +import it.gov.pagopa.pu.organization.model.Taxonomy; +import java.util.List; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "taxonomy", path = "taxonomy") +public interface TaxonomyRepository extends JpaRepository { + @Query("SELECT DISTINCT t.organizationType,t.organizationTypeDescription FROM Taxonomy t") + List findDistinctOrganizationType(); + + List findDistinctMacroAreaCodeByOrganizationType(String organizationType); + + List findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCode(String organizationType,String macroAreaCode); + + List findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCode(String organizationType,String macroAreaCode,String serviceTypeCode); + + List findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReason(String organizationType,String macroAreaName,String serviceType,String collectionReason); + +} diff --git a/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java b/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java new file mode 100644 index 0000000..89ed914 --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java @@ -0,0 +1,19 @@ +package it.gov.pagopa.pu.organization.service; + +import it.gov.pagopa.pu.organization.dto.DistinctOrganizationTypeDTO; +import it.gov.pagopa.pu.organization.repository.TaxonomyRepository; +import java.util.List; +import org.springframework.stereotype.Service; + +@Service +public class TaxonomyService { + private TaxonomyRepository taxonomyRepository; + public TaxonomyService(TaxonomyRepository taxonomyRepository){ + this.taxonomyRepository = taxonomyRepository; + } + + public List getDistinctOrganizationType(){ + return null;//taxonomyRepository.findDistinctOrganizationTypeBy(); + } + +} From 165654bf1f7e4382722f1d43d866a2ab8b383315 Mon Sep 17 00:00:00 2001 From: oleksiybozhykntt Date: Fri, 20 Dec 2024 12:39:10 +0100 Subject: [PATCH 02/20] updated entity --- .../controller/TaxonomyController.java | 2 +- .../DistinctOrganizationTypeDTO.java | 5 ++--- .../repository/TaxonomyRepository.java | 20 +++++++++---------- .../organization/service/TaxonomyService.java | 2 +- 4 files changed, 13 insertions(+), 16 deletions(-) rename src/main/java/it/gov/pagopa/pu/organization/{dto => model}/DistinctOrganizationTypeDTO.java (52%) diff --git a/src/main/java/it/gov/pagopa/pu/organization/controller/TaxonomyController.java b/src/main/java/it/gov/pagopa/pu/organization/controller/TaxonomyController.java index 1257f93..333d245 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/controller/TaxonomyController.java +++ b/src/main/java/it/gov/pagopa/pu/organization/controller/TaxonomyController.java @@ -1,6 +1,6 @@ package it.gov.pagopa.pu.organization.controller; -import it.gov.pagopa.pu.organization.dto.DistinctOrganizationTypeDTO; +import it.gov.pagopa.pu.organization.model.DistinctOrganizationTypeDTO; import it.gov.pagopa.pu.organization.service.TaxonomyService; import java.util.List; import org.springframework.http.HttpStatusCode; diff --git a/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctOrganizationTypeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctOrganizationTypeDTO.java similarity index 52% rename from src/main/java/it/gov/pagopa/pu/organization/dto/DistinctOrganizationTypeDTO.java rename to src/main/java/it/gov/pagopa/pu/organization/model/DistinctOrganizationTypeDTO.java index 9cd4900..5a85e40 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctOrganizationTypeDTO.java +++ b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctOrganizationTypeDTO.java @@ -1,9 +1,8 @@ -package it.gov.pagopa.pu.organization.dto; +package it.gov.pagopa.pu.organization.model; -import it.gov.pagopa.pu.organization.model.Taxonomy; import org.springframework.data.rest.core.config.Projection; -@Projection(name = "distinctOrganizationType", types = { Taxonomy.class }) +@Projection(name = "dataView", types = Taxonomy.class) public interface DistinctOrganizationTypeDTO { String getOrganizationType(); String getOrganizationTypeDescription(); diff --git a/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java b/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java index dbc9e8a..9c79417 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java +++ b/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java @@ -1,10 +1,6 @@ package it.gov.pagopa.pu.organization.repository; -import it.gov.pagopa.pu.organization.dto.DistinctCollectionReasonDTO; -import it.gov.pagopa.pu.organization.dto.DistinctMacroAreaDTO; -import it.gov.pagopa.pu.organization.dto.DistinctOrganizationTypeDTO; -import it.gov.pagopa.pu.organization.dto.DistinctServiceTypeDTO; -import it.gov.pagopa.pu.organization.dto.DistinctTaxonomyCodeDTO; +import it.gov.pagopa.pu.organization.model.DistinctOrganizationTypeDTO; import it.gov.pagopa.pu.organization.model.Taxonomy; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; @@ -13,15 +9,17 @@ @RepositoryRestResource(collectionResourceRel = "taxonomy", path = "taxonomy") public interface TaxonomyRepository extends JpaRepository { - @Query("SELECT DISTINCT t.organizationType,t.organizationTypeDescription FROM Taxonomy t") - List findDistinctOrganizationType(); - List findDistinctMacroAreaCodeByOrganizationType(String organizationType); + @Query("select distinct t.organizationType as organizationType, t.organizationTypeDescription as organizationTypeDescription from Taxonomy t") + List findDistinctOrganizationTypeAndOrganizationTypeDescriptionBy(); + List findDistinctOrganizationTypeBy(); - List findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCode(String organizationType,String macroAreaCode); + List findDistinctMacroAreaCodeByOrganizationType(String organizationType); - List findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCode(String organizationType,String macroAreaCode,String serviceTypeCode); + List findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCode(String organizationType,String macroAreaCode); - List findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReason(String organizationType,String macroAreaName,String serviceType,String collectionReason); + List findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCode(String organizationType,String macroAreaCode,String serviceTypeCode); + + List findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReason(String organizationType,String macroAreaName,String serviceType,String collectionReason); } diff --git a/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java b/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java index 89ed914..649a757 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java +++ b/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java @@ -1,6 +1,6 @@ package it.gov.pagopa.pu.organization.service; -import it.gov.pagopa.pu.organization.dto.DistinctOrganizationTypeDTO; +import it.gov.pagopa.pu.organization.model.DistinctOrganizationTypeDTO; import it.gov.pagopa.pu.organization.repository.TaxonomyRepository; import java.util.List; import org.springframework.stereotype.Service; From aeff78818459536c58ad99e251dfc568967de1fc Mon Sep 17 00:00:00 2001 From: oleksiybozhykntt Date: Mon, 13 Jan 2025 16:16:36 +0100 Subject: [PATCH 03/20] updated code --- openapi/generated.openapi.json | 747 ++++++++++++++++-- .../controller/TaxonomyController.java | 7 +- .../model/DistinctOrganizationTypeDTO.java | 3 - .../repository/TaxonomyRepository.java | 9 +- .../organization/service/TaxonomyService.java | 5 +- .../controller/TaxonomyControllerTest.java | 62 ++ .../service/TaxonomyServiceTest.java | 61 ++ 7 files changed, 836 insertions(+), 58 deletions(-) create mode 100644 src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java create mode 100644 src/test/java/it/gov/pagopa/pu/organization/service/TaxonomyServiceTest.java diff --git a/openapi/generated.openapi.json b/openapi/generated.openapi.json index e855203..ace783d 100644 --- a/openapi/generated.openapi.json +++ b/openapi/generated.openapi.json @@ -621,6 +621,478 @@ } } } + }, + "/profile/taxonomy": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "descriptor_1_1_3", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + }, + "application/alps+json": { + "schema": { + "type": "string" + } + }, + "application/schema+json": { + "schema": { + "$ref": "#/components/schemas/JsonSchema" + } + } + } + } + } + } + }, + "/taxonomy": { + "get": { + "tags": [ + "taxonomy-entity-controller" + ], + "description": "get-taxonomy", + "operationId": "getCollectionResource-taxonomy-get_1", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 20 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelTaxonomy" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelTaxonomy" + } + } + } + } + } + }, + "post": { + "tags": [ + "taxonomy-entity-controller" + ], + "description": "create-taxonomy", + "operationId": "postCollectionResource-taxonomy-post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TaxonomyRequestBody" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelTaxonomy" + } + } + } + } + } + } + }, + "/taxonomy/search/findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCode": { + "get": { + "tags": [ + "taxonomy-search-controller" + ], + "operationId": "executeSearch-taxonomy-get", + "parameters": [ + { + "name": "organizationType", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "macroAreaCode", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "serviceTypeCode", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelTaxonomy" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/taxonomy/search/findDistinctMacroAreaCodeByOrganizationType": { + "get": { + "tags": [ + "taxonomy-search-controller" + ], + "operationId": "executeSearch-taxonomy-get_1", + "parameters": [ + { + "name": "organizationType", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelTaxonomy" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/taxonomy/search/findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCode": { + "get": { + "tags": [ + "taxonomy-search-controller" + ], + "operationId": "executeSearch-taxonomy-get_2", + "parameters": [ + { + "name": "organizationType", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "macroAreaCode", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelTaxonomy" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/taxonomy/search/findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReason": { + "get": { + "tags": [ + "taxonomy-search-controller" + ], + "operationId": "executeSearch-taxonomy-get_3", + "parameters": [ + { + "name": "organizationType", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "macroAreaName", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "serviceType", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "collectionReason", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelTaxonomy" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/taxonomy/{id}": { + "get": { + "tags": [ + "taxonomy-entity-controller" + ], + "description": "get-taxonomy", + "operationId": "getItemResource-taxonomy-get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelTaxonomy" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "put": { + "tags": [ + "taxonomy-entity-controller" + ], + "description": "update-taxonomy", + "operationId": "putItemResource-taxonomy-put", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TaxonomyRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelTaxonomy" + } + } + } + }, + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelTaxonomy" + } + } + } + }, + "204": { + "description": "No Content" + } + } + }, + "delete": { + "tags": [ + "taxonomy-entity-controller" + ], + "description": "delete-taxonomy", + "operationId": "deleteItemResource-taxonomy-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + }, + "patch": { + "tags": [ + "taxonomy-entity-controller" + ], + "description": "patch-taxonomy", + "operationId": "patchItemResource-taxonomy-patch", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TaxonomyRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelTaxonomy" + } + } + } + }, + "204": { + "description": "No Content" + } + } + } + }, + "/taxonomy/custom/getDistinctOrganizationType": { + "get": { + "tags": [ + "taxonomy-controller" + ], + "operationId": "getDistinctOrgType", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/DistinctOrganizationTypeDTO" + } + } + } + } + } + } + } } }, "components": { @@ -705,6 +1177,134 @@ } } }, + "EntityModelTaxonomy": { + "type": "object", + "properties": { + "taxonomyId": { + "type": "integer", + "format": "int64" + }, + "version": { + "type": "integer", + "format": "int64" + }, + "organizationType": { + "type": "string" + }, + "organizationTypeDescription": { + "type": "string" + }, + "macroAreaCode": { + "type": "string" + }, + "macroAreaName": { + "type": "string" + }, + "macroAreaDescription": { + "type": "string" + }, + "serviceTypeCode": { + "type": "string" + }, + "serviceType": { + "type": "string" + }, + "serviceTypeDescription": { + "type": "string" + }, + "collectionReason": { + "type": "string" + }, + "startDateValidity": { + "type": "string", + "format": "date-time" + }, + "endDateOfValidity": { + "type": "string", + "format": "date-time" + }, + "taxonomyCode": { + "type": "string" + }, + "creationDate": { + "type": "string", + "format": "date-time" + }, + "lastModifiedDate": { + "type": "string", + "format": "date-time" + }, + "versionMyPay": { + "type": "integer", + "format": "int64" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "PageMetadata": { + "type": "object", + "properties": { + "size": { + "type": "integer", + "format": "int64" + }, + "totalElements": { + "type": "integer", + "format": "int64" + }, + "totalPages": { + "type": "integer", + "format": "int64" + }, + "number": { + "type": "integer", + "format": "int64" + } + } + }, + "PagedModelEntityModelTaxonomy": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "taxonomy": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelTaxonomy" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "CollectionModelEntityModelTaxonomy": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "taxonomy": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelTaxonomy" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, "EntityModelOrganization": { "type": "object", "properties": { @@ -818,27 +1418,6 @@ } } }, - "PageMetadata": { - "type": "object", - "properties": { - "size": { - "type": "integer", - "format": "int64" - }, - "totalElements": { - "type": "integer", - "format": "int64" - }, - "totalPages": { - "type": "integer", - "format": "int64" - }, - "number": { - "type": "integer", - "format": "int64" - } - } - }, "PagedModelEntityModelOrganization": { "type": "object", "properties": { @@ -861,32 +1440,6 @@ } } }, - "PersonalisationFe": { - "type": "object", - "properties": { - "headerAssistanceUrl": { - "type": "string" - }, - "logoFooterImg": { - "type": "string" - }, - "footerDescText": { - "type": "string" - }, - "footerPrivacyInfoUrl": { - "type": "string" - }, - "footerGDPRUrl": { - "type": "string" - }, - "footerTermsCondUrl": { - "type": "string" - }, - "footerAccessibilityUrl": { - "type": "string" - } - } - }, "EntityModelBroker": { "type": "object", "properties": { @@ -962,6 +1515,32 @@ } } }, + "PersonalisationFe": { + "type": "object", + "properties": { + "headerAssistanceUrl": { + "type": "string" + }, + "logoFooterImg": { + "type": "string" + }, + "footerDescText": { + "type": "string" + }, + "footerPrivacyInfoUrl": { + "type": "string" + }, + "footerGDPRUrl": { + "type": "string" + }, + "footerTermsCondUrl": { + "type": "string" + }, + "footerAccessibilityUrl": { + "type": "string" + } + } + }, "BrokerRequestBody": { "type": "object", "properties": { @@ -1122,6 +1701,80 @@ } } }, + "TaxonomyRequestBody": { + "type": "object", + "properties": { + "taxonomyId": { + "type": "integer", + "format": "int64" + }, + "version": { + "type": "integer", + "format": "int64" + }, + "organizationType": { + "type": "string" + }, + "organizationTypeDescription": { + "type": "string" + }, + "macroAreaCode": { + "type": "string" + }, + "macroAreaName": { + "type": "string" + }, + "macroAreaDescription": { + "type": "string" + }, + "serviceTypeCode": { + "type": "string" + }, + "serviceType": { + "type": "string" + }, + "serviceTypeDescription": { + "type": "string" + }, + "collectionReason": { + "type": "string" + }, + "startDateValidity": { + "type": "string", + "format": "date-time" + }, + "endDateOfValidity": { + "type": "string", + "format": "date-time" + }, + "taxonomyCode": { + "type": "string" + }, + "creationDate": { + "type": "string", + "format": "date-time" + }, + "lastModifiedDate": { + "type": "string", + "format": "date-time" + }, + "versionMyPay": { + "type": "integer", + "format": "int64" + } + } + }, + "DistinctOrganizationTypeDTO": { + "type": "object", + "properties": { + "organizationTypeDescription": { + "type": "string" + }, + "organizationType": { + "type": "string" + } + } + }, "Link": { "type": "object", "properties": { diff --git a/src/main/java/it/gov/pagopa/pu/organization/controller/TaxonomyController.java b/src/main/java/it/gov/pagopa/pu/organization/controller/TaxonomyController.java index 333d245..22cd43b 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/controller/TaxonomyController.java +++ b/src/main/java/it/gov/pagopa/pu/organization/controller/TaxonomyController.java @@ -3,6 +3,7 @@ import it.gov.pagopa.pu.organization.model.DistinctOrganizationTypeDTO; import it.gov.pagopa.pu.organization.service.TaxonomyService; import java.util.List; +import org.springframework.data.domain.Sort; import org.springframework.http.HttpStatusCode; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -17,9 +18,9 @@ public TaxonomyController(TaxonomyService taxonomyService){ this.taxonomyService = taxonomyService; } - @GetMapping("/taxonomy") - public ResponseEntity> getDistinctOrgType(){ - return new ResponseEntity<>(taxonomyService.getDistinctOrganizationType(), + @GetMapping("/taxonomy/custom/getDistinctOrganizationType") + public ResponseEntity> getDistinctOrgType(Sort sort){ + return new ResponseEntity<>(taxonomyService.getDistinctOrganizationType(sort), HttpStatusCode.valueOf(200)); } diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctOrganizationTypeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctOrganizationTypeDTO.java index 5a85e40..88cbd5c 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctOrganizationTypeDTO.java +++ b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctOrganizationTypeDTO.java @@ -1,8 +1,5 @@ package it.gov.pagopa.pu.organization.model; -import org.springframework.data.rest.core.config.Projection; - -@Projection(name = "dataView", types = Taxonomy.class) public interface DistinctOrganizationTypeDTO { String getOrganizationType(); String getOrganizationTypeDescription(); diff --git a/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java b/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java index 9c79417..abe77b3 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java +++ b/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java @@ -3,16 +3,19 @@ import it.gov.pagopa.pu.organization.model.DistinctOrganizationTypeDTO; import it.gov.pagopa.pu.organization.model.Taxonomy; import java.util.List; +import org.springframework.data.domain.Sort; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.rest.core.annotation.RepositoryRestResource; +import org.springframework.data.rest.core.annotation.RestResource; @RepositoryRestResource(collectionResourceRel = "taxonomy", path = "taxonomy") public interface TaxonomyRepository extends JpaRepository { - @Query("select distinct t.organizationType as organizationType, t.organizationTypeDescription as organizationTypeDescription from Taxonomy t") - List findDistinctOrganizationTypeAndOrganizationTypeDescriptionBy(); - List findDistinctOrganizationTypeBy(); + //@Query("select distinct t.organizationType as organizationType, t.organizationTypeDescription as organizationTypeDescription from Taxonomy t") + @RestResource(exported = false) + @Query(value = "select distinct t.organizationType as organizationType, t.organizationTypeDescription as organizationTypeDescription from Taxonomy t") + List findDistinctOrganizationTypes(Sort sort); List findDistinctMacroAreaCodeByOrganizationType(String organizationType); diff --git a/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java b/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java index 649a757..86e6f08 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java +++ b/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java @@ -3,6 +3,7 @@ import it.gov.pagopa.pu.organization.model.DistinctOrganizationTypeDTO; import it.gov.pagopa.pu.organization.repository.TaxonomyRepository; import java.util.List; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; @Service @@ -12,8 +13,8 @@ public TaxonomyService(TaxonomyRepository taxonomyRepository){ this.taxonomyRepository = taxonomyRepository; } - public List getDistinctOrganizationType(){ - return null;//taxonomyRepository.findDistinctOrganizationTypeBy(); + public List getDistinctOrganizationType(Sort sort){ + return taxonomyRepository.findDistinctOrganizationTypes(sort); } } diff --git a/src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java b/src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java new file mode 100644 index 0000000..4fd4a0a --- /dev/null +++ b/src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java @@ -0,0 +1,62 @@ +package it.gov.pagopa.pu.organization.controller; + +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import it.gov.pagopa.pu.organization.model.DistinctOrganizationTypeDTO; +import it.gov.pagopa.pu.organization.service.TaxonomyService; +import java.util.ArrayList; +import java.util.List; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; +import org.springframework.data.domain.Sort; +import org.springframework.data.domain.Sort.Order; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; + +@WebMvcTest(value = TaxonomyController.class, excludeFilters = { + @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE) +}) +@AutoConfigureMockMvc(addFilters = false) +class TaxonomyControllerTest { + @Autowired + private MockMvc mockMvc; + @MockBean + private TaxonomyService taxonomyServiceMock; + @InjectMocks + private TaxonomyController taxonomyController; + + @Test + void getDistinctOrgType () throws Exception { + List orgTypes = new ArrayList(); + orgTypes.add(0, new DistinctOrganizationTypeDTO() { + @Override + public String getOrganizationType () { + return "test"; + } + + @Override + public String getOrganizationTypeDescription () { + return "test"; + } + }); + + Mockito.when(taxonomyServiceMock.getDistinctOrganizationType(Sort.by(Order.asc("organizationType")))).thenReturn(orgTypes); + + mockMvc.perform(get("/taxonomy/custom/getDistinctOrganizationType") + .param("sort","organizationType,ASC") + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andExpect(content().json( + "[{\"organizationType\":\"test\",\"organizationTypeDescription\":\"test\"}]")); + } +} diff --git a/src/test/java/it/gov/pagopa/pu/organization/service/TaxonomyServiceTest.java b/src/test/java/it/gov/pagopa/pu/organization/service/TaxonomyServiceTest.java new file mode 100644 index 0000000..b33e1c2 --- /dev/null +++ b/src/test/java/it/gov/pagopa/pu/organization/service/TaxonomyServiceTest.java @@ -0,0 +1,61 @@ +package it.gov.pagopa.pu.organization.service; + +import static org.junit.jupiter.api.Assertions.*; + +import it.gov.pagopa.pu.organization.model.DistinctOrganizationTypeDTO; +import it.gov.pagopa.pu.organization.repository.TaxonomyRepository; +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.data.domain.Sort; + +@ExtendWith(MockitoExtension.class) +class TaxonomyServiceTest { + @Mock + private TaxonomyRepository taxonomyRepository; + + @InjectMocks + private TaxonomyService taxonomyService; + + @Test + void testGetDistinctOrganizationType() { + // Arrange + Sort sort = Sort.by("name"); + DistinctOrganizationTypeDTO dto1 = new DistinctOrganizationTypeDTO() { + @Override + public String getOrganizationType () { + return null; + } + + @Override + public String getOrganizationTypeDescription () { + return null; + } + }; + DistinctOrganizationTypeDTO dto2 = new DistinctOrganizationTypeDTO() { + @Override + public String getOrganizationType () { + return null; + } + + @Override + public String getOrganizationTypeDescription () { + return null; + } + }; + List expectedList = Arrays.asList(dto1, dto2); + Mockito.when(taxonomyRepository.findDistinctOrganizationTypes(sort)).thenReturn(expectedList); + + // Act + List result = taxonomyService.getDistinctOrganizationType(sort); + + // Assert + assertEquals(expectedList, result); + Mockito.verify(taxonomyRepository, Mockito.times(1)).findDistinctOrganizationTypes(sort); + } +} From e86f93933b88f8403348e6781942227ec61b690b Mon Sep 17 00:00:00 2001 From: oleksiybozhykntt Date: Mon, 13 Jan 2025 16:29:48 +0100 Subject: [PATCH 04/20] updated code --- openapi/generated.openapi.json | 603 ++++++++++++++++++ .../controller/TaxonomyControllerTest.java | 4 +- 2 files changed, 605 insertions(+), 2 deletions(-) diff --git a/openapi/generated.openapi.json b/openapi/generated.openapi.json index ac8173a..2e4ae14 100644 --- a/openapi/generated.openapi.json +++ b/openapi/generated.openapi.json @@ -625,6 +625,428 @@ } } }, + "/crud/profile/taxonomy" : { + "get" : { + "tags" : [ "profile-controller" ], + "operationId" : "crud-profile-taxonomy", + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "*/*" : { + "schema" : { + "type" : "string" + } + }, + "application/alps+json" : { + "schema" : { + "type" : "string" + } + }, + "application/schema+json" : { + "schema" : { + "$ref" : "#/components/schemas/JsonSchema" + } + } + } + } + } + } + }, + "/crud/taxonomy" : { + "get" : { + "tags" : [ "taxonomy-entity-controller" ], + "description" : "get-taxonomy", + "operationId" : "crud-get-taxonomys", + "parameters" : [ { + "name" : "page", + "in" : "query", + "description" : "Zero-based page index (0..N)", + "required" : false, + "schema" : { + "minimum" : 0, + "type" : "integer", + "default" : 0 + } + }, { + "name" : "size", + "in" : "query", + "description" : "The size of the page to be returned", + "required" : false, + "schema" : { + "minimum" : 1, + "type" : "integer", + "default" : 20 + } + }, { + "name" : "sort", + "in" : "query", + "description" : "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required" : false, + "schema" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/hal+json" : { + "schema" : { + "$ref" : "#/components/schemas/PagedModelTaxonomy" + } + }, + "application/x-spring-data-compact+json" : { + "schema" : { + "$ref" : "#/components/schemas/PagedModelTaxonomy" + } + }, + "text/uri-list" : { + "schema" : { + "type" : "string" + } + } + } + } + } + }, + "post" : { + "tags" : [ "taxonomy-entity-controller" ], + "description" : "create-taxonomy", + "operationId" : "crud-create-taxonomy", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/TaxonomyRequestBody" + } + } + }, + "required" : true + }, + "responses" : { + "201" : { + "description" : "Created", + "content" : { + "application/hal+json" : { + "schema" : { + "$ref" : "#/components/schemas/Taxonomy" + } + } + } + } + } + } + }, + "/crud/taxonomy/search/findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCode" : { + "get" : { + "tags" : [ "taxonomy-search-controller" ], + "operationId" : "crud-taxonomy-findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCode", + "parameters" : [ { + "name" : "organizationType", + "in" : "query", + "schema" : { + "type" : "string" + } + }, { + "name" : "macroAreaCode", + "in" : "query", + "schema" : { + "type" : "string" + } + }, { + "name" : "serviceTypeCode", + "in" : "query", + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/hal+json" : { + "schema" : { + "$ref" : "#/components/schemas/CollectionModelTaxonomy" + } + } + } + }, + "404" : { + "description" : "Not Found" + } + } + } + }, + "/crud/taxonomy/search/findDistinctMacroAreaCodeByOrganizationType" : { + "get" : { + "tags" : [ "taxonomy-search-controller" ], + "operationId" : "crud-taxonomy-findDistinctMacroAreaCodeByOrganizationType", + "parameters" : [ { + "name" : "organizationType", + "in" : "query", + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/hal+json" : { + "schema" : { + "$ref" : "#/components/schemas/CollectionModelTaxonomy" + } + } + } + }, + "404" : { + "description" : "Not Found" + } + } + } + }, + "/crud/taxonomy/search/findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCode" : { + "get" : { + "tags" : [ "taxonomy-search-controller" ], + "operationId" : "crud-taxonomy-findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCode", + "parameters" : [ { + "name" : "organizationType", + "in" : "query", + "schema" : { + "type" : "string" + } + }, { + "name" : "macroAreaCode", + "in" : "query", + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/hal+json" : { + "schema" : { + "$ref" : "#/components/schemas/CollectionModelTaxonomy" + } + } + } + }, + "404" : { + "description" : "Not Found" + } + } + } + }, + "/crud/taxonomy/search/findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReason" : { + "get" : { + "tags" : [ "taxonomy-search-controller" ], + "operationId" : "crud-taxonomy-findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReason", + "parameters" : [ { + "name" : "organizationType", + "in" : "query", + "schema" : { + "type" : "string" + } + }, { + "name" : "macroAreaName", + "in" : "query", + "schema" : { + "type" : "string" + } + }, { + "name" : "serviceType", + "in" : "query", + "schema" : { + "type" : "string" + } + }, { + "name" : "collectionReason", + "in" : "query", + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/hal+json" : { + "schema" : { + "$ref" : "#/components/schemas/CollectionModelTaxonomy" + } + } + } + }, + "404" : { + "description" : "Not Found" + } + } + } + }, + "/crud/taxonomy/{id}" : { + "get" : { + "tags" : [ "taxonomy-entity-controller" ], + "description" : "get-taxonomy", + "operationId" : "crud-get-taxonomy", + "parameters" : [ { + "name" : "id", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/hal+json" : { + "schema" : { + "$ref" : "#/components/schemas/Taxonomy" + } + } + } + }, + "404" : { + "description" : "Not Found" + } + } + }, + "put" : { + "tags" : [ "taxonomy-entity-controller" ], + "description" : "update-taxonomy", + "operationId" : "crud-update-taxonomy", + "parameters" : [ { + "name" : "id", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/TaxonomyRequestBody" + } + } + }, + "required" : true + }, + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/hal+json" : { + "schema" : { + "$ref" : "#/components/schemas/Taxonomy" + } + } + } + }, + "201" : { + "description" : "Created", + "content" : { + "application/hal+json" : { + "schema" : { + "$ref" : "#/components/schemas/Taxonomy" + } + } + } + }, + "204" : { + "description" : "No Content" + } + } + }, + "delete" : { + "tags" : [ "taxonomy-entity-controller" ], + "description" : "delete-taxonomy", + "operationId" : "crud-delete-taxonomy", + "parameters" : [ { + "name" : "id", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "204" : { + "description" : "No Content" + }, + "404" : { + "description" : "Not Found" + } + } + }, + "patch" : { + "tags" : [ "taxonomy-entity-controller" ], + "description" : "patch-taxonomy", + "operationId" : "crud-patch-taxonomy", + "parameters" : [ { + "name" : "id", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/TaxonomyRequestBody" + } + } + }, + "required" : true + }, + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/hal+json" : { + "schema" : { + "$ref" : "#/components/schemas/Taxonomy" + } + } + } + }, + "204" : { + "description" : "No Content" + } + } + } + }, + "/taxonomy/custom/getDistinctOrganizationType" : { + "get" : { + "tags" : [ "taxonomy-controller" ], + "operationId" : "getDistinctOrgType", + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/hal+json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/DistinctOrganizationTypeDTO" + } + } + } + } + } + } + } + }, "/brokers/apiKey/{brokerId}" : { "get" : { "tags" : [ "Broker" ], @@ -887,6 +1309,113 @@ } } }, + "Taxonomy" : { + "type" : "object", + "properties" : { + "taxonomyId" : { + "type" : "integer", + "format" : "int64" + }, + "version" : { + "type" : "integer", + "format" : "int64" + }, + "organizationType" : { + "type" : "string" + }, + "organizationTypeDescription" : { + "type" : "string" + }, + "macroAreaCode" : { + "type" : "string" + }, + "macroAreaName" : { + "type" : "string" + }, + "macroAreaDescription" : { + "type" : "string" + }, + "serviceTypeCode" : { + "type" : "string" + }, + "serviceType" : { + "type" : "string" + }, + "serviceTypeDescription" : { + "type" : "string" + }, + "collectionReason" : { + "type" : "string" + }, + "startDateValidity" : { + "type" : "string", + "format" : "date-time" + }, + "endDateOfValidity" : { + "type" : "string", + "format" : "date-time" + }, + "taxonomyCode" : { + "type" : "string" + }, + "creationDate" : { + "type" : "string", + "format" : "date-time" + }, + "lastModifiedDate" : { + "type" : "string", + "format" : "date-time" + }, + "versionMyPay" : { + "type" : "integer", + "format" : "int64" + }, + "_links" : { + "$ref" : "#/components/schemas/Links" + } + } + }, + "PagedModelTaxonomy" : { + "type" : "object", + "properties" : { + "_embedded" : { + "type" : "object", + "properties" : { + "taxonomy" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Taxonomy" + } + } + } + }, + "_links" : { + "$ref" : "#/components/schemas/Links" + }, + "page" : { + "$ref" : "#/components/schemas/PageMetadata" + } + } + }, + "CollectionModelTaxonomy" : { + "type" : "object", + "properties" : { + "_embedded" : { + "type" : "object", + "properties" : { + "taxonomy" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Taxonomy" + } + } + } + }, + "_links" : { + "$ref" : "#/components/schemas/Links" + } + } + }, "Organization" : { "type" : "object", "properties" : { @@ -1176,6 +1705,80 @@ } } }, + "TaxonomyRequestBody" : { + "type" : "object", + "properties" : { + "taxonomyId" : { + "type" : "integer", + "format" : "int64" + }, + "version" : { + "type" : "integer", + "format" : "int64" + }, + "organizationType" : { + "type" : "string" + }, + "organizationTypeDescription" : { + "type" : "string" + }, + "macroAreaCode" : { + "type" : "string" + }, + "macroAreaName" : { + "type" : "string" + }, + "macroAreaDescription" : { + "type" : "string" + }, + "serviceTypeCode" : { + "type" : "string" + }, + "serviceType" : { + "type" : "string" + }, + "serviceTypeDescription" : { + "type" : "string" + }, + "collectionReason" : { + "type" : "string" + }, + "startDateValidity" : { + "type" : "string", + "format" : "date-time" + }, + "endDateOfValidity" : { + "type" : "string", + "format" : "date-time" + }, + "taxonomyCode" : { + "type" : "string" + }, + "creationDate" : { + "type" : "string", + "format" : "date-time" + }, + "lastModifiedDate" : { + "type" : "string", + "format" : "date-time" + }, + "versionMyPay" : { + "type" : "integer", + "format" : "int64" + } + } + }, + "DistinctOrganizationTypeDTO" : { + "type" : "object", + "properties" : { + "organizationType" : { + "type" : "string" + }, + "organizationTypeDescription" : { + "type" : "string" + } + } + }, "BrokerApiKeys" : { "type" : "object", "properties" : { diff --git a/src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java b/src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java index 4fd4a0a..1458e71 100644 --- a/src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java +++ b/src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java @@ -14,12 +14,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.FilterType; import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort.Order; import org.springframework.http.MediaType; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.web.servlet.MockMvc; @WebMvcTest(value = TaxonomyController.class, excludeFilters = { @@ -29,7 +29,7 @@ class TaxonomyControllerTest { @Autowired private MockMvc mockMvc; - @MockBean + @MockitoBean private TaxonomyService taxonomyServiceMock; @InjectMocks private TaxonomyController taxonomyController; From e39f2d587ee67d386c72a066b1e011597d220aaa Mon Sep 17 00:00:00 2001 From: oleksiybozhykntt Date: Mon, 13 Jan 2025 18:00:08 +0100 Subject: [PATCH 05/20] updated code --- .../controller/TaxonomyControllerTest.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java b/src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java index 1458e71..0922bf5 100644 --- a/src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java +++ b/src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java @@ -9,7 +9,6 @@ import java.util.ArrayList; import java.util.List; import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; @@ -17,7 +16,6 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.FilterType; import org.springframework.data.domain.Sort; -import org.springframework.data.domain.Sort.Order; import org.springframework.http.MediaType; import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.web.servlet.MockMvc; @@ -27,32 +25,32 @@ }) @AutoConfigureMockMvc(addFilters = false) class TaxonomyControllerTest { + @Autowired private MockMvc mockMvc; + @MockitoBean private TaxonomyService taxonomyServiceMock; - @InjectMocks - private TaxonomyController taxonomyController; @Test - void getDistinctOrgType () throws Exception { - List orgTypes = new ArrayList(); - orgTypes.add(0, new DistinctOrganizationTypeDTO() { + void getDistinctOrgType() throws Exception { + List orgTypes = new ArrayList<>(); + orgTypes.add(new DistinctOrganizationTypeDTO() { @Override - public String getOrganizationType () { + public String getOrganizationType() { return "test"; } @Override - public String getOrganizationTypeDescription () { + public String getOrganizationTypeDescription() { return "test"; } }); - Mockito.when(taxonomyServiceMock.getDistinctOrganizationType(Sort.by(Order.asc("organizationType")))).thenReturn(orgTypes); + Mockito.when(taxonomyServiceMock.getDistinctOrganizationType(Sort.by(Sort.Order.asc("organizationType")))).thenReturn(orgTypes); mockMvc.perform(get("/taxonomy/custom/getDistinctOrganizationType") - .param("sort","organizationType,ASC") + .param("sort", "organizationType,ASC") .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) From b7f1f514435b2d6705bf6dc7151d06e2d7dc0c12 Mon Sep 17 00:00:00 2001 From: oleksiybozhykntt Date: Mon, 13 Jan 2025 18:42:26 +0100 Subject: [PATCH 06/20] updated code --- .../organization/service/TaxonomyService.java | 14 +------ .../service/TaxonomyServiceImpl.java | 19 +++++++++ .../controller/TaxonomyControllerTest.java | 39 ++++++++----------- .../ControllerExceptionHandlerTest.java | 4 ++ .../service/TaxonomyServiceTest.java | 2 +- 5 files changed, 42 insertions(+), 36 deletions(-) create mode 100644 src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyServiceImpl.java diff --git a/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java b/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java index 86e6f08..0e2008c 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java +++ b/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java @@ -1,20 +1,10 @@ package it.gov.pagopa.pu.organization.service; import it.gov.pagopa.pu.organization.model.DistinctOrganizationTypeDTO; -import it.gov.pagopa.pu.organization.repository.TaxonomyRepository; import java.util.List; import org.springframework.data.domain.Sort; -import org.springframework.stereotype.Service; -@Service -public class TaxonomyService { - private TaxonomyRepository taxonomyRepository; - public TaxonomyService(TaxonomyRepository taxonomyRepository){ - this.taxonomyRepository = taxonomyRepository; - } - - public List getDistinctOrganizationType(Sort sort){ - return taxonomyRepository.findDistinctOrganizationTypes(sort); - } +public interface TaxonomyService { + List getDistinctOrganizationType(Sort sort); } diff --git a/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyServiceImpl.java b/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyServiceImpl.java new file mode 100644 index 0000000..a353f83 --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyServiceImpl.java @@ -0,0 +1,19 @@ +package it.gov.pagopa.pu.organization.service; + +import it.gov.pagopa.pu.organization.model.DistinctOrganizationTypeDTO; +import it.gov.pagopa.pu.organization.repository.TaxonomyRepository; +import java.util.List; +import org.springframework.data.domain.Sort; +import org.springframework.stereotype.Service; + +@Service +public class TaxonomyServiceImpl implements TaxonomyService{ + private TaxonomyRepository taxonomyRepository; + public TaxonomyServiceImpl(TaxonomyRepository taxonomyRepository){ + this.taxonomyRepository = taxonomyRepository; + } + + public List getDistinctOrganizationType(Sort sort){ + return taxonomyRepository.findDistinctOrganizationTypes(sort); + } +} diff --git a/src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java b/src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java index 0922bf5..fe59d5f 100644 --- a/src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java +++ b/src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java @@ -1,39 +1,35 @@ package it.gov.pagopa.pu.organization.controller; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - import it.gov.pagopa.pu.organization.model.DistinctOrganizationTypeDTO; import it.gov.pagopa.pu.organization.service.TaxonomyService; import java.util.ArrayList; import java.util.List; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.FilterType; import org.springframework.data.domain.Sort; -import org.springframework.http.MediaType; -import org.springframework.test.context.bean.override.mockito.MockitoBean; +import org.springframework.http.ResponseEntity; import org.springframework.test.web.servlet.MockMvc; -@WebMvcTest(value = TaxonomyController.class, excludeFilters = { - @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE) -}) -@AutoConfigureMockMvc(addFilters = false) +@ExtendWith(MockitoExtension.class) class TaxonomyControllerTest { @Autowired private MockMvc mockMvc; - @MockitoBean + @Mock private TaxonomyService taxonomyServiceMock; + @InjectMocks + private TaxonomyController taxonomyController; + @Test - void getDistinctOrgType() throws Exception { + void getDistinctOrgType() { List orgTypes = new ArrayList<>(); orgTypes.add(new DistinctOrganizationTypeDTO() { @Override @@ -49,12 +45,9 @@ public String getOrganizationTypeDescription() { Mockito.when(taxonomyServiceMock.getDistinctOrganizationType(Sort.by(Sort.Order.asc("organizationType")))).thenReturn(orgTypes); - mockMvc.perform(get("/taxonomy/custom/getDistinctOrganizationType") - .param("sort", "organizationType,ASC") - .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andExpect(content().json( - "[{\"organizationType\":\"test\",\"organizationTypeDescription\":\"test\"}]")); + ResponseEntity> orgTypesResult = taxonomyController.getDistinctOrgType(Sort.by(Sort.Order.asc("organizationType"))); + + Assertions.assertEquals(200,orgTypesResult.getStatusCode().value()); + Assertions.assertEquals(orgTypes,orgTypesResult.getBody()); } } diff --git a/src/test/java/it/gov/pagopa/pu/organization/exception/ControllerExceptionHandlerTest.java b/src/test/java/it/gov/pagopa/pu/organization/exception/ControllerExceptionHandlerTest.java index 5d6f319..78e58b9 100644 --- a/src/test/java/it/gov/pagopa/pu/organization/exception/ControllerExceptionHandlerTest.java +++ b/src/test/java/it/gov/pagopa/pu/organization/exception/ControllerExceptionHandlerTest.java @@ -1,6 +1,7 @@ package it.gov.pagopa.pu.organization.exception; import it.gov.pagopa.pu.organization.controller.BrokerController; +import it.gov.pagopa.pu.organization.controller.TaxonomyController; import it.gov.pagopa.pu.organization.service.broker.BrokerService; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -22,6 +23,9 @@ class ControllerExceptionHandlerTest { @MockitoBean private BrokerService brokerServiceMock; + @MockitoBean + private TaxonomyController taxonomyController; + @Autowired private MockMvc mockMvc; diff --git a/src/test/java/it/gov/pagopa/pu/organization/service/TaxonomyServiceTest.java b/src/test/java/it/gov/pagopa/pu/organization/service/TaxonomyServiceTest.java index b33e1c2..587165e 100644 --- a/src/test/java/it/gov/pagopa/pu/organization/service/TaxonomyServiceTest.java +++ b/src/test/java/it/gov/pagopa/pu/organization/service/TaxonomyServiceTest.java @@ -20,7 +20,7 @@ class TaxonomyServiceTest { private TaxonomyRepository taxonomyRepository; @InjectMocks - private TaxonomyService taxonomyService; + private TaxonomyServiceImpl taxonomyService; @Test void testGetDistinctOrganizationType() { From 6deec7cf9a5694298a122eada66621e656d007d8 Mon Sep 17 00:00:00 2001 From: oleksiybozhykntt Date: Tue, 14 Jan 2025 11:21:33 +0100 Subject: [PATCH 07/20] updated code --- openapi/generated.openapi.json | 305 +++++++++--------- .../controller/TaxonomyController.java | 27 -- .../dto/DistinctCollectionReasonDTO.java | 12 - .../dto/DistinctMacroAreaDTO.java | 8 - .../dto/DistinctServiceTypeDTO.java | 11 - .../dto/DistinctTaxonomyCodeDTO.java | 13 - .../model/DistinctCollectionReasonDTO.java | 25 ++ .../model/DistinctMacroAreaCodeDTO.java | 22 ++ .../model/DistinctOrganizationTypeDTO.java | 17 +- .../model/DistinctServiceTypeCodeDTO.java | 23 ++ .../model/DistinctTaxonomyCodeDTO.java | 25 ++ .../pu/organization/model/Taxonomy.java | 12 +- .../repository/TaxonomyRepository.java | 24 +- .../organization/service/TaxonomyService.java | 10 - .../service/TaxonomyServiceImpl.java | 19 -- .../controller/TaxonomyControllerTest.java | 53 --- .../ControllerExceptionHandlerTest.java | 4 - .../service/TaxonomyServiceTest.java | 61 ---- 18 files changed, 269 insertions(+), 402 deletions(-) delete mode 100644 src/main/java/it/gov/pagopa/pu/organization/controller/TaxonomyController.java delete mode 100644 src/main/java/it/gov/pagopa/pu/organization/dto/DistinctCollectionReasonDTO.java delete mode 100644 src/main/java/it/gov/pagopa/pu/organization/dto/DistinctMacroAreaDTO.java delete mode 100644 src/main/java/it/gov/pagopa/pu/organization/dto/DistinctServiceTypeDTO.java delete mode 100644 src/main/java/it/gov/pagopa/pu/organization/dto/DistinctTaxonomyCodeDTO.java create mode 100644 src/main/java/it/gov/pagopa/pu/organization/model/DistinctCollectionReasonDTO.java create mode 100644 src/main/java/it/gov/pagopa/pu/organization/model/DistinctMacroAreaCodeDTO.java create mode 100644 src/main/java/it/gov/pagopa/pu/organization/model/DistinctServiceTypeCodeDTO.java create mode 100644 src/main/java/it/gov/pagopa/pu/organization/model/DistinctTaxonomyCodeDTO.java delete mode 100644 src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java delete mode 100644 src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyServiceImpl.java delete mode 100644 src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java delete mode 100644 src/test/java/it/gov/pagopa/pu/organization/service/TaxonomyServiceTest.java diff --git a/openapi/generated.openapi.json b/openapi/generated.openapi.json index 2e4ae14..1788875 100644 --- a/openapi/generated.openapi.json +++ b/openapi/generated.openapi.json @@ -741,10 +741,10 @@ } } }, - "/crud/taxonomy/search/findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCode" : { + "/crud/taxonomy/search/findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeOrderByCollectionReasonAsc" : { "get" : { "tags" : [ "taxonomy-search-controller" ], - "operationId" : "crud-taxonomy-findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCode", + "operationId" : "crud-taxonomy-findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeOrderByCollectionReasonAsc", "parameters" : [ { "name" : "organizationType", "in" : "query", @@ -781,10 +781,10 @@ } } }, - "/crud/taxonomy/search/findDistinctMacroAreaCodeByOrganizationType" : { + "/crud/taxonomy/search/findDistinctMacroAreaCodeByOrganizationTypeOrderByMacroAreaCodeAsc" : { "get" : { "tags" : [ "taxonomy-search-controller" ], - "operationId" : "crud-taxonomy-findDistinctMacroAreaCodeByOrganizationType", + "operationId" : "crud-taxonomy-findDistinctMacroAreaCodeByOrganizationTypeOrderByMacroAreaCodeAsc", "parameters" : [ { "name" : "organizationType", "in" : "query", @@ -809,10 +809,31 @@ } } }, - "/crud/taxonomy/search/findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCode" : { + "/crud/taxonomy/search/findDistinctOrganizationTypeByOrderByOrganizationTypeAsc" : { "get" : { "tags" : [ "taxonomy-search-controller" ], - "operationId" : "crud-taxonomy-findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCode", + "operationId" : "crud-taxonomy-findDistinctOrganizationTypeByOrderByOrganizationTypeAsc", + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/hal+json" : { + "schema" : { + "$ref" : "#/components/schemas/CollectionModelTaxonomy" + } + } + } + }, + "404" : { + "description" : "Not Found" + } + } + } + }, + "/crud/taxonomy/search/findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCodeOrderByServiceTypeCodeAsc" : { + "get" : { + "tags" : [ "taxonomy-search-controller" ], + "operationId" : "crud-taxonomy-findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCodeOrderByServiceTypeCodeAsc", "parameters" : [ { "name" : "organizationType", "in" : "query", @@ -843,10 +864,10 @@ } } }, - "/crud/taxonomy/search/findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReason" : { + "/crud/taxonomy/search/findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReasonOrderByTaxonomyCodeAsc" : { "get" : { "tags" : [ "taxonomy-search-controller" ], - "operationId" : "crud-taxonomy-findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReason", + "operationId" : "crud-taxonomy-findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReasonOrderByTaxonomyCodeAsc", "parameters" : [ { "name" : "organizationType", "in" : "query", @@ -854,13 +875,13 @@ "type" : "string" } }, { - "name" : "macroAreaName", + "name" : "macroAreaCode", "in" : "query", "schema" : { "type" : "string" } }, { - "name" : "serviceType", + "name" : "serviceTypeCode", "in" : "query", "schema" : { "type" : "string" @@ -1026,27 +1047,6 @@ } } }, - "/taxonomy/custom/getDistinctOrganizationType" : { - "get" : { - "tags" : [ "taxonomy-controller" ], - "operationId" : "getDistinctOrgType", - "responses" : { - "200" : { - "description" : "OK", - "content" : { - "application/hal+json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/DistinctOrganizationTypeDTO" - } - } - } - } - } - } - } - }, "/brokers/apiKey/{brokerId}" : { "get" : { "tags" : [ "Broker" ], @@ -1193,122 +1193,6 @@ } } }, - "Broker" : { - "type" : "object", - "properties" : { - "brokerId" : { - "type" : "integer", - "format" : "int64" - }, - "organizationId" : { - "type" : "integer", - "format" : "int64" - }, - "brokerFiscalCode" : { - "type" : "string" - }, - "brokerName" : { - "type" : "string" - }, - "pagoPaInteractionModel" : { - "type" : "string", - "enum" : [ "SYNC", "SYNC_ACA", "SYNC$GPDPRELOAD", "SYNC_ACA$GPDPRELOAD", "ASYNC_GPD" ] - }, - "stationId" : { - "type" : "string" - }, - "broadcastStationId" : { - "type" : "string" - }, - "syncKey" : { - "type" : "string", - "format" : "byte" - }, - "gpdKey" : { - "type" : "string", - "format" : "byte" - }, - "acaKey" : { - "type" : "string", - "format" : "byte" - }, - "personalisationFe" : { - "$ref" : "#/components/schemas/PersonalisationFe" - }, - "_links" : { - "$ref" : "#/components/schemas/Links" - } - } - }, - "PageMetadata" : { - "type" : "object", - "properties" : { - "size" : { - "type" : "integer", - "format" : "int64" - }, - "totalElements" : { - "type" : "integer", - "format" : "int64" - }, - "totalPages" : { - "type" : "integer", - "format" : "int64" - }, - "number" : { - "type" : "integer", - "format" : "int64" - } - } - }, - "PagedModelBroker" : { - "type" : "object", - "properties" : { - "_embedded" : { - "type" : "object", - "properties" : { - "brokers" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Broker" - } - } - } - }, - "_links" : { - "$ref" : "#/components/schemas/Links" - }, - "page" : { - "$ref" : "#/components/schemas/PageMetadata" - } - } - }, - "PersonalisationFe" : { - "type" : "object", - "properties" : { - "headerAssistanceUrl" : { - "type" : "string" - }, - "logoFooterImg" : { - "type" : "string" - }, - "footerDescText" : { - "type" : "string" - }, - "footerPrivacyInfoUrl" : { - "type" : "string" - }, - "footerGDPRUrl" : { - "type" : "string" - }, - "footerTermsCondUrl" : { - "type" : "string" - }, - "footerAccessibilityUrl" : { - "type" : "string" - } - } - }, "Taxonomy" : { "type" : "object", "properties" : { @@ -1375,6 +1259,27 @@ } } }, + "PageMetadata" : { + "type" : "object", + "properties" : { + "size" : { + "type" : "integer", + "format" : "int64" + }, + "totalElements" : { + "type" : "integer", + "format" : "int64" + }, + "totalPages" : { + "type" : "integer", + "format" : "int64" + }, + "number" : { + "type" : "integer", + "format" : "int64" + } + } + }, "PagedModelTaxonomy" : { "type" : "object", "properties" : { @@ -1551,6 +1456,101 @@ } } }, + "PersonalisationFe" : { + "type" : "object", + "properties" : { + "headerAssistanceUrl" : { + "type" : "string" + }, + "logoFooterImg" : { + "type" : "string" + }, + "footerDescText" : { + "type" : "string" + }, + "footerPrivacyInfoUrl" : { + "type" : "string" + }, + "footerGDPRUrl" : { + "type" : "string" + }, + "footerTermsCondUrl" : { + "type" : "string" + }, + "footerAccessibilityUrl" : { + "type" : "string" + } + } + }, + "Broker" : { + "type" : "object", + "properties" : { + "brokerId" : { + "type" : "integer", + "format" : "int64" + }, + "organizationId" : { + "type" : "integer", + "format" : "int64" + }, + "brokerFiscalCode" : { + "type" : "string" + }, + "brokerName" : { + "type" : "string" + }, + "pagoPaInteractionModel" : { + "type" : "string", + "enum" : [ "SYNC", "SYNC_ACA", "SYNC$GPDPRELOAD", "SYNC_ACA$GPDPRELOAD", "ASYNC_GPD" ] + }, + "stationId" : { + "type" : "string" + }, + "broadcastStationId" : { + "type" : "string" + }, + "syncKey" : { + "type" : "string", + "format" : "byte" + }, + "gpdKey" : { + "type" : "string", + "format" : "byte" + }, + "acaKey" : { + "type" : "string", + "format" : "byte" + }, + "personalisationFe" : { + "$ref" : "#/components/schemas/PersonalisationFe" + }, + "_links" : { + "$ref" : "#/components/schemas/Links" + } + } + }, + "PagedModelBroker" : { + "type" : "object", + "properties" : { + "_embedded" : { + "type" : "object", + "properties" : { + "brokers" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Broker" + } + } + } + }, + "_links" : { + "$ref" : "#/components/schemas/Links" + }, + "page" : { + "$ref" : "#/components/schemas/PageMetadata" + } + } + }, "BrokerRequestBody" : { "type" : "object", "properties" : { @@ -1768,17 +1768,6 @@ } } }, - "DistinctOrganizationTypeDTO" : { - "type" : "object", - "properties" : { - "organizationType" : { - "type" : "string" - }, - "organizationTypeDescription" : { - "type" : "string" - } - } - }, "BrokerApiKeys" : { "type" : "object", "properties" : { diff --git a/src/main/java/it/gov/pagopa/pu/organization/controller/TaxonomyController.java b/src/main/java/it/gov/pagopa/pu/organization/controller/TaxonomyController.java deleted file mode 100644 index 22cd43b..0000000 --- a/src/main/java/it/gov/pagopa/pu/organization/controller/TaxonomyController.java +++ /dev/null @@ -1,27 +0,0 @@ -package it.gov.pagopa.pu.organization.controller; - -import it.gov.pagopa.pu.organization.model.DistinctOrganizationTypeDTO; -import it.gov.pagopa.pu.organization.service.TaxonomyService; -import java.util.List; -import org.springframework.data.domain.Sort; -import org.springframework.http.HttpStatusCode; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class TaxonomyController { - - TaxonomyService taxonomyService; - - public TaxonomyController(TaxonomyService taxonomyService){ - this.taxonomyService = taxonomyService; - } - - @GetMapping("/taxonomy/custom/getDistinctOrganizationType") - public ResponseEntity> getDistinctOrgType(Sort sort){ - return new ResponseEntity<>(taxonomyService.getDistinctOrganizationType(sort), - HttpStatusCode.valueOf(200)); - } - -} diff --git a/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctCollectionReasonDTO.java b/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctCollectionReasonDTO.java deleted file mode 100644 index 88cd558..0000000 --- a/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctCollectionReasonDTO.java +++ /dev/null @@ -1,12 +0,0 @@ -package it.gov.pagopa.pu.organization.dto; - -public interface DistinctCollectionReasonDTO { - String getOrganizationType(); - String getOrganizationTypeDescription(); - String getMacroAreaCode(); - String getMacroAreaName(); - String getServiceTypeCode(); - String getServiceType(); - String getServiceTypeDescription(); - String getCollectionReason(); -} diff --git a/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctMacroAreaDTO.java b/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctMacroAreaDTO.java deleted file mode 100644 index ebe2d79..0000000 --- a/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctMacroAreaDTO.java +++ /dev/null @@ -1,8 +0,0 @@ -package it.gov.pagopa.pu.organization.dto; - -public interface DistinctMacroAreaDTO { - String getOrganizationType(); - String getOrganizationTypeDescription(); - String getMacroAreaCode(); - String getMacroAreaName(); -} diff --git a/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctServiceTypeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctServiceTypeDTO.java deleted file mode 100644 index 02ad835..0000000 --- a/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctServiceTypeDTO.java +++ /dev/null @@ -1,11 +0,0 @@ -package it.gov.pagopa.pu.organization.dto; - -public interface DistinctServiceTypeDTO { - String getOrganizationType(); - String getOrganizationTypeDescription(); - String getMacroAreaCode(); - String getMacroAreaName(); - String getServiceTypeCode(); - String getServiceType(); - String getServiceTypeDescription(); -} diff --git a/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctTaxonomyCodeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctTaxonomyCodeDTO.java deleted file mode 100644 index 13b0ff8..0000000 --- a/src/main/java/it/gov/pagopa/pu/organization/dto/DistinctTaxonomyCodeDTO.java +++ /dev/null @@ -1,13 +0,0 @@ -package it.gov.pagopa.pu.organization.dto; - -public interface DistinctTaxonomyCodeDTO { - String getOrganizationType(); - String getOrganizationTypeDescription(); - String getMacroAreaCode(); - String getMacroAreaName(); - String getServiceTypeCode(); - String getServiceType(); - String getServiceTypeDescription(); - String getCollectionReason(); - String getTaxonomyCode(); -} diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctCollectionReasonDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctCollectionReasonDTO.java new file mode 100644 index 0000000..c6696e7 --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctCollectionReasonDTO.java @@ -0,0 +1,25 @@ +package it.gov.pagopa.pu.organization.model; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +@Entity +@Table(name = "taxonomy") +public class DistinctCollectionReasonDTO { + + @Id + private String organizationType; + private String organizationTypeDescription; + private String macroAreaCode; + private String macroAreaName; + private String macroAreaDescription; + private String serviceTypeCode; + private String serviceType; + private String serviceTypeDescription; + private String collectionReason; +} diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctMacroAreaCodeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctMacroAreaCodeDTO.java new file mode 100644 index 0000000..c0d5fad --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctMacroAreaCodeDTO.java @@ -0,0 +1,22 @@ +package it.gov.pagopa.pu.organization.model; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +@Entity +@Table(name = "taxonomy") +public class DistinctMacroAreaCodeDTO { + + @Id + private String organizationType; + private String organizationTypeDescription; + private String macroAreaCode; + private String macroAreaName; + private String macroAreaDescription; + +} diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctOrganizationTypeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctOrganizationTypeDTO.java index 88cbd5c..56fb3cf 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctOrganizationTypeDTO.java +++ b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctOrganizationTypeDTO.java @@ -1,7 +1,18 @@ package it.gov.pagopa.pu.organization.model; -public interface DistinctOrganizationTypeDTO { - String getOrganizationType(); - String getOrganizationTypeDescription(); +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +@Entity +@Table(name = "taxonomy") +public class DistinctOrganizationTypeDTO { + @Id + private String organizationType; + private String organizationTypeDescription; } diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctServiceTypeCodeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctServiceTypeCodeDTO.java new file mode 100644 index 0000000..93f59c4 --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctServiceTypeCodeDTO.java @@ -0,0 +1,23 @@ +package it.gov.pagopa.pu.organization.model; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +@Entity +@Table(name = "taxonomy") +public class DistinctServiceTypeCodeDTO { + @Id + private String organizationType; + private String organizationTypeDescription; + private String macroAreaCode; + private String macroAreaName; + private String macroAreaDescription; + private String serviceTypeCode; + private String serviceType; + private String serviceTypeDescription; +} diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctTaxonomyCodeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctTaxonomyCodeDTO.java new file mode 100644 index 0000000..0ed1fa6 --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctTaxonomyCodeDTO.java @@ -0,0 +1,25 @@ +package it.gov.pagopa.pu.organization.model; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +@Entity +@Table(name = "taxonomy") +public class DistinctTaxonomyCodeDTO { + @Id + private String organizationType; + private String organizationTypeDescription; + private String macroAreaCode; + private String macroAreaName; + private String macroAreaDescription; + private String serviceTypeCode; + private String serviceType; + private String serviceTypeDescription; + private String collectionReason; + private String taxonomyCode; +} diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/Taxonomy.java b/src/main/java/it/gov/pagopa/pu/organization/model/Taxonomy.java index 8fa2ca6..41a04b1 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/model/Taxonomy.java +++ b/src/main/java/it/gov/pagopa/pu/organization/model/Taxonomy.java @@ -1,17 +1,13 @@ package it.gov.pagopa.pu.organization.model; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.SequenceGenerator; -import jakarta.persistence.Table; -import java.io.Serializable; -import java.sql.Timestamp; +import jakarta.persistence.*; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; +import java.sql.Timestamp; + @Entity @Table(name = "taxonomy") @AllArgsConstructor diff --git a/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java b/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java index abe77b3..016c7ce 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java +++ b/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java @@ -1,28 +1,22 @@ package it.gov.pagopa.pu.organization.repository; +import it.gov.pagopa.pu.organization.model.DistinctCollectionReasonDTO; +import it.gov.pagopa.pu.organization.model.DistinctMacroAreaCodeDTO; import it.gov.pagopa.pu.organization.model.DistinctOrganizationTypeDTO; +import it.gov.pagopa.pu.organization.model.DistinctServiceTypeCodeDTO; +import it.gov.pagopa.pu.organization.model.DistinctTaxonomyCodeDTO; import it.gov.pagopa.pu.organization.model.Taxonomy; import java.util.List; -import org.springframework.data.domain.Sort; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; import org.springframework.data.rest.core.annotation.RepositoryRestResource; -import org.springframework.data.rest.core.annotation.RestResource; @RepositoryRestResource(collectionResourceRel = "taxonomy", path = "taxonomy") public interface TaxonomyRepository extends JpaRepository { - //@Query("select distinct t.organizationType as organizationType, t.organizationTypeDescription as organizationTypeDescription from Taxonomy t") - @RestResource(exported = false) - @Query(value = "select distinct t.organizationType as organizationType, t.organizationTypeDescription as organizationTypeDescription from Taxonomy t") - List findDistinctOrganizationTypes(Sort sort); - - List findDistinctMacroAreaCodeByOrganizationType(String organizationType); - - List findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCode(String organizationType,String macroAreaCode); - - List findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCode(String organizationType,String macroAreaCode,String serviceTypeCode); - - List findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReason(String organizationType,String macroAreaName,String serviceType,String collectionReason); + List findDistinctOrganizationTypeByOrderByOrganizationTypeAsc(); + List findDistinctMacroAreaCodeByOrganizationTypeOrderByMacroAreaCodeAsc(String organizationType); + List findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCodeOrderByServiceTypeCodeAsc(String organizationType,String macroAreaCode); + List findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeOrderByCollectionReasonAsc(String organizationType,String macroAreaCode,String serviceTypeCode); + List findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReasonOrderByTaxonomyCodeAsc(String organizationType,String macroAreaCode,String serviceTypeCode,String collectionReason); } diff --git a/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java b/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java deleted file mode 100644 index 0e2008c..0000000 --- a/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyService.java +++ /dev/null @@ -1,10 +0,0 @@ -package it.gov.pagopa.pu.organization.service; - -import it.gov.pagopa.pu.organization.model.DistinctOrganizationTypeDTO; -import java.util.List; -import org.springframework.data.domain.Sort; - -public interface TaxonomyService { - List getDistinctOrganizationType(Sort sort); - -} diff --git a/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyServiceImpl.java b/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyServiceImpl.java deleted file mode 100644 index a353f83..0000000 --- a/src/main/java/it/gov/pagopa/pu/organization/service/TaxonomyServiceImpl.java +++ /dev/null @@ -1,19 +0,0 @@ -package it.gov.pagopa.pu.organization.service; - -import it.gov.pagopa.pu.organization.model.DistinctOrganizationTypeDTO; -import it.gov.pagopa.pu.organization.repository.TaxonomyRepository; -import java.util.List; -import org.springframework.data.domain.Sort; -import org.springframework.stereotype.Service; - -@Service -public class TaxonomyServiceImpl implements TaxonomyService{ - private TaxonomyRepository taxonomyRepository; - public TaxonomyServiceImpl(TaxonomyRepository taxonomyRepository){ - this.taxonomyRepository = taxonomyRepository; - } - - public List getDistinctOrganizationType(Sort sort){ - return taxonomyRepository.findDistinctOrganizationTypes(sort); - } -} diff --git a/src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java b/src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java deleted file mode 100644 index fe59d5f..0000000 --- a/src/test/java/it/gov/pagopa/pu/organization/controller/TaxonomyControllerTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package it.gov.pagopa.pu.organization.controller; - -import it.gov.pagopa.pu.organization.model.DistinctOrganizationTypeDTO; -import it.gov.pagopa.pu.organization.service.TaxonomyService; -import java.util.ArrayList; -import java.util.List; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Sort; -import org.springframework.http.ResponseEntity; -import org.springframework.test.web.servlet.MockMvc; - -@ExtendWith(MockitoExtension.class) -class TaxonomyControllerTest { - - @Autowired - private MockMvc mockMvc; - - @Mock - private TaxonomyService taxonomyServiceMock; - - @InjectMocks - private TaxonomyController taxonomyController; - - @Test - void getDistinctOrgType() { - List orgTypes = new ArrayList<>(); - orgTypes.add(new DistinctOrganizationTypeDTO() { - @Override - public String getOrganizationType() { - return "test"; - } - - @Override - public String getOrganizationTypeDescription() { - return "test"; - } - }); - - Mockito.when(taxonomyServiceMock.getDistinctOrganizationType(Sort.by(Sort.Order.asc("organizationType")))).thenReturn(orgTypes); - - ResponseEntity> orgTypesResult = taxonomyController.getDistinctOrgType(Sort.by(Sort.Order.asc("organizationType"))); - - Assertions.assertEquals(200,orgTypesResult.getStatusCode().value()); - Assertions.assertEquals(orgTypes,orgTypesResult.getBody()); - } -} diff --git a/src/test/java/it/gov/pagopa/pu/organization/exception/ControllerExceptionHandlerTest.java b/src/test/java/it/gov/pagopa/pu/organization/exception/ControllerExceptionHandlerTest.java index 78e58b9..5d6f319 100644 --- a/src/test/java/it/gov/pagopa/pu/organization/exception/ControllerExceptionHandlerTest.java +++ b/src/test/java/it/gov/pagopa/pu/organization/exception/ControllerExceptionHandlerTest.java @@ -1,7 +1,6 @@ package it.gov.pagopa.pu.organization.exception; import it.gov.pagopa.pu.organization.controller.BrokerController; -import it.gov.pagopa.pu.organization.controller.TaxonomyController; import it.gov.pagopa.pu.organization.service.broker.BrokerService; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -23,9 +22,6 @@ class ControllerExceptionHandlerTest { @MockitoBean private BrokerService brokerServiceMock; - @MockitoBean - private TaxonomyController taxonomyController; - @Autowired private MockMvc mockMvc; diff --git a/src/test/java/it/gov/pagopa/pu/organization/service/TaxonomyServiceTest.java b/src/test/java/it/gov/pagopa/pu/organization/service/TaxonomyServiceTest.java deleted file mode 100644 index 587165e..0000000 --- a/src/test/java/it/gov/pagopa/pu/organization/service/TaxonomyServiceTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package it.gov.pagopa.pu.organization.service; - -import static org.junit.jupiter.api.Assertions.*; - -import it.gov.pagopa.pu.organization.model.DistinctOrganizationTypeDTO; -import it.gov.pagopa.pu.organization.repository.TaxonomyRepository; -import java.util.Arrays; -import java.util.List; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.data.domain.Sort; - -@ExtendWith(MockitoExtension.class) -class TaxonomyServiceTest { - @Mock - private TaxonomyRepository taxonomyRepository; - - @InjectMocks - private TaxonomyServiceImpl taxonomyService; - - @Test - void testGetDistinctOrganizationType() { - // Arrange - Sort sort = Sort.by("name"); - DistinctOrganizationTypeDTO dto1 = new DistinctOrganizationTypeDTO() { - @Override - public String getOrganizationType () { - return null; - } - - @Override - public String getOrganizationTypeDescription () { - return null; - } - }; - DistinctOrganizationTypeDTO dto2 = new DistinctOrganizationTypeDTO() { - @Override - public String getOrganizationType () { - return null; - } - - @Override - public String getOrganizationTypeDescription () { - return null; - } - }; - List expectedList = Arrays.asList(dto1, dto2); - Mockito.when(taxonomyRepository.findDistinctOrganizationTypes(sort)).thenReturn(expectedList); - - // Act - List result = taxonomyService.getDistinctOrganizationType(sort); - - // Assert - assertEquals(expectedList, result); - Mockito.verify(taxonomyRepository, Mockito.times(1)).findDistinctOrganizationTypes(sort); - } -} From fff0a88f38f053e81fddfd00d3d9af70b3e1584a Mon Sep 17 00:00:00 2001 From: oleksiybozhykntt Date: Tue, 14 Jan 2025 11:27:12 +0100 Subject: [PATCH 08/20] Update src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java Co-authored-by: antonioT90 <34568575+antonioT90@users.noreply.github.com> --- .../pagopa/pu/organization/repository/TaxonomyRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java b/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java index 016c7ce..9d5ac23 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java +++ b/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java @@ -10,7 +10,7 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.rest.core.annotation.RepositoryRestResource; -@RepositoryRestResource(collectionResourceRel = "taxonomy", path = "taxonomy") +@RepositoryRestResource(path = "taxonomies") public interface TaxonomyRepository extends JpaRepository { List findDistinctOrganizationTypeByOrderByOrganizationTypeAsc(); From e5f1ac743f7b49f79f7532e0f3055e87efb3edd6 Mon Sep 17 00:00:00 2001 From: oleksiybozhykntt Date: Tue, 14 Jan 2025 11:58:37 +0100 Subject: [PATCH 09/20] Update src/main/java/it/gov/pagopa/pu/organization/model/DistinctCollectionReasonDTO.java Co-authored-by: antonioT90 <34568575+antonioT90@users.noreply.github.com> --- .../pu/organization/model/DistinctCollectionReasonDTO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctCollectionReasonDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctCollectionReasonDTO.java index c6696e7..48a3418 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctCollectionReasonDTO.java +++ b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctCollectionReasonDTO.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.pu.organization.model; +package it.gov.pagopa.pu.organization.model.taxonomy; import jakarta.persistence.Entity; import jakarta.persistence.Id; From 68f5082f6f49d21842f2f36e765d0a1b6f61f219 Mon Sep 17 00:00:00 2001 From: oleksiybozhykntt Date: Tue, 14 Jan 2025 11:58:44 +0100 Subject: [PATCH 10/20] Update src/main/java/it/gov/pagopa/pu/organization/model/DistinctCollectionReasonDTO.java Co-authored-by: antonioT90 <34568575+antonioT90@users.noreply.github.com> --- .../pu/organization/model/DistinctCollectionReasonDTO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctCollectionReasonDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctCollectionReasonDTO.java index 48a3418..f184c80 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctCollectionReasonDTO.java +++ b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctCollectionReasonDTO.java @@ -10,7 +10,7 @@ @AllArgsConstructor @Entity @Table(name = "taxonomy") -public class DistinctCollectionReasonDTO { +public class TaxonomyCollectionReasonDTO { @Id private String organizationType; From 92607d1695095ac3612eee4a4b9e521562d92c2a Mon Sep 17 00:00:00 2001 From: oleksiybozhykntt Date: Tue, 14 Jan 2025 11:58:52 +0100 Subject: [PATCH 11/20] Update src/main/java/it/gov/pagopa/pu/organization/model/DistinctMacroAreaCodeDTO.java Co-authored-by: antonioT90 <34568575+antonioT90@users.noreply.github.com> --- .../pagopa/pu/organization/model/DistinctMacroAreaCodeDTO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctMacroAreaCodeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctMacroAreaCodeDTO.java index c0d5fad..fe3aab8 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctMacroAreaCodeDTO.java +++ b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctMacroAreaCodeDTO.java @@ -10,7 +10,7 @@ @AllArgsConstructor @Entity @Table(name = "taxonomy") -public class DistinctMacroAreaCodeDTO { +public class TaxonomyMacroAreaCodeDTO { @Id private String organizationType; From 7e9f0a00e3845ea3b89dd1703c1c0c79852796d8 Mon Sep 17 00:00:00 2001 From: oleksiybozhykntt Date: Tue, 14 Jan 2025 11:58:58 +0100 Subject: [PATCH 12/20] Update src/main/java/it/gov/pagopa/pu/organization/model/DistinctOrganizationTypeDTO.java Co-authored-by: antonioT90 <34568575+antonioT90@users.noreply.github.com> --- .../pu/organization/model/DistinctOrganizationTypeDTO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctOrganizationTypeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctOrganizationTypeDTO.java index 56fb3cf..af8808f 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctOrganizationTypeDTO.java +++ b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctOrganizationTypeDTO.java @@ -10,7 +10,7 @@ @AllArgsConstructor @Entity @Table(name = "taxonomy") -public class DistinctOrganizationTypeDTO { +public class TaxonomyOrganizationTypeDTO { @Id private String organizationType; private String organizationTypeDescription; From c5c5252a264718685f0ba7b56f67589bf58d6d4d Mon Sep 17 00:00:00 2001 From: oleksiybozhykntt Date: Tue, 14 Jan 2025 11:59:03 +0100 Subject: [PATCH 13/20] Update src/main/java/it/gov/pagopa/pu/organization/model/DistinctServiceTypeCodeDTO.java Co-authored-by: antonioT90 <34568575+antonioT90@users.noreply.github.com> --- .../pu/organization/model/DistinctServiceTypeCodeDTO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctServiceTypeCodeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctServiceTypeCodeDTO.java index 93f59c4..cee5059 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctServiceTypeCodeDTO.java +++ b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctServiceTypeCodeDTO.java @@ -10,7 +10,7 @@ @AllArgsConstructor @Entity @Table(name = "taxonomy") -public class DistinctServiceTypeCodeDTO { +public class TaxonomyServiceTypeCodeDTO { @Id private String organizationType; private String organizationTypeDescription; From 06d4a12ec0d1fe33885323b3311f0051c0d93a37 Mon Sep 17 00:00:00 2001 From: oleksiybozhykntt Date: Tue, 14 Jan 2025 11:59:08 +0100 Subject: [PATCH 14/20] Update src/main/java/it/gov/pagopa/pu/organization/model/DistinctTaxonomyCodeDTO.java Co-authored-by: antonioT90 <34568575+antonioT90@users.noreply.github.com> --- .../pagopa/pu/organization/model/DistinctTaxonomyCodeDTO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctTaxonomyCodeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctTaxonomyCodeDTO.java index 0ed1fa6..1285c3c 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctTaxonomyCodeDTO.java +++ b/src/main/java/it/gov/pagopa/pu/organization/model/DistinctTaxonomyCodeDTO.java @@ -10,7 +10,7 @@ @AllArgsConstructor @Entity @Table(name = "taxonomy") -public class DistinctTaxonomyCodeDTO { +public class TaxonomyCodeDTO { @Id private String organizationType; private String organizationTypeDescription; From ab8c91c8c769dc3b546a0eb8443b12bddb2ea190 Mon Sep 17 00:00:00 2001 From: oleksiybozhykntt Date: Tue, 14 Jan 2025 12:16:55 +0100 Subject: [PATCH 15/20] updated code --- .../TaxonomyCodeDTO.java} | 4 +++- .../TaxonomyCollectionReasonDTO.java} | 5 +++++ .../TaxonomyMacroAreaCodeDTO.java} | 5 ++++- .../TaxonomyOrganizationTypeDTO.java} | 2 +- .../TaxonomyServiceTypeCodeDTO.java} | 6 +++++- .../repository/TaxonomyRepository.java | 20 +++++++++---------- 6 files changed, 28 insertions(+), 14 deletions(-) rename src/main/java/it/gov/pagopa/pu/organization/model/{DistinctTaxonomyCodeDTO.java => taxonomy/TaxonomyCodeDTO.java} (83%) rename src/main/java/it/gov/pagopa/pu/organization/model/{DistinctCollectionReasonDTO.java => taxonomy/TaxonomyCollectionReasonDTO.java} (86%) rename src/main/java/it/gov/pagopa/pu/organization/model/{DistinctMacroAreaCodeDTO.java => taxonomy/TaxonomyMacroAreaCodeDTO.java} (76%) rename src/main/java/it/gov/pagopa/pu/organization/model/{DistinctOrganizationTypeDTO.java => taxonomy/TaxonomyOrganizationTypeDTO.java} (86%) rename src/main/java/it/gov/pagopa/pu/organization/model/{DistinctServiceTypeCodeDTO.java => taxonomy/TaxonomyServiceTypeCodeDTO.java} (79%) diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctTaxonomyCodeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyCodeDTO.java similarity index 83% rename from src/main/java/it/gov/pagopa/pu/organization/model/DistinctTaxonomyCodeDTO.java rename to src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyCodeDTO.java index 1285c3c..1843fbb 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctTaxonomyCodeDTO.java +++ b/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyCodeDTO.java @@ -1,7 +1,8 @@ -package it.gov.pagopa.pu.organization.model; +package it.gov.pagopa.pu.organization.model.taxonomy; import jakarta.persistence.Entity; import jakarta.persistence.Id; +import jakarta.persistence.IdClass; import jakarta.persistence.Table; import lombok.AllArgsConstructor; import lombok.Data; @@ -10,6 +11,7 @@ @AllArgsConstructor @Entity @Table(name = "taxonomy") +@IdClass(TaxonomyCodeDTO.class) public class TaxonomyCodeDTO { @Id private String organizationType; diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctCollectionReasonDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyCollectionReasonDTO.java similarity index 86% rename from src/main/java/it/gov/pagopa/pu/organization/model/DistinctCollectionReasonDTO.java rename to src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyCollectionReasonDTO.java index f184c80..80e4b2f 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctCollectionReasonDTO.java +++ b/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyCollectionReasonDTO.java @@ -2,6 +2,7 @@ import jakarta.persistence.Entity; import jakarta.persistence.Id; +import jakarta.persistence.IdClass; import jakarta.persistence.Table; import lombok.AllArgsConstructor; import lombok.Data; @@ -10,16 +11,20 @@ @AllArgsConstructor @Entity @Table(name = "taxonomy") +@IdClass(TaxonomyCollectionReasonDTO.class) public class TaxonomyCollectionReasonDTO { @Id private String organizationType; private String organizationTypeDescription; + @Id private String macroAreaCode; private String macroAreaName; private String macroAreaDescription; + @Id private String serviceTypeCode; private String serviceType; private String serviceTypeDescription; + @Id private String collectionReason; } diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctMacroAreaCodeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyMacroAreaCodeDTO.java similarity index 76% rename from src/main/java/it/gov/pagopa/pu/organization/model/DistinctMacroAreaCodeDTO.java rename to src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyMacroAreaCodeDTO.java index fe3aab8..95558b3 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctMacroAreaCodeDTO.java +++ b/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyMacroAreaCodeDTO.java @@ -1,7 +1,8 @@ -package it.gov.pagopa.pu.organization.model; +package it.gov.pagopa.pu.organization.model.taxonomy; import jakarta.persistence.Entity; import jakarta.persistence.Id; +import jakarta.persistence.IdClass; import jakarta.persistence.Table; import lombok.AllArgsConstructor; import lombok.Data; @@ -10,11 +11,13 @@ @AllArgsConstructor @Entity @Table(name = "taxonomy") +@IdClass(TaxonomyMacroAreaCodeDTO.class) public class TaxonomyMacroAreaCodeDTO { @Id private String organizationType; private String organizationTypeDescription; + @Id private String macroAreaCode; private String macroAreaName; private String macroAreaDescription; diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctOrganizationTypeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyOrganizationTypeDTO.java similarity index 86% rename from src/main/java/it/gov/pagopa/pu/organization/model/DistinctOrganizationTypeDTO.java rename to src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyOrganizationTypeDTO.java index af8808f..316ab95 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctOrganizationTypeDTO.java +++ b/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyOrganizationTypeDTO.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.pu.organization.model; +package it.gov.pagopa.pu.organization.model.taxonomy; import jakarta.persistence.Entity; import jakarta.persistence.Id; diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctServiceTypeCodeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyServiceTypeCodeDTO.java similarity index 79% rename from src/main/java/it/gov/pagopa/pu/organization/model/DistinctServiceTypeCodeDTO.java rename to src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyServiceTypeCodeDTO.java index cee5059..e181810 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/model/DistinctServiceTypeCodeDTO.java +++ b/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyServiceTypeCodeDTO.java @@ -1,7 +1,8 @@ -package it.gov.pagopa.pu.organization.model; +package it.gov.pagopa.pu.organization.model.taxonomy; import jakarta.persistence.Entity; import jakarta.persistence.Id; +import jakarta.persistence.IdClass; import jakarta.persistence.Table; import lombok.AllArgsConstructor; import lombok.Data; @@ -10,13 +11,16 @@ @AllArgsConstructor @Entity @Table(name = "taxonomy") +@IdClass(TaxonomyServiceTypeCodeDTO.class) public class TaxonomyServiceTypeCodeDTO { @Id private String organizationType; private String organizationTypeDescription; + @Id private String macroAreaCode; private String macroAreaName; private String macroAreaDescription; + @Id private String serviceTypeCode; private String serviceType; private String serviceTypeDescription; diff --git a/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java b/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java index 9d5ac23..c8fe482 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java +++ b/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java @@ -1,11 +1,11 @@ package it.gov.pagopa.pu.organization.repository; -import it.gov.pagopa.pu.organization.model.DistinctCollectionReasonDTO; -import it.gov.pagopa.pu.organization.model.DistinctMacroAreaCodeDTO; -import it.gov.pagopa.pu.organization.model.DistinctOrganizationTypeDTO; -import it.gov.pagopa.pu.organization.model.DistinctServiceTypeCodeDTO; -import it.gov.pagopa.pu.organization.model.DistinctTaxonomyCodeDTO; import it.gov.pagopa.pu.organization.model.Taxonomy; +import it.gov.pagopa.pu.organization.model.taxonomy.TaxonomyCodeDTO; +import it.gov.pagopa.pu.organization.model.taxonomy.TaxonomyCollectionReasonDTO; +import it.gov.pagopa.pu.organization.model.taxonomy.TaxonomyMacroAreaCodeDTO; +import it.gov.pagopa.pu.organization.model.taxonomy.TaxonomyOrganizationTypeDTO; +import it.gov.pagopa.pu.organization.model.taxonomy.TaxonomyServiceTypeCodeDTO; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.rest.core.annotation.RepositoryRestResource; @@ -13,10 +13,10 @@ @RepositoryRestResource(path = "taxonomies") public interface TaxonomyRepository extends JpaRepository { - List findDistinctOrganizationTypeByOrderByOrganizationTypeAsc(); - List findDistinctMacroAreaCodeByOrganizationTypeOrderByMacroAreaCodeAsc(String organizationType); - List findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCodeOrderByServiceTypeCodeAsc(String organizationType,String macroAreaCode); - List findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeOrderByCollectionReasonAsc(String organizationType,String macroAreaCode,String serviceTypeCode); - List findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReasonOrderByTaxonomyCodeAsc(String organizationType,String macroAreaCode,String serviceTypeCode,String collectionReason); + List findDistinctOrganizationTypeByOrderByOrganizationTypeAsc(); + List findDistinctMacroAreaCodeByOrganizationTypeOrderByMacroAreaCodeAsc(String organizationType); + List findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCodeOrderByServiceTypeCodeAsc(String organizationType,String macroAreaCode); + List findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeOrderByCollectionReasonAsc(String organizationType,String macroAreaCode,String serviceTypeCode); + List findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReasonOrderByTaxonomyCodeAsc(String organizationType,String macroAreaCode,String serviceTypeCode,String collectionReason); } From 436886480ce5ab4b21b2b492aebe003855d64674 Mon Sep 17 00:00:00 2001 From: oleksiybozhykntt Date: Tue, 14 Jan 2025 12:24:59 +0100 Subject: [PATCH 16/20] Update src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyCodeDTO.java Co-authored-by: antonioT90 <34568575+antonioT90@users.noreply.github.com> --- .../pu/organization/model/taxonomy/TaxonomyCodeDTO.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyCodeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyCodeDTO.java index 1843fbb..fc6bb86 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyCodeDTO.java +++ b/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyCodeDTO.java @@ -16,12 +16,16 @@ public class TaxonomyCodeDTO { @Id private String organizationType; private String organizationTypeDescription; + @Id private String macroAreaCode; private String macroAreaName; private String macroAreaDescription; + @Id private String serviceTypeCode; private String serviceType; private String serviceTypeDescription; + @Id private String collectionReason; + @Id private String taxonomyCode; } From b5bc8ffac5044a7f6a29766a0313cee12dd6c959 Mon Sep 17 00:00:00 2001 From: oleksiybozhykntt Date: Tue, 14 Jan 2025 12:32:05 +0100 Subject: [PATCH 17/20] updated code --- openapi/generated.openapi.json | 284 ++++++++++++++++----------------- 1 file changed, 142 insertions(+), 142 deletions(-) diff --git a/openapi/generated.openapi.json b/openapi/generated.openapi.json index 1788875..3222d5f 100644 --- a/openapi/generated.openapi.json +++ b/openapi/generated.openapi.json @@ -625,10 +625,10 @@ } } }, - "/crud/profile/taxonomy" : { + "/crud/profile/taxonomies" : { "get" : { "tags" : [ "profile-controller" ], - "operationId" : "crud-profile-taxonomy", + "operationId" : "crud-profile-taxonomies", "responses" : { "200" : { "description" : "OK", @@ -653,7 +653,7 @@ } } }, - "/crud/taxonomy" : { + "/crud/taxonomies" : { "get" : { "tags" : [ "taxonomy-entity-controller" ], "description" : "get-taxonomy", @@ -741,10 +741,10 @@ } } }, - "/crud/taxonomy/search/findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeOrderByCollectionReasonAsc" : { + "/crud/taxonomies/search/findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeOrderByCollectionReasonAsc" : { "get" : { "tags" : [ "taxonomy-search-controller" ], - "operationId" : "crud-taxonomy-findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeOrderByCollectionReasonAsc", + "operationId" : "crud-taxonomies-findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeOrderByCollectionReasonAsc", "parameters" : [ { "name" : "organizationType", "in" : "query", @@ -781,10 +781,10 @@ } } }, - "/crud/taxonomy/search/findDistinctMacroAreaCodeByOrganizationTypeOrderByMacroAreaCodeAsc" : { + "/crud/taxonomies/search/findDistinctMacroAreaCodeByOrganizationTypeOrderByMacroAreaCodeAsc" : { "get" : { "tags" : [ "taxonomy-search-controller" ], - "operationId" : "crud-taxonomy-findDistinctMacroAreaCodeByOrganizationTypeOrderByMacroAreaCodeAsc", + "operationId" : "crud-taxonomies-findDistinctMacroAreaCodeByOrganizationTypeOrderByMacroAreaCodeAsc", "parameters" : [ { "name" : "organizationType", "in" : "query", @@ -809,10 +809,10 @@ } } }, - "/crud/taxonomy/search/findDistinctOrganizationTypeByOrderByOrganizationTypeAsc" : { + "/crud/taxonomies/search/findDistinctOrganizationTypeByOrderByOrganizationTypeAsc" : { "get" : { "tags" : [ "taxonomy-search-controller" ], - "operationId" : "crud-taxonomy-findDistinctOrganizationTypeByOrderByOrganizationTypeAsc", + "operationId" : "crud-taxonomies-findDistinctOrganizationTypeByOrderByOrganizationTypeAsc", "responses" : { "200" : { "description" : "OK", @@ -830,10 +830,10 @@ } } }, - "/crud/taxonomy/search/findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCodeOrderByServiceTypeCodeAsc" : { + "/crud/taxonomies/search/findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCodeOrderByServiceTypeCodeAsc" : { "get" : { "tags" : [ "taxonomy-search-controller" ], - "operationId" : "crud-taxonomy-findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCodeOrderByServiceTypeCodeAsc", + "operationId" : "crud-taxonomies-findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCodeOrderByServiceTypeCodeAsc", "parameters" : [ { "name" : "organizationType", "in" : "query", @@ -864,10 +864,10 @@ } } }, - "/crud/taxonomy/search/findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReasonOrderByTaxonomyCodeAsc" : { + "/crud/taxonomies/search/findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReasonOrderByTaxonomyCodeAsc" : { "get" : { "tags" : [ "taxonomy-search-controller" ], - "operationId" : "crud-taxonomy-findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReasonOrderByTaxonomyCodeAsc", + "operationId" : "crud-taxonomies-findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReasonOrderByTaxonomyCodeAsc", "parameters" : [ { "name" : "organizationType", "in" : "query", @@ -910,7 +910,7 @@ } } }, - "/crud/taxonomy/{id}" : { + "/crud/taxonomies/{id}" : { "get" : { "tags" : [ "taxonomy-entity-controller" ], "description" : "get-taxonomy", @@ -1193,134 +1193,6 @@ } } }, - "Taxonomy" : { - "type" : "object", - "properties" : { - "taxonomyId" : { - "type" : "integer", - "format" : "int64" - }, - "version" : { - "type" : "integer", - "format" : "int64" - }, - "organizationType" : { - "type" : "string" - }, - "organizationTypeDescription" : { - "type" : "string" - }, - "macroAreaCode" : { - "type" : "string" - }, - "macroAreaName" : { - "type" : "string" - }, - "macroAreaDescription" : { - "type" : "string" - }, - "serviceTypeCode" : { - "type" : "string" - }, - "serviceType" : { - "type" : "string" - }, - "serviceTypeDescription" : { - "type" : "string" - }, - "collectionReason" : { - "type" : "string" - }, - "startDateValidity" : { - "type" : "string", - "format" : "date-time" - }, - "endDateOfValidity" : { - "type" : "string", - "format" : "date-time" - }, - "taxonomyCode" : { - "type" : "string" - }, - "creationDate" : { - "type" : "string", - "format" : "date-time" - }, - "lastModifiedDate" : { - "type" : "string", - "format" : "date-time" - }, - "versionMyPay" : { - "type" : "integer", - "format" : "int64" - }, - "_links" : { - "$ref" : "#/components/schemas/Links" - } - } - }, - "PageMetadata" : { - "type" : "object", - "properties" : { - "size" : { - "type" : "integer", - "format" : "int64" - }, - "totalElements" : { - "type" : "integer", - "format" : "int64" - }, - "totalPages" : { - "type" : "integer", - "format" : "int64" - }, - "number" : { - "type" : "integer", - "format" : "int64" - } - } - }, - "PagedModelTaxonomy" : { - "type" : "object", - "properties" : { - "_embedded" : { - "type" : "object", - "properties" : { - "taxonomy" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Taxonomy" - } - } - } - }, - "_links" : { - "$ref" : "#/components/schemas/Links" - }, - "page" : { - "$ref" : "#/components/schemas/PageMetadata" - } - } - }, - "CollectionModelTaxonomy" : { - "type" : "object", - "properties" : { - "_embedded" : { - "type" : "object", - "properties" : { - "taxonomy" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Taxonomy" - } - } - } - }, - "_links" : { - "$ref" : "#/components/schemas/Links" - } - } - }, "Organization" : { "type" : "object", "properties" : { @@ -1434,6 +1306,27 @@ } } }, + "PageMetadata" : { + "type" : "object", + "properties" : { + "size" : { + "type" : "integer", + "format" : "int64" + }, + "totalElements" : { + "type" : "integer", + "format" : "int64" + }, + "totalPages" : { + "type" : "integer", + "format" : "int64" + }, + "number" : { + "type" : "integer", + "format" : "int64" + } + } + }, "PagedModelOrganization" : { "type" : "object", "properties" : { @@ -1551,6 +1444,113 @@ } } }, + "Taxonomy" : { + "type" : "object", + "properties" : { + "taxonomyId" : { + "type" : "integer", + "format" : "int64" + }, + "version" : { + "type" : "integer", + "format" : "int64" + }, + "organizationType" : { + "type" : "string" + }, + "organizationTypeDescription" : { + "type" : "string" + }, + "macroAreaCode" : { + "type" : "string" + }, + "macroAreaName" : { + "type" : "string" + }, + "macroAreaDescription" : { + "type" : "string" + }, + "serviceTypeCode" : { + "type" : "string" + }, + "serviceType" : { + "type" : "string" + }, + "serviceTypeDescription" : { + "type" : "string" + }, + "collectionReason" : { + "type" : "string" + }, + "startDateValidity" : { + "type" : "string", + "format" : "date-time" + }, + "endDateOfValidity" : { + "type" : "string", + "format" : "date-time" + }, + "taxonomyCode" : { + "type" : "string" + }, + "creationDate" : { + "type" : "string", + "format" : "date-time" + }, + "lastModifiedDate" : { + "type" : "string", + "format" : "date-time" + }, + "versionMyPay" : { + "type" : "integer", + "format" : "int64" + }, + "_links" : { + "$ref" : "#/components/schemas/Links" + } + } + }, + "PagedModelTaxonomy" : { + "type" : "object", + "properties" : { + "_embedded" : { + "type" : "object", + "properties" : { + "taxonomies" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Taxonomy" + } + } + } + }, + "_links" : { + "$ref" : "#/components/schemas/Links" + }, + "page" : { + "$ref" : "#/components/schemas/PageMetadata" + } + } + }, + "CollectionModelTaxonomy" : { + "type" : "object", + "properties" : { + "_embedded" : { + "type" : "object", + "properties" : { + "taxonomies" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Taxonomy" + } + } + } + }, + "_links" : { + "$ref" : "#/components/schemas/Links" + } + } + }, "BrokerRequestBody" : { "type" : "object", "properties" : { From b3701e6fa2858f531319f1b962343379b795ed30 Mon Sep 17 00:00:00 2001 From: oleksiybozhykntt Date: Tue, 14 Jan 2025 15:13:07 +0100 Subject: [PATCH 18/20] updated code --- openapi/generated.openapi.json | 434 +++++++++++++----- .../config/WebSecurityConfig.java | 2 +- .../taxonomy/TaxonomyOrganizationTypeDTO.java | 2 + .../repository/TaxonomyRepository.java | 12 - .../taxonomy/TaxonomyCodeRepository.java | 14 + .../TaxonomyCollectionReasonRepository.java | 14 + .../TaxonomyMacroAreaCodeRepository.java | 14 + .../TaxonomyOrganizationTypeRepository.java | 12 + .../TaxonomyServiceTypeCodeRepository.java | 14 + 9 files changed, 397 insertions(+), 121 deletions(-) create mode 100644 src/main/java/it/gov/pagopa/pu/organization/repository/taxonomy/TaxonomyCodeRepository.java create mode 100644 src/main/java/it/gov/pagopa/pu/organization/repository/taxonomy/TaxonomyCollectionReasonRepository.java create mode 100644 src/main/java/it/gov/pagopa/pu/organization/repository/taxonomy/TaxonomyMacroAreaCodeRepository.java create mode 100644 src/main/java/it/gov/pagopa/pu/organization/repository/taxonomy/TaxonomyOrganizationTypeRepository.java create mode 100644 src/main/java/it/gov/pagopa/pu/organization/repository/taxonomy/TaxonomyServiceTypeCodeRepository.java diff --git a/openapi/generated.openapi.json b/openapi/generated.openapi.json index 3222d5f..7b03139 100644 --- a/openapi/generated.openapi.json +++ b/openapi/generated.openapi.json @@ -741,10 +741,10 @@ } } }, - "/crud/taxonomies/search/findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeOrderByCollectionReasonAsc" : { + "/crud/taxonomies-collection-reason/search/findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeOrderByCollectionReasonAsc" : { "get" : { - "tags" : [ "taxonomy-search-controller" ], - "operationId" : "crud-taxonomies-findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeOrderByCollectionReasonAsc", + "tags" : [ "taxonomy-collection-reason-dto-search-controller" ], + "operationId" : "crud-taxonomies-collection-reason-findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeOrderByCollectionReasonAsc", "parameters" : [ { "name" : "organizationType", "in" : "query", @@ -770,7 +770,7 @@ "content" : { "application/hal+json" : { "schema" : { - "$ref" : "#/components/schemas/CollectionModelTaxonomy" + "$ref" : "#/components/schemas/CollectionModelTaxonomyCollectionReasonDTO" } } } @@ -781,10 +781,10 @@ } } }, - "/crud/taxonomies/search/findDistinctMacroAreaCodeByOrganizationTypeOrderByMacroAreaCodeAsc" : { + "/crud/taxonomies-macro-area/search/findDistinctMacroAreaCodeByOrganizationTypeOrderByMacroAreaCodeAsc" : { "get" : { - "tags" : [ "taxonomy-search-controller" ], - "operationId" : "crud-taxonomies-findDistinctMacroAreaCodeByOrganizationTypeOrderByMacroAreaCodeAsc", + "tags" : [ "taxonomy-macro-area-code-dto-search-controller" ], + "operationId" : "crud-taxonomies-macro-area-findDistinctMacroAreaCodeByOrganizationTypeOrderByMacroAreaCodeAsc", "parameters" : [ { "name" : "organizationType", "in" : "query", @@ -798,7 +798,7 @@ "content" : { "application/hal+json" : { "schema" : { - "$ref" : "#/components/schemas/CollectionModelTaxonomy" + "$ref" : "#/components/schemas/CollectionModelTaxonomyMacroAreaCodeDTO" } } } @@ -809,17 +809,17 @@ } } }, - "/crud/taxonomies/search/findDistinctOrganizationTypeByOrderByOrganizationTypeAsc" : { + "/crud/taxonomies-organization-types/search/findDistinctOrganizationTypeByOrderByOrganizationTypeAsc" : { "get" : { - "tags" : [ "taxonomy-search-controller" ], - "operationId" : "crud-taxonomies-findDistinctOrganizationTypeByOrderByOrganizationTypeAsc", + "tags" : [ "taxonomy-organization-type-dto-search-controller" ], + "operationId" : "crud-taxonomies-organization-types-findDistinctOrganizationTypeByOrderByOrganizationTypeAsc", "responses" : { "200" : { "description" : "OK", "content" : { "application/hal+json" : { "schema" : { - "$ref" : "#/components/schemas/CollectionModelTaxonomy" + "$ref" : "#/components/schemas/CollectionModelTaxonomyOrganizationTypeDTO" } } } @@ -830,10 +830,10 @@ } } }, - "/crud/taxonomies/search/findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCodeOrderByServiceTypeCodeAsc" : { + "/crud/taxonomies-service-type/search/findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCodeOrderByServiceTypeCodeAsc" : { "get" : { - "tags" : [ "taxonomy-search-controller" ], - "operationId" : "crud-taxonomies-findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCodeOrderByServiceTypeCodeAsc", + "tags" : [ "taxonomy-service-type-code-dto-search-controller" ], + "operationId" : "crud-taxonomies-service-type-findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCodeOrderByServiceTypeCodeAsc", "parameters" : [ { "name" : "organizationType", "in" : "query", @@ -853,7 +853,7 @@ "content" : { "application/hal+json" : { "schema" : { - "$ref" : "#/components/schemas/CollectionModelTaxonomy" + "$ref" : "#/components/schemas/CollectionModelTaxonomyServiceTypeCodeDTO" } } } @@ -864,10 +864,10 @@ } } }, - "/crud/taxonomies/search/findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReasonOrderByTaxonomyCodeAsc" : { + "/crud/taxonomies-taxonomy-code/search/findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReasonOrderByTaxonomyCodeAsc" : { "get" : { - "tags" : [ "taxonomy-search-controller" ], - "operationId" : "crud-taxonomies-findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReasonOrderByTaxonomyCodeAsc", + "tags" : [ "taxonomy-code-dto-search-controller" ], + "operationId" : "crud-taxonomies-taxonomy-code-findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReasonOrderByTaxonomyCodeAsc", "parameters" : [ { "name" : "organizationType", "in" : "query", @@ -899,7 +899,7 @@ "content" : { "application/hal+json" : { "schema" : { - "$ref" : "#/components/schemas/CollectionModelTaxonomy" + "$ref" : "#/components/schemas/CollectionModelTaxonomyCodeDTO" } } } @@ -1193,6 +1193,157 @@ } } }, + "Taxonomy" : { + "type" : "object", + "properties" : { + "taxonomyId" : { + "type" : "integer", + "format" : "int64" + }, + "version" : { + "type" : "integer", + "format" : "int64" + }, + "organizationType" : { + "type" : "string" + }, + "organizationTypeDescription" : { + "type" : "string" + }, + "macroAreaCode" : { + "type" : "string" + }, + "macroAreaName" : { + "type" : "string" + }, + "macroAreaDescription" : { + "type" : "string" + }, + "serviceTypeCode" : { + "type" : "string" + }, + "serviceType" : { + "type" : "string" + }, + "serviceTypeDescription" : { + "type" : "string" + }, + "collectionReason" : { + "type" : "string" + }, + "startDateValidity" : { + "type" : "string", + "format" : "date-time" + }, + "endDateOfValidity" : { + "type" : "string", + "format" : "date-time" + }, + "taxonomyCode" : { + "type" : "string" + }, + "creationDate" : { + "type" : "string", + "format" : "date-time" + }, + "lastModifiedDate" : { + "type" : "string", + "format" : "date-time" + }, + "versionMyPay" : { + "type" : "integer", + "format" : "int64" + }, + "_links" : { + "$ref" : "#/components/schemas/Links" + } + } + }, + "PageMetadata" : { + "type" : "object", + "properties" : { + "size" : { + "type" : "integer", + "format" : "int64" + }, + "totalElements" : { + "type" : "integer", + "format" : "int64" + }, + "totalPages" : { + "type" : "integer", + "format" : "int64" + }, + "number" : { + "type" : "integer", + "format" : "int64" + } + } + }, + "PagedModelTaxonomy" : { + "type" : "object", + "properties" : { + "_embedded" : { + "type" : "object", + "properties" : { + "taxonomies" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Taxonomy" + } + } + } + }, + "_links" : { + "$ref" : "#/components/schemas/Links" + }, + "page" : { + "$ref" : "#/components/schemas/PageMetadata" + } + } + }, + "CollectionModelTaxonomyMacroAreaCodeDTO" : { + "type" : "object", + "properties" : { + "_embedded" : { + "type" : "object", + "properties" : { + "taxonomyMacroAreaCodeDTOes" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/TaxonomyMacroAreaCodeDTO" + } + } + } + }, + "_links" : { + "$ref" : "#/components/schemas/Links" + } + } + }, + "TaxonomyMacroAreaCodeDTO" : { + "type" : "object", + "properties" : { + "organizationType" : { + "type" : "string" + }, + "organizationTypeDescription" : { + "type" : "string" + }, + "macroAreaCode" : { + "type" : "string" + }, + "macroAreaName" : { + "type" : "string" + }, + "macroAreaDescription" : { + "type" : "string" + }, + "_links" : { + "$ref" : "#/components/schemas/Links" + } + } + }, "Organization" : { "type" : "object", "properties" : { @@ -1306,155 +1457,155 @@ } } }, - "PageMetadata" : { + "PagedModelOrganization" : { "type" : "object", "properties" : { - "size" : { - "type" : "integer", - "format" : "int64" - }, - "totalElements" : { - "type" : "integer", - "format" : "int64" + "_embedded" : { + "type" : "object", + "properties" : { + "organizations" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Organization" + } + } + } }, - "totalPages" : { - "type" : "integer", - "format" : "int64" + "_links" : { + "$ref" : "#/components/schemas/Links" }, - "number" : { - "type" : "integer", - "format" : "int64" + "page" : { + "$ref" : "#/components/schemas/PageMetadata" } } }, - "PagedModelOrganization" : { + "CollectionModelTaxonomyServiceTypeCodeDTO" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "organizations" : { + "taxonomyServiceTypeCodeDTOes" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/Organization" + "$ref" : "#/components/schemas/TaxonomyServiceTypeCodeDTO" } } } }, "_links" : { "$ref" : "#/components/schemas/Links" - }, - "page" : { - "$ref" : "#/components/schemas/PageMetadata" } } }, - "PersonalisationFe" : { + "TaxonomyServiceTypeCodeDTO" : { "type" : "object", "properties" : { - "headerAssistanceUrl" : { + "organizationType" : { "type" : "string" }, - "logoFooterImg" : { + "organizationTypeDescription" : { "type" : "string" }, - "footerDescText" : { + "macroAreaCode" : { "type" : "string" }, - "footerPrivacyInfoUrl" : { + "macroAreaName" : { "type" : "string" }, - "footerGDPRUrl" : { + "macroAreaDescription" : { "type" : "string" }, - "footerTermsCondUrl" : { + "serviceTypeCode" : { "type" : "string" }, - "footerAccessibilityUrl" : { + "serviceType" : { + "type" : "string" + }, + "serviceTypeDescription" : { "type" : "string" + }, + "_links" : { + "$ref" : "#/components/schemas/Links" } } }, - "Broker" : { + "CollectionModelTaxonomyCollectionReasonDTO" : { "type" : "object", "properties" : { - "brokerId" : { - "type" : "integer", - "format" : "int64" - }, - "organizationId" : { - "type" : "integer", - "format" : "int64" + "_embedded" : { + "type" : "object", + "properties" : { + "taxonomyCollectionReasonDTOes" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/TaxonomyCollectionReasonDTO" + } + } + } }, - "brokerFiscalCode" : { + "_links" : { + "$ref" : "#/components/schemas/Links" + } + } + }, + "TaxonomyCollectionReasonDTO" : { + "type" : "object", + "properties" : { + "organizationType" : { "type" : "string" }, - "brokerName" : { + "organizationTypeDescription" : { "type" : "string" }, - "pagoPaInteractionModel" : { - "type" : "string", - "enum" : [ "SYNC", "SYNC_ACA", "SYNC$GPDPRELOAD", "SYNC_ACA$GPDPRELOAD", "ASYNC_GPD" ] + "macroAreaCode" : { + "type" : "string" }, - "stationId" : { + "macroAreaName" : { "type" : "string" }, - "broadcastStationId" : { + "macroAreaDescription" : { "type" : "string" }, - "syncKey" : { - "type" : "string", - "format" : "byte" + "serviceTypeCode" : { + "type" : "string" }, - "gpdKey" : { - "type" : "string", - "format" : "byte" + "serviceType" : { + "type" : "string" }, - "acaKey" : { - "type" : "string", - "format" : "byte" + "serviceTypeDescription" : { + "type" : "string" }, - "personalisationFe" : { - "$ref" : "#/components/schemas/PersonalisationFe" + "collectionReason" : { + "type" : "string" }, "_links" : { "$ref" : "#/components/schemas/Links" } } }, - "PagedModelBroker" : { + "CollectionModelTaxonomyCodeDTO" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "brokers" : { + "taxonomyCodeDTOes" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/Broker" + "$ref" : "#/components/schemas/TaxonomyCodeDTO" } } } }, "_links" : { "$ref" : "#/components/schemas/Links" - }, - "page" : { - "$ref" : "#/components/schemas/PageMetadata" } } }, - "Taxonomy" : { + "TaxonomyCodeDTO" : { "type" : "object", "properties" : { - "taxonomyId" : { - "type" : "integer", - "format" : "int64" - }, - "version" : { - "type" : "integer", - "format" : "int64" - }, "organizationType" : { "type" : "string" }, @@ -1482,44 +1633,97 @@ "collectionReason" : { "type" : "string" }, - "startDateValidity" : { - "type" : "string", - "format" : "date-time" + "taxonomyCode" : { + "type" : "string" }, - "endDateOfValidity" : { + "_links" : { + "$ref" : "#/components/schemas/Links" + } + } + }, + "PersonalisationFe" : { + "type" : "object", + "properties" : { + "headerAssistanceUrl" : { + "type" : "string" + }, + "logoFooterImg" : { + "type" : "string" + }, + "footerDescText" : { + "type" : "string" + }, + "footerPrivacyInfoUrl" : { + "type" : "string" + }, + "footerGDPRUrl" : { + "type" : "string" + }, + "footerTermsCondUrl" : { + "type" : "string" + }, + "footerAccessibilityUrl" : { + "type" : "string" + } + } + }, + "Broker" : { + "type" : "object", + "properties" : { + "brokerId" : { + "type" : "integer", + "format" : "int64" + }, + "organizationId" : { + "type" : "integer", + "format" : "int64" + }, + "brokerFiscalCode" : { + "type" : "string" + }, + "brokerName" : { + "type" : "string" + }, + "pagoPaInteractionModel" : { "type" : "string", - "format" : "date-time" + "enum" : [ "SYNC", "SYNC_ACA", "SYNC$GPDPRELOAD", "SYNC_ACA$GPDPRELOAD", "ASYNC_GPD" ] }, - "taxonomyCode" : { + "stationId" : { "type" : "string" }, - "creationDate" : { + "broadcastStationId" : { + "type" : "string" + }, + "syncKey" : { "type" : "string", - "format" : "date-time" + "format" : "byte" }, - "lastModifiedDate" : { + "gpdKey" : { "type" : "string", - "format" : "date-time" + "format" : "byte" }, - "versionMyPay" : { - "type" : "integer", - "format" : "int64" + "acaKey" : { + "type" : "string", + "format" : "byte" + }, + "personalisationFe" : { + "$ref" : "#/components/schemas/PersonalisationFe" }, "_links" : { "$ref" : "#/components/schemas/Links" } } }, - "PagedModelTaxonomy" : { + "PagedModelBroker" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "taxonomies" : { + "brokers" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/Taxonomy" + "$ref" : "#/components/schemas/Broker" } } } @@ -1532,16 +1736,16 @@ } } }, - "CollectionModelTaxonomy" : { + "CollectionModelTaxonomyOrganizationTypeDTO" : { "type" : "object", "properties" : { "_embedded" : { "type" : "object", "properties" : { - "taxonomies" : { + "taxonomyOrganizationTypeDTOes" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/Taxonomy" + "$ref" : "#/components/schemas/TaxonomyOrganizationTypeDTO" } } } @@ -1551,6 +1755,20 @@ } } }, + "TaxonomyOrganizationTypeDTO" : { + "type" : "object", + "properties" : { + "organizationType" : { + "type" : "string" + }, + "organizationTypeDescription" : { + "type" : "string" + }, + "_links" : { + "$ref" : "#/components/schemas/Links" + } + } + }, "BrokerRequestBody" : { "type" : "object", "properties" : { diff --git a/src/main/java/it/gov/pagopa/pu/organization/config/WebSecurityConfig.java b/src/main/java/it/gov/pagopa/pu/organization/config/WebSecurityConfig.java index 7398061..a301baa 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/config/WebSecurityConfig.java +++ b/src/main/java/it/gov/pagopa/pu/organization/config/WebSecurityConfig.java @@ -76,7 +76,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http, JwtDecoder jwt "/favicon.ico", "/error" ).permitAll() - .anyRequest().authenticated() + .anyRequest().permitAll() ) .sessionManagement(session -> session .sessionCreationPolicy(SessionCreationPolicy.STATELESS)) diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyOrganizationTypeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyOrganizationTypeDTO.java index 316ab95..d46eaf9 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyOrganizationTypeDTO.java +++ b/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyOrganizationTypeDTO.java @@ -5,9 +5,11 @@ import jakarta.persistence.Table; import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; @Data @AllArgsConstructor +@NoArgsConstructor @Entity @Table(name = "taxonomy") public class TaxonomyOrganizationTypeDTO { diff --git a/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java b/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java index c8fe482..a6b9d7c 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java +++ b/src/main/java/it/gov/pagopa/pu/organization/repository/TaxonomyRepository.java @@ -1,22 +1,10 @@ package it.gov.pagopa.pu.organization.repository; import it.gov.pagopa.pu.organization.model.Taxonomy; -import it.gov.pagopa.pu.organization.model.taxonomy.TaxonomyCodeDTO; -import it.gov.pagopa.pu.organization.model.taxonomy.TaxonomyCollectionReasonDTO; -import it.gov.pagopa.pu.organization.model.taxonomy.TaxonomyMacroAreaCodeDTO; -import it.gov.pagopa.pu.organization.model.taxonomy.TaxonomyOrganizationTypeDTO; -import it.gov.pagopa.pu.organization.model.taxonomy.TaxonomyServiceTypeCodeDTO; -import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(path = "taxonomies") public interface TaxonomyRepository extends JpaRepository { - List findDistinctOrganizationTypeByOrderByOrganizationTypeAsc(); - List findDistinctMacroAreaCodeByOrganizationTypeOrderByMacroAreaCodeAsc(String organizationType); - List findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCodeOrderByServiceTypeCodeAsc(String organizationType,String macroAreaCode); - List findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeOrderByCollectionReasonAsc(String organizationType,String macroAreaCode,String serviceTypeCode); - List findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReasonOrderByTaxonomyCodeAsc(String organizationType,String macroAreaCode,String serviceTypeCode,String collectionReason); - } diff --git a/src/main/java/it/gov/pagopa/pu/organization/repository/taxonomy/TaxonomyCodeRepository.java b/src/main/java/it/gov/pagopa/pu/organization/repository/taxonomy/TaxonomyCodeRepository.java new file mode 100644 index 0000000..d41f17a --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/organization/repository/taxonomy/TaxonomyCodeRepository.java @@ -0,0 +1,14 @@ +package it.gov.pagopa.pu.organization.repository.taxonomy; + +import it.gov.pagopa.pu.organization.model.taxonomy.TaxonomyCodeDTO; +import java.util.List; +import org.springframework.data.repository.Repository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(path = "taxonomies-taxonomy-code") +public interface TaxonomyCodeRepository extends + Repository { + + List findDistinctTaxonomyCodeByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeAndCollectionReasonOrderByTaxonomyCodeAsc(String organizationType,String macroAreaCode,String serviceTypeCode,String collectionReason); + +} diff --git a/src/main/java/it/gov/pagopa/pu/organization/repository/taxonomy/TaxonomyCollectionReasonRepository.java b/src/main/java/it/gov/pagopa/pu/organization/repository/taxonomy/TaxonomyCollectionReasonRepository.java new file mode 100644 index 0000000..62e7376 --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/organization/repository/taxonomy/TaxonomyCollectionReasonRepository.java @@ -0,0 +1,14 @@ +package it.gov.pagopa.pu.organization.repository.taxonomy; + +import it.gov.pagopa.pu.organization.model.taxonomy.TaxonomyCollectionReasonDTO; +import java.util.List; +import org.springframework.data.repository.Repository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(path = "taxonomies-collection-reason") +public interface TaxonomyCollectionReasonRepository extends + Repository { + + List findDistinctCollectionReasonByOrganizationTypeAndMacroAreaCodeAndServiceTypeCodeOrderByCollectionReasonAsc(String organizationType,String macroAreaCode,String serviceTypeCode); + +} diff --git a/src/main/java/it/gov/pagopa/pu/organization/repository/taxonomy/TaxonomyMacroAreaCodeRepository.java b/src/main/java/it/gov/pagopa/pu/organization/repository/taxonomy/TaxonomyMacroAreaCodeRepository.java new file mode 100644 index 0000000..b3a7582 --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/organization/repository/taxonomy/TaxonomyMacroAreaCodeRepository.java @@ -0,0 +1,14 @@ +package it.gov.pagopa.pu.organization.repository.taxonomy; + +import it.gov.pagopa.pu.organization.model.taxonomy.TaxonomyMacroAreaCodeDTO; +import java.util.List; +import org.springframework.data.repository.Repository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(path = "taxonomies-macro-area") +public interface TaxonomyMacroAreaCodeRepository extends + Repository { + + List findDistinctMacroAreaCodeByOrganizationTypeOrderByMacroAreaCodeAsc(String organizationType); + +} diff --git a/src/main/java/it/gov/pagopa/pu/organization/repository/taxonomy/TaxonomyOrganizationTypeRepository.java b/src/main/java/it/gov/pagopa/pu/organization/repository/taxonomy/TaxonomyOrganizationTypeRepository.java new file mode 100644 index 0000000..fb998ba --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/organization/repository/taxonomy/TaxonomyOrganizationTypeRepository.java @@ -0,0 +1,12 @@ +package it.gov.pagopa.pu.organization.repository.taxonomy; + +import it.gov.pagopa.pu.organization.model.taxonomy.TaxonomyOrganizationTypeDTO; +import org.springframework.data.repository.Repository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +import java.util.List; + +@RepositoryRestResource(path = "taxonomies-organization-types") +public interface TaxonomyOrganizationTypeRepository extends Repository { + List findDistinctOrganizationTypeByOrderByOrganizationTypeAsc(); +} diff --git a/src/main/java/it/gov/pagopa/pu/organization/repository/taxonomy/TaxonomyServiceTypeCodeRepository.java b/src/main/java/it/gov/pagopa/pu/organization/repository/taxonomy/TaxonomyServiceTypeCodeRepository.java new file mode 100644 index 0000000..53ffdc7 --- /dev/null +++ b/src/main/java/it/gov/pagopa/pu/organization/repository/taxonomy/TaxonomyServiceTypeCodeRepository.java @@ -0,0 +1,14 @@ +package it.gov.pagopa.pu.organization.repository.taxonomy; + +import it.gov.pagopa.pu.organization.model.taxonomy.TaxonomyServiceTypeCodeDTO; +import java.util.List; +import org.springframework.data.repository.Repository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(path = "taxonomies-service-type") +public interface TaxonomyServiceTypeCodeRepository extends + Repository { + + List findDistinctServiceTypeCodeByOrganizationTypeAndMacroAreaCodeOrderByServiceTypeCodeAsc(String organizationType,String macroAreaCode); + +} From 73cc7b1b5bf67730f08d9797f336db59bfd9bf94 Mon Sep 17 00:00:00 2001 From: oleksiybozhykntt Date: Tue, 14 Jan 2025 15:19:09 +0100 Subject: [PATCH 19/20] updated code --- .../pagopa/pu/organization/model/taxonomy/TaxonomyCodeDTO.java | 2 ++ .../model/taxonomy/TaxonomyCollectionReasonDTO.java | 2 ++ .../organization/model/taxonomy/TaxonomyMacroAreaCodeDTO.java | 2 ++ .../organization/model/taxonomy/TaxonomyServiceTypeCodeDTO.java | 2 ++ 4 files changed, 8 insertions(+) diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyCodeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyCodeDTO.java index fc6bb86..b0e23ff 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyCodeDTO.java +++ b/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyCodeDTO.java @@ -6,9 +6,11 @@ import jakarta.persistence.Table; import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; @Data @AllArgsConstructor +@NoArgsConstructor @Entity @Table(name = "taxonomy") @IdClass(TaxonomyCodeDTO.class) diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyCollectionReasonDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyCollectionReasonDTO.java index 80e4b2f..282907c 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyCollectionReasonDTO.java +++ b/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyCollectionReasonDTO.java @@ -6,9 +6,11 @@ import jakarta.persistence.Table; import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; @Data @AllArgsConstructor +@NoArgsConstructor @Entity @Table(name = "taxonomy") @IdClass(TaxonomyCollectionReasonDTO.class) diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyMacroAreaCodeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyMacroAreaCodeDTO.java index 95558b3..8a04744 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyMacroAreaCodeDTO.java +++ b/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyMacroAreaCodeDTO.java @@ -6,9 +6,11 @@ import jakarta.persistence.Table; import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; @Data @AllArgsConstructor +@NoArgsConstructor @Entity @Table(name = "taxonomy") @IdClass(TaxonomyMacroAreaCodeDTO.class) diff --git a/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyServiceTypeCodeDTO.java b/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyServiceTypeCodeDTO.java index e181810..fd67a7b 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyServiceTypeCodeDTO.java +++ b/src/main/java/it/gov/pagopa/pu/organization/model/taxonomy/TaxonomyServiceTypeCodeDTO.java @@ -6,9 +6,11 @@ import jakarta.persistence.Table; import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; @Data @AllArgsConstructor +@NoArgsConstructor @Entity @Table(name = "taxonomy") @IdClass(TaxonomyServiceTypeCodeDTO.class) From c5695ee58546074fca4259ae28a6b03a35a5ec1a Mon Sep 17 00:00:00 2001 From: oleksiybozhykntt Date: Tue, 14 Jan 2025 15:23:46 +0100 Subject: [PATCH 20/20] updated code --- .../it/gov/pagopa/pu/organization/config/WebSecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/it/gov/pagopa/pu/organization/config/WebSecurityConfig.java b/src/main/java/it/gov/pagopa/pu/organization/config/WebSecurityConfig.java index a301baa..7398061 100644 --- a/src/main/java/it/gov/pagopa/pu/organization/config/WebSecurityConfig.java +++ b/src/main/java/it/gov/pagopa/pu/organization/config/WebSecurityConfig.java @@ -76,7 +76,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http, JwtDecoder jwt "/favicon.ico", "/error" ).permitAll() - .anyRequest().permitAll() + .anyRequest().authenticated() ) .sessionManagement(session -> session .sessionCreationPolicy(SessionCreationPolicy.STATELESS))