Search in sources :

Example 6 with GtfsRelationalDao

use of org.onebusaway.gtfs.services.GtfsRelationalDao 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 7 with GtfsRelationalDao

use of org.onebusaway.gtfs.services.GtfsRelationalDao in project onebusaway-gtfs-modules by OneBusAway.

the class ShapePointMergeStrategy method saveElementsForKey.

@Override
protected void saveElementsForKey(GtfsMergeContext context, AgencyAndId shapeId) {
    GtfsRelationalDao source = context.getSource();
    GtfsMutableRelationalDao target = context.getTarget();
    for (ShapePoint shapePoint : source.getShapePointsForShapeId(shapeId)) {
        shapePoint.setId(0);
        shapePoint.setSequence(context.getNextSequenceCounter());
        target.saveEntity(shapePoint);
    }
}
Also used : GtfsMutableRelationalDao(org.onebusaway.gtfs.services.GtfsMutableRelationalDao) GtfsRelationalDao(org.onebusaway.gtfs.services.GtfsRelationalDao) ShapePoint(org.onebusaway.gtfs.model.ShapePoint)

Example 8 with GtfsRelationalDao

use of org.onebusaway.gtfs.services.GtfsRelationalDao in project onebusaway-gtfs-modules by OneBusAway.

the class StopMergeStrategy method replaceDuplicateEntry.

@Override
protected void replaceDuplicateEntry(GtfsMergeContext context, Stop oldStop, Stop newStop) {
    GtfsRelationalDao source = context.getSource();
    for (StopTime stopTime : source.getStopTimesForStop(oldStop)) {
        stopTime.setStop(newStop);
    }
    MergeSupport.bulkReplaceValueInProperties(source.getAllTransfers(), oldStop, newStop, "fromStop", "toStop");
    MergeSupport.bulkReplaceValueInProperties(source.getAllPathways(), oldStop, newStop, "fromStop", "toStop");
}
Also used : GtfsRelationalDao(org.onebusaway.gtfs.services.GtfsRelationalDao) StopTime(org.onebusaway.gtfs.model.StopTime)

Example 9 with GtfsRelationalDao

use of org.onebusaway.gtfs.services.GtfsRelationalDao in project onebusaway-gtfs-modules by OneBusAway.

the class StopMergeStrategy method save.

@Override
protected void save(GtfsMergeContext context, IdentityBean<?> entity) {
    GtfsRelationalDao source = context.getSource();
    GtfsMutableRelationalDao target = context.getTarget();
    Stop stop = (Stop) entity;
    super.save(context, entity);
}
Also used : GtfsMutableRelationalDao(org.onebusaway.gtfs.services.GtfsMutableRelationalDao) GtfsRelationalDao(org.onebusaway.gtfs.services.GtfsRelationalDao) Stop(org.onebusaway.gtfs.model.Stop)

Example 10 with GtfsRelationalDao

use of org.onebusaway.gtfs.services.GtfsRelationalDao in project onebusaway-gtfs-modules by OneBusAway.

the class CalendarSimplicationStrategyTest method testBasicSimplification.

@Test
public void testBasicSimplification() {
    _gtfs.putAgencies(1);
    _gtfs.putStops(1);
    _gtfs.putRoutes(1);
    _gtfs.putTrips(1, "r0", "sid0");
    _gtfs.putStopTimes("t0", "s0");
    _gtfs.putCalendars(1, "start_date=20120903", "end_date=20120916");
    _gtfs.putCalendarDates("sid0=20120917,20120918,20120919,20120920,20120921,20120922,20120923");
    GtfsRelationalDao dao = transform();
    AgencyAndId serviceId = new AgencyAndId("a0", "sid0");
    ServiceCalendar c = dao.getCalendarForServiceId(serviceId);
    assertEquals(new ServiceDate(2012, 9, 3), c.getStartDate());
    assertEquals(new ServiceDate(2012, 9, 23), c.getEndDate());
    List<ServiceCalendarDate> serviceDates = dao.getCalendarDatesForServiceId(serviceId);
    assertEquals(0, serviceDates.size());
}
Also used : ServiceCalendarDate(org.onebusaway.gtfs.model.ServiceCalendarDate) GtfsRelationalDao(org.onebusaway.gtfs.services.GtfsRelationalDao) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) ServiceCalendar(org.onebusaway.gtfs.model.ServiceCalendar) Test(org.junit.Test)

Aggregations

GtfsRelationalDao (org.onebusaway.gtfs.services.GtfsRelationalDao)29 Test (org.junit.Test)15 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)11 Trip (org.onebusaway.gtfs.model.Trip)8 GtfsMutableRelationalDao (org.onebusaway.gtfs.services.GtfsMutableRelationalDao)7 ServiceCalendar (org.onebusaway.gtfs.model.ServiceCalendar)6 ServiceCalendarDate (org.onebusaway.gtfs.model.ServiceCalendarDate)5 Stop (org.onebusaway.gtfs.model.Stop)5 StopTime (org.onebusaway.gtfs.model.StopTime)5 Agency (org.onebusaway.gtfs.model.Agency)3 TripMergeStrategy (org.onebusaway.gtfs_merge.strategies.TripMergeStrategy)3 Collection (java.util.Collection)2 HashSet (java.util.HashSet)2 Frequency (org.onebusaway.gtfs.model.Frequency)2 Route (org.onebusaway.gtfs.model.Route)2 ShapePoint (org.onebusaway.gtfs.model.ShapePoint)2 ServiceDate (org.onebusaway.gtfs.model.calendar.ServiceDate)2 AgencyMergeStrategy (org.onebusaway.gtfs_merge.strategies.AgencyMergeStrategy)2 StopMergeStrategy (org.onebusaway.gtfs_merge.strategies.StopMergeStrategy)2 Serializable (java.io.Serializable)1