Search in sources :

Example 21 with Agency

use of org.onebusaway.gtfs.model.Agency in project onebusaway-gtfs-modules by OneBusAway.

the class AgencyMergeStrategy method rename.

@Override
protected void rename(GtfsMergeContext context, IdentityBean<?> entity) {
    GtfsRelationalDao source = context.getSource();
    String prefix = context.getPrefix();
    Agency agency = (Agency) entity;
    String oldAgencyId = agency.getId();
    String newAgencyId = prefix + oldAgencyId;
    agency.setId(newAgencyId);
    renameAgencyId(source, oldAgencyId, newAgencyId);
}
Also used : GtfsRelationalDao(org.onebusaway.gtfs.services.GtfsRelationalDao) Agency(org.onebusaway.gtfs.model.Agency)

Example 22 with Agency

use of org.onebusaway.gtfs.model.Agency in project onebusaway-gtfs-modules by OneBusAway.

the class CalendarServiceDataFactoryImplSyntheticTest method agency.

private Agency agency(String id, String timezone) {
    Agency agency = new Agency();
    agency.setId(id);
    agency.setTimezone(timezone);
    return agency;
}
Also used : Agency(org.onebusaway.gtfs.model.Agency)

Example 23 with Agency

use of org.onebusaway.gtfs.model.Agency in project onebusaway-gtfs-modules by OneBusAway.

the class GtfsRelationalDaoImplTest method testBart.

@Test
public void testBart() throws IOException {
    GtfsRelationalDaoImpl dao = new GtfsRelationalDaoImpl();
    GtfsTestData.readGtfs(dao, GtfsTestData.getBartGtfs(), "BART");
    List<String> tripAgencyIds = dao.getTripAgencyIdsReferencingServiceId(new AgencyAndId("BART", "WKDY"));
    assertEquals(1, tripAgencyIds.size());
    assertEquals("BART", tripAgencyIds.get(0));
    Agency agency = dao.getAgencyForId("BART");
    List<Route> routes = dao.getRoutesForAgency(agency);
    assertEquals(10, routes.size());
    agency = dao.getAgencyForId("AirBART");
    routes = dao.getRoutesForAgency(agency);
    assertEquals(1, routes.size());
    Route route = dao.getRouteForId(new AgencyAndId("BART", "01"));
    List<Trip> trips = dao.getTripsForRoute(route);
    assertEquals(225, trips.size());
    Trip trip = dao.getTripForId(new AgencyAndId("BART", "15PB1"));
    List<StopTime> stopTimes = dao.getStopTimesForTrip(trip);
    assertEquals(12, stopTimes.size());
    // Ensure the stopTimes are in stop sequence order
    for (int i = 0; i < stopTimes.size() - 1; i++) assertTrue(stopTimes.get(i).getStopSequence() < stopTimes.get(i + 1).getStopSequence());
    Stop stop = dao.getStopForId(new AgencyAndId("BART", "DBRK"));
    stopTimes = dao.getStopTimesForStop(stop);
    assertEquals(584, stopTimes.size());
    List<ShapePoint> shapePoints = dao.getShapePointsForShapeId(new AgencyAndId("BART", "airbart-dn.csv"));
    assertEquals(50, shapePoints.size());
    for (int i = 0; i < shapePoints.size() - 1; i++) assertTrue(shapePoints.get(i).getSequence() < shapePoints.get(i + 1).getSequence());
    trip = dao.getTripForId(new AgencyAndId("AirBART", "M-FSAT1DN"));
    List<Frequency> frequencies = dao.getFrequenciesForTrip(trip);
    assertEquals(1, frequencies.size());
    Frequency frequency = frequencies.get(0);
    assertEquals(5 * 60 * 60, frequency.getStartTime());
    assertEquals(6 * 60 * 60, frequency.getEndTime());
    assertEquals(trip, frequency.getTrip());
    assertEquals(1200, frequency.getHeadwaySecs());
    ServiceCalendar calendar = dao.getCalendarForServiceId(new AgencyAndId("BART", "WKDY"));
    assertEquals(new ServiceDate(2007, 1, 1), calendar.getStartDate());
    List<ServiceCalendarDate> calendarDates = dao.getCalendarDatesForServiceId(new AgencyAndId("BART", "WKDY"));
    assertEquals(7, calendarDates.size());
}
Also used : ServiceCalendarDate(org.onebusaway.gtfs.model.ServiceCalendarDate) Trip(org.onebusaway.gtfs.model.Trip) Agency(org.onebusaway.gtfs.model.Agency) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Stop(org.onebusaway.gtfs.model.Stop) ShapePoint(org.onebusaway.gtfs.model.ShapePoint) ShapePoint(org.onebusaway.gtfs.model.ShapePoint) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) Frequency(org.onebusaway.gtfs.model.Frequency) Route(org.onebusaway.gtfs.model.Route) StopTime(org.onebusaway.gtfs.model.StopTime) ServiceCalendar(org.onebusaway.gtfs.model.ServiceCalendar) Test(org.junit.Test)

