Search in sources :

Example 21 with ServiceAlertBean

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

the class SituationsPresentation method getUnreadCount.

public int getUnreadCount() {
    int unreadServiceAlertCount = 0;
    Map<String, Long> readServiceAlerts = _user.getReadServiceAlerts();
    for (ServiceAlertBean situation : _situations) {
        if (isSituationUnread(readServiceAlerts, situation))
            unreadServiceAlertCount++;
    }
    return unreadServiceAlertCount;
}
Also used : ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)

Example 22 with ServiceAlertBean

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

the class ServiceAlertAffectsAction method delete.

public String delete() {
    if (_id == null || _index == -1) {
        return INPUT;
    }
    ServiceAlertBean alert = null;
    try {
        alert = _transitDataService.getServiceAlertForId(_id);
    } catch (RuntimeException e) {
        _log.error("Error retrieving Service Alert", e);
        throw e;
    }
    if (alert == null) {
        return INPUT;
    }
    List<SituationAffectsBean> allAffects = alert.getAllAffects();
    if (allAffects == null || _index >= allAffects.size()) {
        return INPUT;
    }
    allAffects.remove(_index);
    try {
        _transitDataService.updateServiceAlert(alert);
    } catch (RuntimeException e) {
        _log.error("Error removing Service Alert Affects clause", e);
        throw e;
    }
    return SUCCESS;
}
Also used : SituationAffectsBean(org.onebusaway.transit_data.model.service_alerts.SituationAffectsBean) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)

Example 23 with ServiceAlertBean

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

the class ServiceAlertEditAction method getModel.

@Override
public ServiceAlertBean getModel() {
    if (_model == null) {
        _model = new ServiceAlertBean();
        _model.setReason("Initial setup of empty ServiceAlert");
    }
    return _model;
}
Also used : ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)

Example 24 with ServiceAlertBean

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

the class ServiceAlertEditAction method execute.

@Override
public String execute() {
    try {
        if (_alertId != null && !_alertId.trim().isEmpty()) {
            _model = _transitDataService.getServiceAlertForId(_alertId);
            if (_agencyId == null) {
                _agencyId = ServiceAlertsUtil.getAgencyFromAlertId(_alertId);
            }
        }
    } catch (RuntimeException e) {
        _log.error("Unable to retrieve Service Alert", e);
        throw e;
    }
    try {
        _agencies = _transitDataService.getAgenciesWithCoverage();
        _situationTemplatesByAgency = new ArrayList<ServiceAlertBean>();
        for (int i = 0; i < _agencies.size(); ++i) {
            AgencyWithCoverageBean agency = _agencies.get(i);
            String agencyId = agency.getAgency().getId();
            ListBean<ServiceAlertRecordBean> result = _transitDataService.getAllServiceAlertRecordsForAgencyId(agencyId);
            for (ServiceAlertRecordBean serviceAlertRecord : result.getList()) {
                if (Boolean.TRUE.equals(serviceAlertRecord.isCopy())) {
                    _situationTemplatesByAgency.add(serviceAlertRecord.getServiceAlertBean());
                }
            }
        }
    } catch (Throwable t) {
        _log.error("unable to retrieve agencies with coverage", t);
        _log.error("issue connecting to TDS -- check your configuration in data-sources.xml");
        throw new RuntimeException("Check your onebusaway-nyc-transit-data-federation-webapp configuration", t);
    }
    if (isFromFavorite()) {
        setStartDate(null);
        setEndDate(null);
    }
    return "SUCCESS";
}
Also used : ServiceAlertRecordBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertRecordBean) AgencyWithCoverageBean(org.onebusaway.transit_data.model.AgencyWithCoverageBean) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)

Example 25 with ServiceAlertBean

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

the class BeanFactoryV2 method getStopWithArrivalAndDepartures.

public StopWithArrivalsAndDeparturesV2Bean getStopWithArrivalAndDepartures(StopWithArrivalsAndDeparturesBean sad) {
    StopWithArrivalsAndDeparturesV2Bean bean = new StopWithArrivalsAndDeparturesV2Bean();
    bean.setStopId(sad.getStop().getId());
    addToReferences(sad.getStop());
    List<ArrivalAndDepartureV2Bean> ads = new ArrayList<ArrivalAndDepartureV2Bean>();
    for (ArrivalAndDepartureBean ad : sad.getArrivalsAndDepartures()) ads.add(getArrivalAndDeparture(ad));
    bean.setArrivalsAndDepartures(ads);
    List<String> nearbyStopIds = new ArrayList<String>();
    for (StopBean nearbyStop : sad.getNearbyStops()) {
        nearbyStopIds.add(nearbyStop.getId());
        addToReferences(nearbyStop);
    }
    bean.setNearbyStopIds(nearbyStopIds);
    List<ServiceAlertBean> situations = sad.getSituations();
    if (!CollectionsLibrary.isEmpty(situations)) {
        List<String> situationIds = new ArrayList<String>();
        for (ServiceAlertBean situation : situations) {
            addToReferences(situation);
            situationIds.add(situation.getId());
        }
        bean.setSituationIds(situationIds);
    }
    return bean;
}
Also used : ArrayList(java.util.ArrayList) StopBean(org.onebusaway.transit_data.model.StopBean) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean) ArrivalAndDepartureBean(org.onebusaway.transit_data.model.ArrivalAndDepartureBean)

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