use of org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean in project onebusaway-application-modules by camsys.
the class NotifyResource method tweetServiceAlert.
@GET
@Produces("application/json")
public Response tweetServiceAlert(@QueryParam("serviceAlertId") String serviceAlertId) {
// construct a short message based on the contents of the service alert
ServiceAlertBean serviceAlertBean = null;
try {
serviceAlertBean = _transitDataService.getServiceAlertForId(serviceAlertId);
return Response.serverError().build();
} catch (Exception any) {
_log.error("retrieval of service alert failed!", any);
}
String tweet = toTweet(serviceAlertBean);
String responseJson = null;
try {
responseJson = _notificationService.tweet(tweet);
} catch (IOException ioe) {
_log.error("tweet failed!", ioe);
return Response.serverError().build();
}
return Response.ok(responseJson).build();
}
use of org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean in project onebusaway-application-modules by camsys.
the class VehicleMonitoringActionTest method testExecuteByRouteNoActivity.
@Test
public void testExecuteByRouteNoActivity() throws Exception {
when(request.getParameter(eq("LineRef"))).thenReturn("40_100479");
when(request.getParameter(eq("OperatorRef"))).thenReturn("1");
PrintWriter nothingPrintWriter = new PrintWriter(new OutputStream() {
@Override
public void write(int b) throws IOException {
// Do nothing
}
});
when(servletResponse.getWriter()).thenReturn(nothingPrintWriter);
List<VehicleActivityStructure> vehicleActivities = new ArrayList<VehicleActivityStructure>();
when(realtimeService.getVehicleActivityForRoute(eq("40_100479"), anyString(), eq(0), anyLong(), eq(false))).thenReturn(vehicleActivities);
ServiceAlertBean serviceAlertBean = ServiceAlertsTestSupport.createServiceAlertBean("1_1");
when(transitDataService.getServiceAlertForId(anyString())).thenReturn(serviceAlertBean);
RouteBean routeBean = RouteBean.builder().create();
when(transitDataService.getRouteForId(anyString())).thenReturn(routeBean);
ListBean<ServiceAlertBean> serviceAlertListBean = new ListBean<ServiceAlertBean>();
List<ServiceAlertBean> list = new ArrayList<ServiceAlertBean>();
list.add(serviceAlertBean);
serviceAlertListBean.setList(list);
when(transitDataService.getServiceAlerts(any(SituationQueryBean.class))).thenReturn(serviceAlertListBean);
SiriXmlSerializer serializer = new SiriXmlSerializer();
when(realtimeService.getSiriXmlSerializer()).thenReturn(serializer);
action.setServletRequest(request);
action.setServletResponse(servletResponse);
action.index();
String monitoring = action.getVehicleMonitoring();
assertTrue("Result XML does not match expected", monitoring.matches("(?s).*<SituationExchangeDelivery><Situations><PtSituationElement><SituationNumber>1_1</SituationNumber><Summary xml:lang=\"EN\">summary</Summary><Description xml:lang=\"EN\">description</Description><Affects><VehicleJourneys><AffectedVehicleJourney><LineRef>1_100277</LineRef><DirectionRef>0</DirectionRef></AffectedVehicleJourney><AffectedVehicleJourney><LineRef>1_100277</LineRef><DirectionRef>1</DirectionRef></AffectedVehicleJourney><AffectedVehicleJourney><LineRef>1_100194</LineRef><DirectionRef>0</DirectionRef></AffectedVehicleJourney><AffectedVehicleJourney><LineRef>1_100194</LineRef><DirectionRef>1</DirectionRef></AffectedVehicleJourney></VehicleJourneys></Affects></PtSituationElement></Situations></SituationExchangeDelivery></ServiceDelivery></Siri>.*"));
}
use of org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean in project onebusaway-application-modules by camsys.
the class AbstractSearchResultFactoryImpl method populateServiceAlerts.
protected void populateServiceAlerts(Set<String> serviceAlertDescriptions, List<ServiceAlertBean> serviceAlertBeans, boolean htmlizeNewlines) {
if (serviceAlertBeans == null)
return;
for (ServiceAlertBean serviceAlertBean : serviceAlertBeans) {
boolean descriptionsAdded = false;
descriptionsAdded = setDescription(serviceAlertDescriptions, serviceAlertBean.getDescriptions(), htmlizeNewlines) || setDescription(serviceAlertDescriptions, serviceAlertBean.getSummaries(), htmlizeNewlines);
if (!descriptionsAdded) {
serviceAlertDescriptions.add("(no description)");
}
}
}
use of org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean in project onebusaway-application-modules by camsys.
the class ServiceAlertsHelper method addSituationExchangeToServiceDelivery.
public void addSituationExchangeToServiceDelivery(ServiceDelivery serviceDelivery, Collection<ServiceAlertBean> serviceAlerts) {
Situations situations = new Situations();
for (ServiceAlertBean serviceAlert : serviceAlerts) {
situations.getPtSituationElement().add(getServiceAlertBeanAsPtSituationElementStructure(serviceAlert));
}
if (situations.getPtSituationElement().size() > 0) {
SituationExchangeDeliveryStructure situationExchangeDelivery = new SituationExchangeDeliveryStructure();
situationExchangeDelivery.setSituations(situations);
serviceDelivery.getSituationExchangeDelivery().add(situationExchangeDelivery);
}
}
use of org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean in project onebusaway-application-modules by camsys.
the class ServiceAlertsHelper method addFromQuery.
private void addFromQuery(TransitDataService nycTransitDataService, Map<String, PtSituationElementStructure> ptSituationElements, SituationQueryBean queryBean) {
ListBean<ServiceAlertBean> serviceAlerts = nycTransitDataService.getServiceAlerts(queryBean);
ServiceAlertsHelper helper = new ServiceAlertsHelper();
for (ServiceAlertBean bean : serviceAlerts.getList()) {
PtSituationElementStructure ptSit = helper.getServiceAlertBeanAsPtSituationElementStructure(bean);
ptSituationElements.put(ptSit.getSituationNumber().getValue(), ptSit);
}
}
Aggregations