Search in sources :

Example 1 with Notice

use of org.rutebanken.netex.model.Notice in project OpenTripPlanner by opentripplanner.

the class NoticeAssignmentMapperTest method mapNoticeAssignment.

@Test
public void mapNoticeAssignment() {
    NoticeAssignment noticeAssignment = new NoticeAssignment();
    noticeAssignment.setNoticedObjectRef(new VersionOfObjectRefStructure().withRef(ROUTE_ID));
    noticeAssignment.setNotice(NOTICE);
    Route route = new Route();
    route.setId(MappingSupport.ID_FACTORY.createId(ROUTE_ID));
    EntityById<FeedScopedId, Route> routesById = new EntityById<>();
    routesById.add(route);
    NoticeAssignmentMapper noticeAssignmentMapper = new NoticeAssignmentMapper(MappingSupport.ID_FACTORY, new HierarchicalMultimap<>(), new HierarchicalMapById<>(), routesById, new EntityById<>(), new HashMap<>());
    Multimap<TransitEntity<?>, org.opentripplanner.model.Notice> noticesByElement = noticeAssignmentMapper.map(noticeAssignment);
    org.opentripplanner.model.Notice notice2 = noticesByElement.get(route).iterator().next();
    assertEquals(NOTICE_ID, notice2.getId().getId());
}
Also used : VersionOfObjectRefStructure(org.rutebanken.netex.model.VersionOfObjectRefStructure) TransitEntity(org.opentripplanner.model.TransitEntity) EntityById(org.opentripplanner.model.impl.EntityById) Notice(org.rutebanken.netex.model.Notice) NoticeAssignment(org.rutebanken.netex.model.NoticeAssignment) FeedScopedId(org.opentripplanner.model.FeedScopedId) Route(org.opentripplanner.model.Route) Test(org.junit.Test)

Example 2 with Notice

use of org.rutebanken.netex.model.Notice in project OpenTripPlanner by opentripplanner.

the class NoticeAssignmentMapperTest method mapNoticeAssignmentOnStopPoint.

@Test
public void mapNoticeAssignmentOnStopPoint() {
    HierarchicalMultimap<String, TimetabledPassingTime> passingTimeByStopPointId = new HierarchicalMultimap<>();
    HierarchicalMapById<Notice> noticesById = new HierarchicalMapById<>();
    passingTimeByStopPointId.add(STOP_POINT_ID, new TimetabledPassingTime().withId(TIMETABLED_PASSING_TIME1));
    passingTimeByStopPointId.add(STOP_POINT_ID, new TimetabledPassingTime().withId(TIMETABLED_PASSING_TIME2));
    Trip trip = new Trip();
    trip.setId(new FeedScopedId("T", "1"));
    StopTime stopTime1 = createStopTime(1, trip);
    StopTime stopTime2 = createStopTime(2, trip);
    Map<String, StopTime> stopTimesById = new HashMap<>();
    stopTimesById.put(TIMETABLED_PASSING_TIME1, stopTime1);
    stopTimesById.put(TIMETABLED_PASSING_TIME2, stopTime2);
    noticesById.add(NOTICE);
    NoticeAssignment noticeAssignment = new NoticeAssignment().withNoticedObjectRef(new VersionOfObjectRefStructure().withRef(STOP_POINT_ID)).withNoticeRef(new NoticeRefStructure().withRef(NOTICE_ID));
    NoticeAssignmentMapper noticeAssignmentMapper = new NoticeAssignmentMapper(MappingSupport.ID_FACTORY, passingTimeByStopPointId, noticesById, new EntityById<>(), new EntityById<>(), stopTimesById);
    Multimap<TransitEntity<?>, org.opentripplanner.model.Notice> noticesByElement = noticeAssignmentMapper.map(noticeAssignment);
    org.opentripplanner.model.Notice notice2a = noticesByElement.get(stopTime1.getId()).stream().findFirst().orElseThrow(IllegalStateException::new);
    org.opentripplanner.model.Notice notice2b = noticesByElement.get(stopTime2.getId()).stream().findFirst().orElseThrow(IllegalStateException::new);
    assertEquals(NOTICE_ID, notice2a.getId().getId());
    assertEquals(NOTICE_ID, notice2b.getId().getId());
}
Also used : Trip(org.opentripplanner.model.Trip) NoticeRefStructure(org.rutebanken.netex.model.NoticeRefStructure) VersionOfObjectRefStructure(org.rutebanken.netex.model.VersionOfObjectRefStructure) HashMap(java.util.HashMap) TransitEntity(org.opentripplanner.model.TransitEntity) MultilingualString(org.rutebanken.netex.model.MultilingualString) HierarchicalMultimap(org.opentripplanner.netex.loader.util.HierarchicalMultimap) HierarchicalMapById(org.opentripplanner.netex.loader.util.HierarchicalMapById) TimetabledPassingTime(org.rutebanken.netex.model.TimetabledPassingTime) Notice(org.rutebanken.netex.model.Notice) FeedScopedId(org.opentripplanner.model.FeedScopedId) NoticeAssignment(org.rutebanken.netex.model.NoticeAssignment) StopTime(org.opentripplanner.model.StopTime) Test(org.junit.Test)