Example 24 with Agency

use of org.onebusaway.gtfs.model.Agency in project onebusaway-gtfs-modules by OneBusAway.

the class WSFScheduleService method run.

@Override
public void run(TransformContext context, GtfsMutableRelationalDao dao) {
    _dao = dao;
    Agency agency = dao.getAllAgencies().iterator().next();
    _agencyId = agency.getId();
    _agencyTimeZone = TimeZone.getTimeZone(agency.getTimezone());
    _tripResolutionService = new WSFTripResolutionService(_dao, _agencyId, _agencyTimeZone);
    try {
        _scheduleService = new WSFScheduleService(apiAccessCode);
        setAllBlockIds();
    } catch (Exception e) {
        _log.error("Error initializing WSFBlockResolutionStrategy: " + e);
        return;
    }
}
Also used : Agency(org.onebusaway.gtfs.model.Agency) JAXBException(javax.xml.bind.JAXBException)

Example 25 with Agency

use of org.onebusaway.gtfs.model.Agency in project onebusaway-gtfs-modules by OneBusAway.

the class DeferredValueConverterTest method testEntity.

@Test
public void testEntity() {
    Agency agency = new Agency();
    agency.setId("1");
    _dao.saveEntity(agency);
    Route route = new Route();
    Object value = convert(route, "agency", "1");
    assertEquals(agency, value);
}
Also used : Agency(org.onebusaway.gtfs.model.Agency) Route(org.onebusaway.gtfs.model.Route) Test(org.junit.Test)

Aggregations

Agency (org.onebusaway.gtfs.model.Agency)57 Test (org.junit.Test)28 Route (org.onebusaway.gtfs.model.Route)21 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)20 Trip (org.onebusaway.gtfs.model.Trip)19 Stop (org.onebusaway.gtfs.model.Stop)18 StopTime (org.onebusaway.gtfs.model.StopTime)15 GtfsRelationalDaoImpl (org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl)10 ServiceDate (org.onebusaway.gtfs.model.calendar.ServiceDate)9 ArrayList (java.util.ArrayList)8 ServiceCalendar (org.onebusaway.gtfs.model.ServiceCalendar)7 TripPattern (org.opentripplanner.routing.edgetype.TripPattern)7 TransitStop (org.opentripplanner.routing.vertextype.TransitStop)7 TransitGraphImpl (org.onebusaway.transit_data_federation.impl.transit_graph.TransitGraphImpl)6 ServiceCalendarDate (org.onebusaway.gtfs.model.ServiceCalendarDate)5 CalendarServiceData (org.onebusaway.gtfs.model.calendar.CalendarServiceData)5 TripEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.TripEntryImpl)5 ShapePoints (org.onebusaway.transit_data_federation.model.ShapePoints)5 StopPattern (org.opentripplanner.model.StopPattern)5 Graph (org.opentripplanner.routing.graph.Graph)5