ServiceCalendarDate scd = new ServiceCalendarDate(); scd.setDate(serviceDate); scd.setExceptionType(ServiceCalendarDate.EXCEPTION_TYPE_ADD); scd.setServiceId(updatedServiceId); newEntities.add(scd); ServiceCalendarDate scd = new ServiceCalendarDate(); scd.setDate(serviceDate); scd.setExceptionType(ServiceCalendarDate.EXCEPTION_TYPE_REMOVE); scd.setServiceId(updatedServiceId); newEntities.add(scd); ServiceCalendarDate scd = new ServiceCalendarDate(); scd.setDate(serviceDate); scd.setExceptionType(ServiceCalendarDate.EXCEPTION_TYPE_ADD); scd.setServiceId(updatedServiceId); newEntities.add(scd);
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { Date today = removeTime(new Date()); boolean hasEntryToday; for (AgencyAndId aai : dao.getAllServiceIds()) { hasEntryToday = false; for (ServiceCalendarDate calDate : dao.getCalendarDatesForServiceId(aai)) { Date date = removeTime(calDate.getDate().getAsDate()); if (date.equals(today)) { hasEntryToday = true; if (calDate.getExceptionType() == 1) { calDate.setExceptionType(2); dao.saveOrUpdateEntity(calDate); } } } if (!hasEntryToday) { _log.error("No entry for today, adding one, id: {}", aai); ServiceCalendarDate calendarDate = new ServiceCalendarDate(); calendarDate.setServiceId(aai); calendarDate.setDate(new ServiceDate(today)); calendarDate.setExceptionType(2); dao.saveOrUpdateEntity(calendarDate); } } }
newScd.setServiceId(newServiceId); newScd.setDate(calDate.getDate()); newScd.setExceptionType(calDate.getExceptionType()); dao.saveOrUpdateEntity(newScd);
newScd.setServiceId(newServiceId); newScd.setDate(sd); newScd.setExceptionType(1); //add dao.saveOrUpdateEntity(newScd);
ServiceCalendarDate scd = new ServiceCalendarDate(); scd.setDate(serviceDate); scd.setExceptionType(ServiceCalendarDate.EXCEPTION_TYPE_ADD); scd.setServiceId(serviceId); dao.saveEntity(scd);