private ServiceCalendar createServiceCalendar(AgencyAndId updatedServiceId, Set<Integer> daysOfTheWeekToUse, ServiceDate fromDate, ServiceDate toDate) { ServiceCalendar sc = new ServiceCalendar(); sc.setServiceId(updatedServiceId); sc.setStartDate(fromDate); sc.setEndDate(toDate); if (daysOfTheWeekToUse.contains(Calendar.MONDAY)) sc.setMonday(1); if (daysOfTheWeekToUse.contains(Calendar.TUESDAY)) sc.setTuesday(1); if (daysOfTheWeekToUse.contains(Calendar.WEDNESDAY)) sc.setWednesday(1); if (daysOfTheWeekToUse.contains(Calendar.THURSDAY)) sc.setThursday(1); if (daysOfTheWeekToUse.contains(Calendar.FRIDAY)) sc.setFriday(1); if (daysOfTheWeekToUse.contains(Calendar.SATURDAY)) sc.setSaturday(1); if (daysOfTheWeekToUse.contains(Calendar.SUNDAY)) sc.setSunday(1); return sc; }
/** * Replaces all references to the specified old service_id with the new * service_id for all {@link ServiceCalendar}, {@link ServiceCalendarDate}, * and {@link Trip} entities in the source feed. */ @Override protected void renameKey(GtfsMergeContext context, AgencyAndId oldId, AgencyAndId newId) { GtfsRelationalDao source = context.getSource(); ServiceCalendar calendar = source.getCalendarForServiceId(oldId); if (calendar != null) { calendar.setServiceId(newId); } for (ServiceCalendarDate calendarDate : source.getCalendarDatesForServiceId(oldId)) { calendarDate.setServiceId(newId); } for (Trip trip : source.getTripsForServiceId(oldId)) { trip.setServiceId(newId); } }
/** * Replaces all references to the specified old service_id with the new * service_id for all {@link ServiceCalendar}, {@link ServiceCalendarDate}, * and {@link Trip} entities in the source feed. */ @Override protected void renameKey(GtfsMergeContext context, AgencyAndId oldId, AgencyAndId newId) { GtfsRelationalDao source = context.getSource(); ServiceCalendar calendar = source.getCalendarForServiceId(oldId); if (calendar != null) { calendar.setServiceId(newId); } for (ServiceCalendarDate calendarDate : source.getCalendarDatesForServiceId(oldId)) { calendarDate.setServiceId(newId); } for (Trip trip : source.getTripsForServiceId(oldId)) { trip.setServiceId(newId); } }
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao, Object entity) { AgencyAndId oldServiceId = context.resolveId(ServiceIdKey.class, _oldServiceId); AgencyAndId newServiceId = context.resolveId(ServiceIdKey.class, _newServiceId); ServiceCalendar calendar = dao.getCalendarForServiceId(oldServiceId); if (calendar != null) { calendar.setServiceId(newServiceId); } for (ServiceCalendarDate calendarDate : dao.getCalendarDatesForServiceId(oldServiceId)) { calendarDate.setServiceId(newServiceId); } for (Trip trip : dao.getTripsForServiceId(oldServiceId)) { trip.setServiceId(newServiceId); } } }