Search in sources :

Example 1 with MessageText

use of org.onebusaway.nextbus.model.nextbus.MessageText 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;
}
Also used : TimeRangeBean(org.onebusaway.transit_data.model.service_alerts.TimeRangeBean) Message(org.onebusaway.nextbus.model.nextbus.Message) NaturalLanguageStringBean(org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean) ArrayList(java.util.ArrayList) MessageText(org.onebusaway.nextbus.model.nextbus.MessageText) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)

Aggregations

ArrayList (java.util.ArrayList)1 Message (org.onebusaway.nextbus.model.nextbus.Message)1 MessageText (org.onebusaway.nextbus.model.nextbus.MessageText)1 NaturalLanguageStringBean (org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean)1 ServiceAlertBean (org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)1 TimeRangeBean (org.onebusaway.transit_data.model.service_alerts.TimeRangeBean)1