Search in sources :

Example 1 with ESeverity

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

the class SituationsPresentation method getHighestUnreadSeverity.

private ESeverity getHighestUnreadSeverity() {
    ESeverity maxSeverity = null;
    Map<String, Long> readServiceAlerts = _user.getReadServiceAlerts();
    for (ServiceAlertBean situation : _situations) {
        if (isSituationUnread(readServiceAlerts, situation)) {
            ESeverity s = situation.getSeverity();
            if (s == null)
                s = ESeverity.UNDEFINED;
            if (maxSeverity == null || maxSeverity.getNumericValue() < s.getNumericValue())
                maxSeverity = s;
        }
    }
    return maxSeverity;
}
Also used : ESeverity(org.onebusaway.transit_data.model.service_alerts.ESeverity) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)

Example 2 with ESeverity

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

the class SiriService method handleOtherFields.

private void handleOtherFields(PtSituationElementStructure ptSituation, ServiceAlertRecord serviceAlert) {
    SeverityEnumeration severity = ptSituation.getSeverity();
    if (severity != null) {
        ESeverity severityEnum = ESeverity.valueOfTpegCode(severity.value());
        serviceAlert.setSeverity(severityEnum);
    }
    if (ptSituation.getPublicationWindow() != null) {
        HalfOpenTimestampRangeStructure window = ptSituation.getPublicationWindow();
        ServiceAlertTimeRange range = new ServiceAlertTimeRange();
        if (window.getStartTime() != null)
            range.setFromValue(window.getStartTime().getTime());
        if (window.getEndTime() != null)
            range.setToValue(window.getEndTime().getTime());
        if (serviceAlert.getActiveWindows() == null)
            serviceAlert.setActiveWindows(new HashSet<ServiceAlertTimeRange>());
        if (range.getFromValue() != null || range.getToValue() != null)
            serviceAlert.getActiveWindows().add(range);
    }
}
Also used : ESeverity(org.onebusaway.transit_data.model.service_alerts.ESeverity) HashSet(java.util.HashSet)

Example 3 with ESeverity

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

the class BeanFactoryV2 method getSituation.

public SituationV2Bean getSituation(ServiceAlertBean situation) {
    SituationV2Bean bean = new SituationV2Bean();
    bean.setId(situation.getId());
    bean.setCreationTime(situation.getCreationTime());
    if (!CollectionsLibrary.isEmpty(situation.getActiveWindows())) {
        List<TimeRangeV2Bean> activeWindows = new ArrayList<TimeRangeV2Bean>();
        for (TimeRangeBean activeWindow : situation.getActiveWindows()) activeWindows.add(getTimeRange(activeWindow));
        bean.setActiveWindows(activeWindows);
    }
    if (!CollectionsLibrary.isEmpty(situation.getPublicationWindows())) {
        List<TimeRangeV2Bean> publicationWindows = new ArrayList<TimeRangeV2Bean>();
        for (TimeRangeBean publicationWindow : situation.getPublicationWindows()) publicationWindows.add(getTimeRange(publicationWindow));
        bean.setPublicationWindows(publicationWindows);
    }
    if (!CollectionsLibrary.isEmpty(situation.getAllAffects())) {
        List<SituationAffectsV2Bean> affects = new ArrayList<SituationAffectsV2Bean>();
        for (SituationAffectsBean affect : situation.getAllAffects()) affects.add(getSituationAffects(affect));
        bean.setAllAffects(affects);
    }
    if (!CollectionsLibrary.isEmpty(situation.getConsequences())) {
        List<SituationConsequenceV2Bean> beans = new ArrayList<SituationConsequenceV2Bean>();
        for (SituationConsequenceBean consequence : situation.getConsequences()) {
            SituationConsequenceV2Bean consequenceBean = getSituationConsequence(consequence);
            beans.add(consequenceBean);
        }
        bean.setConsequences(beans);
    }
    bean.setReason(situation.getReason());
    bean.setSummary(getBestString(situation.getSummaries()));
    bean.setDescription(getBestString(situation.getDescriptions()));
    bean.setUrl(getBestString(situation.getUrls()));
    ESeverity severity = situation.getSeverity();
    if (severity != null) {
        String[] codes = severity.getTpegCodes();
        bean.setSeverity(codes[0]);
    }
    return bean;
}
Also used : ArrayList(java.util.ArrayList) SituationConsequenceV2Bean(org.onebusaway.api.model.transit.service_alerts.SituationConsequenceV2Bean) ESeverity(org.onebusaway.transit_data.model.service_alerts.ESeverity) SituationAffectsV2Bean(org.onebusaway.api.model.transit.service_alerts.SituationAffectsV2Bean) SituationV2Bean(org.onebusaway.api.model.transit.service_alerts.SituationV2Bean) TimeRangeBean(org.onebusaway.transit_data.model.service_alerts.TimeRangeBean) SituationAffectsBean(org.onebusaway.transit_data.model.service_alerts.SituationAffectsBean) TimeRangeV2Bean(org.onebusaway.api.model.transit.service_alerts.TimeRangeV2Bean) SituationConsequenceBean(org.onebusaway.transit_data.model.service_alerts.SituationConsequenceBean)

Aggregations

ESeverity (org.onebusaway.transit_data.model.service_alerts.ESeverity)3 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 SituationAffectsV2Bean (org.onebusaway.api.model.transit.service_alerts.SituationAffectsV2Bean)1 SituationConsequenceV2Bean (org.onebusaway.api.model.transit.service_alerts.SituationConsequenceV2Bean)1 SituationV2Bean (org.onebusaway.api.model.transit.service_alerts.SituationV2Bean)1 TimeRangeV2Bean (org.onebusaway.api.model.transit.service_alerts.TimeRangeV2Bean)1 ServiceAlertBean (org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)1 SituationAffectsBean (org.onebusaway.transit_data.model.service_alerts.SituationAffectsBean)1 SituationConsequenceBean (org.onebusaway.transit_data.model.service_alerts.SituationConsequenceBean)1 TimeRangeBean (org.onebusaway.transit_data.model.service_alerts.TimeRangeBean)1