use of uk.org.siri.siri.AffectsScopeStructure in project onebusaway-application-modules by camsys.
the class ServiceAlertsHelper method handleAffects.
/*
@SuppressWarnings("unused")
private void handlReasons(PtSituationElementStructure ptSituation,
ServiceAlertBean serviceAlert) {
throw new RuntimeException("handleReasons not implemented");
}
*/
private void handleAffects(ServiceAlertBean serviceAlert, PtSituationElementStructure ptSituation) {
if (serviceAlert.getAllAffects() == null)
return;
boolean hasOperators = false;
AffectsScopeStructure affectsStructure = new AffectsScopeStructure();
VehicleJourneys vehicleJourneys = new VehicleJourneys();
for (SituationAffectsBean affects : serviceAlert.getAllAffects()) {
String agencyId = affects.getAgencyId();
if (agencyId != null) {
Operators operators = new Operators();
if (StringUtils.equals(agencyId, "__ALL_OPERATORS__")) {
operators.setAllOperators("");
} else {
AffectedOperatorStructure affectedOperator = new AffectedOperatorStructure();
affectedOperator.setOperatorName(createDefaultedTextStructure(agencyId));
operators.getAffectedOperator().add(affectedOperator);
}
affectsStructure.setOperators(operators);
hasOperators = true;
}
// LineRef
String routeId = affects.getRouteId();
String directionId = affects.getDirectionId();
String stopId = affects.getStopId();
if (!StringUtils.isBlank(routeId)) {
AffectedVehicleJourneyStructure affectedVehicleJourneyStructure = new AffectedVehicleJourneyStructure();
LineRefStructure lineRefStructure = new LineRefStructure();
lineRefStructure.setValue(routeId);
affectedVehicleJourneyStructure.setLineRef(lineRefStructure);
if (!StringUtils.isBlank(directionId)) {
DirectionRefStructure directionRefStructure = new DirectionRefStructure();
directionRefStructure.setValue(directionId);
affectedVehicleJourneyStructure.setDirectionRef(directionRefStructure);
}
vehicleJourneys.getAffectedVehicleJourney().add(affectedVehicleJourneyStructure);
}
// add support for stop level alerts
if (!StringUtils.isBlank(stopId)) {
AffectedStopPointStructure stop = new AffectedStopPointStructure();
StopPointRefStructure stopRef = new StopPointRefStructure();
stopRef.setValue(stopId);
stop.setStopPointRef(stopRef);
if (affectsStructure.getStopPoints() == null) {
affectsStructure.setStopPoints(new AffectsScopeStructure.StopPoints());
}
affectsStructure.getStopPoints().getAffectedStopPoint().add(stop);
}
}
if (vehicleJourneys.getAffectedVehicleJourney().size() > 0) {
affectsStructure.setVehicleJourneys(vehicleJourneys);
}
if ((vehicleJourneys.getAffectedVehicleJourney().size() > 0) || hasOperators) {
ptSituation.setAffects(affectsStructure);
}
}
Aggregations