Search in sources :

Example 36 with AgencyAndId

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

the class CalendarServiceDataFactoryImplSyntheticTest method trip.

private Trip trip(String agencyId, String id, AgencyAndId serviceId) {
    Trip trip = new Trip();
    trip.setId(new AgencyAndId(agencyId, id));
    trip.setServiceId(serviceId);
    return trip;
}
Also used : Trip(org.onebusaway.gtfs.model.Trip) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId)

Example 37 with AgencyAndId

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

the class DeferredValueSupportTest method testResolveAgencyAndId_ExistingAgencyId.

@Test
public void testResolveAgencyAndId_ExistingAgencyId() {
    Stop stop = new Stop();
    stop.setId(new AgencyAndId("a1", "2"));
    BeanWrapper bean = BeanWrapperFactory.wrap(stop);
    AgencyAndId id = _support.resolveAgencyAndId(bean, "id", "1");
    assertEquals(new AgencyAndId("a1", "1"), id);
}
Also used : BeanWrapper(org.onebusaway.csv_entities.schema.BeanWrapper) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Stop(org.onebusaway.gtfs.model.Stop) Test(org.junit.Test)

Example 38 with AgencyAndId

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

the class PropertyMethodResolverImplTest method testTripCalendarsVirtualMethod.

@Test
public void testTripCalendarsVirtualMethod() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
    Trip trip = new Trip();
    trip.setId(new AgencyAndId("1", "t0"));
    trip.setServiceId(new AgencyAndId("1", "sid0"));
    _dao.saveEntity(trip);
    ServiceCalendar calendar = new ServiceCalendar();
    calendar.setServiceId(trip.getServiceId());
    _dao.saveEntity(calendar);
    PropertyMethod method = _resolver.getPropertyMethod(Trip.class, "calendar");
    assertEquals(calendar, method.invoke(trip));
}
Also used : Trip(org.onebusaway.gtfs.model.Trip) PropertyMethod(org.onebusaway.collections.beans.PropertyMethod) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) ServiceCalendar(org.onebusaway.gtfs.model.ServiceCalendar) Test(org.junit.Test)

Example 39 with AgencyAndId

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

the class PropertyMethodResolverImplTest method testAgencyRoutesVirtualMethod.

@Test
public void testAgencyRoutesVirtualMethod() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
    Agency agency = new Agency();
    agency.setId("1");
    Route route = new Route();
    route.setId(new AgencyAndId("1", "r0"));
    route.setAgency(agency);
    _dao.saveEntity(route);
    PropertyMethod method = _resolver.getPropertyMethod(Agency.class, "routes");
    assertEquals(Arrays.asList(route), method.invoke(agency));
}
Also used : PropertyMethod(org.onebusaway.collections.beans.PropertyMethod) Agency(org.onebusaway.gtfs.model.Agency) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Route(org.onebusaway.gtfs.model.Route) Test(org.junit.Test)

Example 40 with AgencyAndId

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

the class GtfsReaderExampleMain method main.

public static void main(String[] args) throws IOException {
    if (args.length != 1) {
        System.err.println("usage: gtfsPath");
        System.exit(-1);
    }
    GtfsReader reader = new GtfsReader();
    reader.setInputLocation(new File(args[0]));
    /**
     * You can register an entity handler that listens for new objects as they
     * are read
     */
    reader.addEntityHandler(new GtfsEntityHandler());
    /**
     * Or you can use the internal entity store, which has references to all the
     * loaded entities
     */
    GtfsDaoImpl store = new GtfsDaoImpl();
    reader.setEntityStore(store);
    reader.run();
    // Access entities through the store
    Map<AgencyAndId, Route> routesById = store.getEntitiesByIdForEntityType(AgencyAndId.class, Route.class);
    for (Route route : routesById.values()) {
        System.out.println("route: " + route.getShortName());
    }
}
Also used : GtfsReader(org.onebusaway.gtfs.serialization.GtfsReader) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) GtfsDaoImpl(org.onebusaway.gtfs.impl.GtfsDaoImpl) File(java.io.File) Route(org.onebusaway.gtfs.model.Route)

Aggregations

AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)102 Test (org.junit.Test)63 Trip (org.onebusaway.gtfs.model.Trip)37 ServiceDate (org.onebusaway.gtfs.model.calendar.ServiceDate)25 Stop (org.onebusaway.gtfs.model.Stop)24 ServiceCalendar (org.onebusaway.gtfs.model.ServiceCalendar)17 ServiceCalendarDate (org.onebusaway.gtfs.model.ServiceCalendarDate)16 ArrayList (java.util.ArrayList)15 Route (org.onebusaway.gtfs.model.Route)15 StopTime (org.onebusaway.gtfs.model.StopTime)15 GtfsMutableRelationalDao (org.onebusaway.gtfs.services.GtfsMutableRelationalDao)15 Agency (org.onebusaway.gtfs.model.Agency)13 ShapePoint (org.onebusaway.gtfs.model.ShapePoint)12 GtfsRelationalDao (org.onebusaway.gtfs.services.GtfsRelationalDao)11 HashSet (java.util.HashSet)10 GtfsRelationalDaoImpl (org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl)10 List (java.util.List)9 Frequency (org.onebusaway.gtfs.model.Frequency)9 CalendarService (org.onebusaway.gtfs.services.calendar.CalendarService)7 Set (java.util.Set)6