Skip to content

Commit

Permalink
save and refresh changes from the DB.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwigway committed Nov 3, 2014
1 parent 4947f06 commit 26be34d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/models/transit/Trip.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class Trip extends Model {
public Integer endTime;

public Integer headway;
public Boolean invalid;


public static BigInteger nativeInsert(EntityManager em, org.onebusaway.gtfs.model.Trip gtfsTrip, BigInteger routeId, BigInteger shapeId, BigInteger serviceCalendarId, BigInteger serviceCalendarDateId)
Expand Down
20 changes: 18 additions & 2 deletions app/models/transit/TripPattern.java
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,19 @@ else if (newStopIds[firstDifferentIndex] == originalStopIds[lastDifferentIndex])

TripPatternStop current;

// record if there were stop times
// if there were, invalidate the trip.
boolean hadStopTimes = false;

for (StopTime st : stopTimes) {
if (st.arrivalTime != null || st.departureTime != null)
hadStopTimes = true;

if (st.stop.id.equals(movedStopId) && st.stopSequence.equals(movedStopSeq)) {
// we are dealing with the moved stop
st.stopSequence = newStopSeq;
StopTime.em().merge(st).save();
StopTime updated = StopTime.em().merge(st);
updated.save();
}

else {
Expand All @@ -412,9 +420,17 @@ else if (newStopIds[firstDifferentIndex] == originalStopIds[lastDifferentIndex])
current = psi.next();

st.stopSequence = current.stopSequence;
StopTime.em().merge(st).save();
StopTime updated = StopTime.em().merge(st);
updated.save();
}
}

if (hadStopTimes) {
trip.invalid = true;
trip.save();
}

trip.refresh();
}
}

Expand Down

0 comments on commit 26be34d

Please sign in to comment.