Skip to content

Commit

Permalink
NOD-784 re
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsca committed Apr 10, 2024
1 parent db6a394 commit 051bf2e
Show file tree
Hide file tree
Showing 11 changed files with 180 additions and 11 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
<artifactId>logback-ecs-encoder</artifactId>
<version>${java-ecs-logging.version}</version>
</dependency>

</dependencies>

<profiles>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package it.gov.pagopa.wispconverter.repository;

import com.azure.spring.data.cosmos.repository.CosmosRepository;
import it.gov.pagopa.wispconverter.repository.model.ReEventEntity;
import org.springframework.stereotype.Repository;

import java.util.Optional;

@Repository
public interface ReEventRepository extends CosmosRepository<ReEventEntity, String> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package it.gov.pagopa.wispconverter.repository.model;

import com.azure.spring.data.cosmos.core.mapping.Container;
import com.azure.spring.data.cosmos.core.mapping.PartitionKey;

import lombok.*;
import org.springframework.data.annotation.Id;
import it.gov.pagopa.wispconverter.repository.model.enumz.*;

import java.time.Instant;

@Container(containerName = "re")
@Data
@Builder(toBuilder = true)
public class ReEventEntity {
//// START KEY
@Id
private String id;

@PartitionKey
private String partitionKey;
//// END KEY

//// START LOGICAL REF
private String requestId; //gruppo, tutte le chiamate fatte con lo stesso X-Request-ID
private String operationId; //id operation associato a un requestId
private String clientOperationId; //id client operation associato a un operationId
private ComponenteEnum componente; //componente che scrive l'evento
private Instant insertedTimestamp; //ora di inserimento evento
//// END LOGICAL REF

//// START FIELD FOR INTERFACE AND INTERN CHANGE
private CategoriaEventoEnum categoriaEvento;
private SottoTipoEventoEnum sottoTipoEvento;
//// END FIELD FOR INTERFACE AND INTERN CHANGE

//// START FIELD FOR INTERFACE
private CallTypeEnum callType;

private String fruitore;
private String fruitoreDescr;
private String erogatore;
private String erogatoreDescr;

private EsitoEnum esito;

private String httpMethod;
private String httpUri;
private String httpHeaders;
private String httpCallRemoteAddress;

private Integer httpStatusCode;
private Long executionTimeMs;

private String compressedPayload; //zip+Base64
private Integer compressedPayloadLength;

private String businessProcess;

private String operationStatus; //dettaglio response in uscita
private String operationErrorTitle; //dettaglio response in uscita
private String operationErrorDetail; //dettaglio response in uscita
private String operationErrorCode; //dettaglio response in uscita
//// END FIELD FOR INTERFACE

//// START FIELD FOR INTERN CHANGE
private String idDominio;
private String iuv;
private String ccp;
private String psp;
private String tipoVersamento;
private String tipoEvento;
private String stazione;
private String canale;
private String parametriSpecificiInterfaccia;
private String status;
private String info;

private String pspDescr;
private String noticeNumber;
private String creditorReferenceId;
private String paymentToken;
private String sessionIdOriginal;
private Boolean standIn;
//// END FIELD FOR INTERN CHANGE

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package it.gov.pagopa.wispconverter.repository.model.enumz;

public enum CallTypeEnum {
SERVER,
CLIENT;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package it.gov.pagopa.wispconverter.repository.model.enumz;

public enum CategoriaEventoEnum {
INTERFACCIA,
INTERNO;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package it.gov.pagopa.wispconverter.repository.model.enumz;

public enum ComponenteEnum {
// FESP,
WISP_SOAP_CONVERTER,
WISP_CONVERTER;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package it.gov.pagopa.wispconverter.repository.model.enumz;

public enum EsitoEnum {
INVIATA, INVIATA_KO, RICEVUTA, RICEVUTA_KO, NO_RICEVUTA, CAMBIO_STATO;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package it.gov.pagopa.wispconverter.repository.model.enumz;

public enum SottoTipoEventoEnum {
REQ,
RESP,
INTERN;
}
27 changes: 17 additions & 10 deletions src/main/java/it/gov/pagopa/wispconverter/service/ReService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import it.gov.pagopa.wispconverter.repository.ReEventRepository;
import it.gov.pagopa.wispconverter.repository.model.ReEventEntity;
import it.gov.pagopa.wispconverter.service.mapper.ReEventMapper;
import it.gov.pagopa.wispconverter.service.model.re.ReEventDto;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -12,18 +15,22 @@
@RequiredArgsConstructor
public class ReService {

private final ObjectMapper objectMapper;
private final ReEventRepository reEventRepository;
private final ReEventMapper reEventMapper;
// private final ObjectMapper objectMapper;

public void addRe(ReEventDto reEventDto) {
try {
log.info("\n" +
"#################\n" +
"# RE "+reEventDto.getCategoriaEvento()+"/"+reEventDto.getCallType()+"/"+reEventDto.getSottoTipoEvento()+" \n" +
objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(reEventDto) + "\n" +
"#################");
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
// try {
// log.info("\n" +
// "#################\n" +
// "# RE "+reEventDto.getCategoriaEvento()+"/"+reEventDto.getCallType()+"/"+reEventDto.getSottoTipoEvento()+" \n" +
// objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(reEventDto) + "\n" +
// "#################");
ReEventEntity reEventEntity = reEventMapper.toReEventEntity(reEventDto);
reEventRepository.save(reEventEntity);
// } catch (JsonProcessingException e) {
// throw new RuntimeException(e);
// }
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package it.gov.pagopa.wispconverter.service.mapper;

import it.gov.pagopa.wispconverter.repository.model.ReEventEntity;
import it.gov.pagopa.wispconverter.service.model.CommonRPTFieldsDTO;
import it.gov.pagopa.wispconverter.service.model.PaymentNoticeContentDTO;
import it.gov.pagopa.wispconverter.service.model.re.ReEventDto;
import org.mapstruct.*;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.TimeZone;

@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface ReEventMapper {

static final String PATTERN_FORMAT = "yyyy-MM-dd";

@Mapping(source = "insertedTimestamp", target = "partitionKey", qualifiedByName = "partitionKeyFromInstant")
ReEventEntity toReEventEntity(ReEventDto reEventDto);

@Named("partitionKeyFromInstant")
public static String partitionKeyFromInstant(Instant insertedTimestamp) {
return insertedTimestamp == null ? null : DateTimeFormatter
.ofPattern(PATTERN_FORMAT)
.withZone(ZoneId.systemDefault())
.format(insertedTimestamp);
}

}
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ client.gpd.api-key=${CLIENT_GPD_SUBKEY:none}
# IUV generator client configuration
client.iuvgenerator.read-timeout=${CLIENT_IUVGENERATOR_READ_TIMEOUT:5000}
client.iuvgenerator.connect-timeout=${CLIENT_IUVGENERATOR_READ_TIMEOUT:5000}
client.iuvgenerator.base-path=${CLIENT_IUVGENERATOR_HOST:https://api.devvo.platform.pagopa.it/shared/iuv-generator-service/v1}
client.iuvgenerator.base-path=${CLIENT_IUVGENERATOR_HOST:https://api.dev.platform.pagopa.it/shared/iuv-generator-service/v1}
client.iuvgenerator.api-key=${CLIENT_IUVGENERATOR_SUBKEY:none}


Expand Down

0 comments on commit 051bf2e

Please sign in to comment.