Search in sources :

Example 1 with Notice

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

the class NoticeAssignmentMapper method map.

Multimap<TransitEntity<?>, Notice> map(NoticeAssignment noticeAssignment) {
    // TODO OTP2 - Idealy this should en up as one key,value pair.
    // The `StopPointInJourneyPattern` witch result in more than one key/valye pair,
    // can be replaced with a new compound key type.
    Multimap<TransitEntity<?>, Notice> noticiesByEntity = ArrayListMultimap.create();
    String noticedObjectId = noticeAssignment.getNoticedObjectRef().getRef();
    Notice otpNotice = getOrMapNotice(noticeAssignment);
    if (otpNotice == null) {
        LOG.warn("Notice in notice assignment is missing for assignment {}", noticeAssignment);
        return noticiesByEntity;
    }
    // Special case for StopPointInJourneyPattern. The OTP model do not have this element, so we
    // attach the notice to all StopTimes for the pattern at the given stop.
    Collection<TimetabledPassingTime> times = passingTimeByStopPointId.lookup(noticedObjectId);
    if (!times.isEmpty()) {
        for (TimetabledPassingTime time : times) {
            noticiesByEntity.put(lookupStopTimeKey(time.getId()), otpNotice);
        }
    } else if (stopTimesByNetexId.containsKey(noticedObjectId)) {
        noticiesByEntity.put(lookupStopTimeKey(noticedObjectId), otpNotice);
    } else {
        FeedScopedId otpId = idFactory.createId(noticedObjectId);
        if (routesById.containsKey(otpId)) {
            noticiesByEntity.put(routesById.get(otpId), otpNotice);
        } else if (tripsById.containsKey(otpId)) {
            noticiesByEntity.put(tripsById.get(otpId), otpNotice);
        } else {
            LOG.warn("Could not map noticeAssignment for element with id {}", noticedObjectId);
        }
    }
    return noticiesByEntity;
}
Also used : Notice(org.opentripplanner.model.Notice) TransitEntity(org.opentripplanner.model.TransitEntity) FeedScopedId(org.opentripplanner.model.FeedScopedId) TimetabledPassingTime(org.rutebanken.netex.model.TimetabledPassingTime)

Example 2 with Notice

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

the class NetexLoaderSmokeTest method assertNote.

private void assertNote(Multimap<TransitEntity<?>, Notice> map, Serializable entityKey, String code, String text) {
    TransitEntity<?> key = map.keySet().stream().filter(it -> entityKey.equals(it.getId())).findFirst().orElseThrow(IllegalStateException::new);
    List<Notice> list = list(map.get(key));
    if (list.size() == 0)
        fail("Notice not found: " + key + " -> <Notice " + code + ", " + text + ">\n\t" + map);
    Notice n = list.get(0);
    assertTrue(n.getId().toString().startsWith("RB:RUT:Notice:"));
    assertEquals(code, n.getPublicCode());
    assertEquals(text, n.getText());
    assertEquals(1, list.size());
}
Also used : Notice(org.opentripplanner.model.Notice)

Example 3 with Notice

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

the class NetexMapper method mapNoticeAssignments.

private void mapNoticeAssignments(NetexImportDataIndexReadOnlyView netexIndex) {
    NoticeAssignmentMapper noticeAssignmentMapper = new NoticeAssignmentMapper(idFactory, netexIndex.getPassingTimeByStopPointId(), netexIndex.getNoticeById(), transitBuilder.getRoutes(), transitBuilder.getTripsById(), stopTimesByNetexId);
    for (NoticeAssignment noticeAssignment : netexIndex.getNoticeAssignmentById().localValues()) {
        Multimap<TransitEntity<?>, Notice> noticesByElementId;
        noticesByElementId = noticeAssignmentMapper.map(noticeAssignment);
        transitBuilder.getNoticeAssignments().putAll(noticesByElementId);
    }
}
Also used : Notice(org.opentripplanner.model.Notice) NoticeAssignment(org.rutebanken.netex.model.NoticeAssignment) TransitEntity(org.opentripplanner.model.TransitEntity)

Example 4 with Notice

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

the class NoticeMapper method map.

Notice map(org.rutebanken.netex.model.Notice netexNotice) {
    FeedScopedId id = idFactory.createId(netexNotice.getId());
    Notice otpNotice = cache.get(id);
    if (otpNotice == null) {
        otpNotice = new Notice();
        otpNotice.setId(id);
        otpNotice.setText(netexNotice.getText().getValue());
        otpNotice.setPublicCode(netexNotice.getPublicCode());
        cache.add(otpNotice);
    }
    return otpNotice;
}
Also used : Notice(org.opentripplanner.model.Notice) FeedScopedId(org.opentripplanner.model.FeedScopedId)

Aggregations

Notice (org.opentripplanner.model.Notice)4 FeedScopedId (org.opentripplanner.model.FeedScopedId)2 TransitEntity (org.opentripplanner.model.TransitEntity)2 NoticeAssignment (org.rutebanken.netex.model.NoticeAssignment)1 TimetabledPassingTime (org.rutebanken.netex.model.TimetabledPassingTime)1