use of org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl in project onebusaway-gtfs-modules by OneBusAway.
the class TransformFactoryTest method testPathInUpdate.
@Test
public void testPathInUpdate() throws IOException, TransformSpecificationException {
_factory.addModificationsFromString("{'op':'update', " + "'match':{'file':'trips.txt'}, " + "'update':{'trip_headsign': 'path(route.longName)'}}");
GtfsTransformStrategy transform = _transformer.getLastTransform();
TransformContext context = new TransformContext();
GtfsMutableRelationalDao dao = new GtfsRelationalDaoImpl();
Route route = new Route();
route.setLongName("long cat");
Trip trip = new Trip();
trip.setId(new AgencyAndId("1", "1"));
trip.setRoute(route);
dao.saveEntity(trip);
transform.run(context, dao);
assertEquals("long cat", trip.getTripHeadsign());
}
use of org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl in project OpenTripPlanner by opentripplanner.
the class GtfsLibrary method readGtfs.
public static GtfsContext readGtfs(File path) throws IOException {
GtfsRelationalDaoImpl dao = new GtfsRelationalDaoImpl();
GtfsReader reader = new GtfsReader();
reader.setInputLocation(path);
reader.setEntityStore(dao);
GtfsFeedId feedId = new GtfsFeedId.Builder().fromGtfsFeed(reader.getInputSource()).build();
reader.setDefaultAgencyId(feedId.getId());
reader.run();
CalendarService calendarService = createCalendarService(dao);
return new GtfsContextImpl(feedId, dao, calendarService);
}
use of org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl in project onebusaway-gtfs-modules by OneBusAway.
the class GtfsReaderTest method processFeed.
/**
**
* Private Methods
***
*/
private GtfsRelationalDao processFeed(File resourcePath, String agencyId, boolean internStrings) throws IOException {
GtfsReader reader = new GtfsReader();
reader.setDefaultAgencyId(agencyId);
reader.setInternStrings(internStrings);
reader.setInputLocation(resourcePath);
GtfsRelationalDaoImpl entityStore = new GtfsRelationalDaoImpl();
entityStore.setGenerateIds(true);
reader.setEntityStore(entityStore);
reader.run();
return entityStore;
}
use of org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl in project onebusaway-gtfs-modules by OneBusAway.
the class AgencyMergeStrategyTest method testIdentityMatch.
@Test
public void testIdentityMatch() {
GtfsRelationalDaoImpl sourceA = new GtfsRelationalDaoImpl();
Agency agencyA = new Agency();
agencyA.setId("1");
agencyA.setName("Metro");
agencyA.setUrl("http://metro.gov/");
sourceA.saveEntity(agencyA);
GtfsRelationalDaoImpl sourceB = new GtfsRelationalDaoImpl();
Agency agencyB = new Agency();
agencyB.setId("1");
agencyB.setName("Metro");
agencyB.setUrl("http://metro.gov/");
sourceB.saveEntity(agencyB);
Agency agencyC = new Agency();
agencyC.setId("2");
agencyC.setName("Metra");
agencyC.setUrl("http://metra.gov/");
sourceB.saveEntity(agencyC);
GtfsMergeContext contextA = context(sourceA, _target, "a-");
_strategy.merge(contextA);
GtfsMergeContext contextB = context(sourceB, _target, "b-");
_strategy.merge(contextB);
assertEquals(EDuplicateDetectionStrategy.IDENTITY, contextB.getResolvedDuplicateDetectionStrategy());
Collection<Agency> agencies = _target.getAllAgencies();
assertEquals(2, agencies.size());
assertSame(agencyA, _target.getAgencyForId("1"));
assertSame(agencyC, _target.getAgencyForId("2"));
}
use of org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl in project onebusaway-gtfs-modules by OneBusAway.
the class AgencyMergeStrategyTest method before.
@Before
public void before() {
_strategy = new AgencyMergeStrategy();
_target = new GtfsRelationalDaoImpl();
}
Aggregations