LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
- Trips brauchten weitere Annotation um zyklische Abhängigkeit zu verhindern - Anpassen FriendCode länge und generierung
89 lines
2.1 KiB
Java
89 lines
2.1 KiB
Java
package SuMoC.backend.trip.models;
|
|
|
|
|
|
import SuMoC.backend.trip.Modality;
|
|
import SuMoC.backend.user.models.User;
|
|
import com.fasterxml.jackson.annotation.JsonBackReference;
|
|
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
import jakarta.persistence.*;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.Getter;
|
|
import lombok.NoArgsConstructor;
|
|
import lombok.Setter;
|
|
|
|
import java.time.Instant;
|
|
import java.util.HashSet;
|
|
import java.util.Set;
|
|
|
|
@Entity
|
|
@Table(name = "trips")
|
|
@Getter
|
|
@Setter
|
|
@NoArgsConstructor
|
|
@AllArgsConstructor
|
|
public class Trip {
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
private Long id;
|
|
|
|
@ManyToOne
|
|
@JoinColumn(name = "user_id", nullable = false)
|
|
@JsonBackReference("user-trips")
|
|
private User user;
|
|
|
|
@Column(nullable = false)
|
|
private String startPlace;
|
|
|
|
@Column(nullable = false)
|
|
private double startLatitude;
|
|
|
|
@Column(nullable = false)
|
|
private double startLongitude;
|
|
|
|
@Column(nullable = false, name = "start_h3_cell", length = 15)
|
|
private String startH3Cell;
|
|
|
|
@Column(nullable = false)
|
|
private String endPlace;
|
|
|
|
@Column(nullable = false)
|
|
private double endLatitude;
|
|
|
|
@Column(nullable = false)
|
|
private double endLongitude;
|
|
|
|
@Column(nullable = false, name = "end_h3_cell", length = 15)
|
|
private String endH3Cell;
|
|
|
|
@Column(nullable = false)
|
|
private Instant startTime;
|
|
|
|
@Column(nullable = false)
|
|
private Instant endTime;
|
|
|
|
/**
|
|
* Mobilityscore for the trip.
|
|
*/
|
|
@Column(nullable = false)
|
|
private double mobilityScore;
|
|
|
|
@Column(nullable = false)
|
|
private double co2Emissions;
|
|
|
|
@Column(nullable = true)
|
|
private float cost;
|
|
|
|
@Column(nullable = false)
|
|
private boolean invalidated = false;
|
|
|
|
@Column(nullable = false)
|
|
@Enumerated(EnumType.STRING)
|
|
@Schema(description = "Main modality by distance.")
|
|
private Modality mainModality;
|
|
|
|
@OneToMany(mappedBy = "trip", cascade = CascadeType.ALL, orphanRemoval = true)
|
|
@JsonManagedReference("trip-segments")
|
|
private Set<TripSegment> tripSegments = new HashSet<>();
|
|
}
|