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);
}
}
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);
}
}
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);
}
}
Aggregations