use of org.onebusaway.gtfs.model.translation.TranslationServiceData in project onebusaway-gtfs-modules by OneBusAway.
the class TranslationServiceDataFactoryImpl method getTranslationServiceData.
@Override
public TranslationServiceData getTranslationServiceData() {
if (_dao.getAllFeedInfos().isEmpty()) {
_log.warn("No feed_info present, there will be no translations available.");
return null;
}
TranslationServiceData data = new TranslationServiceData();
FeedInfo feedInfo = _dao.getAllFeedInfos().iterator().next();
if (feedInfo.getDefaultLang() != null) {
data.setFeedLanguage(feedInfo.getDefaultLang());
} else {
data.setFeedLanguage(feedInfo.getLang());
}
for (Translation translation : _dao.getAllTranslations()) {
Class<?> type = getEntityTypeForTableName(translation.getTableName());
if (type == null) {
_log.error("No entity type for table_name {}, skipping.", translation.getTableName());
continue;
}
String propertyName = getPropertyNameByClassAndCsvName(type, translation.getFieldName());
if (propertyName == null) {
_log.error("No property for field_name {}, skipping.", translation.getFieldName());
continue;
}
PropertyTranslation propertyTranslation = new PropertyTranslation(propertyName, translation);
data.putTranslation(type, translation.getLanguage(), propertyTranslation);
}
return data;
}
use of org.onebusaway.gtfs.model.translation.TranslationServiceData in project onebusaway-gtfs-modules by OneBusAway.
the class TranslationServiceDataFactoryImpl method getTranslationService.
public static TranslationService getTranslationService(GtfsRelationalDao dao) {
TranslationServiceData data = createData(dao);
TranslationServiceImpl translationService = new TranslationServiceImpl();
translationService.setData(data);
return translationService;
}
Aggregations