use of org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl in project onebusaway-gtfs-modules by OneBusAway.
the class AgencyMergeStrategyTest method testRenameAllAgencyIdReferences.
@Test
public void testRenameAllAgencyIdReferences() {
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");
agencyA.setName("Metra");
agencyA.setUrl("http://metra.gov/");
sourceB.saveEntity(agencyB);
Route route = new Route();
route.setAgency(agencyB);
route.setId(new AgencyAndId("1", "routeId"));
sourceB.saveEntity(route);
Trip trip = new Trip();
trip.setRoute(route);
trip.setId(new AgencyAndId("1", "tripId"));
trip.setServiceId(new AgencyAndId("1", "serviceId"));
trip.setShapeId(new AgencyAndId("1", "shapeId"));
sourceB.saveEntity(trip);
FareAttribute fare = new FareAttribute();
fare.setId(new AgencyAndId("1", "fareId"));
sourceB.saveEntity(fare);
Stop stop = new Stop();
stop.setId(new AgencyAndId("1", "stopId"));
sourceB.saveEntity(stop);
ServiceCalendar calendar = new ServiceCalendar();
calendar.setServiceId(new AgencyAndId("1", "serviceId"));
sourceB.saveEntity(calendar);
ServiceCalendarDate calendarDate = new ServiceCalendarDate();
calendarDate.setServiceId(new AgencyAndId("1", "serviceId"));
sourceB.saveEntity(calendarDate);
ShapePoint point = new ShapePoint();
point.setShapeId(new AgencyAndId("1", "shapeId"));
sourceB.saveEntity(point);
_strategy.merge(context(sourceA, _target, "a-"));
_strategy.merge(context(sourceB, _target, "b-"));
Collection<Agency> agencies = _target.getAllAgencies();
assertEquals(2, agencies.size());
assertSame(agencyA, _target.getAgencyForId("1"));
assertSame(agencyB, _target.getAgencyForId("b-1"));
assertEquals("b-1", route.getId().getAgencyId());
assertEquals("b-1", trip.getId().getAgencyId());
assertEquals("b-1", trip.getServiceId().getAgencyId());
assertEquals("b-1", trip.getShapeId().getAgencyId());
assertEquals("b-1", fare.getId().getAgencyId());
assertEquals("b-1", stop.getId().getAgencyId());
assertEquals("b-1", calendar.getServiceId().getAgencyId());
assertEquals("b-1", calendarDate.getServiceId().getAgencyId());
assertEquals("b-1", point.getShapeId().getAgencyId());
}
use of org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl in project onebusaway-gtfs-modules by OneBusAway.
the class AgencyMergeStrategyTest method testFuzzyMatchAgencyName.
@Test
public void testFuzzyMatchAgencyName() {
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("Metra");
agencyB.setUrl("http://metra.gov/");
sourceB.saveEntity(agencyB);
Agency agencyC = new Agency();
agencyC.setId("2");
agencyC.setName("Metro");
agencyC.setUrl("http://metro.gov/");
sourceB.saveEntity(agencyC);
GtfsMergeContext contextA = context(sourceA, _target, "a-");
_strategy.merge(contextA);
GtfsMergeContext contextB = context(sourceB, _target, "b-");
_strategy.merge(contextB);
assertEquals(EDuplicateDetectionStrategy.FUZZY, contextB.getResolvedDuplicateDetectionStrategy());
Collection<Agency> agencies = _target.getAllAgencies();
assertEquals(2, agencies.size());
assertSame(agencyA, _target.getAgencyForId("1"));
assertSame(agencyB, _target.getAgencyForId("b-1"));
}
use of org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl in project onebusaway-gtfs-modules by OneBusAway.
the class GtfsMergerTest method merge.
private GtfsRelationalDao merge() throws IOException {
List<File> paths = new ArrayList<File>();
paths.add(_oldGtfs.getPath());
paths.add(_newGtfs.getPath());
if (_pugetGtfs != null) {
paths.add(_pugetGtfs.getPath());
}
_merger.run(paths, _mergedGtfs.getPath());
GtfsReader reader = new GtfsReader();
GtfsRelationalDaoImpl dao = new GtfsRelationalDaoImpl();
reader.setEntityStore(dao);
reader.setInputLocation(_mergedGtfs.getPath());
reader.run();
return dao;
}
use of org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl 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);
}
use of org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl in project onebusaway-gtfs-modules by OneBusAway.
the class LastStopToHeadsignStrategyTest method setup.
@Before
public void setup() throws IOException, URISyntaxException {
_dao = new GtfsRelationalDaoImpl();
GtfsReader reader = new GtfsReader();
File path = new File(getClass().getResource("/org/onebusaway/gtfs_transformer/testagency").toURI());
reader.setInputLocation(path);
reader.setEntityStore(_dao);
reader.run();
}
Aggregations