Skip to content

Commit

Permalink
fix: Remove InstitutionType from institutionContractMappings on onboa…
Browse files Browse the repository at this point in the history
…rding-sdk (#475)

Co-authored-by: pierpaolodidato89 <[email protected]>
Co-authored-by: [email protected] <Aiap1955?^@#>
Co-authored-by: giampieroFerrara <[email protected]>
Co-authored-by: andrea-putzu <[email protected]>
  • Loading branch information
5 people authored Sep 9, 2024
1 parent c82b1d2 commit fe0ec20
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 32 deletions.
2 changes: 1 addition & 1 deletion apps/onboarding-cdc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<quarkus.platform.version>3.5.2</quarkus.platform.version>
<skipITs>true</skipITs>
<surefire-plugin.version>3.1.2</surefire-plugin.version>
<onboarding-sdk.version>0.1.21</onboarding-sdk.version>
<onboarding-sdk.version>0.2.0</onboarding-sdk.version>
<quarkus-openapi-generator.version>2.4.1</quarkus-openapi-generator.version>
</properties>
<dependencyManagement>
Expand Down
2 changes: 1 addition & 1 deletion apps/onboarding-functions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<quarkus.platform.version>3.5.1</quarkus.platform.version>
<skipITs>true</skipITs>
<surefire-plugin.version>3.1.2</surefire-plugin.version>
<onboarding-sdk.version>0.1.21</onboarding-sdk.version>
<onboarding-sdk.version>0.2.0</onboarding-sdk.version>
<mapstruct.version>1.5.5.Final</mapstruct.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import it.pagopa.selfcare.product.entity.ContractStorage;
import it.pagopa.selfcare.product.entity.Product;

import java.util.Objects;
import java.util.Optional;

public class OnboardingWorkflowAggregator extends OnboardingWorkflow {
Expand Down Expand Up @@ -41,9 +42,13 @@ public String getEmailCompletionPath(MailTemplatePathConfig config) {

@Override
public String getContractTemplatePath(Product product) {
if(Objects.isNull(onboarding.getInstitution()) || Objects.isNull(onboarding.getInstitution().getInstitutionType())){
return null;
}

return Optional.ofNullable(product.getInstitutionContractMappings())
.filter(mappings -> mappings.containsKey(onboarding.getInstitution().getInstitutionType()))
.map(mappings -> mappings.get(onboarding.getInstitution().getInstitutionType()))
.filter(mappings -> mappings.containsKey(onboarding.getInstitution().getInstitutionType().name()))
.map(mappings -> mappings.get(onboarding.getInstitution().getInstitutionType().name()))
.map(ContractStorage::getContractTemplatePath)
.orElse(product.getContractTemplatePath());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import it.pagopa.selfcare.product.entity.ContractStorage;
import it.pagopa.selfcare.product.entity.Product;

import java.util.Objects;
import java.util.Optional;

import static it.pagopa.selfcare.onboarding.common.ProductId.PROD_FD;
Expand Down Expand Up @@ -62,10 +63,13 @@ public String getRejectTokenUrl(MailTemplatePlaceholdersConfig config) {

@Override
public String getContractTemplatePath(Product product) {
if(Objects.isNull(onboarding.getInstitution()) || Objects.isNull(onboarding.getInstitution().getInstitutionType())){
return null;
}

return Optional.ofNullable(product.getInstitutionContractMappings())
.filter(mappings -> mappings.containsKey(onboarding.getInstitution().getInstitutionType()))
.map(mappings -> mappings.get(onboarding.getInstitution().getInstitutionType()))
.filter(mappings -> mappings.containsKey(onboarding.getInstitution().getInstitutionType().name()))
.map(mappings -> mappings.get(onboarding.getInstitution().getInstitutionType().name()))
.map(ContractStorage::getContractTemplatePath)
.orElse(product.getContractTemplatePath());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ void createContract_InstitutionContractMappings() {

Product product = createDummyProduct();
/* add contract mapping */
Map<InstitutionType, ContractStorage> contractStorageMap = new HashMap<>();
Map<String, ContractStorage> contractStorageMap = new HashMap<>();
ContractStorage contractStorage = new ContractStorage();
contractStorage.setContractTemplatePath("setContractTemplatePath");
contractStorageMap.put(onboarding.getInstitution().getInstitutionType(), contractStorage);
contractStorageMap.put(onboarding.getInstitution().getInstitutionType().name(), contractStorage);
product.setInstitutionContractMappings(contractStorageMap);

when(userRegistryApi.findByIdUsingGET(USERS_WORKS_FIELD_LIST,manager.getId()))
Expand Down
2 changes: 1 addition & 1 deletion apps/onboarding-ms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<quarkus.platform.version>3.11.2</quarkus.platform.version>
<skipITs>true</skipITs>
<surefire-plugin.version>3.1.2</surefire-plugin.version>
<onboarding-sdk.version>0.1.21</onboarding-sdk.version>
<onboarding-sdk.version>0.2.0</onboarding-sdk.version>
<quarkus-openapi-generator.version>2.4.1</quarkus-openapi-generator.version>
</properties>
<dependencyManagement>
Expand Down
2 changes: 1 addition & 1 deletion libs/onboarding-sdk-azure-storage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk-pom</artifactId>
<version>0.1.21</version>
<onboarding-sdk.version>0.2.0</onboarding-sdk.version>
<relativePath>../onboarding-sdk-pom</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion libs/onboarding-sdk-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk-pom</artifactId>
<version>0.1.21</version>
<version>0.2.0</version>
<relativePath>../onboarding-sdk-pom</relativePath>
</parent>
<artifactId>onboarding-sdk-common</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion libs/onboarding-sdk-crypto/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk-pom</artifactId>
<version>0.1.21</version>
<version>0.2.0</version>
<relativePath>../onboarding-sdk-pom</relativePath>
</parent>
<artifactId>onboarding-sdk-crypto</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion libs/onboarding-sdk-pom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<artifactId>onboarding-sdk-pom</artifactId>
<packaging>pom</packaging>
<name>onboarding-sdk-pom</name>
<version>0.1.21</version>
<version>0.2.0</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
Expand Down
6 changes: 3 additions & 3 deletions libs/onboarding-sdk-product/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
<parent>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk-pom</artifactId>
<version>0.1.21</version>
<version>0.2.0</version>
<relativePath>../onboarding-sdk-pom</relativePath>
</parent>
<artifactId>onboarding-sdk-product</artifactId>
<name>onboarding-sdk-product</name>
<version>0.1.21</version>
<version>0.2.0</version>

<properties>
<jackson.version>2.15.2</jackson.version>
<onboarding-sdk.version>0.1.21</onboarding-sdk.version>
<onboarding-sdk.version>0.2.0</onboarding-sdk.version>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package it.pagopa.selfcare.product.entity;

import it.pagopa.selfcare.onboarding.common.InstitutionType;
import it.pagopa.selfcare.onboarding.common.PartyRole;

import java.time.Instant;
Expand All @@ -27,7 +26,7 @@ public class Product {
private Instant contractTemplateUpdatedAt;
private String contractTemplatePath;
private String contractTemplateVersion;
private Map<InstitutionType, ContractStorage> institutionContractMappings;
private Map<String, ContractStorage> institutionContractMappings;
private boolean enabled = true;
private boolean delegable;
private boolean invoiceable;
Expand Down Expand Up @@ -177,11 +176,11 @@ public void setContractTemplateVersion(String contractTemplateVersion) {
this.contractTemplateVersion = contractTemplateVersion;
}

public Map<InstitutionType, ContractStorage> getInstitutionContractMappings() {
public Map<String, ContractStorage> getInstitutionContractMappings() {
return institutionContractMappings;
}

public void setInstitutionContractMappings(Map<InstitutionType, ContractStorage> institutionContractMappings) {
public void setInstitutionContractMappings(Map<String, ContractStorage> institutionContractMappings) {
this.institutionContractMappings = institutionContractMappings;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import it.pagopa.selfcare.onboarding.common.InstitutionType;
import it.pagopa.selfcare.onboarding.common.PartyRole;
import it.pagopa.selfcare.product.entity.Product;
import it.pagopa.selfcare.product.entity.ProductRole;
import it.pagopa.selfcare.product.entity.ProductRoleInfo;
import it.pagopa.selfcare.product.entity.ProductStatus;
import it.pagopa.selfcare.product.entity.*;
import it.pagopa.selfcare.product.exception.InvalidRoleMappingException;
import it.pagopa.selfcare.product.exception.ProductNotFoundException;

Expand Down Expand Up @@ -148,9 +145,10 @@ private Product getProduct(String productId, boolean filterValid) {
*/
@Override
public void fillContractTemplatePathAndVersion(Product product, InstitutionType institutionType) {
if (institutionType != null && product.getInstitutionContractMappings() != null && product.getInstitutionContractMappings().containsKey(institutionType)) {
product.setContractTemplatePath(product.getInstitutionContractMappings().get(institutionType).getContractTemplatePath());
product.setContractTemplateVersion(product.getInstitutionContractMappings().get(institutionType).getContractTemplateVersion());
if (Objects.nonNull(institutionType) && Objects.nonNull(product.getInstitutionContractMappings())
&& product.getInstitutionContractMappings().containsKey(institutionType.name())) {
product.setContractTemplatePath(product.getInstitutionContractMappings().get(institutionType.name()).getContractTemplatePath());
product.setContractTemplateVersion(product.getInstitutionContractMappings().get(institutionType.name()).getContractTemplateVersion());
}
}

Expand Down Expand Up @@ -204,5 +202,4 @@ private static boolean statusIsNotValid(ProductStatus status) {
return List.of(ProductStatus.INACTIVE, ProductStatus.PHASE_OUT).contains(status);
}


}
8 changes: 4 additions & 4 deletions test-coverage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,22 @@
<dependency>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk-product</artifactId>
<version>0.1.21</version>
<version>0.2.0</version>
</dependency>
<dependency>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk-common</artifactId>
<version>0.1.21</version>
<version>0.2.0</version>
</dependency>
<dependency>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk-azure-storage</artifactId>
<version>0.1.21</version>
<version>0.2.0</version>
</dependency>
<dependency>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk-crypto</artifactId>
<version>0.1.21</version>
<version>0.2.0</version>
</dependency>
</dependencies>

Expand Down

0 comments on commit fe0ec20

Please sign in to comment.