Search in sources :

Example 1 with AlertPatchCreationResponse

use of org.opentripplanner.api.model.alertpatch.AlertPatchCreationResponse 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)

Aggregations

RolesAllowed (javax.annotation.security.RolesAllowed)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)1 AlertPatchCreationResponse (org.opentripplanner.api.model.alertpatch.AlertPatchCreationResponse)1 AlertPatch (org.opentripplanner.routing.alertpatch.AlertPatch)1