-
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.
Update next with wrapper hotfix (#445)
Co-authored-by: pagopa-github-bot <github-bot@pagopa.it> Co-authored-by: Jacopo Carlini <jacopo.carlini@gmail.com>
- Loading branch information
1 parent
1b03b1b
commit 6b0b08a
Showing
10 changed files
with
345 additions
and
121 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/main/java/it/pagopa/selfcare/pagopa/backoffice/entity/WrapperEntityStation.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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package it.pagopa.selfcare.pagopa.backoffice.entity; | ||
|
||
import it.pagopa.selfcare.pagopa.backoffice.model.connector.station.StationDetails; | ||
import it.pagopa.selfcare.pagopa.backoffice.model.connector.wrapper.WrapperStatus; | ||
import it.pagopa.selfcare.pagopa.backoffice.model.connector.wrapper.WrapperType; | ||
import lombok.*; | ||
|
||
import java.time.Instant; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class WrapperEntityStation { | ||
|
||
private String id; | ||
private WrapperType type; | ||
private WrapperStatus status; | ||
private StationDetails entity; | ||
|
||
private Instant createdAt; | ||
private Instant modifiedAt; | ||
private String modifiedBy; | ||
private String modifiedByOpt; | ||
|
||
private String note; | ||
|
||
|
||
public WrapperEntityStation(StationDetails entity) { | ||
this.createdAt = Instant.now(); | ||
this.id = entity.getStationCode(); | ||
this.type = WrapperType.STATION; | ||
this.entity = entity; | ||
} | ||
|
||
|
||
} |
82 changes: 82 additions & 0 deletions
82
src/main/java/it/pagopa/selfcare/pagopa/backoffice/entity/WrapperEntityStations.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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package it.pagopa.selfcare.pagopa.backoffice.entity; | ||
|
||
|
||
import it.pagopa.selfcare.pagopa.backoffice.model.connector.wrapper.WrapperStatus; | ||
import it.pagopa.selfcare.pagopa.backoffice.model.connector.wrapper.WrapperType; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.FieldNameConstants; | ||
import org.springframework.data.annotation.*; | ||
import org.springframework.data.domain.Persistable; | ||
import org.springframework.data.mongodb.core.mapping.Document; | ||
|
||
import java.time.Instant; | ||
import java.util.ArrayList; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@EqualsAndHashCode(of = "id") | ||
@Document("wrappers") | ||
@FieldNameConstants(onlyExplicitlyIncluded = true) | ||
public class WrapperEntityStations implements Persistable<String> { | ||
|
||
@Id | ||
private String id; | ||
|
||
private String brokerCode; | ||
@FieldNameConstants.Include | ||
private WrapperType type; | ||
|
||
@FieldNameConstants.Include | ||
private WrapperStatus status; | ||
|
||
@LastModifiedDate | ||
@FieldNameConstants.Include | ||
private Instant modifiedAt; | ||
@LastModifiedBy | ||
@FieldNameConstants.Include | ||
private String modifiedBy; | ||
|
||
@FieldNameConstants.Include | ||
private String modifiedByOpt; | ||
@CreatedDate | ||
private Instant createdAt; | ||
@CreatedBy | ||
private String createdBy; | ||
|
||
private String note; | ||
|
||
private List<WrapperEntityStation> entities; | ||
|
||
|
||
public WrapperEntityStations(WrapperEntityStation wrapperEntity) { | ||
this.createdAt = Instant.now(); | ||
this.id = wrapperEntity.getEntity().getStationCode(); | ||
this.type = WrapperType.STATION; | ||
this.brokerCode = wrapperEntity.getEntity().getBrokerCode(); | ||
this.status = wrapperEntity.getStatus(); | ||
if(entities == null) { | ||
entities = new ArrayList<>(); | ||
} | ||
entities.add(wrapperEntity); | ||
} | ||
|
||
@Override | ||
public boolean isNew() { | ||
return false; | ||
} | ||
|
||
|
||
public void sortEntitiesById() { | ||
this.entities.sort(Comparator.comparing(WrapperEntityStation::getId, Comparator.naturalOrder())); | ||
} | ||
|
||
|
||
public static class Fields { | ||
public static String id = org.springframework.data.mongodb.core.aggregation.Fields.UNDERSCORE_ID; | ||
} | ||
|
||
} |
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
32 changes: 32 additions & 0 deletions
32
...java/it/pagopa/selfcare/pagopa/backoffice/model/connector/channel/WrapperStationList.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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package it.pagopa.selfcare.pagopa.backoffice.model.connector.channel; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import it.pagopa.selfcare.pagopa.backoffice.entity.WrapperEntityStations; | ||
import it.pagopa.selfcare.pagopa.backoffice.model.connector.PageInfo; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import java.util.List; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class WrapperStationList { | ||
|
||
@JsonProperty("wrapper_entities") | ||
@NotNull | ||
private List<WrapperEntityStations> wrapperEntities; | ||
|
||
@JsonProperty("page_info") | ||
@NotNull | ||
private PageInfo pageInfo; | ||
} | ||
|
||
|
||
|
||
|
||
|
24 changes: 24 additions & 0 deletions
24
src/main/java/it/pagopa/selfcare/pagopa/backoffice/repository/WrapperStationsRepository.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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package it.pagopa.selfcare.pagopa.backoffice.repository; | ||
|
||
import it.pagopa.selfcare.pagopa.backoffice.entity.WrapperEntityStations; | ||
import it.pagopa.selfcare.pagopa.backoffice.model.connector.wrapper.WrapperStatus; | ||
import it.pagopa.selfcare.pagopa.backoffice.model.connector.wrapper.WrapperType; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.mongodb.repository.MongoRepository; | ||
|
||
public interface WrapperStationsRepository extends MongoRepository<WrapperEntityStations, String> { | ||
|
||
Page<WrapperEntityStations> findByIdLikeAndTypeAndBrokerCodeAndStatusNot(String id, WrapperType wrapperType, String brokerCode, WrapperStatus status, Pageable pageable); | ||
|
||
Page<WrapperEntityStations> findByTypeAndBrokerCodeAndStatusNot(WrapperType wrapperType, String brokerCode, WrapperStatus status, Pageable pageable); | ||
|
||
Page<WrapperEntityStations> findByType(WrapperType wrapperType, Pageable pageable); | ||
|
||
Page<WrapperEntityStations> findByIdLikeAndType(String idLike, WrapperType wrapperType, Pageable pageable); | ||
|
||
Page<WrapperEntityStations> findByTypeAndBrokerCode(WrapperType wrapperType, String brokerCode, Pageable pageable); | ||
|
||
Page<WrapperEntityStations> findByIdLikeAndTypeAndBrokerCode(String id, WrapperType wrapperType, String brokerCode, Pageable pageable); | ||
|
||
} |
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
Oops, something went wrong.