Search in sources :

Example 1 with StopUpdate

use of org.onebusaway.gtfs_realtime.archiver.model.StopUpdate in project onebusaway-application-modules by camsys.

the class LinkAvlRealtimeArchiverTask method deserializeAvlJson.

private LinkAVLData deserializeAvlJson(String avlJson) {
    LinkAVLData avlData = new LinkAVLData();
    ObjectMapper mapper = new ObjectMapper().enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
    mapper.configure(SerializationConfig.Feature.AUTO_DETECT_FIELDS, true);
    try {
        avlData = mapper.readValue(avlJson, LinkAVLData.class);
    } catch (JsonParseException e) {
        _log.error("JsonParseException trying to parse feed data.");
    } catch (JsonMappingException e) {
        _log.error("JsonMappingException: " + e.getMessage());
    } catch (IOException e) {
        _log.error("IOException trying to parse feed data.");
    } catch (Exception e) {
        _log.error("Exception trying to parse feed data: " + e.getMessage());
    }
    avlData.setAvlSource(_avlFeedId);
    if (avlData.getTrips() == null)
        return avlData;
    for (TripInfo tripInfo : avlData.getTrips()) {
        tripInfo.setLinkAVLData(avlData);
        for (StopUpdate stopUpdate : tripInfo.getStopUpdates()) {
            stopUpdate.setTripInfo(tripInfo);
        }
    }
    return avlData;
}
Also used : TripInfo(org.onebusaway.gtfs_realtime.archiver.model.TripInfo) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) LinkAVLData(org.onebusaway.gtfs_realtime.archiver.model.LinkAVLData) StopUpdate(org.onebusaway.gtfs_realtime.archiver.model.StopUpdate) IOException(java.io.IOException) JsonParseException(org.codehaus.jackson.JsonParseException) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) JsonParseException(org.codehaus.jackson.JsonParseException)

Aggregations

IOException (java.io.IOException)1 GeneralSecurityException (java.security.GeneralSecurityException)1 CertificateException (java.security.cert.CertificateException)1 JsonParseException (org.codehaus.jackson.JsonParseException)1 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1 LinkAVLData (org.onebusaway.gtfs_realtime.archiver.model.LinkAVLData)1 StopUpdate (org.onebusaway.gtfs_realtime.archiver.model.StopUpdate)1 TripInfo (org.onebusaway.gtfs_realtime.archiver.model.TripInfo)1