Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
119 additions
and
9 deletions.
There are no files selected for viewing
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
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
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
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
39 changes: 39 additions & 0 deletions
39
src/main/java/org/opentripplanner/graph_builder/module/TripPlanInPastModule.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 @@ | ||
/* This program is free software: you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public License | ||
as published by the Free Software Foundation, either version 3 of | ||
the License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
package org.opentripplanner.graph_builder.module; | ||
|
||
import org.opentripplanner.graph_builder.services.GraphBuilderModule; | ||
import org.opentripplanner.routing.graph.Graph; | ||
import org.opentripplanner.routing.services.notes.TripPlanInPastNotesService; | ||
|
||
import java.util.HashMap; | ||
|
||
public class TripPlanInPastModule implements GraphBuilderModule { | ||
|
||
private String message; | ||
|
||
public TripPlanInPastModule(String message) { | ||
this.message = message; | ||
} | ||
|
||
@Override | ||
public void buildGraph(Graph graph, HashMap<Class<?>, Object> extra) { | ||
TripPlanInPastNotesService svc = new TripPlanInPastNotesService(); | ||
svc.setMessage(message); | ||
graph.planNotesServices.add(svc); | ||
} | ||
|
||
@Override | ||
public void checkInputs() { | ||
} | ||
} |
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
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
11 changes: 11 additions & 0 deletions
11
src/main/java/org/opentripplanner/routing/services/notes/PlanNotesService.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,11 @@ | ||
package org.opentripplanner.routing.services.notes; | ||
|
||
import org.opentripplanner.api.model.TripPlan; | ||
import org.opentripplanner.routing.alertpatch.Alert; | ||
import org.opentripplanner.routing.core.RoutingRequest; | ||
|
||
import java.util.Collection; | ||
|
||
public interface PlanNotesService { | ||
Collection<Alert> getAlerts(RoutingRequest request, TripPlan plan); | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/org/opentripplanner/routing/services/notes/TripPlanInPastNotesService.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,44 @@ | ||
/* This program is free software: you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public License | ||
as published by the Free Software Foundation, either version 3 of | ||
the License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
package org.opentripplanner.routing.services.notes; | ||
|
||
import org.opentripplanner.api.model.TripPlan; | ||
import org.opentripplanner.routing.alertpatch.Alert; | ||
import org.opentripplanner.routing.core.RoutingRequest; | ||
|
||
import java.io.Serializable; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
|
||
public class TripPlanInPastNotesService implements Serializable, PlanNotesService { | ||
|
||
private static final long serialVersionUID = 1; | ||
|
||
private String message; | ||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
|
||
@Override | ||
public Collection<Alert> getAlerts(RoutingRequest request, TripPlan plan) { | ||
Collection<Alert> alerts = new ArrayList<>(); | ||
long maxStartTime = plan.itinerary.stream() | ||
.mapToLong(i -> i.startTime.getTimeInMillis()) | ||
.max().orElse(Long.MAX_VALUE); | ||
if (maxStartTime < request.rctx.debugOutput.getStartedCalculating()) { | ||
alerts.add(Alert.createSimpleAlerts(message)); | ||
} | ||
return alerts; | ||
} | ||
} |
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