-
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 - 5220] feat: added PDND InfoCamere endpoint retrieveInstitutio…
…nsByDescription (#207)
- Loading branch information
1 parent
92abe15
commit c2bdc75
Showing
21 changed files
with
812 additions
and
1 deletion.
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
11 changes: 11 additions & 0 deletions
11
...t/pagopa/selfcare/party/registry_proxy/connector/api/PDNDNationalRegistriesConnector.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package it.pagopa.selfcare.party.registry_proxy.connector.api; | ||
|
||
import it.pagopa.selfcare.party.registry_proxy.connector.model.nationalregistriespdnd.PDNDBusiness; | ||
|
||
import java.util.List; | ||
|
||
public interface PDNDNationalRegistriesConnector { | ||
|
||
List<PDNDBusiness> retrieveInstitutionsPdndByDescription(String description); | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
...pa/selfcare/party/registry_proxy/connector/model/nationalregistriespdnd/PDNDBusiness.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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package it.pagopa.selfcare.party.registry_proxy.connector.model.nationalregistriespdnd; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class PDNDBusiness { | ||
private String businessTaxId; | ||
private String businessName; | ||
private String legalNature; | ||
private String legalNatureDescription; | ||
private String cciaa; | ||
private String nRea; | ||
private String businessStatus; | ||
private String city; | ||
private String county; | ||
private String zipCode; | ||
private String address; | ||
private String digitalAddress; | ||
} |
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
43 changes: 43 additions & 0 deletions
43
...opa/selfcare/party/registry_proxy/connector/rest/PDNDNationalRegistriesConnectorImpl.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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package it.pagopa.selfcare.party.registry_proxy.connector.rest; | ||
|
||
import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker; | ||
import io.github.resilience4j.retry.annotation.Retry; | ||
import it.pagopa.selfcare.party.registry_proxy.connector.api.PDNDNationalRegistriesConnector; | ||
import it.pagopa.selfcare.party.registry_proxy.connector.model.nationalregistriespdnd.PDNDBusiness; | ||
import it.pagopa.selfcare.party.registry_proxy.connector.rest.client.PDNDNationalRegistriesRestClient; | ||
import it.pagopa.selfcare.party.registry_proxy.connector.rest.model.*; | ||
import it.pagopa.selfcare.party.registry_proxy.connector.rest.model.mapper.PDNDBusinessMapper; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.util.Assert; | ||
|
||
import java.util.List; | ||
|
||
@Slf4j | ||
@Service | ||
public class PDNDNationalRegistriesConnectorImpl implements PDNDNationalRegistriesConnector { | ||
public static final String ERROR_PDND_NATIONAL_REGISTRIES_REST_CLIENT_MESSAGE = "Error pdnd-national-registries rest client, message: %s"; | ||
|
||
private final PDNDNationalRegistriesRestClient pdndNationalRegistriesRestClient; | ||
private final PDNDBusinessMapper pdndBusinessMapper; | ||
|
||
public PDNDNationalRegistriesConnectorImpl(PDNDNationalRegistriesRestClient pdndNationalRegistriesRestClient, PDNDBusinessMapper pdndBusinessMapper) { | ||
this.pdndNationalRegistriesRestClient = pdndNationalRegistriesRestClient; | ||
this.pdndBusinessMapper = pdndBusinessMapper; | ||
} | ||
|
||
@Override | ||
@CircuitBreaker(name = "pdndNationalRegistriesCircuitbreaker", fallbackMethod = "fallbackRetrieveInstitutionByDescription") | ||
@Retry(name = "retryServiceUnavailable") | ||
public List<PDNDBusiness> retrieveInstitutionsPdndByDescription(String description) { | ||
Assert.hasText(description, "Description is required"); | ||
List<PDNDImpresa> result = pdndNationalRegistriesRestClient.retrieveInstitutionsPdndByDescription(description); | ||
return pdndBusinessMapper.toPDNDBusiness(result); | ||
} | ||
|
||
public List<PDNDBusiness> fallbackRetrieveInstitutionByDescription(RuntimeException e) { | ||
log.error(String.format(ERROR_PDND_NATIONAL_REGISTRIES_REST_CLIENT_MESSAGE, e.getMessage())); | ||
return List.of(); | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
...selfcare/party/registry_proxy/connector/rest/client/PDNDNationalRegistriesRestClient.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package it.pagopa.selfcare.party.registry_proxy.connector.rest.client; | ||
|
||
import it.pagopa.selfcare.party.registry_proxy.connector.rest.model.*; | ||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; | ||
|
||
@FeignClient(name = "${rest-client.pdnd-national-registries.serviceCode}", url = "${rest-client.pdnd-national-registries.base-url}") | ||
public interface PDNDNationalRegistriesRestClient { | ||
|
||
@GetMapping(value = "${rest-client.pdnd-national-registries.getDescription.path}", consumes = APPLICATION_JSON_VALUE) | ||
@ResponseBody | ||
List<PDNDImpresa> retrieveInstitutionsPdndByDescription(@RequestParam String description); | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
...re/party/registry_proxy/connector/rest/config/PDNDNationalRegistriesRestClientConfig.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package it.pagopa.selfcare.party.registry_proxy.connector.rest.config; | ||
|
||
import it.pagopa.selfcare.commons.connector.rest.config.RestClientBaseConfig; | ||
import it.pagopa.selfcare.party.registry_proxy.connector.rest.client.PDNDNationalRegistriesRestClient; | ||
import org.springframework.cloud.openfeign.EnableFeignClients; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.context.annotation.PropertySource; | ||
|
||
@Configuration | ||
@Import(RestClientBaseConfig.class) | ||
@EnableFeignClients(clients = PDNDNationalRegistriesRestClient.class) | ||
@PropertySource("classpath:config/pdnd-national-registries-rest-client.properties") | ||
public class PDNDNationalRegistriesRestClientConfig { | ||
|
||
} |
99 changes: 99 additions & 0 deletions
99
...c/main/java/it/pagopa/selfcare/party/registry_proxy/connector/rest/model/PDNDImpresa.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 |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package it.pagopa.selfcare.party.registry_proxy.connector.rest.model; | ||
|
||
import lombok.Data; | ||
|
||
import javax.xml.bind.annotation.XmlElement; | ||
import javax.xml.bind.annotation.XmlRootElement; | ||
import javax.xml.bind.annotation.XmlTransient; | ||
import javax.xml.bind.annotation.XmlType; | ||
|
||
@Data | ||
@XmlRootElement(name = "Impresa", namespace = "http://it.registroimprese.pcad.ws") | ||
@XmlType(propOrder = { | ||
"businessTaxId", | ||
"businessName", | ||
"legalNature", | ||
"legalNatureDescription", | ||
"cciaa", | ||
"nRea", | ||
"businessStatus", | ||
"provinciaSede", | ||
"comuneSede", | ||
"toponimoSede", | ||
"viaSede", | ||
"ncivicoSede", | ||
"capSede", | ||
"digitalAddress" | ||
}) | ||
public class PDNDImpresa { | ||
|
||
@XmlElement(name = "CodiceFiscale") | ||
private String businessTaxId; | ||
|
||
@XmlElement(name = "Denominazione") | ||
private String businessName; | ||
|
||
@XmlElement(name = "NaturaGiuridica") | ||
private String legalNature; | ||
|
||
@XmlElement(name = "DescNaturaGiuridica") | ||
private String legalNatureDescription; | ||
|
||
@XmlElement(name = "Cciaa") | ||
private String cciaa; | ||
|
||
@XmlElement(name = "NRea") | ||
private String nRea; | ||
|
||
@XmlElement(name = "StatoImpresa") | ||
private String businessStatus; | ||
|
||
@XmlElement(name = "ComuneSede") | ||
private String city; | ||
|
||
@XmlElement(name = "ProvinciaSede") | ||
private String county; | ||
|
||
@XmlElement(name = "CapSede") | ||
private String zipCode; | ||
|
||
@XmlElement(name = "PEC") | ||
private String digitalAddress; | ||
|
||
private String toponimoSede; | ||
private String viaSede; | ||
private String ncivicoSede; | ||
|
||
@XmlElement(name = "ToponimoSede") | ||
public String getToponimoSede() { | ||
return toponimoSede; | ||
} | ||
|
||
public void setToponimoSede(String toponimoSede) { | ||
this.toponimoSede = toponimoSede; | ||
} | ||
|
||
@XmlElement(name = "ViaSede") | ||
public String getViaSede() { | ||
return viaSede; | ||
} | ||
|
||
public void setViaSede(String viaSede) { | ||
this.viaSede = viaSede; | ||
} | ||
|
||
@XmlElement(name = "NcivicoSede") | ||
public String getNcivicoSede() { | ||
return ncivicoSede; | ||
} | ||
|
||
public void setNcivicoSede(String ncivicoSede) { | ||
this.ncivicoSede = ncivicoSede; | ||
} | ||
|
||
@XmlTransient | ||
public String getAddress() { | ||
return toponimoSede + " " + viaSede + " " + ncivicoSede; | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
.../pagopa/selfcare/party/registry_proxy/connector/rest/model/mapper/PDNDBusinessMapper.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package it.pagopa.selfcare.party.registry_proxy.connector.rest.model.mapper; | ||
|
||
import it.pagopa.selfcare.party.registry_proxy.connector.model.nationalregistriespdnd.PDNDBusiness; | ||
import it.pagopa.selfcare.party.registry_proxy.connector.rest.model.PDNDImpresa; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
|
||
import java.util.List; | ||
|
||
@Mapper(componentModel = "spring") | ||
public interface PDNDBusinessMapper { | ||
|
||
@Mapping(source = "getAddress", target = "address") | ||
List<PDNDBusiness> toPDNDBusiness(List<PDNDImpresa> pdndImpresaList); | ||
|
||
} |
Oops, something went wrong.