use of uk.org.siri.siri_2.StopPointsDeliveryStructure in project onebusaway-application-modules by camsys.
the class StopPointsV2Action method generateSiriResponse.
private Siri generateSiriResponse(List<AnnotatedStopPointStructure> stopPoints, Boolean hasUpcomingScheduledService, Exception error, long responseTimestamp) {
StopPointsDeliveryStructure stopPointsDelivery = new StopPointsDeliveryStructure();
stopPointsDelivery.setResponseTimestamp(DateUtil.toXmlGregorianCalendar(responseTimestamp));
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);
stopPointsDelivery.setErrorCondition(errorConditionStructure);
} else {
Calendar gregorianCalendar = new GregorianCalendar();
gregorianCalendar.setTimeInMillis(responseTimestamp);
gregorianCalendar.add(Calendar.MINUTE, 1);
stopPointsDelivery.setValidUntil(DateUtil.toXmlGregorianCalendar(gregorianCalendar.getTimeInMillis()));
stopPointsDelivery.getAnnotatedStopPointRef().addAll(stopPoints);
if (hasUpcomingScheduledService != null) {
// siri extensions
ExtensionsStructure upcomingServiceExtensions = new ExtensionsStructure();
SiriUpcomingServiceExtension upcomingService = new SiriUpcomingServiceExtension();
upcomingService.setUpcomingScheduledService(hasUpcomingScheduledService);
upcomingServiceExtensions.setAny(upcomingService);
stopPointsDelivery.setExtensions(upcomingServiceExtensions);
}
stopPointsDelivery.setResponseTimestamp(DateUtil.toXmlGregorianCalendar(responseTimestamp));
// TODO - LCARABALLO Do I still need serviceAlertsHelper?
/*
* _serviceAlertsHelper.addSituationExchangeToSiriForStops(
* serviceDelivery, visits, _nycTransitDataService, stopIds);
* _serviceAlertsHelper.addGlobalServiceAlertsToServiceDelivery(
* serviceDelivery, _realtimeService);
*/
}
Siri siri = new Siri();
siri.setStopPointsDelivery(stopPointsDelivery);
return siri;
}
Aggregations