Skip to content

Commit

Permalink
[SELC-5806] feat: Refactored class Product
Browse files Browse the repository at this point in the history
  • Loading branch information
giampieroferrara authored Oct 28, 2024
1 parent a2eb1a9 commit e68c683
Show file tree
Hide file tree
Showing 28 changed files with 3,727 additions and 2,801 deletions.
6 changes: 3 additions & 3 deletions apps/onboarding-functions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,17 @@
<dependency>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk-crypto</artifactId>
<version>0.3.5</version>
<version>0.4.0</version>
</dependency>
<dependency>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk-azure-storage</artifactId>
<version>0.3.5</version>
<version>0.4.0</version>
</dependency>
<dependency>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk-product</artifactId>
<version>0.3.5</version>
<version>0.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,44 @@

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
@JsonSubTypes({
@JsonSubTypes.Type(value = OnboardingWorkflowAggregator.class, name = "AGGREGATOR"),
@JsonSubTypes.Type(value = OnboardingWorkflowInstitution.class, name = "INSTITUTION"),
@JsonSubTypes.Type(value = OnboardingWorkflowUser.class, name = "USER")
@JsonSubTypes.Type(value = OnboardingWorkflowAggregator.class, name = "AGGREGATOR"),
@JsonSubTypes.Type(value = OnboardingWorkflowInstitution.class, name = "INSTITUTION"),
@JsonSubTypes.Type(value = OnboardingWorkflowUser.class, name = "USER")
})
public abstract class OnboardingWorkflow {

protected static final String PDF_FORMAT_FILENAME = "%s_accordo_adesione.pdf";
protected static final String PDF_FORMAT_FILENAME = "%s_accordo_adesione.pdf";

OnboardingWorkflow(Onboarding onboarding) {
this.onboarding = onboarding;
}
OnboardingWorkflow(Onboarding onboarding) {
this.onboarding = onboarding;
}

public OnboardingWorkflow() {
}
public OnboardingWorkflow() {}

protected Onboarding onboarding;
public abstract String emailRegistrationPath(MailTemplatePathConfig config);
protected Onboarding onboarding;

public abstract String getEmailCompletionPath(MailTemplatePathConfig config);
public abstract String getEmailRegistrationPath(MailTemplatePathConfig config);

public abstract String getPdfFormatFilename();
public abstract String getEmailCompletionPath(MailTemplatePathConfig config);

public abstract TokenType getTokenType();
public abstract String getPdfFormatFilename();

public abstract String getConfirmTokenUrl(MailTemplatePlaceholdersConfig config);
public abstract TokenType getTokenType();

public abstract String getRejectTokenUrl(MailTemplatePlaceholdersConfig config);
public abstract String getConfirmTokenUrl(MailTemplatePlaceholdersConfig config);

public abstract String getContractTemplatePath(Product product);
public abstract String getRejectTokenUrl(MailTemplatePlaceholdersConfig config);

public abstract String getContractTemplateVersion(Product product);
public abstract String getContractTemplatePath(Product product);

public Onboarding getOnboarding() {
return onboarding;
}
public abstract String getContractTemplateVersion(Product product);

public void setOnboarding(Onboarding onboarding) {
this.onboarding = onboarding;
}
public Onboarding getOnboarding() {
return onboarding;
}

public void setOnboarding(Onboarding onboarding) {
this.onboarding = onboarding;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,76 +3,69 @@
import it.pagopa.selfcare.onboarding.common.TokenType;
import it.pagopa.selfcare.onboarding.config.MailTemplatePathConfig;
import it.pagopa.selfcare.onboarding.config.MailTemplatePlaceholdersConfig;
import it.pagopa.selfcare.product.entity.ContractStorage;
import it.pagopa.selfcare.onboarding.utils.InstitutionUtils;
import it.pagopa.selfcare.product.entity.Product;

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

public class OnboardingWorkflowAggregator extends OnboardingWorkflow {

private String type;

public OnboardingWorkflowAggregator(){}

public OnboardingWorkflowAggregator(Onboarding onboarding, String type) {
super(onboarding);
this.type = type;
}

@Override
public TokenType getTokenType() {
return TokenType.INSTITUTION;
}

@Override
public String getPdfFormatFilename() {
return PDF_FORMAT_FILENAME;
}

@Override
public String emailRegistrationPath(MailTemplatePathConfig config) {
return config.registrationAggregatorPath();
}

@Override
public String getEmailCompletionPath(MailTemplatePathConfig config) {
return config.completePath();
}

@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().name()))
.map(mappings -> mappings.get(onboarding.getInstitution().getInstitutionType().name()))
.map(ContractStorage::getContractTemplatePath)
.orElse(product.getContractTemplatePath());
}

@Override
public String getContractTemplateVersion(Product product) {
return product.getContractTemplateVersion();
}

@Override
public String getConfirmTokenUrl(MailTemplatePlaceholdersConfig config) {
return config.confirmTokenPlaceholder();
}

@Override
public String getRejectTokenUrl(MailTemplatePlaceholdersConfig config) {
return config.rejectTokenPlaceholder();
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}
private String type;

public OnboardingWorkflowAggregator() {}

public OnboardingWorkflowAggregator(Onboarding onboarding, String type) {
super(onboarding);
this.type = type;
}

