Search in sources :

Example 41 with ServiceAlertBean

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

the class RealtimeServiceV2Impl method getServiceAlertsGlobal.

/**
 * Returns true if there are vehicles in service for given route+direction
 * that will stop at the indicated stop in the future.
 */
/* These methods were used in nyc branch.  Not used here so far.
  @Override
  public boolean getVehiclesInServiceForStopAndRoute(String stopId,
      String routeId, long currentTime) {
    for (ArrivalAndDepartureBean adBean : getArrivalsAndDeparturesForStop(
        stopId, currentTime)) {
      TripStatusBean statusBean = adBean.getTripStatus();
      if (!_presentationService.include(statusBean)
          || !_presentationService.include(adBean, statusBean))
        continue;

      // filtered out by user
      if (routeId != null
          && !adBean.getTrip().getRoute().getId().equals(routeId))
        continue;

      return true;
    }

    return false;
  }
*/
/**
 * SERVICE ALERTS METHODS
 */
/*
  @Override
  public List<ServiceAlertBean> getServiceAlertsForRoute(String routeId) {
    return getServiceAlertsForRouteAndDirection(routeId, null);
  }

  @Override
  public List<ServiceAlertBean> getServiceAlertsForRouteAndDirection(
      String routeId, String directionId) {
    SituationQueryBean query = new SituationQueryBean();
    SituationQueryBean.AffectsBean affects = new SituationQueryBean.AffectsBean();
    query.getAffects().add(affects);

    affects.setRouteId(routeId);
    if (directionId != null) {
      affects.setDirectionId(directionId);
    } else {
    */
/*
       * TODO The route index is not currently being populated correctly;
       * query by route and direction, and supply both directions if not
       * present
       */
/*
      SituationQueryBean.AffectsBean affects1 = new SituationQueryBean.AffectsBean();
      query.getAffects().add(affects1);
      affects1.setRouteId(routeId);
      affects1.setDirectionId("0");
      SituationQueryBean.AffectsBean affects2 = new SituationQueryBean.AffectsBean();
      query.getAffects().add(affects2);
      affects2.setRouteId(routeId);
      affects2.setDirectionId("1");
    }

    ListBean<ServiceAlertBean> serviceAlerts = _nycTransitDataService
        .getServiceAlerts(query);
    return serviceAlerts.getList();
  }
*/
@Override
public List<ServiceAlertBean> getServiceAlertsGlobal() {
    SituationQueryBean query = new SituationQueryBean();
    SituationQueryBean.AffectsBean affects = new SituationQueryBean.AffectsBean();
    affects.setAgencyId("__ALL_OPERATORS__");
    query.getAffects().add(affects);
    ListBean<ServiceAlertBean> serviceAlerts = _transitDataService.getServiceAlerts(query);
    return serviceAlerts.getList();
}
Also used : SituationQueryBean(org.onebusaway.transit_data.model.service_alerts.SituationQueryBean) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)

Example 42 with ServiceAlertBean

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

the class ServiceAlertsHelperV2 method addFromQuery.

private void addFromQuery(TransitDataService transitDataService, Map<String, PtSituationElementStructure> ptSituationElements, SituationQueryBean queryBean) {
    ListBean<ServiceAlertBean> serviceAlerts = transitDataService.getServiceAlerts(queryBean);
    ServiceAlertsHelperV2 helper = new ServiceAlertsHelperV2();
    for (ServiceAlertBean bean : serviceAlerts.getList()) {
        PtSituationElementStructure ptSit = helper.getServiceAlertBeanAsPtSituationElementStructure(bean);
        ptSituationElements.put(ptSit.getSituationNumber().getValue(), ptSit);
    }
}
Also used : PtSituationElementStructure(uk.org.siri.siri_2.PtSituationElementStructure) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)

Example 43 with ServiceAlertBean

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

the class ServiceAlertsHelperV2 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);
    }
}
Also used : SituationExchangeDeliveryStructure(uk.org.siri.siri_2.SituationExchangeDeliveryStructure) Situations(uk.org.siri.siri_2.SituationExchangeDeliveryStructure.Situations) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)

Example 44 with ServiceAlertBean

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

the class ServiceAlertsHelperV2 method addSituationElement.

