Search in sources :

Example 1 with OneBusAwayConsequence

use of org.onebusaway.siri.OneBusAwayConsequence 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 OneBusAwayConsequence

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

the class SiriService method handleConsequences.

private void handleConsequences(PtSituationElementStructure ptSituation, ServiceAlertRecord serviceAlert) {
    PtConsequencesStructure consequences = ptSituation.getConsequences();
    if (consequences == null || consequences.getConsequence() == null)
        return;
    for (PtConsequenceStructure consequence : consequences.getConsequence()) {
        ServiceAlertSituationConsequenceClause builder = new ServiceAlertSituationConsequenceClause();
        if (consequence.getCondition() != null)
            builder.setEffect(getConditionAsEffect(consequence.getCondition()));
        ExtensionsStructure extensions = consequence.getExtensions();
        if (extensions != null) {
            Object obj = extensions.getAny();
            if (obj instanceof OneBusAwayConsequence) {
                OneBusAwayConsequence obaConsequence = (OneBusAwayConsequence) obj;
                if (obaConsequence.getDiversionPath() != null)
                    builder.setDetourPath(obaConsequence.getDiversionPath());
            }
        }
        if (serviceAlert.getConsequences() == null)
            serviceAlert.setConsequences(new HashSet<ServiceAlertSituationConsequenceClause>());
        if (builder.getDetourPath() != null || builder.getEffect() != null)
            serviceAlert.getConsequences().add(builder);
    }
}
Also used : OneBusAwayConsequence(org.onebusaway.siri.OneBusAwayConsequence) HashSet(java.util.HashSet)

Example 3 with OneBusAwayConsequence

use of org.onebusaway.siri.OneBusAwayConsequence 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

OneBusAwayConsequence (org.onebusaway.siri.OneBusAwayConsequence)3 EEffect (org.onebusaway.transit_data.model.service_alerts.EEffect)2 SituationConsequenceBean (org.onebusaway.transit_data.model.service_alerts.SituationConsequenceBean)2 HashSet (java.util.HashSet)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