Example 3 with Notice

use of org.rutebanken.netex.model.Notice in project OpenTripPlanner by opentripplanner.

the class NoticeMapperTest method mapNotice.

@Test
public void mapNotice() {
    org.opentripplanner.model.Notice otpNotice;
    // Given
    NoticeMapper mapper = new NoticeMapper(MappingSupport.ID_FACTORY);
    // And
    Notice netexNotice = new Notice();
    netexNotice.setId(NOTICE_ID);
    netexNotice.setText(new MultilingualString().withValue(NOTICE_TEXT));
    netexNotice.setPublicCode(PUBLIC_CODE);
    // When
    otpNotice = mapper.map(netexNotice);
    // Then
    assertEquals(NOTICE_ID, otpNotice.getId().getId());
    assertEquals(NOTICE_TEXT, otpNotice.getText());
    assertEquals(PUBLIC_CODE, otpNotice.getPublicCode());
    // And when other instance with same id is mapped, the first one is returned
    // from cache - ignoring all properties except the id
    otpNotice = mapper.map(new Notice().withId(NOTICE_ID).withPublicCode("Albatross").withText(new MultilingualString().withValue("Different text")));
    // Then
    assertEquals(NOTICE_ID, otpNotice.getId().getId());
    assertEquals("Not Albatross", NOTICE_TEXT, otpNotice.getText());
}
Also used : Notice(org.rutebanken.netex.model.Notice) MultilingualString(org.rutebanken.netex.model.MultilingualString) Test(org.junit.Test)

Example 4 with Notice

use of org.rutebanken.netex.model.Notice 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();
        }
    };
}
Also used : Operator(org.rutebanken.netex.model.Operator) StopPlace(org.rutebanken.netex.model.StopPlace) TariffZone(org.rutebanken.netex.model.TariffZone) DestinationDisplay(org.rutebanken.netex.model.DestinationDisplay) GroupOfStopPlaces(org.rutebanken.netex.model.GroupOfStopPlaces) Authority(org.rutebanken.netex.model.Authority) DayType(org.rutebanken.netex.model.DayType) GroupOfLines(org.rutebanken.netex.model.GroupOfLines) Line(org.rutebanken.netex.model.Line) JourneyPattern(org.rutebanken.netex.model.JourneyPattern) Notice(org.rutebanken.netex.model.Notice) DayTypeRefsToServiceIdAdapter(org.opentripplanner.netex.support.DayTypeRefsToServiceIdAdapter) OperatingPeriod(org.rutebanken.netex.model.OperatingPeriod) Collection(java.util.Collection) NoticeAssignment(org.rutebanken.netex.model.NoticeAssignment) Quay(org.rutebanken.netex.model.Quay) ServiceLink(org.rutebanken.netex.model.ServiceLink) Route(org.rutebanken.netex.model.Route)

Aggregations

Notice (org.rutebanken.netex.model.Notice)4 Test (org.junit.Test)3 NoticeAssignment (org.rutebanken.netex.model.NoticeAssignment)3 FeedScopedId (org.opentripplanner.model.FeedScopedId)2 TransitEntity (org.opentripplanner.model.TransitEntity)2 MultilingualString (org.rutebanken.netex.model.MultilingualString)2 VersionOfObjectRefStructure (org.rutebanken.netex.model.VersionOfObjectRefStructure)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Route (org.opentripplanner.model.Route)1 StopTime (org.opentripplanner.model.StopTime)1 Trip (org.opentripplanner.model.Trip)1 EntityById (org.opentripplanner.model.impl.EntityById)1 HierarchicalMapById (org.opentripplanner.netex.loader.util.HierarchicalMapById)1 HierarchicalMultimap (org.opentripplanner.netex.loader.util.HierarchicalMultimap)1 DayTypeRefsToServiceIdAdapter (org.opentripplanner.netex.support.DayTypeRefsToServiceIdAdapter)1 Authority (org.rutebanken.netex.model.Authority)1 DayType (org.rutebanken.netex.model.DayType)1 DestinationDisplay (org.rutebanken.netex.model.DestinationDisplay)1 GroupOfLines (org.rutebanken.netex.model.GroupOfLines)1