/*
  public void addSituationExchangeToServiceDelivery(ServiceDelivery serviceDelivery,
      Map<String, ServiceAlertBean> currentServiceAlerts) {
    addSituationExchangeToServiceDelivery(serviceDelivery, currentServiceAlerts.values());
  }

  public void addClosedSituationExchangesToSiri(
      ServiceDelivery serviceDelivery, Collection<String> deletedIds) {
    Map<String, PtSituationElementStructure> ptSituationElements = new HashMap<String, PtSituationElementStructure>();

    for (String id : deletedIds) {
      PtSituationElementStructure ptSit = new PtSituationElementStructure();
      EntryQualifierStructure value = new EntryQualifierStructure();
      value.setValue(id);
      ptSit.setSituationNumber(value);
      ptSit.setProgress(WorkflowStatusEnumeration.CLOSED);
      ptSituationElements.put(id, ptSit);
    }

    addPtSituationElementsToServiceDelivery(serviceDelivery,
        ptSituationElements);

  }
*/
private void addSituationElement(TransitDataService transitDataService, Map<String, PtSituationElementStructure> ptSituationElements, List<SituationRefStructure> situationRefs) {
    if (situationRefs == null)
        return;
    for (SituationRefStructure situationRef : situationRefs) {
        String situationId = situationRef.getSituationSimpleRef().getValue();
        ServiceAlertBean serviceAlert = transitDataService.getServiceAlertForId(situationId);
        PtSituationElementStructure e = getServiceAlertBeanAsPtSituationElementStructure(serviceAlert);
        ptSituationElements.put(situationId, e);
    }
}
Also used : SituationRefStructure(uk.org.siri.siri_2.SituationRefStructure) PtSituationElementStructure(uk.org.siri.siri_2.PtSituationElementStructure) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)

Example 45 with ServiceAlertBean

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

the class SiriSupportV2 method fillSituations.

private static void fillSituations(MonitoredVehicleJourneyStructure monitoredVehicleJourney, TripStatusBean tripStatus) {
    if (tripStatus == null || tripStatus.getSituations() == null || tripStatus.getSituations().isEmpty()) {
        return;
    }
    List<SituationRefStructure> situationRef = monitoredVehicleJourney.getSituationRef();
    for (ServiceAlertBean situation : tripStatus.getSituations()) {
        SituationRefStructure sitRef = new SituationRefStructure();
        SituationSimpleRefStructure sitSimpleRef = new SituationSimpleRefStructure();
        sitSimpleRef.setValue(situation.getId());
        sitRef.setSituationSimpleRef(sitSimpleRef);
        situationRef.add(sitRef);
    }
}
Also used : SituationRefStructure(uk.org.siri.siri_2.SituationRefStructure) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean) SituationSimpleRefStructure(uk.org.siri.siri_2.SituationSimpleRefStructure)

Aggregations

ServiceAlertBean (org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)54 ArrayList (java.util.ArrayList)22 SituationQueryBean (org.onebusaway.transit_data.model.service_alerts.SituationQueryBean)11 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)8 StopBean (org.onebusaway.transit_data.model.StopBean)8 SituationAffectsBean (org.onebusaway.transit_data.model.service_alerts.SituationAffectsBean)8 HashMap (java.util.HashMap)7 List (java.util.List)5 RouteBean (org.onebusaway.transit_data.model.RouteBean)5 TripBean (org.onebusaway.transit_data.model.trips.TripBean)5 Test (org.junit.Test)4 NaturalLanguageStringBean (org.onebusaway.transit_data.model.service_alerts.NaturalLanguageStringBean)4 TripStatusBean (org.onebusaway.transit_data.model.trips.TripStatusBean)4 PtSituationElementStructure (uk.org.siri.siri.PtSituationElementStructure)4 PtSituationElementStructure (uk.org.siri.siri_2.PtSituationElementStructure)4 HashSet (java.util.HashSet)3 ArrivalAndDepartureBean (org.onebusaway.transit_data.model.ArrivalAndDepartureBean)3 StopsForRouteBean (org.onebusaway.transit_data.model.StopsForRouteBean)3 BlockTripBean (org.onebusaway.transit_data.model.blocks.BlockTripBean)3 TimeRangeBean (org.onebusaway.transit_data.model.service_alerts.TimeRangeBean)3