Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing wrong database configuration #13

Merged
merged 2 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class ExportTable implements Serializable {
@Column(name = "export_status")
private int exportStatus;

@Column(name = "first_name")
@Column(name = "file_name")
private String fileName;

@Column(name = "file")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ public class TravelTimesForTrip implements Serializable {
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "travel_times_for_trip_to_travel_times_for_path",
joinColumns = {
@JoinColumn(name = "for_path_id", referencedColumnName = "id")
@JoinColumn(name = "for_trip_id", referencedColumnName = "id")
},
inverseJoinColumns = {
@JoinColumn(name = "for_trip_id", referencedColumnName = "id")
@JoinColumn(name = "for_path_id", referencedColumnName = "id")
})
@Cascade({CascadeType.SAVE_UPDATE})
@OrderColumn(name = "list_index")
Expand Down
20 changes: 10 additions & 10 deletions core/src/main/java/org/transitclock/domain/structs/TripPattern.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.CallbackException;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.annotations.Cascade;
Expand All @@ -15,10 +14,8 @@

import jakarta.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;

/**
* A trip pattern, as obtained from stop_times.txt GTFS file. A trip pattern defines what stops are
Expand Down Expand Up @@ -570,9 +567,9 @@ public boolean isStopAtOrAfterStop(String stopId1, String stopId2) {
* @return
*/
public List<String> getStopIds() {
List<String> list = new ArrayList<String>(stopPaths.size());
for (StopPath stopPath : stopPaths) list.add(stopPath.getStopId());
return list;
return stopPaths.stream()
.map(StopPath::getStopId)
.collect(Collectors.toList());
}

/**
Expand All @@ -581,7 +578,9 @@ public List<String> getStopIds() {
* @return ID of last stop
*/
public String getLastStopIdForTrip() {
return stopPaths.get(stopPaths.size() - 1).getStopId();
return Optional.ofNullable(getStopPath(stopPaths.size() - 1))
.map(StopPath::getStopId)
.orElse(null);
}

/**
Expand All @@ -602,7 +601,8 @@ public double getLength() {
* @return The specified StopPath or null if index out of range
*/
public StopPath getStopPath(int index) {
if (index < 0 || index >= stopPaths.size()) return null;
if (index < 0 || index >= stopPaths.size())
return null;

return stopPaths.get(index);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE export_table RENAME COLUMN first_name TO file_name;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- removing faulty constraints definitions
ALTER TABLE travel_times_for_trip_to_travel_times_for_path
DROP CONSTRAINT fk_tratimfortritotratimforpat_on_travel_times_for_stop_path;

ALTER TABLE travel_times_for_trip_to_travel_times_for_path
DROP CONSTRAINT fk_tratimfortritotratimforpat_on_travel_times_for_trip;

-- recreating new constraints
ALTER TABLE travel_times_for_trip_to_travel_times_for_path
ADD CONSTRAINT fk_tratimfortritotratimforpat_on_travel_times_for_stop_path FOREIGN KEY (for_path_id) REFERENCES travel_times_for_stop_paths (id);

ALTER TABLE travel_times_for_trip_to_travel_times_for_path
ADD CONSTRAINT fk_tratimfortritotratimforpat_on_travel_times_for_trip FOREIGN KEY (for_trip_id) REFERENCES travel_times_for_trips (id);
2 changes: 2 additions & 0 deletions extensions/traccar/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<maven-plugin-version>1.0.0</maven-plugin-version>
</properties>

<packaging>jar</packaging>

<build>
<plugins>
<!-- activate the plugin -->
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@
<configuration>
<javaVersion>17</javaVersion>
<failOnViolations>false</failOnViolations>
<includeTestClasses>false</includeTestClasses>
</configuration>
<executions>
<execution>
Expand Down
Loading