Search in sources :

Example 1 with PtSituationElementStructure

use of uk.org.siri.siri.PtSituationElementStructure in project onebusaway-application-modules by camsys.

the class ServiceAlertsHelper method addSituationExchangeToServiceDelivery.

public void addSituationExchangeToServiceDelivery(ServiceDelivery serviceDelivery, List<VehicleActivityStructure> activities, TransitDataService transitDataService, List<AgencyAndId> routeIds) {
    if (activities == null)
        return;
    Map<String, PtSituationElementStructure> ptSituationElements = new HashMap<String, PtSituationElementStructure>();
    for (VehicleActivityStructure activity : activities) {
        if (activity.getMonitoredVehicleJourney() != null) {
            addSituationElement(transitDataService, ptSituationElements, activity.getMonitoredVehicleJourney().getSituationRef());
        }
    }
    addPtSituationElementsToServiceDelivery(serviceDelivery, ptSituationElements);
    if (routeIds == null)
        return;
    List<ServiceAlertBean> serviceAlerts = new ArrayList<ServiceAlertBean>();
    for (AgencyAndId routeId : routeIds) {
        SituationQueryBean query = new SituationQueryBean();
        SituationQueryBean.AffectsBean affects = new SituationQueryBean.AffectsBean();
        query.getAffects().add(affects);
        affects.setRouteId(routeId.toString());
        ListBean<ServiceAlertBean> serviceAlertsForRoute = transitDataService.getServiceAlerts(query);
        if (serviceAlertsForRoute != null) {
            serviceAlerts.addAll(serviceAlertsForRoute.getList());
        }
    }
    if (serviceAlerts.size() == 0)
        return;
    addSituationExchangeToServiceDelivery(serviceDelivery, serviceAlerts);
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PtSituationElementStructure(uk.org.siri.siri.PtSituationElementStructure) SituationAffectsBean(org.onebusaway.transit_data.model.service_alerts.SituationAffectsBean) SituationQueryBean(org.onebusaway.transit_data.model.service_alerts.SituationQueryBean) VehicleActivityStructure(uk.org.siri.siri.VehicleActivityStructure) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)

Example 2 with PtSituationElementStructure

use of uk.org.siri.siri.PtSituationElementStructure in project onebusaway-application-modules by camsys.

the class ServiceAlertsHelper method addSituationElement.

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.SituationRefStructure) PtSituationElementStructure(uk.org.siri.siri.PtSituationElementStructure) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)

Example 3 with PtSituationElementStructure

use of uk.org.siri.siri.PtSituationElementStructure in project onebusaway-application-modules by camsys.

the class ServiceAlertsHelper method addGlobalServiceAlertsToServiceDelivery.

public void addGlobalServiceAlertsToServiceDelivery(ServiceDelivery serviceDelivery, RealtimeService realtimeService) {
    List<ServiceAlertBean> serviceAlertBeans = realtimeService.getServiceAlertsGlobal();
    if (serviceAlertBeans == null)
        return;
    Map<String, PtSituationElementStructure> ptSituationElements = new HashMap<String, PtSituationElementStructure>();
    for (ServiceAlertBean serviceAlertBean : serviceAlertBeans) {
        ptSituationElements.put(serviceAlertBean.getId(), getServiceAlertBeanAsPtSituationElementStructure(serviceAlertBean));
    }
    addPtSituationElementsToServiceDelivery(serviceDelivery, ptSituationElements);
}
Also used : HashMap(java.util.HashMap) PtSituationElementStructure(uk.org.siri.siri.PtSituationElementStructure) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)

Example 4 with PtSituationElementStructure

use of uk.org.siri.siri.PtSituationElementStructure in project onebusaway-application-modules by camsys.

the class ServiceAlertsHelper method getServiceAlertBeanAsPtSituationElementStructure.

public PtSituationElementStructure getServiceAlertBeanAsPtSituationElementStructure(ServiceAlertBean serviceAlert) {
    PtSituationElementStructure ptSit = new PtSituationElementStructure();
    EntryQualifierStructure value = new EntryQualifierStructure();
    if (serviceAlert != null) {
        value.setValue(serviceAlert.getId());
        ptSit.setSituationNumber(value);
    } else {
        // nothing to do
        return ptSit;
    }
    if (serviceAlert.getCreationTime() != 0)
        ptSit.setCreationTime(new Date(serviceAlert.getCreationTime()));
    handleDescriptions(serviceAlert, ptSit);
    handleOtherFields(serviceAlert, ptSit);
    handleAffects(serviceAlert, ptSit);
    handleConsequences(serviceAlert, ptSit);
    return ptSit;
}
Also used : PtSituationElementStructure(uk.org.siri.siri.PtSituationElementStructure) EntryQualifierStructure(uk.org.siri.siri.EntryQualifierStructure) Date(java.util.Date)

Example 5 with PtSituationElementStructure

use of uk.org.siri.siri.PtSituationElementStructure in project onebusaway-application-modules by camsys.

the class ServiceAlertsHelper method addClosedSituationExchangesToSiri.

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);
}
Also used : HashMap(java.util.HashMap) PtSituationElementStructure(uk.org.siri.siri.PtSituationElementStructure) EntryQualifierStructure(uk.org.siri.siri.EntryQualifierStructure)

Aggregations

PtSituationElementStructure (uk.org.siri.siri.PtSituationElementStructure)8 HashMap (java.util.HashMap)4 ServiceAlertBean (org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)4 ArrayList (java.util.ArrayList)2 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)2 SituationAffectsBean (org.onebusaway.transit_data.model.service_alerts.SituationAffectsBean)2 SituationQueryBean (org.onebusaway.transit_data.model.service_alerts.SituationQueryBean)2 EntryQualifierStructure (uk.org.siri.siri.EntryQualifierStructure)2 Date (java.util.Date)1 RouteBean (org.onebusaway.transit_data.model.RouteBean)1 StopBean (org.onebusaway.transit_data.model.StopBean)1 StopGroupBean (org.onebusaway.transit_data.model.StopGroupBean)1 StopGroupingBean (org.onebusaway.transit_data.model.StopGroupingBean)1 StopsForRouteBean (org.onebusaway.transit_data.model.StopsForRouteBean)1 MonitoredStopVisitStructure (uk.org.siri.siri.MonitoredStopVisitStructure)1 SituationExchangeDeliveryStructure (uk.org.siri.siri.SituationExchangeDeliveryStructure)1 Situations (uk.org.siri.siri.SituationExchangeDeliveryStructure.Situations)1 SituationRefStructure (uk.org.siri.siri.SituationRefStructure)1 VehicleActivityStructure (uk.org.siri.siri.VehicleActivityStructure)1