@Override
public TokenType getTokenType() {
return TokenType.INSTITUTION;
}

@Override
public String getPdfFormatFilename() {
return PDF_FORMAT_FILENAME;
}

@Override
public String getEmailRegistrationPath(MailTemplatePathConfig config) {
return config.registrationAggregatorPath();
}

@Override
public String getEmailCompletionPath(MailTemplatePathConfig config) {
return config.completePath();
}

@Override
public String getContractTemplatePath(Product product) {
return product
.getUserContractTemplate(InstitutionUtils.getCurrentInstitutionType(onboarding))
.getContractTemplatePath();
}

@Override
public String getContractTemplateVersion(Product product) {
return product
.getUserContractTemplate(InstitutionUtils.getCurrentInstitutionType(onboarding))
.getContractTemplateVersion();
}

@Override
public String getConfirmTokenUrl(MailTemplatePlaceholdersConfig config) {
return config.confirmTokenPlaceholder();
}

@Override
public String getRejectTokenUrl(MailTemplatePlaceholdersConfig config) {
return config.rejectTokenPlaceholder();
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}
}
Original file line number Diff line number Diff line change
@@ -1,89 +1,78 @@
package it.pagopa.selfcare.onboarding.entity;

import static it.pagopa.selfcare.onboarding.common.ProductId.PROD_FD;
import static it.pagopa.selfcare.onboarding.common.ProductId.PROD_FD_GARANTITO;

import it.pagopa.selfcare.onboarding.common.InstitutionType;
import it.pagopa.selfcare.onboarding.common.TokenType;
import it.pagopa.selfcare.onboarding.config.MailTemplatePathConfig;
import it.pagopa.selfcare.onboarding.config.MailTemplatePlaceholdersConfig;
import it.pagopa.selfcare.product.entity.ContractStorage;
import it.pagopa.selfcare.onboarding.utils.InstitutionUtils;
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;
import static it.pagopa.selfcare.onboarding.common.ProductId.PROD_FD_GARANTITO;

public class OnboardingWorkflowInstitution extends OnboardingWorkflow {

private String type;

public OnboardingWorkflowInstitution() {
}

public OnboardingWorkflowInstitution(Onboarding onboarding, String type) {
super(onboarding);
this.type = type;
}

@Override
public String emailRegistrationPath(MailTemplatePathConfig config) {
return config.registrationPath();
}

@Override
public String getEmailCompletionPath(MailTemplatePathConfig config) {
if (InstitutionType.PT.equals(this.onboarding.getInstitution().getInstitutionType())) {
return config.completePathPt();
} else {
return this.onboarding.getProductId().equals(PROD_FD.getValue()) || this.onboarding.getProductId().equals(PROD_FD_GARANTITO.getValue())
? config.completePathFd()
: config.completePath();
}
}

@Override
public TokenType getTokenType() {
return TokenType.INSTITUTION;
}

@Override
public String getPdfFormatFilename() {
return PDF_FORMAT_FILENAME;
}

@Override
public String getConfirmTokenUrl(MailTemplatePlaceholdersConfig config) {
return config.confirmTokenPlaceholder();
}

@Override
public String getRejectTokenUrl(MailTemplatePlaceholdersConfig config) {
return config.rejectTokenPlaceholder();
}

@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().name()))
.map(mappings -> mappings.get(onboarding.getInstitution().getInstitutionType().name()))
.map(ContractStorage::getContractTemplatePath)
.orElse(product.getContractTemplatePath());
}

@Override
public String getContractTemplateVersion(Product product) {
return product.getContractTemplateVersion();
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
private String type;

public OnboardingWorkflowInstitution() {}

public OnboardingWorkflowInstitution(Onboarding onboarding, String type) {
super(onboarding);
this.type = type;
}

@Override
public String getEmailRegistrationPath(MailTemplatePathConfig config) {
return config.registrationPath();
}

@Override
public String getEmailCompletionPath(MailTemplatePathConfig config) {
if (InstitutionType.PT.equals(this.onboarding.getInstitution().getInstitutionType())) {
return config.completePathPt();
} else {
return this.onboarding.getProductId().equals(PROD_FD.getValue())
|| this.onboarding.getProductId().equals(PROD_FD_GARANTITO.getValue())
? config.completePathFd()
: config.completePath();
}
}

@Override
public TokenType getTokenType() {
return TokenType.INSTITUTION;
}

@Override
public String getPdfFormatFilename() {
return PDF_FORMAT_FILENAME;
}

@Override
public String getConfirmTokenUrl(MailTemplatePlaceholdersConfig config) {
return config.confirmTokenPlaceholder();
}

@Override
public String getRejectTokenUrl(MailTemplatePlaceholdersConfig config) {
return config.rejectTokenPlaceholder();
}

@Override
public String getContractTemplatePath(Product product) {
return product.getInstitutionContractTemplate(InstitutionUtils.getCurrentInstitutionType(onboarding)).getContractTemplatePath();
}

@Override
public String getContractTemplateVersion(Product product) {
return product.getInstitutionContractTemplate(InstitutionUtils.getCurrentInstitutionType(onboarding)).getContractTemplateVersion();
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}
}
Loading

0 comments on commit e68c683

Please sign in to comment.