Skip to content

Commit

Permalink
Merge pull request #54 from pagopa/VAS-759-bo-export-ec-stazioni-upgrade
Browse files Browse the repository at this point in the history
[VAS-759] Backoffice export ec stazioni upgrade
  • Loading branch information
jacopocarlini authored Jun 13, 2024
2 parents 913ddc2 + ad9cf68 commit f1b1aee
Show file tree
Hide file tree
Showing 10 changed files with 2,065 additions and 2,101 deletions.
4,038 changes: 1,952 additions & 2,086 deletions openapi/openapi.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,78 @@
import it.gov.pagopa.apiconfig.starter.entity.Pa;
import it.gov.pagopa.apiconfig.starter.entity.PaStazionePa;
import it.gov.pagopa.apiconfig.starter.entity.Stazioni;
import org.apache.logging.log4j.util.Strings;
import org.modelmapper.Converter;
import org.modelmapper.spi.MappingContext;

import static it.gov.pagopa.apiconfig.selfcareintegration.util.Utility.deNull;

public class ConvertPaStazionePaToCreditorInstitutionDetail implements Converter<PaStazionePa, CreditorInstitutionDetail> {

@Override
public CreditorInstitutionDetail convert(MappingContext<PaStazionePa, CreditorInstitutionDetail> context) {

PaStazionePa src = context.getSource();
Pa pa = src.getPa();
Stazioni stazioni = src.getFkStazione();
IntermediariPa intermediariPa = stazioni.getIntermediarioPa();
Stazioni stazione = src.getFkStazione();
IntermediariPa intermediariPa = stazione.getIntermediarioPa();

return CreditorInstitutionDetail.builder()
var builder = CreditorInstitutionDetail.builder()
.businessName(pa.getRagioneSociale())
.creditorInstitutionCode(pa.getIdDominio())
.pspPayment(pa.getPagamentoPressoPsp())
.cbillCode(pa.getCbill())
.brokerBusinessName(intermediariPa.getCodiceIntermediario())
.brokerCode(intermediariPa.getIdIntermediarioPa())
.stationCode(stazioni.getIdStazione())
.stationEnabled(stazioni.getEnabled())
.stationVersion(stazioni.getVersione())
.stationCode(stazione.getIdStazione())
.stationEnabled(stazione.getEnabled())
.stationVersion(stazione.getVersione())
.auxDigit(src.getAuxDigit())
.segregationCode(getDoubleDigitCode(src.getSegregazione()))
.applicationCode(getDoubleDigitCode(src.getProgressivo()))
.broadcast(src.getBroadcast())
.build();
.broadcast(src.getBroadcast());

if (Strings.isNotBlank(stazione.getIp())) {
String endpointRT = String.format("%s://%s:%s%s",
deNull(stazione.getProtocollo()).toLowerCase(),
deNull(stazione.getIp()),
deNull(stazione.getPorta()),
addPrefixIfAbsent("/", deNull(stazione.getServizio()))
);
builder.endpointRT(endpointRT);
}

if (Strings.isNotBlank(stazione.getRedirectIp())) {
String endpointRedirect = String.format("%s://%s:%s%s%s",
deNull(stazione.getRedirectProtocollo().toLowerCase()),
deNull(stazione.getRedirectIp()),
deNull(stazione.getRedirectPorta()),
addPrefixIfAbsent("/", deNull(stazione.getRedirectPath())),
addPrefixIfAbsent("?", deNull(stazione.getRedirectQueryString()))
);
builder.endpointRedirect(endpointRedirect);
}

if (Strings.isNotBlank(stazione.getIp4Mod())) {
String endpointMU = String.format("%s://%s:%s%s",
deNull(stazione.getProtocollo4Mod()).toLowerCase(),
deNull(stazione.getIp4Mod()),
deNull(stazione.getPorta4Mod()),
addPrefixIfAbsent("/", deNull(stazione.getServizio4Mod()))
);
builder.endpointMU(endpointMU);
}

builder.primitiveVersion(stazione.getVersionePrimitive());
builder.ciStatus(deNull(src.getPa().getEnabled()));
return builder.build();
}

private String addPrefixIfAbsent(String prefix, String s) {
if (!s.startsWith(prefix)) {
return prefix + s;
}
return s;
}

private String getDoubleDigitCode(Long code) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,25 @@ public class CreditorInstitutionDetail {
@JsonProperty("broadcast")
@Schema(description = "The flag that define if the station is made for broadcast operations", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private Boolean broadcast;

@JsonProperty("endpoint_rt")
@Schema(description = "endpoint for Ricevuta Telematica", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String endpointRT;

@JsonProperty("endpoint_redirect")
@Schema(description = "endpoint for Redirect", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String endpointRedirect;

@JsonProperty("endpoint_mod4")
@Schema(description = "endpoint for Modello Unico", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private String endpointMU;

@JsonProperty("primitive_version")
@Schema(description = "Version of the primitive", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private Integer primitiveVersion;

@JsonProperty("ci_status")
@Schema(description = "True if the CI is enabled", requiredMode = Schema.RequiredMode.REQUIRED)
private Boolean ciStatus;

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ public static <T> PageInfo buildPageInfo(Page<T> page) {
public static String deNull(Object value) {
return Optional.ofNullable(value).orElse("").toString();
}

public static Boolean deNull(Boolean value) {
return Optional.ofNullable(value).orElse(false);
}
}
10 changes: 10 additions & 0 deletions src/main/resources/application-local.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Info
info.properties.environment=local

server.port=8081


# Logging
logging.level.root=INFO
logging.level.it.gov.pagopa=DEBUG
Expand All @@ -16,6 +20,12 @@ spring.datasource.url=jdbc:postgresql://pagopa-d-weu-nodo-flexible-postgresql.po
spring.datasource.username=cfg
spring.datasource.password=${PASSWORD}
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.hikari.connection-test-query=select 1

# JPA settings
spring.jpa.properties.hibernate.default_schema=cfg
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect

# Applicative parameters
sc-int.application_code.max_value=48
sc-int.segregation_code.max_value=45
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ void getCreditorInstitutionsAssociatedToBroker_200(String enabledStation) throws
String actual = TestUtil.toJson(result);

String expected = TestUtil.readJsonFromFile("response/get_creditor_institution_details_ok" + fileIndex + ".json");
System.out.println(actual);
JSONAssert.assertEquals(expected, actual, JSONCompareMode.STRICT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public static List<PaStazionePa> getMockPaStazionePa(Boolean enabledStation) {
.ragioneSociale("Comune di Roma")
.idDominio("02438750586")
.cbill("APNEY")
.enabled(true)
.build())
.fkStazione(
Stazioni.builder()
Expand All @@ -141,6 +142,15 @@ public static List<PaStazionePa> getMockPaStazionePa(Boolean enabledStation) {
.idStazione("80143490581_01")
.enabled(true)
.versione(2L)
.ip("1.1.1.1")
.protocollo("https")
.porta(8080L)
.servizio("/service")
.redirectIp("2.2.2.2")
.redirectProtocollo("http")
.redirectPorta(443L)
.redirectPath("/base")
.redirectQueryString("key=value")
.build()
)
.segregazione(11L)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
"station_version": 2,
"aux_digit": 3,
"segregation_code": "11",
"broadcast": false
"broadcast": false,
"endpoint_rt": "https://1.1.1.1:8080/service",
"endpoint_redirect": "http://2.2.2.2:443/base?key=value",
"ci_status": true
},
{
"business_name": "Comune di Roma",
Expand All @@ -24,7 +27,8 @@
"station_version": 2,
"aux_digit": 3,
"segregation_code": "02",
"broadcast": false
"broadcast": false,
"ci_status": false
}
],
"page_info": {
Expand All @@ -34,4 +38,4 @@
"total_pages": 1,
"total_items": 2
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
"station_version": 2,
"aux_digit": 3,
"segregation_code": "11",
"broadcast": false
"broadcast": false,
"endpoint_rt": "https://1.1.1.1:8080/service",
"endpoint_redirect": "http://2.2.2.2:443/base?key=value",
"ci_status": true
}
],
"page_info": {
Expand All @@ -21,4 +24,4 @@
"total_pages": 1,
"total_items": 1
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"station_version": 2,
"aux_digit": 3,
"segregation_code": "02",
"broadcast": false
"broadcast": false,
"ci_status": false
}
],
"page_info": {
Expand All @@ -21,4 +22,4 @@
"total_pages": 1,
"total_items": 1
}
}
}

0 comments on commit f1b1aee

Please sign in to comment.