Skip to content

Commit

Permalink
code smell
Browse files Browse the repository at this point in the history
  • Loading branch information
manuraf committed Nov 10, 2023
1 parent 0ba5e0c commit 8edb8ca
Showing 1 changed file with 37 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@
public class PdfMapper {

private static final String[] PLAN_LIST = {"C1", "C2", "C3", "C4", "C5", "C6", "C7"};
public static final String INSTITUTION_REA = "institutionREA";
public static final String INSTITUTION_NAME = "institutionName";
public static final String INSTITUTION_SHARE_CAPITAL = "institutionShareCapital";
public static final String INSTITUTION_BUSINESS_REGISTER_PLACE = "institutionBusinessRegisterPlace";
public static final String PRICING_PLAN_PREMIUM = "pricingPlanPremium";
public static final String PRICING_PLAN_PREMIUM_CHECKBOX = "pricingPlanPremiumCheckbox";
public static final String PRICING_PLAN_FAST_CHECKBOX = "pricingPlanFastCheckbox";
public static final String PRICING_PLAN_BASE_CHECKBOX = "pricingPlanBaseCheckbox";
public static final String PRICING_PLAN = "pricingPlan";
public static final String INSTITUTION_REGISTER_LABEL_VALUE = "institutionRegisterLabelValue";

public static Map<String, Object> setUpCommonData(UserResource validManager, List<UserResource> users, Institution institution, Billing billing, List<String> geographicTaxonomies) {

Expand All @@ -24,7 +34,7 @@ public static Map<String, Object> setUpCommonData(UserResource validManager, Lis
//}

Map<String, Object> map = new HashMap<>();
map.put("institutionName", institution.getDescription());
map.put(INSTITUTION_NAME, institution.getDescription());
map.put("address", institution.getAddress());
map.put("institutionTaxCode", institution.getTaxCode());
map.put("zipCode", institution.getZipCode());
Expand Down Expand Up @@ -90,19 +100,19 @@ public static void setupProdIOData(Onboarding onboarding, Map<String, Object> ma
map.put("GPSmanagerSurname", InstitutionType.GSP == institutionType ? validManager.getFamilyName() : underscore);
map.put("GPSmanagerTaxCode", InstitutionType.GSP == institutionType ? validManager.getFiscalCode() : underscore);

map.put("institutionREA", Optional.ofNullable(institution.getRea()).orElse(underscore));
map.put("institutionShareCapital", Optional.ofNullable(institution.getShareCapital()).orElse(underscore));
map.put("institutionBusinessRegisterPlace", Optional.ofNullable(institution.getBusinessRegisterPlace()).orElse(underscore));
map.put(INSTITUTION_REA, Optional.ofNullable(institution.getRea()).orElse(underscore));
map.put(INSTITUTION_SHARE_CAPITAL, Optional.ofNullable(institution.getShareCapital()).orElse(underscore));
map.put(INSTITUTION_BUSINESS_REGISTER_PLACE, Optional.ofNullable(institution.getBusinessRegisterPlace()).orElse(underscore));

addPricingPlan(onboarding.getPricingPlan(), map);
}

public static void setupSAProdInteropData(Map<String, Object> map, Institution institution) {

String underscore = "_______________";
map.put("institutionREA", Optional.ofNullable(institution.getRea()).orElse(underscore));
map.put("institutionShareCapital", Optional.ofNullable(institution.getShareCapital()).orElse(underscore));
map.put("institutionBusinessRegisterPlace", Optional.ofNullable(institution.getBusinessRegisterPlace()).orElse(underscore));
map.put(INSTITUTION_REA, Optional.ofNullable(institution.getRea()).orElse(underscore));
map.put(INSTITUTION_SHARE_CAPITAL, Optional.ofNullable(institution.getShareCapital()).orElse(underscore));
map.put(INSTITUTION_BUSINESS_REGISTER_PLACE, Optional.ofNullable(institution.getBusinessRegisterPlace()).orElse(underscore));
//override originId to not fill ipa code in case of SA
if(InstitutionType.SA.equals(institution.getInstitutionType()))
map.put("originId", underscore);
Expand All @@ -119,50 +129,50 @@ public static void setupProdPNData(Map<String, Object> map, Institution institut

private static void addPricingPlan(String pricingPlan, Map<String, Object> map) {
if (Objects.nonNull(pricingPlan) && Arrays.stream(PLAN_LIST).anyMatch(s -> s.equalsIgnoreCase(pricingPlan))) {
map.put("pricingPlanPremium", pricingPlan.replace("C", ""));
map.put("pricingPlanPremiumCheckbox", "X");
map.put(PRICING_PLAN_PREMIUM, pricingPlan.replace("C", ""));
map.put(PRICING_PLAN_PREMIUM_CHECKBOX, "X");
} else {
map.put("pricingPlanPremium", "");
map.put("pricingPlanPremiumCheckbox", "");
map.put(PRICING_PLAN_PREMIUM, "");
map.put(PRICING_PLAN_PREMIUM_CHECKBOX, "");
}

map.put("pricingPlanPremiumBase", Optional.ofNullable(pricingPlan).orElse(""));

if (Objects.nonNull(pricingPlan) && "C0".equalsIgnoreCase(pricingPlan)) {
map.put("pricingPlanPremiumBaseCheckbox", "X");
map.put(PRICING_PLAN_PREMIUM_CHECKBOX, "X");
} else {
map.put("pricingPlanPremiumBaseCheckbox", "");
map.put(PRICING_PLAN_PREMIUM_CHECKBOX, "");
}
}

private static void addInstitutionRegisterLabelValue(Institution institution, Map<String, Object> map) {
if (institution.getPaymentServiceProvider() != null
&& Objects.nonNull(institution.getPaymentServiceProvider().getBusinessRegisterNumber())) {
map.put("number", institution.getPaymentServiceProvider().getBusinessRegisterNumber());
map.put("institutionRegisterLabelValue", "<li class=\"c19 c39 li-bullet-0\"><span class=\"c1\">codice di iscrizione all&rsquo;Indice delle Pubbliche Amministrazioni e dei gestori di pubblici servizi (I.P.A.) <span class=\"c3\">${number}</span> </span><span class=\"c1\"></span></li>\n");
map.put(INSTITUTION_REGISTER_LABEL_VALUE, "<li class=\"c19 c39 li-bullet-0\"><span class=\"c1\">codice di iscrizione all&rsquo;Indice delle Pubbliche Amministrazioni e dei gestori di pubblici servizi (I.P.A.) <span class=\"c3\">${number}</span> </span><span class=\"c1\"></span></li>\n");
} else {
map.put("institutionRegisterLabelValue", "");
map.put(INSTITUTION_REGISTER_LABEL_VALUE, "");
}
}

private static void decodePricingPlan(String pricingPlan, String productId, Map<String, Object> map) {
if (PricingPlan.FA.name().equals(pricingPlan)) {
map.put("pricingPlanFastCheckbox", "X");
map.put("pricingPlanBaseCheckbox", "");
map.put("pricingPlanPremiumCheckbox", "");
map.put("pricingPlan", PricingPlan.FA.getValue());
map.put(PRICING_PLAN_FAST_CHECKBOX, "X");
map.put(PRICING_PLAN_BASE_CHECKBOX, "");
map.put(PRICING_PLAN_PREMIUM_CHECKBOX, "");
map.put(PRICING_PLAN, PricingPlan.FA.getValue());
return;
}
if (PROD_IO.getValue().equalsIgnoreCase(productId)) {
map.put("pricingPlanFastCheckbox", "");
map.put("pricingPlanBaseCheckbox", "X");
map.put("pricingPlanPremiumCheckbox", "");
map.put("pricingPlan", PricingPlan.BASE.getValue());
map.put(PRICING_PLAN_FAST_CHECKBOX, "");
map.put(PRICING_PLAN_BASE_CHECKBOX, "X");
map.put(PRICING_PLAN_PREMIUM_CHECKBOX, "");
map.put(PRICING_PLAN, PricingPlan.BASE.getValue());
} else {
map.put("pricingPlanFastCheckbox", "");
map.put("pricingPlanBaseCheckbox", "");
map.put("pricingPlanPremiumCheckbox", "X");
map.put("pricingPlan", PricingPlan.PREMIUM.getValue());
map.put(PRICING_PLAN_FAST_CHECKBOX, "");
map.put(PRICING_PLAN_BASE_CHECKBOX, "");
map.put(PRICING_PLAN_PREMIUM_CHECKBOX, "X");
map.put(PRICING_PLAN, PricingPlan.PREMIUM.getValue());
}
}

Expand Down

0 comments on commit 8edb8ca

Please sign in to comment.