Search in sources :

Example 1 with TranslationServiceData

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;
}
Also used : PropertyTranslation(org.onebusaway.gtfs.model.translation.PropertyTranslation) Translation(org.onebusaway.gtfs.model.Translation) TranslationServiceData(org.onebusaway.gtfs.model.translation.TranslationServiceData) PropertyTranslation(org.onebusaway.gtfs.model.translation.PropertyTranslation) FeedInfo(org.onebusaway.gtfs.model.FeedInfo)

Example 2 with TranslationServiceData

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;
}
Also used : TranslationServiceData(org.onebusaway.gtfs.model.translation.TranslationServiceData)

Aggregations

TranslationServiceData (org.onebusaway.gtfs.model.translation.TranslationServiceData)2 FeedInfo (org.onebusaway.gtfs.model.FeedInfo)1 Translation (org.onebusaway.gtfs.model.Translation)1 PropertyTranslation (org.onebusaway.gtfs.model.translation.PropertyTranslation)1