Search in sources :

Example 1 with ScheduleRoute

use of org.onebusaway.nextbus.model.transiTime.ScheduleRoute in project onebusaway-application-modules by camsys.

the class ScheduleHorizAction method getModel.

public Body<List<ScheduleRoute>> getModel() {
    Body<List<ScheduleRoute>> body = new Body<List<ScheduleRoute>>();
    List<AgencyAndId> routeIds = new ArrayList<AgencyAndId>();
    if (isValid(body, routeIds)) {
        String serviceUrl = getServiceUrl() + agencyId + SCHEDULE_COMMAND + "?";
        String route = "r=" + getIdNoAgency(routeId);
        String uri = serviceUrl + route + "&format=" + REQUEST_TYPE;
        try {
            int timeout = _configUtil.getHttpTimeoutSeconds();
            JsonArray scheduleJson = _httpUtil.getJsonObject(uri, timeout).getAsJsonArray("schedule");
            Type listType = new TypeToken<List<ScheduleRoute>>() {
            }.getType();
            List<ScheduleRoute> schedules = new Gson().fromJson(scheduleJson, listType);
            modifyJSONObject(schedules);
            body.getResponse().add(schedules);
        } catch (Exception e) {
            _log.error(e.getMessage());
        }
    }
    return body;
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) JsonArray(com.google.gson.JsonArray) Type(java.lang.reflect.Type) ScheduleRoute(org.onebusaway.nextbus.model.transiTime.ScheduleRoute) ArrayList(java.util.ArrayList) List(java.util.List) Body(org.onebusaway.nextbus.model.nextbus.Body)

Aggregations

Gson (com.google.gson.Gson)1 JsonArray (com.google.gson.JsonArray)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)1 Body (org.onebusaway.nextbus.model.nextbus.Body)1 ScheduleRoute (org.onebusaway.nextbus.model.transiTime.ScheduleRoute)1