Skip to content

Commit

Permalink
[PAGOPA-2070] remove cart merge: removed merge (#84)
Browse files Browse the repository at this point in the history
Co-authored-by: aacitelli <aacitelli@PDD-NB-0205.dgsgroup.it>
  • Loading branch information
alessio-acitelli and aacitelli authored Sep 4, 2024
1 parent e163862 commit ec1b9b7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import it.gov.pagopa.bizeventsservice.model.response.enumeration.EntityUniqueIdentifierType;
import lombok.AllArgsConstructor;
Expand All @@ -16,6 +17,7 @@
@Data
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class Debtor implements Serializable{
/**
* generated serialVersionUID
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
package it.gov.pagopa.bizeventsservice.service.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import org.apache.commons.lang3.SerializationUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import com.azure.spring.data.cosmos.core.query.CosmosPageRequest;

import feign.FeignException;
Expand All @@ -25,24 +39,6 @@
import it.gov.pagopa.bizeventsservice.util.Constants;
import it.gov.pagopa.bizeventsservice.util.Util;

import org.apache.commons.lang3.SerializationUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

@Service
public class TransactionService implements ITransactionService {

Expand Down Expand Up @@ -83,16 +79,9 @@ public TransactionListResponse getTransactionList(String taxCode, Boolean isPaye
final Sort sort = Sort.by(Sort.Direction.fromString(direction), columnName);
final CosmosPageRequest pageRequest = new CosmosPageRequest(0, size, continuationToken, sort);
final Page<BizEventsViewUser> page = this.bizEventsViewUserRepository.getBizEventsViewUserByTaxCode(taxCode, isPayer, isDebtor, pageRequest);
Set<String> set = new HashSet<>(page.getContent().size());

List<BizEventsViewUser> listOfViewUser = page.getContent().stream()
.sorted(Comparator.comparing(BizEventsViewUser::getIsDebtor,Comparator.reverseOrder()))
.filter(p -> set.add(p.getTransactionId()))
.collect(Collectors.toList())
.stream()
.sorted(Comparator.comparing(BizEventsViewUser::getTransactionDate,Comparator.reverseOrder()))
.toList();

List<BizEventsViewUser> listOfViewUser = page.getContent();

if(listOfViewUser.isEmpty()){
throw new AppException(AppError.VIEW_USER_NOT_FOUND_WITH_TAX_CODE_AND_FILTER, taxCode, isPayer, isDebtor);
}
Expand Down

0 comments on commit ec1b9b7

Please sign in to comment.