Skip to content

Commit

Permalink
Merge pull request #13 from goeuropa/bugfix/fix-faulty-database-config
Browse files Browse the repository at this point in the history
  • Loading branch information
wkulesza authored May 18, 2024
2 parents ca6d969 + f857636 commit bb0897f
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 13 deletions.
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

0 comments on commit bb0897f

Please sign in to comment.