Search in sources :

Example 6 with NaturalLanguageStringBean

use of org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean in project onebusaway-application-modules by camsys.

the class ServiceAlertsHelper method handleOtherFields.

private void handleOtherFields(ServiceAlertBean serviceAlert, PtSituationElementStructure ptSituation) {
    if (serviceAlert == null) {
        return;
    }
    if (serviceAlert.getUrls() != null && !serviceAlert.getUrls().isEmpty()) {
        InfoLinks infoLinks = ptSituation.getInfoLinks();
        if (infoLinks == null) {
            infoLinks = new InfoLinks();
            ptSituation.setInfoLinks(infoLinks);
        }
        for (NaturalLanguageStringBean linkBean : serviceAlert.getUrls()) {
            InfoLinkStructure infoLinkStructure = new InfoLinkStructure();
            infoLinkStructure.setUri(linkBean.getValue());
            infoLinks.getInfoLink().add(infoLinkStructure);
        }
    }
    if (serviceAlert.getPublicationWindows() == null) {
        return;
    }
    // TODO Not handling severity yet.
    ptSituation.setSeverity(SeverityEnumeration.UNDEFINED);
    HalfOpenTimestampRangeStructure timestampRangeStructure = new HalfOpenTimestampRangeStructure();
    if (serviceAlert.getPublicationWindows() != null && !serviceAlert.getPublicationWindows().isEmpty()) {
        timestampRangeStructure.setStartTime(serviceAlertTimeToDate(serviceAlert.getPublicationWindows().get(0).getFrom()));
        timestampRangeStructure.setEndTime(serviceAlertTimeToDate(serviceAlert.getPublicationWindows().get(0).getTo()));
        ptSituation.setPublicationWindow(timestampRangeStructure);
    }
}
Also used : InfoLinks(uk.org.siri.siri.RoadSituationElementStructure.InfoLinks) HalfOpenTimestampRangeStructure(uk.org.siri.siri.HalfOpenTimestampRangeStructure) InfoLinkStructure(uk.org.siri.siri.InfoLinkStructure) NaturalLanguageStringBean(org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean)

Example 7 with NaturalLanguageStringBean

use of org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean in project onebusaway-application-modules by camsys.

the class ServiceAlertsTestSupport method createServiceAlertBean.

public static ServiceAlertBean createServiceAlertBean(String id) {
    ServiceAlertBean serviceAlertBean = new ServiceAlertBean();
    serviceAlertBean.setId(id);
    List<NaturalLanguageStringBean> summaries = new ArrayList<NaturalLanguageStringBean>();
    summaries.add(createNaturalLanguageStringBean("summary"));
    serviceAlertBean.setSummaries(summaries);
    List<NaturalLanguageStringBean> descriptions = new ArrayList<NaturalLanguageStringBean>();
    descriptions.add(createNaturalLanguageStringBean("description"));
    serviceAlertBean.setDescriptions(descriptions);
    List<SituationAffectsBean> allAffects = new ArrayList<SituationAffectsBean>();
    serviceAlertBean.setAllAffects(allAffects);
    allAffects.add(addAffects("1_100277", "0"));
    allAffects.add(addAffects("1_100277", "1"));
    allAffects.add(addAffects("1_100194", "0"));
    allAffects.add(addAffects("1_100194", "1"));
    return serviceAlertBean;
}
Also used : SituationAffectsBean(org.onebusaway.transit_data.model.service_alerts.SituationAffectsBean) NaturalLanguageStringBean(org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean) ArrayList(java.util.ArrayList) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)

Example 8 with NaturalLanguageStringBean

use of org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean in project onebusaway-application-modules by camsys.

the class ServiceAlertsTestSupport method createNaturalLanguageStringBean.

public static NaturalLanguageStringBean createNaturalLanguageStringBean(String string) {
    NaturalLanguageStringBean n = new NaturalLanguageStringBean();
    n.setValue(string);
    n.setLang("EN");
    return n;
}
Also used : NaturalLanguageStringBean(org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean)

Example 9 with NaturalLanguageStringBean

use of org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean in project onebusaway-application-modules by camsys.

the class ServiceAlertAction method getSummary.

public String getSummary() {
    List<NaturalLanguageStringBean> summaries = _model.getSummaries();
    if (summaries == null || summaries.isEmpty()) {
        return null;
    }
    NaturalLanguageStringBean nls = summaries.get(0);
    return nls.getValue();
}
Also used : NaturalLanguageStringBean(org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean)

Example 10 with NaturalLanguageStringBean

use of org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean in project onebusaway-application-modules by camsys.

the class ServiceAlertAction method getDescription.

public String getDescription() {
    List<NaturalLanguageStringBean> descriptions = _model.getDescriptions();
    if (descriptions == null || descriptions.isEmpty()) {
        return null;
    }
    NaturalLanguageStringBean nls = descriptions.get(0);
    return nls.getValue();
}
Also used : NaturalLanguageStringBean(org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean)

Aggregations

NaturalLanguageStringBean (org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean)21 ServiceAlertBean (org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)4 ArrayList (java.util.ArrayList)3 SituationAffectsBean (org.onebusaway.transit_data.model.service_alerts.SituationAffectsBean)3 Translation (com.google.transit.realtime.GtfsRealtime.TranslatedString.Translation)2 Test (org.junit.Test)2 TimeRangeBean (org.onebusaway.transit_data.model.service_alerts.TimeRangeBean)2 Alert (com.google.transit.realtime.GtfsRealtime.Alert)1 EntitySelector (com.google.transit.realtime.GtfsRealtime.EntitySelector)1 FeedEntity (com.google.transit.realtime.GtfsRealtime.FeedEntity)1 FeedMessage (com.google.transit.realtime.GtfsRealtime.FeedMessage)1 TimeRange (com.google.transit.realtime.GtfsRealtime.TimeRange)1 TranslatedString (com.google.transit.realtime.GtfsRealtime.TranslatedString)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 Locale (java.util.Locale)1 NotificationServiceImpl (org.onebusaway.admin.service.impl.NotificationServiceImpl)1 ResponseBean (org.onebusaway.api.model.ResponseBean)1 Message (org.onebusaway.nextbus.model.nextbus.Message)1 MessageText (org.onebusaway.nextbus.model.nextbus.MessageText)1