Search in sources :

Example 1 with SituationConsequenceBean

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

the class ServiceAlertsHelper method handleConsequences.

private void handleConsequences(ServiceAlertBean serviceAlert, PtSituationElementStructure ptSituation) {
    if (serviceAlert == null)
        return;
    List<SituationConsequenceBean> consequences = serviceAlert.getConsequences();
    if (consequences == null || consequences.isEmpty())
        return;
    PtConsequencesStructure ptConsequences = new PtConsequencesStructure();
    ptSituation.setConsequences(ptConsequences);
    for (SituationConsequenceBean consequence : consequences) {
        EEffect effect = consequence.getEffect();
        PtConsequenceStructure ptConsequenceStructure = new PtConsequenceStructure();
        ServiceConditionEnumeration serviceCondition = getEFfectAsCondition(effect);
        ptConsequenceStructure.setCondition(serviceCondition);
        String detourPath = consequence.getDetourPath();
        if (!StringUtils.isBlank(detourPath)) {
            ExtensionsStructure extensionStructure = new ExtensionsStructure();
            OneBusAwayConsequence oneBusAwayConsequence = new OneBusAwayConsequence();
            oneBusAwayConsequence.setDiversionPath(detourPath);
            extensionStructure.setAny(oneBusAwayConsequence);
            ptConsequenceStructure.setExtensions(extensionStructure);
        }
        ptConsequences.getConsequence().add(ptConsequenceStructure);
    }
}
Also used : PtConsequenceStructure(uk.org.siri.siri.PtConsequenceStructure) OneBusAwayConsequence(org.onebusaway.siri.OneBusAwayConsequence) PtConsequencesStructure(uk.org.siri.siri.PtConsequencesStructure) ExtensionsStructure(uk.org.siri.siri.ExtensionsStructure) SituationConsequenceBean(org.onebusaway.transit_data.model.service_alerts.SituationConsequenceBean) ServiceConditionEnumeration(uk.org.siri.siri.ServiceConditionEnumeration) EEffect(org.onebusaway.transit_data.model.service_alerts.EEffect)

Example 2 with SituationConsequenceBean

use of org.onebusaway.transit_data.model.service_alerts.SituationConsequenceBean 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)

Example 3 with SituationConsequenceBean

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

the class ServiceAlertsHelperV2 method handleConsequences.

private void handleConsequences(ServiceAlertBean serviceAlert, PtSituationElementStructure ptSituation) {
    if (serviceAlert == null)
        return;
    List<SituationConsequenceBean> consequences = serviceAlert.getConsequences();
    if (consequences == null || consequences.isEmpty())
        return;
    PtConsequencesStructure ptConsequences = new PtConsequencesStructure();
    ptSituation.setConsequences(ptConsequences);
    for (SituationConsequenceBean consequence : consequences) {
        EEffect effect = consequence.getEffect();
        PtConsequenceStructure ptConsequenceStructure = new PtConsequenceStructure();
        ServiceConditionEnumeration serviceCondition = getEFfectAsCondition(effect);
        ptConsequenceStructure.getCondition().add(serviceCondition);
        String detourPath = consequence.getDetourPath();
        if (!StringUtils.isBlank(detourPath)) {
            ExtensionsStructure extensionStructure = new ExtensionsStructure();
            OneBusAwayConsequence oneBusAwayConsequence = new OneBusAwayConsequence();
            oneBusAwayConsequence.setDiversionPath(detourPath);
            extensionStructure.setAny(oneBusAwayConsequence);
            ptConsequenceStructure.setExtensions(extensionStructure);
        }
        ptConsequences.getConsequence().add(ptConsequenceStructure);
    }
}
Also used : PtConsequenceStructure(uk.org.siri.siri_2.PtConsequenceStructure) OneBusAwayConsequence(org.onebusaway.siri.OneBusAwayConsequence) PtConsequencesStructure(uk.org.siri.siri_2.PtConsequencesStructure) ExtensionsStructure(uk.org.siri.siri_2.ExtensionsStructure) SituationConsequenceBean(org.onebusaway.transit_data.model.service_alerts.SituationConsequenceBean) ServiceConditionEnumeration(uk.org.siri.siri_2.ServiceConditionEnumeration) EEffect(org.onebusaway.transit_data.model.service_alerts.EEffect)

Aggregations

SituationConsequenceBean (org.onebusaway.transit_data.model.service_alerts.SituationConsequenceBean)3 OneBusAwayConsequence (org.onebusaway.siri.OneBusAwayConsequence)2 EEffect (org.onebusaway.transit_data.model.service_alerts.EEffect)2 ArrayList (java.util.ArrayList)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 ESeverity (org.onebusaway.transit_data.model.service_alerts.ESeverity)1 SituationAffectsBean (org.onebusaway.transit_data.model.service_alerts.SituationAffectsBean)1 TimeRangeBean (org.onebusaway.transit_data.model.service_alerts.TimeRangeBean)1 ExtensionsStructure (uk.org.siri.siri.ExtensionsStructure)1 PtConsequenceStructure (uk.org.siri.siri.PtConsequenceStructure)1 PtConsequencesStructure (uk.org.siri.siri.PtConsequencesStructure)1 ServiceConditionEnumeration (uk.org.siri.siri.ServiceConditionEnumeration)1 ExtensionsStructure (uk.org.siri.siri_2.ExtensionsStructure)1 PtConsequenceStructure (uk.org.siri.siri_2.PtConsequenceStructure)1 PtConsequencesStructure (uk.org.siri.siri_2.PtConsequencesStructure)1 ServiceConditionEnumeration (uk.org.siri.siri_2.ServiceConditionEnumeration)1