Skip to content

Commit

Permalink
[PAGOPA-2103] removed dead code that was causing problems (#90)
Browse files Browse the repository at this point in the history
Co-authored-by: pagopa-github-bot <[email protected]>
  • Loading branch information
alessio-acitelli and pagopa-github-bot authored Sep 10, 2024
1 parent eb587a8 commit 910a29e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 70 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package it.gov.pagopa.bizeventsservice.entity.view;

import java.io.Serializable;

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

import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
* Entity model for biz-events-view-user
Expand All @@ -33,9 +36,4 @@ public class BizEventsViewUser implements Serializable {
private Boolean hidden;
private Boolean isPayer;
private Boolean isDebtor;

public LocalDateTime getTransactionDateAsLocalDateTime() {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("[yyyy-MM-dd'T'HH:mm:ss'Z'][yyyy-MM-dd'T'HH:mm:ss.SSSSSS]");
return LocalDateTime.parse(this.getTransactionDate(), formatter);
}
}
43 changes: 8 additions & 35 deletions src/main/java/it/gov/pagopa/bizeventsservice/util/Util.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
package it.gov.pagopa.bizeventsservice.util;

import it.gov.pagopa.bizeventsservice.entity.view.BizEventsViewUser;
import it.gov.pagopa.bizeventsservice.model.filterandorder.Order.TransactionListOrder;
import org.springframework.data.domain.Sort.Direction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import java.util.*;
import it.gov.pagopa.bizeventsservice.entity.view.BizEventsViewUser;

public class Util {

private Util() {
}

public static List<List<BizEventsViewUser>> getPaginatedList(List<BizEventsViewUser> mergedListByTIDOfViewUser, Boolean isPayer, Boolean isDebtor,
int pageSize, TransactionListOrder order, Direction direction) {
List<BizEventsViewUser> filteredListOfViewUser = new ArrayList<>(Util.getFilteredList(mergedListByTIDOfViewUser, isPayer, isDebtor));
Util.getSortedList(filteredListOfViewUser, order, direction);
return Util.getPages(filteredListOfViewUser, pageSize);
}
private Util() {}


public static List<BizEventsViewUser> getMergedListByTID(List<BizEventsViewUser> fullListOfViewUser) {
Expand Down Expand Up @@ -45,28 +40,6 @@ public static <T> List<List<T>> getPages(Collection<T> c, Integer pageSize) {
return pages;
}

public static void getSortedList(List<BizEventsViewUser> listToSort, TransactionListOrder order,
Direction direction) {
if (TransactionListOrder.TRANSACTION_DATE.equals(order)) {
switch (direction) {
case ASC:
Collections.sort(listToSort, Comparator.comparing(BizEventsViewUser::getTransactionDateAsLocalDateTime,
Comparator.nullsLast(Comparator.naturalOrder())));
break;
case DESC:
default:
Collections.sort(listToSort, Comparator.comparing(BizEventsViewUser::getTransactionDateAsLocalDateTime,
Comparator.nullsLast(Comparator.naturalOrder())).reversed());
break;
}
} else {
// the default sorting is by transaction date and DESC direction
Collections.sort(listToSort, Comparator
.comparing(BizEventsViewUser::getTransactionDateAsLocalDateTime, Comparator.nullsLast(Comparator.naturalOrder()))
.reversed());
}
}

public static List<BizEventsViewUser> getFilteredList(List<BizEventsViewUser> listToFilter, Boolean isPayer, Boolean isDebtor) {
return listToFilter.stream()
.filter(u -> (isPayer == null || u.getIsPayer().equals(isPayer)) && (isDebtor == null || u.getIsDebtor().equals(isDebtor)))
Expand Down
26 changes: 0 additions & 26 deletions src/test/java/it/gov/pagopa/bizeventsservice/util/UtilTest.java

This file was deleted.

0 comments on commit 910a29e

Please sign in to comment.