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