use of org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean in project onebusaway-application-modules by camsys.
the class ServiceAlertAction method setSummary.
public void setSummary(String summary) {
List<NaturalLanguageStringBean> summaries = _model.getSummaries();
if (summaries == null) {
summaries = new ArrayList<NaturalLanguageStringBean>();
_model.setSummaries(summaries);
}
if (summaries.isEmpty()) {
summaries.add(new NaturalLanguageStringBean());
}
NaturalLanguageStringBean nls = summaries.get(0);
nls.setValue(summary);
nls.setLang(Locale.getDefault().getLanguage());
}
use of org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean in project onebusaway-application-modules by camsys.
the class ServiceAlertEditAction method setSummary.
public void setSummary(String summary) {
List<NaturalLanguageStringBean> summaries = _model.getSummaries();
if (summaries == null) {
summaries = new ArrayList<NaturalLanguageStringBean>();
_model.setSummaries(summaries);
}
if (summaries.isEmpty()) {
summaries.add(new NaturalLanguageStringBean());
}
NaturalLanguageStringBean nls = summaries.get(0);
nls.setValue(summary);
nls.setLang(Locale.getDefault().getLanguage());
}
use of org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean in project onebusaway-application-modules by camsys.
the class ServiceAlertEditAction 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();
}
use of org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean in project onebusaway-application-modules by camsys.
the class ServiceAlertEditAction 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());
}
use of org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean in project onebusaway-application-modules by camsys.
the class NotifyResourceTest method testToTweet.
@Test
public void testToTweet() {
ServiceAlertBean bean = null;
NotificationServiceImpl nsi = new NotificationServiceImpl();
NotificationStrategy ns = new TestNotificationStrategy();
nsi.setNotificationStrategy(ns);
NotifyResource resource = new NotifyResource();
resource.setNotificationService(nsi);
assertNull(resource.toTweet(bean));
bean = new ServiceAlertBean();
assertNull(resource.toTweet(bean));
bean.setSummaries(new ArrayList<NaturalLanguageStringBean>());
bean.getSummaries().add(createNLS("Snow Routes in Affect"));
// service alert has no affects clause, nothing to do
assertEquals(null, resource.toTweet(bean));
SituationAffectsBean affects = new SituationAffectsBean();
affects.setAgencyId("ACTA");
bean.setAllAffects(new ArrayList<SituationAffectsBean>());
bean.getAllAffects().add(affects);
// we don't include agency in tweet -- it will be obvious from the twitter handle
assertEquals("Snow Routes in Affect", resource.toTweet(bean));
// add a single route
affects.setRouteId("A1");
assertEquals("Snow Routes in Affect affecting route(s) ACTA_A1", resource.toTweet(bean));
// add a stop
affects = new SituationAffectsBean();
affects.setAgencyId("ACTA");
bean.getAllAffects().add(affects);
affects.setStopId("Water and Blowers");
try {
assertEquals("Snow Routes in Affect affecting route(s) A1 and stop(s) Water and Blowers", resource.toTweet(bean));
fail("expected IllegalArgumentException");
} catch (IllegalArgumentException iae) {
// pass
}
affects.setStopId("ACTA_6968");
assertEquals("Snow Routes in Affect affecting route(s) ACTA_A1 and stop(s) ACTA_6968", resource.toTweet(bean));
// add another route
affects = new SituationAffectsBean();
affects.setAgencyId("ACTA");
bean.getAllAffects().add(affects);
affects.setRouteId("B2");
assertEquals("Snow Routes in Affect affecting route(s) ACTA_A1, ACTA_B2 and stop(s) ACTA_6968", resource.toTweet(bean));
// add another stop
affects = new SituationAffectsBean();
affects.setAgencyId("ACTA");
bean.getAllAffects().add(affects);
affects.setStopId("ACTA_4370");
assertEquals("Snow Routes in Affect affecting route(s) ACTA_A1, ACTA_B2 and stop(s) ACTA_6968, ACTA_4370", resource.toTweet(bean));
// clear out routes, add a single stop
affects = new SituationAffectsBean();
affects.setAgencyId("ACTA");
bean.setAllAffects(new ArrayList<SituationAffectsBean>());
bean.getAllAffects().add(affects);
affects.setStopId("ACTA_4370");
assertEquals("Snow Routes in Affect affecting stop(s) ACTA_4370", resource.toTweet(bean));
// add another stop
affects = new SituationAffectsBean();
affects.setAgencyId("ACTA");
bean.getAllAffects().add(affects);
affects.setStopId("ACTA_6968");
assertEquals("Snow Routes in Affect affecting stop(s) ACTA_4370, ACTA_6968", resource.toTweet(bean));
// we don't support trip level tweets
}
Aggregations