use of org.opentripplanner.netex.support.DayTypeRefsToServiceIdAdapter in project OpenTripPlanner by opentripplanner.
the class CalendarMapper method mapToCalendarDates.
Collection<ServiceCalendarDate> mapToCalendarDates(DayTypeRefsToServiceIdAdapter dayTypeRefs) {
String serviceId = dayTypeRefs.getServiceId();
// The mapper store intermediate results and need to be initialized every time
DayTypeAssignmentMapper dayTypeAssignmentMapper = new DayTypeAssignmentMapper(dayTypeById, operatingPeriodById);
for (String dayTypeId : dayTypeRefs.getDayTypeRefs()) {
dayTypeAssignmentMapper.mapAll(dayTypeId, dayTypeAssignments(dayTypeId));
}
Set<LocalDateTime> dates = dayTypeAssignmentMapper.mergeDates();
if (dates.isEmpty()) {
addDataImportIssue(new ServiceCodeDoesNotContainServiceDates(serviceId));
// Add one date exception when list is empty to ensure serviceId is not lost
LocalDateTime today = LocalDate.now().atStartOfDay();
return Collections.singleton(newServiceCalendarDate(today, serviceId, EXCEPTION_TYPE_REMOVE));
}
return dates.stream().map(it -> newServiceCalendarDate(it, serviceId, EXCEPTION_TYPE_ADD)).collect(Collectors.toList());
}
use of org.opentripplanner.netex.support.DayTypeRefsToServiceIdAdapter in project OpenTripPlanner by opentripplanner.
the class NetexMapper method mapCalendarDayTypes.
private void mapCalendarDayTypes(NetexImportDataIndexReadOnlyView netexIndex) {
CalendarMapper calMapper = new CalendarMapper(idFactory, netexIndex.getDayTypeAssignmentByDayTypeId(), netexIndex.getOperatingPeriodById(), netexIndex.getDayTypeById(), issueStore);
for (DayTypeRefsToServiceIdAdapter dayTypeRefs : netexIndex.getDayTypeRefs()) {
Collection<ServiceCalendarDate> dates = calMapper.mapToCalendarDates(dayTypeRefs);
transitBuilder.getCalendarDates().addAll(dates);
}
}
use of org.opentripplanner.netex.support.DayTypeRefsToServiceIdAdapter in project OpenTripPlanner by opentripplanner.
the class NetexImportDataIndex method readOnlyView.
public NetexImportDataIndexReadOnlyView readOnlyView() {
return new NetexImportDataIndexReadOnlyView() {
/**
* Lookup a Network given a GroupOfLine id or an Network id. If the given
* {@code groupOfLineOrNetworkId} is a GroupOfLine ID, we lookup the GroupOfLine, and then
* lookup its Network. If the given {@code groupOfLineOrNetworkId} is a Network ID then we
* can lookup the Network directly.
* <p/>
* If no Network is found {@code null} is returned.
*/
public Network lookupNetworkForLine(String groupOfLineOrNetworkId) {
GroupOfLines groupOfLines = groupOfLinesById.lookup(groupOfLineOrNetworkId);
String networkId = groupOfLines == null ? groupOfLineOrNetworkId : networkIdByGroupOfLineId.lookup(groupOfLines.getId());
return networkById.lookup(networkId);
}
public ReadOnlyHierarchicalMapById<Authority> getAuthoritiesById() {
return authoritiesById;
}
public ReadOnlyHierarchicalMapById<DayType> getDayTypeById() {
return dayTypeById;
}
public ReadOnlyHierarchicalMap<String, Collection<DayTypeAssignment>> getDayTypeAssignmentByDayTypeId() {
return dayTypeAssignmentByDayTypeId;
}
public Iterable<DayTypeRefsToServiceIdAdapter> getDayTypeRefs() {
return Collections.unmodifiableSet(dayTypeRefs);
}
public ReadOnlyHierarchicalMapById<DestinationDisplay> getDestinationDisplayById() {
return destinationDisplayById;
}
public ReadOnlyHierarchicalMapById<GroupOfStopPlaces> getGroupOfStopPlacesById() {
return groupOfStopPlacesById;
}
public ReadOnlyHierarchicalMapById<JourneyPattern> getJourneyPatternsById() {
return journeyPatternsById;
}
public ReadOnlyHierarchicalMapById<Line> getLineById() {
return lineById;
}
public ReadOnlyHierarchicalMapById<StopPlace> getMultiModalStopPlaceById() {
return multiModalStopPlaceById;
}
public ReadOnlyHierarchicalMapById<Notice> getNoticeById() {
return noticeById;
}
public ReadOnlyHierarchicalMapById<NoticeAssignment> getNoticeAssignmentById() {
return noticeAssignmentById;
}
public ReadOnlyHierarchicalMapById<OperatingPeriod> getOperatingPeriodById() {
return operatingPeriodById;
}
public ReadOnlyHierarchicalMapById<Operator> getOperatorsById() {
return operatorsById;
}
public ReadOnlyHierarchicalMap<String, Collection<TimetabledPassingTime>> getPassingTimeByStopPointId() {
return passingTimeByStopPointId;
}
public ReadOnlyHierarchicalVersionMapById<Quay> getQuayById() {
return quayById;
}
public ReadOnlyHierarchicalMap<String, String> getQuayIdByStopPointRef() {
return quayIdByStopPointRef;
}
public ReadOnlyHierarchicalMapById<Route> getRouteById() {
return routeById;
}
public ReadOnlyHierarchicalMap<String, Collection<ServiceJourney>> getServiceJourneyByPatternId() {
return serviceJourneyByPatternId;
}
public ReadOnlyHierarchicalMapById<ServiceLink> getServiceLinkById() {
return serviceLinkById;
}
public ReadOnlyHierarchicalVersionMapById<StopPlace> getStopPlaceById() {
return stopPlaceById;
}
public ReadOnlyHierarchicalMapById<TariffZone> getTariffZonesById() {
return tariffZonesById;
}
public String getTimeZone() {
return timeZone.get();
}
};
}
use of org.opentripplanner.netex.support.DayTypeRefsToServiceIdAdapter in project OpenTripPlanner by opentripplanner.
the class TimeTableFrameParser method parseServiceJourney.
private void parseServiceJourney(ServiceJourney sj) {
DayTypeRefsToServiceIdAdapter serviceAdapter = DayTypeRefsToServiceIdAdapter.create(sj.getDayTypes());
if (serviceAdapter == null) {
LOG.warn("Skipping ServiceJourney with empty dayTypes. Service Journey id : {}", sj.getId());
return;
}
dayTypeRefs.add(serviceAdapter);
String journeyPatternId = sj.getJourneyPatternRef().getValue().getRef();
JourneyPattern journeyPattern = journeyPatternById.lookup(journeyPatternId);
if (journeyPattern != null) {
int nStopPointsInJourneyPattern = journeyPattern.getPointsInSequence().getPointInJourneyPatternOrStopPointInJourneyPatternOrTimingPointInJourneyPattern().size();
int nTimetablePassingTimes = sj.getPassingTimes().getTimetabledPassingTime().size();
// - is know at this point.
if (nStopPointsInJourneyPattern == nTimetablePassingTimes) {
serviceJourneyByPatternId.put(journeyPatternId, sj);
for (TimetabledPassingTime it : sj.getPassingTimes().getTimetabledPassingTime()) {
passingTimeByStopPointId.put(it.getPointInJourneyPatternRef().getValue().getRef(), it);
}
} else {
LOG.warn("Mismatch between ServiceJourney and JourneyPattern. " + "ServiceJourney will be skipped. - " + sj.getId());
}
} else {
LOG.warn("JourneyPattern not found. " + journeyPatternId);
}
}
Aggregations