use of uk.org.siri.siri_2.VehicleMonitoringDeliveryStructure in project onebusaway-application-modules by camsys.
the class VehicleMonitoringV2Action method generateSiriResponse.
/**
* Generate a siri response for a set of VehicleActivities
*
* @param routeId
*/
private Siri generateSiriResponse(List<VehicleActivityStructure> activities, List<AgencyAndId> routeIds, Exception error, long currentTimestamp) {
VehicleMonitoringDeliveryStructure vehicleMonitoringDelivery = new VehicleMonitoringDeliveryStructure();
vehicleMonitoringDelivery.setResponseTimestamp(DateUtil.toXmlGregorianCalendar(currentTimestamp));
ServiceDelivery serviceDelivery = new ServiceDelivery();
serviceDelivery.setResponseTimestamp(DateUtil.toXmlGregorianCalendar(currentTimestamp));
serviceDelivery.getVehicleMonitoringDelivery().add(vehicleMonitoringDelivery);
if (error != null) {
ServiceDeliveryErrorConditionStructure errorConditionStructure = new ServiceDeliveryErrorConditionStructure();
ErrorDescriptionStructure errorDescriptionStructure = new ErrorDescriptionStructure();
errorDescriptionStructure.setValue(error.getMessage());
OtherErrorStructure otherErrorStructure = new OtherErrorStructure();
otherErrorStructure.setErrorText(error.getMessage());
errorConditionStructure.setDescription(errorDescriptionStructure);
errorConditionStructure.setOtherError(otherErrorStructure);
vehicleMonitoringDelivery.setErrorCondition(errorConditionStructure);
} else {
Calendar gregorianCalendar = new GregorianCalendar();
gregorianCalendar.setTimeInMillis(currentTimestamp);
gregorianCalendar.add(Calendar.MINUTE, 1);
vehicleMonitoringDelivery.setValidUntil(DateUtil.toXmlGregorianCalendar(gregorianCalendar.getTimeInMillis()));
vehicleMonitoringDelivery.getVehicleActivity().addAll(activities);
_serviceAlertsHelper.addSituationExchangeToServiceDelivery(serviceDelivery, activities, _transitDataService, routeIds);
_serviceAlertsHelper.addGlobalServiceAlertsToServiceDelivery(serviceDelivery, _realtimeService);
}
Siri siri = new Siri();
siri.setServiceDelivery(serviceDelivery);
return siri;
}
Aggregations