Search in sources :

Example 1 with GenericMutableDao

use of org.onebusaway.gtfs.services.GenericMutableDao in project onebusaway-gtfs-modules by OneBusAway.

the class GtfsTransformer method readGtfs.

/**
 **
 * Protected Methods
 ***
 */
/**
 **
 * Private Methods
 ***
 */
private void readGtfs() throws IOException {
    GenericMutableDao dao = _dao;
    if (!_entityTransformStrategies.isEmpty())
        dao = new DaoInterceptor(_dao);
    DefaultEntitySchemaFactory schemaFactory = new DefaultEntitySchemaFactory();
    schemaFactory.addFactory(GtfsEntitySchemaFactory.createEntitySchemaFactory());
    _transformStrategies.forEach(s -> s.updateReadSchema(schemaFactory));
    _reader.setEntitySchemaFactory(schemaFactory);
    _reader.setEntityStore(dao);
    if (_agencyId != null)
        _reader.setDefaultAgencyId(_agencyId);
    for (File path : _gtfsInputDirectories) {
        _log.info("reading gtfs from " + path);
        if (path.isFile()) {
            FileTime fileTime = ((FileTime) Files.readAttributes(path.toPath(), "lastModifiedTime").get("lastModifiedTime"));
            if (fileTime != null) {
                _log.info("found lastModifiedTime of " + new Date(fileTime.toMillis()));
                _reader.setLastModifiedTime(fileTime.toMillis());
            }
        }
        _reader.setInputLocation(path);
        _reader.run();
    }
}
Also used : GenericMutableDao(org.onebusaway.gtfs.services.GenericMutableDao) DefaultEntitySchemaFactory(org.onebusaway.csv_entities.schema.DefaultEntitySchemaFactory) FileTime(java.nio.file.attribute.FileTime) File(java.io.File) Date(java.util.Date)

Example 2 with GenericMutableDao

use of org.onebusaway.gtfs.services.GenericMutableDao in project onebusaway-gtfs-modules by OneBusAway.

the class GtfsTransformer method readReferenceGtfs.

private void readReferenceGtfs() throws IOException {
    _log.info("reading reference GTFS at " + _gtfsReferenceDirectory);
    GenericMutableDao dao = new GtfsRelationalDaoImpl();
    _referenceReader.setEntityStore(dao);
    if (_agencyId != null)
        _referenceReader.setDefaultAgencyId(_agencyId);
    _referenceReader.setInputLocation(_gtfsReferenceDirectory);
    _referenceReader.run();
    _context.setReferenceReader(_referenceReader);
}
Also used : GenericMutableDao(org.onebusaway.gtfs.services.GenericMutableDao) GtfsRelationalDaoImpl(org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl)

Aggregations

GenericMutableDao (org.onebusaway.gtfs.services.GenericMutableDao)2 File (java.io.File)1 FileTime (java.nio.file.attribute.FileTime)1 Date (java.util.Date)1 DefaultEntitySchemaFactory (org.onebusaway.csv_entities.schema.DefaultEntitySchemaFactory)1 GtfsRelationalDaoImpl (org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl)1