Search in sources :

Example 11 with NaturalLanguageStringBean

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

the class ServiceAlertEditAction 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)

Example 12 with NaturalLanguageStringBean

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

the class AbstractSearchResultFactoryImpl method setDescription.

private boolean setDescription(Set<String> serviceAlertDescriptions, List<NaturalLanguageStringBean> descriptions, boolean htmlizeNewlines) {
    boolean descriptionsAdded = false;
    if (descriptions != null) {
        for (NaturalLanguageStringBean description : descriptions) {
            if (description.getValue() != null) {
                serviceAlertDescriptions.add((htmlizeNewlines ? description.getValue().replace("\n", "<br/>") : description.getValue()));
                descriptionsAdded = true;
            }
        }
    }
    return descriptionsAdded;
}
Also used : NaturalLanguageStringBean(org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean)

Example 13 with NaturalLanguageStringBean

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

the class BeanFactoryV2 method getBestString.

public NaturalLanguageStringV2Bean getBestString(List<NaturalLanguageStringBean> strings) {
    if (strings == null || strings.isEmpty())
        return null;
    NaturalLanguageStringBean noLang = null;
    for (NaturalLanguageStringBean nls : strings) {
        String lang = nls.getLang();
        if (lang == null) {
            noLang = nls;
            continue;
        }
        /**
         * To better match the language, we let Locale handle canonicalization
         */
        Locale locale = new Locale(lang);
        if (locale.getLanguage().equals(_locale.getLanguage()))
            return getString(nls);
    }
    if (noLang != null)
        return getString(noLang);
    return null;
}
Also used : Locale(java.util.Locale) NaturalLanguageStringBean(org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean)

Example 14 with NaturalLanguageStringBean

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

the class AlertsForAgencyAction method fillTranslations.

private void fillTranslations(List<NaturalLanguageStringBean> input, TranslatedString.Builder output) {
    for (NaturalLanguageStringBean nls : input) {
        Translation.Builder translation = output.addTranslationBuilder();
        translation.setText(nls.getValue());
        if (nls.getLang() != null) {
            translation.setLanguage(nls.getLang());
        }
    }
}
Also used : Translation(com.google.transit.realtime.GtfsRealtime.TranslatedString.Translation) NaturalLanguageStringBean(org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean)

Example 15 with NaturalLanguageStringBean

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

the class ServiceAlertAction method setDescription.

public void setDescription(String description) {
    List<NaturalLanguageStringBean> descriptions = _model.getDescriptions();
    if (descriptions == null) {
        descriptions = new ArrayList<NaturalLanguageStringBean>();
        _model.setDescriptions(descriptions);
    }
    if (descriptions.isEmpty()) {
        descriptions.add(new NaturalLanguageStringBean());
    }
    NaturalLanguageStringBean nls = descriptions.get(0);
    nls.setValue(description);
    nls.setLang(Locale.getDefault().getLanguage());
}
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