Search in sources :

Example 1 with LinkAVLData

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

the class LinkAvlRealtimeArchiverTask method update.

public void update() throws IOException {
    // Read feed
    String avlJson = _linkAvlUrl == null ? "" : readFeedFromUrl(_linkAvlUrl);
    // Parse into model classes
    LinkAVLData avlData = deserializeAvlJson(avlJson);
    // Persist
    _persistor.persist(avlData);
    return;
}
Also used : LinkAVLData(org.onebusaway.gtfs_realtime.archiver.model.LinkAVLData)

Example 2 with LinkAVLData

use of org.onebusaway.gtfs_realtime.archiver.model.LinkAVLData 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

LinkAVLData (org.onebusaway.gtfs_realtime.archiver.model.LinkAVLData)2 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 StopUpdate (org.onebusaway.gtfs_realtime.archiver.model.StopUpdate)1 TripInfo (org.onebusaway.gtfs_realtime.archiver.model.TripInfo)1