use of org.onebusaway.transit_data_federation.services.AlarmAction in project onebusaway-application-modules by camsys.
the class ArrivalAndDepartureAlarmServiceImpl method registerAlarmForArrivalAndDepartureAtStop.
/**
**
* {@link ArrivalAndDepartureAlarmService} Interface
***
*/
@Override
public AgencyAndId registerAlarmForArrivalAndDepartureAtStop(ArrivalAndDepartureQuery query, RegisterAlarmQueryBean alarmBean) {
ArrivalAndDepartureInstance instance = _arrivalAndDepartureService.getArrivalAndDepartureForStop(query);
if (instance == null)
throw new ServiceException("no arrival-departure found");
/**
* We group alarms by block instance
*/
BlockInstance blockInstance = instance.getBlockInstance();
/**
* Retrieve the alarms for the block instance
*/
AlarmsForBlockInstance alarms = getAlarmsForBlockInstance(blockInstance);
/**
* The effective schedule time is the point in the transit vehicle's
* schedule run time when the alarm should be fired
*/
int effectiveScheduleTime = computeEffectiveScheduleTimeForAlarm(alarmBean, instance);
/**
* Create and register the alarm
*/
AlarmAction action = new AlarmAction();
action.setUrl(alarmBean.getUrl());
AlarmForBlockInstance alarm = alarms.registerAlarm(action, effectiveScheduleTime, instance);
_alarmsById.put(alarm.getId(), alarm);
_log.debug("alarm created: {}", alarm.getId());
return alarm.getId();
}
Aggregations