use of org.onebusaway.api.model.transit.service_alerts.SituationConsequenceV2Bean in project onebusaway-application-modules by camsys.
the class BeanFactoryV2 method getSituationConsequence.
private SituationConsequenceV2Bean getSituationConsequence(SituationConsequenceBean consequence) {
SituationConsequenceV2Bean bean = new SituationConsequenceV2Bean();
if (consequence.getEffect() != null)
bean.setCondition(consequence.getEffect().toString().toLowerCase());
if (_includeConditionDetails && (consequence.getDetourPath() != null || !CollectionsLibrary.isEmpty(consequence.getDetourStopIds()))) {
SituationConditionDetailsV2Bean detailsBean = new SituationConditionDetailsV2Bean();
if (consequence.getDetourPath() != null) {
EncodedPolylineBean poly = new EncodedPolylineBean();
poly.setPoints(consequence.getDetourPath());
detailsBean.setDiversionPath(poly);
}
detailsBean.setDiversionStopIds(consequence.getDetourStopIds());
bean.setConditionDetails(detailsBean);
}
return bean;
}
use of org.onebusaway.api.model.transit.service_alerts.SituationConsequenceV2Bean 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;
}
Aggregations