Search in sources :

Example 6 with AlertPatch

use of org.opentripplanner.routing.alertpatch.AlertPatch in project OpenTripPlanner by opentripplanner.

the class AlertPatcher method createPatches.

@RolesAllowed("user")
@POST
@Path("/patch")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML + Q, MediaType.TEXT_XML + Q })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
public AlertPatchCreationResponse createPatches(AlertPatchSet alertPatches) {
    AlertPatchCreationResponse response = new AlertPatchCreationResponse();
    for (AlertPatch alertPatch : alertPatches.alertPatches) {
        if (alertPatch.getId() == null) {
            response.status = "Every patch must have an id";
            return response;
        }
        final AgencyAndId route = alertPatch.getRoute();
        if (route != null && route.getId().equals("")) {
            response.status = "Every route patch must have a route id";
            return response;
        }
    }
    for (AlertPatch alertPatch : alertPatches.alertPatches) {
        alertPatchService.apply(alertPatch);
    }
    response.status = "OK";
    return response;
}
Also used : AlertPatch(org.opentripplanner.routing.alertpatch.AlertPatch) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) AlertPatchCreationResponse(org.opentripplanner.api.model.alertpatch.AlertPatchCreationResponse) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes)

Example 7 with AlertPatch

use of org.opentripplanner.routing.alertpatch.AlertPatch in project OpenTripPlanner by opentripplanner.

the class AlertPatcher method getStopPatches.

/**
 * Return a list of all patches that apply to a given stop
 *
 * @return Returns either an XML or a JSON document, depending on the HTTP Accept header of the
 *         client making the request.
 */
@GET
@Path("/stopPatches")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML + Q, MediaType.TEXT_XML + Q })
public AlertPatchResponse getStopPatches(@QueryParam("agency") String agency, @QueryParam("id") String id) {
    AlertPatchResponse response = new AlertPatchResponse();
    Collection<AlertPatch> alertPatches = alertPatchService.getStopPatches(new AgencyAndId(agency, id));
    for (AlertPatch alertPatch : alertPatches) {
        response.addAlertPatch(alertPatch);
    }
    return response;
}
Also used : AlertPatchResponse(org.opentripplanner.api.model.alertpatch.AlertPatchResponse) AlertPatch(org.opentripplanner.routing.alertpatch.AlertPatch) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

AlertPatch (org.opentripplanner.routing.alertpatch.AlertPatch)7 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)5 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 TripDescriptor (com.google.transit.realtime.GtfsRealtime.TripDescriptor)2 GET (javax.ws.rs.GET)2 AlertPatchResponse (org.opentripplanner.api.model.alertpatch.AlertPatchResponse)2 Alert (org.opentripplanner.routing.alertpatch.Alert)2 TimePeriod (org.opentripplanner.routing.alertpatch.TimePeriod)2 EntitySelector (com.google.transit.realtime.GtfsRealtime.EntitySelector)1 TimeRange (com.google.transit.realtime.GtfsRealtime.TimeRange)1 TripUpdate (com.google.transit.realtime.GtfsRealtime.TripUpdate)1 StopTimeEvent (com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeEvent)1 StopTimeUpdate (com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeUpdate)1 Coordinate (com.vividsolutions.jts.geom.Coordinate)1 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)1 LineString (com.vividsolutions.jts.geom.LineString)1 RolesAllowed (javax.annotation.security.RolesAllowed)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1