use of org.onebusaway.nextbus.model.nextbus.Message in project onebusaway-application-modules by camsys.
the class MessagesAction method getMessagesForRoute.
private List<Message> getMessagesForRoute(String agencyId, String routeId) {
List<Message> messageList = new ArrayList<Message>();
ListBean<ServiceAlertBean> serviceAlertBeans = getAllSituations(agencyId, routeId);
serviceAlerts: for (ServiceAlertBean serviceAlert : serviceAlertBeans.getList()) {
if (serviceAlert.getActiveWindows() != null) {
long currentTime = SystemTime.currentTimeMillis();
for (TimeRangeBean timerange : serviceAlert.getActiveWindows()) {
if (timerange.getFrom() < currentTime || timerange.getTo() < currentTime) {
continue serviceAlerts;
}
}
}
Message message = new Message();
message.setId(serviceAlert.getId());
message.setCreator(serviceAlert.getSource());
// message.setEndBoundaryStr(serviceAlert.getPublicationWindows().toString());
String messageText = "";
for (NaturalLanguageStringBean description : serviceAlert.getDescriptions()) {
messageText += description.getValue();
}
message.setMessageText(new MessageText(messageText));
messageList.add(message);
}
return messageList;
}
use of org.onebusaway.nextbus.model.nextbus.Message in project onebusaway-application-modules by camsys.
the class MessagesAction method getModel.
@Override
public Body<Message> getModel() {
Body<Message> body = new Body<Message>();
List<String> agencyIds = processAgencyIds(getA());
List<AgencyAndId> routeIds = new ArrayList<AgencyAndId>();
if (processRouteIds(routeId, routeIds, agencyIds, body)) {
for (AgencyAndId routeId : routeIds) {
body.getResponse().addAll(getMessagesForRoute(agencyId, routeId.toString()));
}
}
return body;
}
Aggregations