Search in sources :

Example 1 with GroupOfStopPlaces

use of org.rutebanken.netex.model.GroupOfStopPlaces in project tiamat by entur.

the class ExportResourceTest method exportGroupOfStopPlacesToNetex.

@Test
public void exportGroupOfStopPlacesToNetex() throws Exception {
    org.rutebanken.tiamat.model.StopPlace stopPlace = new org.rutebanken.tiamat.model.StopPlace();
    stopPlace.setName(new EmbeddableMultilingualString("stopPlace"));
    stopPlace.setCentroid(point(60.000, 10.78));
    stopPlaceVersionedSaverService.saveNewVersion(stopPlace);
    org.rutebanken.tiamat.model.StopPlace stopPlace2 = new org.rutebanken.tiamat.model.StopPlace();
    stopPlace2.setName(new EmbeddableMultilingualString("stopPlace 2"));
    stopPlace2.setCentroid(point(61.000, 11.78));
    stopPlaceVersionedSaverService.saveNewVersion(stopPlace2);
    org.rutebanken.tiamat.model.GroupOfStopPlaces groupOfStopPlaces = new org.rutebanken.tiamat.model.GroupOfStopPlaces();
    groupOfStopPlaces.getMembers().add(new StopPlaceReference(stopPlace.getNetexId()));
    groupOfStopPlaces.getMembers().add(new StopPlaceReference(stopPlace2.getNetexId()));
    groupOfStopPlaces.setChangedBy("mr. Solem");
    groupOfStopPlaces.setCreated(Instant.now());
    groupOfStopPlaces.setChanged(Instant.now());
    groupOfStopPlaces.setName(new EmbeddableMultilingualString("oh my gosp"));
    org.rutebanken.tiamat.model.AlternativeName alternativeName = new org.rutebanken.tiamat.model.AlternativeName();
    alternativeName.setName(new EmbeddableMultilingualString("alternative name alias"));
    alternativeName.setNameType(org.rutebanken.tiamat.model.NameTypeEnumeration.ALIAS);
    groupOfStopPlaces.getAlternativeNames().add(alternativeName);
    groupOfStopPlacesSaverService.saveNewVersion(groupOfStopPlaces);
    stopPlaceRepository.flush();
    groupOfStopPlacesRepository.flush();
    ExportParams exportParams = ExportParams.newExportParamsBuilder().setStopPlaceSearch(StopPlaceSearch.newStopPlaceSearchBuilder().build()).setGroupOfStopPlacesExportMode(ExportParams.ExportMode.RELEVANT).build();
    Response response = exportResource.exportStopPlaces(exportParams);
    PublicationDeliveryStructure publicationDeliveryStructure = publicationDeliveryTestHelper.fromResponse(response);
    SiteFrame siteFrame = publicationDeliveryTestHelper.findSiteFrame(publicationDeliveryStructure);
    List<StopPlace> stopPlaces = publicationDeliveryTestHelper.extractStopPlaces(siteFrame);
    Assert.assertEquals(2, stopPlaces.size());
    GroupOfStopPlaces netexGroupOfStopPlaces = publicationDeliveryTestHelper.extractGroupOfStopPlaces(siteFrame).get(0);
    assertThat(netexGroupOfStopPlaces).isNotNull();
    assertThat(netexGroupOfStopPlaces.getName().getValue()).as("name.value").isEqualTo(groupOfStopPlaces.getName().getValue());
    assertThat(netexGroupOfStopPlaces.getAlternativeNames()).as("alternativeNames").isNotNull();
    assertThat(netexGroupOfStopPlaces.getMembers()).as("members").isNotNull();
    assertThat(netexGroupOfStopPlaces.getMembers().getStopPlaceRef()).as("stop place ref list").isNotNull().isNotEmpty().extracting(StopPlaceRefStructure::getRef).as("reference to stop place id").containsOnly(stopPlace.getNetexId(), stopPlace2.getNetexId());
    assertThat(netexGroupOfStopPlaces.getCentroid()).as("centroid").isNotNull();
    assertThat(netexGroupOfStopPlaces.getChanged()).as("changed").isNotNull();
    assertThat(netexGroupOfStopPlaces.getVersion()).as("version").isEqualTo(String.valueOf(groupOfStopPlaces.getVersion()));
}
Also used : StopPlace(org.rutebanken.netex.model.StopPlace) SiteFrame(org.rutebanken.netex.model.SiteFrame) GroupOfStopPlaces(org.rutebanken.netex.model.GroupOfStopPlaces) StopPlaceReference(org.rutebanken.tiamat.model.StopPlaceReference) PublicationDeliveryStructure(org.rutebanken.netex.model.PublicationDeliveryStructure) StopPlaceRefStructure(org.rutebanken.netex.model.StopPlaceRefStructure) EmbeddableMultilingualString(org.rutebanken.tiamat.model.EmbeddableMultilingualString) Response(javax.ws.rs.core.Response) ExportParams(org.rutebanken.tiamat.exporter.params.ExportParams) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Example 2 with GroupOfStopPlaces

use of org.rutebanken.netex.model.GroupOfStopPlaces 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

GroupOfStopPlaces (org.rutebanken.netex.model.GroupOfStopPlaces)2 StopPlace (org.rutebanken.netex.model.StopPlace)2 Collection (java.util.Collection)1 Response (javax.ws.rs.core.Response)1 Test (org.junit.Test)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 JourneyPattern (org.rutebanken.netex.model.JourneyPattern)1 Line (org.rutebanken.netex.model.Line)1 Notice (org.rutebanken.netex.model.Notice)1 NoticeAssignment (org.rutebanken.netex.model.NoticeAssignment)1 OperatingPeriod (org.rutebanken.netex.model.OperatingPeriod)1 Operator (org.rutebanken.netex.model.Operator)1 PublicationDeliveryStructure (org.rutebanken.netex.model.PublicationDeliveryStructure)1 Quay (org.rutebanken.netex.model.Quay)1 Route (org.rutebanken.netex.model.Route)1 ServiceLink (org.rutebanken.netex.model.ServiceLink)1