Skip to content

Commit

Permalink
[SELC-4551] Refactor string for status to constant
Browse files Browse the repository at this point in the history
  • Loading branch information
flaminiaScarciofolo committed Apr 15, 2024
1 parent 8d588f1 commit 15c39f0
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import java.util.Map;

import static it.pagopa.selfcare.user.constant.CollectionUtil.*;
import static it.pagopa.selfcare.user.constant.OnboardedProductState.ACTIVE;
import static it.pagopa.selfcare.user.constant.OnboardedProductState.SUSPENDED;
import static it.pagopa.selfcare.user.entity.filter.OnboardedProductFilter.OnboardedProductEnum.*;
import static it.pagopa.selfcare.user.util.GeneralUtils.formatQueryParameterList;

Expand Down Expand Up @@ -69,7 +71,7 @@ public Uni<UserInstitution> retrieveFirstFilteredUserInstitution(Map<String, Obj

@Override
public Uni<Long> deleteUserInstitutionProduct(String userId, String institutionId, String productId) {
OnboardedProductFilter onboardedProductFilter = OnboardedProductFilter.builder().productId(productId).status("ACTIVE").build();
OnboardedProductFilter onboardedProductFilter = OnboardedProductFilter.builder().productId(productId).status(ACTIVE.name()).build();
UserInstitutionFilter userInstitutionFilter = UserInstitutionFilter.builder().userId(userId).institutionId(institutionId).build();
Map<String, Object> filterMap = userUtils.retrieveMapForFilter(onboardedProductFilter.constructMap(), userInstitutionFilter.constructMap());
return updateUserStatusDao(filterMap, OnboardedProductState.DELETED);
Expand All @@ -79,9 +81,9 @@ public Uni<Long> deleteUserInstitutionProduct(String userId, String institutionI
public Uni<Long> updateUserStatusWithOptionalFilterByInstitutionAndProduct(String userId, String institutionId, String productId, PartyRole role, String productRole, OnboardedProductState status) {
Map<String, Object> onboardedProductFilterMap;
if(status.equals(OnboardedProductState.ACTIVE)) {
onboardedProductFilterMap = OnboardedProductFilter.builder().productId(productId).role(role).productRole(productRole).status("SUSPENDED").build().constructMap();
}else if(status.equals(OnboardedProductState.SUSPENDED)) {
onboardedProductFilterMap = OnboardedProductFilter.builder().productId(productId).role(role).productRole(productRole).status("ACTIVE").build().constructMap();
onboardedProductFilterMap = OnboardedProductFilter.builder().productId(productId).role(role).productRole(productRole).status(SUSPENDED.name()).build().constructMap();
}else if(status.equals(SUSPENDED)) {
onboardedProductFilterMap = OnboardedProductFilter.builder().productId(productId).role(role).productRole(productRole).status(ACTIVE.name()).build().constructMap();
}else {
onboardedProductFilterMap = OnboardedProductFilter.builder().productId(productId).role(role).productRole(productRole).build().constructMap();
}
Expand Down

0 comments on commit 15c39f0

Please sign in to comment.