Skip to content

Commit

Permalink
map selcRole ADMIN_EA in getProductRoles API
Browse files Browse the repository at this point in the history
  • Loading branch information
giulia-tremolada committed Nov 14, 2024
1 parent 2c7d06e commit 07e6ebb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package it.pagopa.selfcare.dashboard.connector.model.delegation;

import it.pagopa.selfcare.onboarding.common.InstitutionType;
import lombok.Data;

import java.time.OffsetDateTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@
import it.pagopa.selfcare.dashboard.web.model.product.ProductsResource;
import it.pagopa.selfcare.dashboard.web.model.product.SubProductResource;
import it.pagopa.selfcare.onboarding.common.PartyRole;
import it.pagopa.selfcare.product.entity.*;
import it.pagopa.selfcare.product.entity.BackOfficeConfigurations;
import it.pagopa.selfcare.product.entity.Product;
import it.pagopa.selfcare.product.entity.ProductRole;
import it.pagopa.selfcare.product.entity.ProductRoleInfo;

import java.util.Collection;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;

public class ProductsMapper {

static final Map<PartyRole, SelfCareAuthority> ROLE_MAP = Map.of(
PartyRole.OPERATOR, SelfCareAuthority.LIMITED,
PartyRole.ADMIN_EA, SelfCareAuthority.ADMIN_EA
);

public static ProductsResource toResource(ProductTree model) {
ProductsResource resource = null;
if (model != null) {
Expand Down Expand Up @@ -99,7 +105,7 @@ static ProductRoleMappingsResource toProductRoleMappingsResource(Map.Entry<Party
if (entry != null) {
resource = new ProductRoleMappingsResource();
resource.setPartyRole(entry.getKey().name());
resource.setSelcRole(entry.getKey() != PartyRole.OPERATOR ? SelfCareAuthority.ADMIN : SelfCareAuthority.LIMITED);
resource.setSelcRole(toSelcRole(entry.getKey()));
resource.setMultiroleAllowed(entry.getValue().isMultiroleAllowed());
resource.setPhasesAdditionAllowed(entry.getValue().getPhasesAdditionAllowed());

Expand All @@ -124,4 +130,8 @@ static ProductRoleMappingsResource.ProductRoleResource toProductRoleResource(Pro
return resource;
}

static SelfCareAuthority toSelcRole(PartyRole partyRole) {
return ROLE_MAP.getOrDefault(partyRole, SelfCareAuthority.ADMIN);
}

}

0 comments on commit 07e6ebb

Please sign in to comment.