use of org.onebusaway.transit_data.model.ListBean in project onebusaway-application-modules by camsys.
the class UserReportingServiceImpl method getTripProblemReportSummaries.
@Override
public ListBean<TripProblemReportSummaryBean> getTripProblemReportSummaries(TripProblemReportQueryBean query, ETripProblemGroupBy groupBy) {
List<T2<Object, Integer>> records = _userReportingDao.getTripProblemReportSummaries(query, groupBy);
List<TripProblemReportSummaryBean> beans = new ArrayList<TripProblemReportSummaryBean>(records.size());
for (T2<Object, Integer> record : records) {
TripProblemReportSummaryBean bean = new TripProblemReportSummaryBean();
bean.setCount(record.getSecond());
switch(groupBy) {
case TRIP:
{
AgencyAndId tripId = (AgencyAndId) record.getFirst();
bean.setTrip(_tripBeanService.getTripForId(tripId));
break;
}
case STATUS:
{
EProblemReportStatus status = (EProblemReportStatus) record.getFirst();
bean.setStatus(status);
break;
}
case LABEL:
{
String label = (String) record.getFirst();
bean.setLabel(label);
break;
}
}
beans.add(bean);
}
return new ListBean<TripProblemReportSummaryBean>(beans, false);
}
use of org.onebusaway.transit_data.model.ListBean in project onebusaway-application-modules by camsys.
the class UserReportingServiceImpl method getStopProblemReportSummaries.
@Override
public ListBean<StopProblemReportSummaryBean> getStopProblemReportSummaries(StopProblemReportQueryBean query) {
List<T2<AgencyAndId, Integer>> records = _userReportingDao.getStopProblemReportSummaries(query.getAgencyId(), query.getTimeFrom(), query.getTimeTo(), query.getStatus());
List<StopProblemReportSummaryBean> beans = new ArrayList<StopProblemReportSummaryBean>(records.size());
for (T2<AgencyAndId, Integer> record : records) {
AgencyAndId stopId = record.getFirst();
Integer count = record.getSecond();
StopProblemReportSummaryBean bean = new StopProblemReportSummaryBean();
bean.setStop(_stopBeanService.getStopForId(stopId));
bean.setStatus(query.getStatus());
bean.setCount(count);
beans.add(bean);
}
return new ListBean<StopProblemReportSummaryBean>(beans, false);
}
use of org.onebusaway.transit_data.model.ListBean 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.ListBean in project onebusaway-application-modules by camsys.
the class StopsBeanServiceImpl method getStopsIdsForAgencyId.
@Override
public ListBean<String> getStopsIdsForAgencyId(String agencyId) {
AgencyEntry agency = _transitGraphDao.getAgencyForId(agencyId);
if (agency == null)
throw new NoSuchAgencyServiceException(agencyId);
List<String> ids = new ArrayList<String>();
for (StopEntry stop : agency.getStops()) {
AgencyAndId id = stop.getId();
ids.add(AgencyAndIdLibrary.convertToString(id));
}
return new ListBean<String>(ids, false);
}
use of org.onebusaway.transit_data.model.ListBean in project onebusaway-application-modules by camsys.
the class CurrentVehicleEstimationServiceImpl method getCurrentVehicleEstimates.
@Override
public ListBean<CurrentVehicleEstimateBean> getCurrentVehicleEstimates(CurrentVehicleEstimateQueryBean query) {
long minT = SystemTime.currentTimeMillis() - _maxWindow * 60 * 1000;
minT = 0;
List<Record> records = getRecords(query.getRecords(), minT);
if (records.isEmpty())
return new ListBean<CurrentVehicleEstimateBean>();
List<CurrentVehicleEstimateBean> beans = new ArrayList<CurrentVehicleEstimateBean>();
if (tryDirectMatchAgainstVehicleId(query, records, beans))
return new ListBean<CurrentVehicleEstimateBean>(beans, true);
Map<Date, Record> recordsByTime = getRecordsByTimestamp(records);
List<Date> timestamps = new ArrayList<Date>(recordsByTime.keySet());
Collections.sort(timestamps);
if (tryDirectMatchAgainstBlockId(query, records, recordsByTime, timestamps, query.getMinProbability(), beans))
return new ListBean<CurrentVehicleEstimateBean>(beans, true);
Set<BlockSequenceIndex> allIndices = getBlockSequenceIndicesForRecords(recordsByTime);
for (BlockSequenceIndex index : allIndices) {
Map<BlockInstance, List<List<BlockLocation>>> allLocations = _blockStatusService.getBlocksForIndex(index, timestamps);
for (Map.Entry<BlockInstance, List<List<BlockLocation>>> entry : allLocations.entrySet()) {
BlockInstance blockInstance = entry.getKey();
List<List<BlockLocation>> realTimeLocations = entry.getValue();
computeEstimatesForBlockInstance(records, recordsByTime, blockInstance, realTimeLocations, query.getMinProbability(), beans);
}
}
Collections.sort(beans);
return new ListBean<CurrentVehicleEstimateBean>(beans, false);
}
Aggregations