generated from pagopa/template-payments-java-repository
-
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.
Merge branch 'refs/heads/develop' into P4ADEV-1744-add-api-finalize-s…
…ync-status # Conflicts: # openapi/generated.openapi.json # src/main/java/it/gov/pagopa/pu/debtpositions/mapper/DebtPositionMapper.java # src/main/java/it/gov/pagopa/pu/debtpositions/mapper/InstallmentMapper.java # src/main/java/it/gov/pagopa/pu/debtpositions/mapper/PaymentOptionMapper.java # src/main/java/it/gov/pagopa/pu/debtpositions/mapper/PersonMapper.java # src/main/java/it/gov/pagopa/pu/debtpositions/mapper/TransferMapper.java # src/main/java/it/gov/pagopa/pu/debtpositions/model/DebtPosition.java # src/main/java/it/gov/pagopa/pu/debtpositions/model/PaymentOption.java # src/main/java/it/gov/pagopa/pu/debtpositions/model/Transfer.java # src/main/java/it/gov/pagopa/pu/debtpositions/service/DebtPositionService.java # src/main/java/it/gov/pagopa/pu/debtpositions/service/DebtPositionServiceImpl.java # src/test/java/it/gov/pagopa/pu/debtpositions/util/faker/DebtPositionFaker.java # src/test/java/it/gov/pagopa/pu/debtpositions/util/faker/InstallmentFaker.java # src/test/java/it/gov/pagopa/pu/debtpositions/util/faker/PaymentOptionFaker.java # src/test/java/it/gov/pagopa/pu/debtpositions/util/faker/PersonFaker.java # src/test/java/it/gov/pagopa/pu/debtpositions/util/faker/TransferFaker.java
- Loading branch information
Showing
34 changed files
with
1,141 additions
and
649 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
58 changes: 55 additions & 3 deletions
58
src/main/java/it/gov/pagopa/pu/debtpositions/mapper/DebtPositionMapper.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 |
---|---|---|
@@ -1,12 +1,64 @@ | ||
package it.gov.pagopa.pu.debtpositions.mapper; | ||
|
||
import it.gov.pagopa.pu.debtpositions.dto.Installment; | ||
import it.gov.pagopa.pu.debtpositions.dto.generated.DebtPositionDTO; | ||
import it.gov.pagopa.pu.debtpositions.model.DebtPosition; | ||
import it.gov.pagopa.pu.debtpositions.model.InstallmentNoPII; | ||
import it.gov.pagopa.pu.debtpositions.model.PaymentOption; | ||
import org.mapstruct.Mapper; | ||
import org.springframework.data.util.Pair; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Mapper(componentModel = "spring", uses = {PaymentOptionMapper.class}) | ||
public interface DebtPositionMapper { | ||
import java.util.*; | ||
import java.util.stream.Collector; | ||
import java.util.stream.Collectors; | ||
|
||
DebtPositionDTO map(DebtPosition debtPosition); | ||
@Service | ||
public class DebtPositionMapper { | ||
|
||
private final PaymentOptionMapper paymentOptionMapper; | ||
|
||
private static final Collector<PaymentOption, ?, SortedSet<PaymentOption>> toPaymentOptionTreeSet = Collectors.toCollection(TreeSet::new); | ||
|
||
public DebtPositionMapper(PaymentOptionMapper paymentOptionMapper) { | ||
this.paymentOptionMapper = paymentOptionMapper; | ||
} | ||
|
||
public Pair<DebtPosition, Map<InstallmentNoPII, Installment>> mapToModel(DebtPositionDTO dto) { | ||
DebtPosition debtPosition = new DebtPosition(); | ||
debtPosition.setDebtPositionId(dto.getDebtPositionId()); | ||
debtPosition.setIupdOrg(dto.getIupdOrg()); | ||
debtPosition.setDescription(dto.getDescription()); | ||
debtPosition.setStatus(dto.getStatus()); | ||
debtPosition.setIngestionFlowFileId(dto.getIngestionFlowFileId()); | ||
debtPosition.setIngestionFlowFileLineNumber(dto.getIngestionFlowFileLineNumber()); | ||
debtPosition.setOrganizationId(dto.getOrganizationId()); | ||
debtPosition.setDebtPositionTypeOrgId(dto.getDebtPositionTypeOrgId()); | ||
debtPosition.setNotificationDate(dto.getNotificationDate()); | ||
debtPosition.setValidityDate(dto.getValidityDate()); | ||
debtPosition.setFlagIuvVolatile(dto.getFlagIuvVolatile()); | ||
debtPosition.setCreationDate(dto.getCreationDate().toLocalDateTime()); | ||
debtPosition.setUpdateDate(dto.getUpdateDate().toLocalDateTime()); | ||
|
||
Map<InstallmentNoPII, Installment> installmentMapping = new HashMap<>(); | ||
|
||
SortedSet<PaymentOption> paymentOptions = dto.getPaymentOptions().stream() | ||
.map(paymentOptionDTO -> { | ||
Pair<PaymentOption, Map<InstallmentNoPII, Installment>> paymentOptionWithInstallments = paymentOptionMapper.mapToModel(paymentOptionDTO); | ||
installmentMapping.putAll(paymentOptionWithInstallments.getSecond()); | ||
return paymentOptionWithInstallments.getFirst(); | ||
}) | ||
.collect(toPaymentOptionTreeSet); | ||
|
||
debtPosition.setPaymentOptions(paymentOptions); | ||
|
||
return Pair.of(debtPosition, installmentMapping); | ||
} | ||
} | ||
|
||
//@Mapper(componentModel = "spring", uses = {PaymentOptionMapper.class}) | ||
//public interface DebtPositionMapper { | ||
// | ||
// DebtPositionDTO map(DebtPosition debtPosition); | ||
//} | ||
|
50 changes: 47 additions & 3 deletions
50
src/main/java/it/gov/pagopa/pu/debtpositions/mapper/InstallmentMapper.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 |
---|---|---|
@@ -1,11 +1,55 @@ | ||
package it.gov.pagopa.pu.debtpositions.mapper; | ||
|
||
import it.gov.pagopa.pu.debtpositions.dto.Installment; | ||
import it.gov.pagopa.pu.debtpositions.dto.generated.InstallmentDTO; | ||
import it.gov.pagopa.pu.debtpositions.model.InstallmentNoPII; | ||
import org.mapstruct.Mapper; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Mapper(componentModel = "spring", uses = {TransferMapper.class, PersonMapper.class}) | ||
public interface InstallmentMapper { | ||
@Service | ||
public class InstallmentMapper { | ||
|
||
private final PersonMapper personMapper; | ||
|
||
private final TransferMapper transferMapper; | ||
|
||
public InstallmentMapper(PersonMapper personMapper, TransferMapper transferMapper) { | ||
this.personMapper = personMapper; | ||
this.transferMapper = transferMapper; | ||
} | ||
|
||
public Installment mapToModel(InstallmentDTO dto) { | ||
Installment installment = new Installment(); | ||
installment.setInstallmentId(dto.getInstallmentId()); | ||
installment.setPaymentOptionId(dto.getPaymentOptionId()); | ||
installment.setStatus(dto.getStatus()); | ||
installment.setIupdPagopa(dto.getIupdPagopa()); | ||
installment.setIud(dto.getIud()); | ||
installment.setIuv(dto.getIuv()); | ||
installment.setIur(dto.getIur()); | ||
installment.setIuf(dto.getIuf()); | ||
installment.setNav(dto.getNav()); | ||
installment.setDueDate(dto.getDueDate()); | ||
installment.setPaymentTypeCode(dto.getPaymentTypeCode()); | ||
installment.setAmountCents(dto.getAmountCents()); | ||
installment.setNotificationFeeCents(dto.getNotificationFeeCents()); | ||
installment.setRemittanceInformation(dto.getRemittanceInformation()); | ||
installment.setHumanFriendlyRemittanceInformation(dto.getHumanFriendlyRemittanceInformation()); | ||
installment.setBalance(dto.getBalance()); | ||
installment.setLegacyPaymentMetadata(dto.getLegacyPaymentMetadata()); | ||
installment.setDebtor(personMapper.mapToModel(dto.getDebtor())); | ||
installment.setTransfers(dto.getTransfers().stream() | ||
.map(transferMapper::mapToModel) | ||
.toList()); | ||
installment.setCreationDate(dto.getCreationDate().toLocalDateTime()); | ||
installment.setUpdateDate(dto.getUpdateDate().toLocalDateTime()); | ||
return installment; | ||
} | ||
|
||
InstallmentDTO map(InstallmentNoPII installment); | ||
} | ||
|
||
//@Mapper(componentModel = "spring", uses = {TransferMapper.class, PersonMapper.class}) | ||
//public interface InstallmentMapper { | ||
// | ||
// InstallmentDTO map(InstallmentNoPII installment); | ||
//} |
59 changes: 56 additions & 3 deletions
59
src/main/java/it/gov/pagopa/pu/debtpositions/mapper/PaymentOptionMapper.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 |
---|---|---|
@@ -1,11 +1,64 @@ | ||
package it.gov.pagopa.pu.debtpositions.mapper; | ||
|
||
import it.gov.pagopa.pu.debtpositions.dto.Installment; | ||
import it.gov.pagopa.pu.debtpositions.dto.InstallmentPIIDTO; | ||
import it.gov.pagopa.pu.debtpositions.dto.generated.PaymentOptionDTO; | ||
import it.gov.pagopa.pu.debtpositions.enums.PaymentOptionType; | ||
import it.gov.pagopa.pu.debtpositions.model.InstallmentNoPII; | ||
import it.gov.pagopa.pu.debtpositions.model.PaymentOption; | ||
import org.mapstruct.Mapper; | ||
import org.springframework.data.util.Pair; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Mapper(componentModel = "spring", uses = {InstallmentMapper.class}) | ||
public interface PaymentOptionMapper { | ||
import java.util.*; | ||
import java.util.stream.Collector; | ||
import java.util.stream.Collectors; | ||
|
||
PaymentOptionDTO map(PaymentOption paymentOption); | ||
@Service | ||
public class PaymentOptionMapper { | ||
|
||
private final InstallmentMapper installmentMapper; | ||
private final InstallmentPIIMapper installmentPIIMapper; | ||
|
||
private static final Collector<InstallmentNoPII, ?, SortedSet<InstallmentNoPII>> toInstallmentTreeSet = Collectors.toCollection(TreeSet::new); | ||
|
||
public PaymentOptionMapper(InstallmentMapper installmentMapper, InstallmentPIIMapper installmentPIIMapper) { | ||
this.installmentMapper = installmentMapper; | ||
this.installmentPIIMapper = installmentPIIMapper; | ||
} | ||
|
||
public Pair<PaymentOption, Map<InstallmentNoPII, Installment>> mapToModel(PaymentOptionDTO dto) { | ||
Map<InstallmentNoPII, Installment> installmentMapping = new HashMap<>(); | ||
|
||
List<Installment> installments = dto.getInstallments().stream() | ||
.map(installmentMapper::mapToModel) | ||
.toList(); | ||
|
||
SortedSet<InstallmentNoPII> installmentNoPIIs = installments.stream() | ||
.map(installment -> { | ||
Pair<InstallmentNoPII, InstallmentPIIDTO> result = installmentPIIMapper.map(installment); | ||
InstallmentNoPII installmentNoPII = result.getFirst(); | ||
installmentMapping.put(installmentNoPII, installment); | ||
return installmentNoPII; | ||
}) | ||
.collect(toInstallmentTreeSet); | ||
|
||
PaymentOption paymentOption = new PaymentOption(); | ||
paymentOption.setPaymentOptionId(dto.getPaymentOptionId()); | ||
paymentOption.setDebtPositionId(dto.getDebtPositionId()); | ||
paymentOption.setTotalAmountCents(dto.getTotalAmountCents()); | ||
paymentOption.setStatus(dto.getStatus()); | ||
paymentOption.setMultiDebtor(dto.getMultiDebtor()); | ||
paymentOption.setDueDate(dto.getDueDate()); | ||
paymentOption.setDescription(dto.getDescription()); | ||
paymentOption.setPaymentOptionType(PaymentOptionType.valueOf(dto.getPaymentOptionType().name())); | ||
paymentOption.setInstallments(installmentNoPIIs); | ||
|
||
return Pair.of(paymentOption, installmentMapping); | ||
} | ||
} | ||
//@Mapper(componentModel = "spring", uses = {InstallmentMapper.class}) | ||
//public interface PaymentOptionMapper { | ||
// | ||
// PaymentOptionDTO map(PaymentOption paymentOption); | ||
//} |
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
29 changes: 25 additions & 4 deletions
29
src/main/java/it/gov/pagopa/pu/debtpositions/mapper/TransferMapper.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 |
---|---|---|
@@ -1,12 +1,33 @@ | ||
package it.gov.pagopa.pu.debtpositions.mapper; | ||
|
||
import it.gov.pagopa.pu.debtpositions.dto.generated.TransferDTO; | ||
import it.gov.pagopa.pu.debtpositions.model.Stamp; | ||
import it.gov.pagopa.pu.debtpositions.model.Transfer; | ||
import org.mapstruct.Mapper; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Mapper(componentModel = "spring") | ||
public interface TransferMapper { | ||
@Service | ||
public class TransferMapper { | ||
|
||
TransferDTO map(Transfer transfer); | ||
} | ||
public Transfer mapToModel(TransferDTO dto) { | ||
Transfer transfer = new Transfer(); | ||
transfer.setTransferId(dto.getTransferId()); | ||
transfer.setInstallmentId(dto.getInstallmentId()); | ||
transfer.setOrgFiscalCode(dto.getOrgFiscalCode()); | ||
transfer.setOrgName(dto.getOrgName()); | ||
transfer.setAmountCents(dto.getAmountCents()); | ||
transfer.setRemittanceInformation(dto.getRemittanceInformation()); | ||
transfer.setStamp(new Stamp(dto.getStampType(), dto.getStampHashDocument(), dto.getStampProvincialResidence())); | ||
transfer.setIban(dto.getIban()); | ||
transfer.setPostalIban(dto.getPostalIban()); | ||
transfer.setCategory(dto.getCategory()); | ||
transfer.setTransferIndex(dto.getTransferIndex()); | ||
return transfer; | ||
} | ||
|
||
} | ||
//@Mapper(componentModel = "spring") | ||
//public interface TransferMapper { | ||
// | ||
// TransferDTO map(Transfer transfer); | ||
//} |
Oops, something went wrong.