-
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.
[VAS-1170] feat: Add station maintenance entity (#48)
* [VAS-1170] added entity and repository for station maintenance * [VAS-1170] fixed entity configuration and query * [VAS-1170] renamed entity and fields and refactored StationMaintenance structure * [VAS-1170] fix
- Loading branch information
1 parent
54ad752
commit 709d1a7
Showing
7 changed files
with
223 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
src/main/java/it/gov/pagopa/apiconfig/starter/entity/StationMaintenance.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,57 @@ | ||
package it.gov.pagopa.apiconfig.starter.entity; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
import javax.persistence.SequenceGenerator; | ||
import javax.persistence.Table; | ||
import java.time.OffsetDateTime; | ||
|
||
@Entity | ||
@Table(name = "MANUTENZIONE_STAZIONE") | ||
@Setter | ||
@Getter | ||
@ToString | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class StationMaintenance { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "hibernate_sequence") | ||
@SequenceGenerator( | ||
name = "hibernate_sequence", | ||
sequenceName = "hibernate_sequence", | ||
allocationSize = 1) | ||
@Column(name = "OBJ_ID", nullable = false) | ||
private Long objId; | ||
|
||
@Column(name = "DATA_ORA_INIZIO", nullable = false) | ||
private OffsetDateTime startDateTime; | ||
|
||
@Column(name = "DATA_ORA_FINE", nullable = false) | ||
private OffsetDateTime endDateTime; | ||
|
||
@Column(name = "STANDIN", nullable = false) | ||
private Boolean standIn; | ||
|
||
@ManyToOne(optional = false) | ||
@JoinColumn(name = "FK_STAZIONE", nullable = false) | ||
@ToString.Exclude | ||
private Stazioni station; | ||
|
||
@Column(name = "FK_STAZIONE", nullable = false, insertable = false, updatable = false) | ||
private Long fkStation; | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/it/gov/pagopa/apiconfig/starter/entity/StationMaintenanceExpandedView.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,39 @@ | ||
package it.gov.pagopa.apiconfig.starter.entity; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Id; | ||
import javax.persistence.Table; | ||
import java.time.OffsetDateTime; | ||
|
||
@Entity | ||
@Table(name = "MANUTENZIONE_STAZIONE_ESPANSA") | ||
@Setter | ||
@Getter | ||
@ToString | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class StationMaintenanceExpandedView { | ||
|
||
@Id | ||
@Column(name = "ID", nullable = false) | ||
private String id; | ||
|
||
@Column(name = "DATA_ORA_INIZIO", nullable = false) | ||
private OffsetDateTime startDateTime; | ||
|
||
@Column(name = "DATA_ORA_FINE", nullable = false) | ||
private OffsetDateTime endDateTime; | ||
|
||
@Column(name = "INTERMEDIARIO_PA_CODICE_FISCALE", nullable = false) | ||
private String brokerCode; | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/it/gov/pagopa/apiconfig/starter/entity/StationMaintenanceSummaryId.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,26 @@ | ||
package it.gov.pagopa.apiconfig.starter.entity; | ||
|
||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
import javax.persistence.Column; | ||
import java.io.Serializable; | ||
|
||
@Setter | ||
@Getter | ||
@SuperBuilder | ||
@NoArgsConstructor | ||
@EqualsAndHashCode | ||
public class StationMaintenanceSummaryId implements Serializable { | ||
|
||
private static final long serialVersionUID = 7800783561114522190L; | ||
|
||
@Column(name = "INTERMEDIARIO_PA_CODICE_FISCALE", nullable = false) | ||
private String brokerCode; | ||
|
||
@Column(name = "ANNO_MANUTENZIONE", nullable = false) | ||
private String maintenanceYear; | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/it/gov/pagopa/apiconfig/starter/entity/StationMaintenanceSummaryView.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,41 @@ | ||
package it.gov.pagopa.apiconfig.starter.entity; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Id; | ||
import javax.persistence.IdClass; | ||
import javax.persistence.Table; | ||
|
||
@Entity | ||
@Table(name = "MANUTENZIONE_STAZIONE_RIEPILOGO") | ||
@IdClass(StationMaintenanceSummaryId.class) | ||
@Setter | ||
@Getter | ||
@ToString | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class StationMaintenanceSummaryView { | ||
|
||
@Id | ||
@Column(name = "INTERMEDIARIO_PA_CODICE_FISCALE", nullable = false) | ||
private String brokerCode; | ||
|
||
@Id | ||
@Column(name = "ANNO_MANUTENZIONE", nullable = false) | ||
private String maintenanceYear; | ||
|
||
@Column(name = "ORE_UTILIZZATE", nullable = false) | ||
private Double usedHours; | ||
|
||
@Column(name = "ORE_PROGRAMMATE", nullable = false) | ||
private Double scheduledHours; | ||
} |
12 changes: 12 additions & 0 deletions
12
.../it/gov/pagopa/apiconfig/starter/repository/StationMaintenanceExpandedViewRepository.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,12 @@ | ||
package it.gov.pagopa.apiconfig.starter.repository; | ||
|
||
import it.gov.pagopa.apiconfig.starter.entity.StationMaintenanceExpandedView; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@SuppressWarnings("java:S100") | ||
// Disabled naming convention rule for method name to use Spring Data interface | ||
@Repository | ||
public interface StationMaintenanceExpandedViewRepository extends JpaRepository<StationMaintenanceExpandedView, String> { | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/it/gov/pagopa/apiconfig/starter/repository/StationMaintenanceRepository.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,36 @@ | ||
package it.gov.pagopa.apiconfig.starter.repository; | ||
|
||
import it.gov.pagopa.apiconfig.starter.entity.StationMaintenance; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.time.OffsetDateTime; | ||
|
||
@SuppressWarnings("java:S100") | ||
// Disabled naming convention rule for method name to use Spring Data interface | ||
@Repository | ||
public interface StationMaintenanceRepository extends JpaRepository<StationMaintenance, Long> { | ||
|
||
@Query(value = | ||
"SELECT m " + | ||
"FROM StationMaintenance m JOIN Stazioni s ON m.fkStation = s.objId JOIN IntermediariPa ipa ON s.fkIntermediarioPa = ipa.objId " + | ||
"WHERE ipa.idIntermediarioPa = :brokerCode " + | ||
"AND (:stationCode IS NULL OR UPPER(s.idStazione) LIKE CONCAT('%', UPPER(:stationCode), '%')) " + | ||
"AND (:startDateTimeBefore IS NULL OR m.startDateTime < :startDateTimeBefore) " + | ||
"AND (:startDateTimeAfter IS NULL OR m.startDateTime > :startDateTimeAfter) " + | ||
"AND (:endDateTimeBefore IS NULL OR m.endDateTime < :endDateTimeBefore) " + | ||
"AND (:endDateTimeAfter IS NULL OR m.endDateTime > :endDateTimeAfter)") | ||
Page<StationMaintenance> findAllByFilters( | ||
@Param("brokerCode") String brokerCode, | ||
@Param("stationCode") String stationCode, | ||
@Param("startDateTimeBefore") OffsetDateTime startDateTimeBefore, | ||
@Param("startDateTimeAfter") OffsetDateTime startDateTimeAfter, | ||
@Param("endDateTimeBefore") OffsetDateTime endDateTimeBefore, | ||
@Param("endDateTimeAfter") OffsetDateTime endDateTimeAfter, | ||
Pageable pageable | ||
); | ||
} |
12 changes: 12 additions & 0 deletions
12
...a/it/gov/pagopa/apiconfig/starter/repository/StationMaintenanceSummaryViewRepository.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,12 @@ | ||
package it.gov.pagopa.apiconfig.starter.repository; | ||
|
||
import it.gov.pagopa.apiconfig.starter.entity.StationMaintenanceSummaryId; | ||
import it.gov.pagopa.apiconfig.starter.entity.StationMaintenanceSummaryView; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@SuppressWarnings("java:S100") | ||
// Disabled naming convention rule for method name to use Spring Data interface | ||
@Repository | ||
public interface StationMaintenanceSummaryViewRepository extends JpaRepository<StationMaintenanceSummaryView, StationMaintenanceSummaryId> { | ||
} |