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;
}
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;
}
Aggregations