generated from pagopa/pagopa-functions-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SELC-5806] feat: Refactored class Product
- Loading branch information
1 parent
a2eb1a9
commit e68c683
Showing
28 changed files
with
3,727 additions
and
2,801 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
143 changes: 66 additions & 77 deletions
143
...ons/src/main/java/it/pagopa/selfcare/onboarding/entity/OnboardingWorkflowInstitution.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.