Search in sources :

Example 1 with CsvEntityReader

use of org.onebusaway.csv_entities.CsvEntityReader in project onebusaway-application-modules by camsys.

the class OrbcadRecordFtpSource method setup.

/**
 **
 * Private Methods
 ***
 */
@Override
protected void setup() {
    _reader = new CsvEntityReader();
    AnnotationDrivenEntitySchemaFactory entitySchemaFactory = new AnnotationDrivenEntitySchemaFactory();
    entitySchemaFactory.addEntityClass(OrbcadRecord.class);
    _reader.setEntitySchemaFactory(entitySchemaFactory);
    _reader.addEntityHandler(new RecordHandler());
}
Also used : AnnotationDrivenEntitySchemaFactory(org.onebusaway.csv_entities.schema.AnnotationDrivenEntitySchemaFactory) CsvEntityReader(org.onebusaway.csv_entities.CsvEntityReader)

Example 2 with CsvEntityReader

use of org.onebusaway.csv_entities.CsvEntityReader in project onebusaway-application-modules by camsys.

the class OrbcadRecordHttpSource method setup.

/**
 **
 * Protected Methods
 ***
 */
protected void setup() {
    _reader = new CsvEntityReader();
    AnnotationDrivenEntitySchemaFactory entitySchemaFactory = new AnnotationDrivenEntitySchemaFactory();
    entitySchemaFactory.addEntityClass(OrbcadRecord.class);
    _reader.setEntitySchemaFactory(entitySchemaFactory);
    _reader.addEntityHandler(new RecordHandler());
}
Also used : AnnotationDrivenEntitySchemaFactory(org.onebusaway.csv_entities.schema.AnnotationDrivenEntitySchemaFactory) CsvEntityReader(org.onebusaway.csv_entities.CsvEntityReader)

Example 3 with CsvEntityReader

use of org.onebusaway.csv_entities.CsvEntityReader in project onebusaway-application-modules by camsys.

the class BlockLocationHistoryServiceImpl method getHistoryForTripId.

@Override
public Map<AgencyAndIdInstance, List<BlockLocationArchiveRecord>> getHistoryForTripId(AgencyAndId tripId) {
    TripEntry trip = _transitGraphDao.getTripEntryForId(tripId);
    if (trip == null)
        return null;
    BlockEntry block = trip.getBlock();
    List<File> files = getFilesForBlockId(block.getId());
    CsvEntityReader reader = new CsvEntityReader();
    reader.setTokenizerStrategy(new DelimiterTokenizerStrategy("\t"));
    EntityHandlerImpl handler = new EntityHandlerImpl(tripId);
    reader.addEntityHandler(handler);
    try {
        for (File file : files) {
            InputStream in = openFileForInput(file);
            reader.readEntities(BlockLocationArchiveRecord.class, in);
            in.close();
        }
    } catch (IOException ex) {
        throw new IllegalStateException(ex);
    }
    Map<AgencyAndIdInstance, List<BlockLocationArchiveRecord>> recordsByInstance = handler.getRecordsByInstance();
    for (List<BlockLocationArchiveRecord> records : recordsByInstance.values()) Collections.sort(records, new DistanceAlongBlockComparator());
    return recordsByInstance;
}
Also used : AgencyAndIdInstance(org.onebusaway.gtfs.model.AgencyAndIdInstance) GZIPInputStream(java.util.zip.GZIPInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry) IOException(java.io.IOException) DelimiterTokenizerStrategy(org.onebusaway.csv_entities.DelimiterTokenizerStrategy) BlockEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockEntry) ArrayList(java.util.ArrayList) List(java.util.List) CsvEntityReader(org.onebusaway.csv_entities.CsvEntityReader) File(java.io.File)

Aggregations

CsvEntityReader (org.onebusaway.csv_entities.CsvEntityReader)3 AnnotationDrivenEntitySchemaFactory (org.onebusaway.csv_entities.schema.AnnotationDrivenEntitySchemaFactory)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 GZIPInputStream (java.util.zip.GZIPInputStream)1 DelimiterTokenizerStrategy (org.onebusaway.csv_entities.DelimiterTokenizerStrategy)1 AgencyAndIdInstance (org.onebusaway.gtfs.model.AgencyAndIdInstance)1 BlockEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockEntry)1 TripEntry (org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)1