Search in sources :

Example 1 with PublicationDeliveryStructure

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

the class NetexBundle method loadSingeFileEntry.

/**
 * Load a single entry and store it in the index for later
 */
private void loadSingeFileEntry(String fileDescription, DataSource entry) {
    try {
        LOG.info("reading entity {}: {}", fileDescription, entry.name());
        PublicationDeliveryStructure doc = xmlParser.parseXmlDoc(entry.asInputStream());
        NetexDocumentParser.parseAndPopulateIndex(index(), doc);
    } catch (JAXBException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
Also used : JAXBException(javax.xml.bind.JAXBException) PublicationDeliveryStructure(org.rutebanken.netex.model.PublicationDeliveryStructure)

Example 2 with PublicationDeliveryStructure

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

the class ExportResourceTest method verifyPaging.

@Test
public void verifyPaging() throws Exception {
    org.rutebanken.tiamat.model.StopPlace stopPlace = new org.rutebanken.tiamat.model.StopPlace();
    stopPlace.setName(new EmbeddableMultilingualString("stopPlace"));
    stopPlaceVersionedSaverService.saveNewVersion(stopPlace);
    org.rutebanken.tiamat.model.StopPlace stopPlace2 = new org.rutebanken.tiamat.model.StopPlace();
    stopPlace2.setName(new EmbeddableMultilingualString("stopPlace 2"));
    stopPlaceVersionedSaverService.saveNewVersion(stopPlace2);
    stopPlaceRepository.flush();
    final int size = 1;
    ExportParams exportParams = ExportParams.newExportParamsBuilder().setStopPlaceSearch(StopPlaceSearch.newStopPlaceSearchBuilder().setSize(size).build()).build();
    Response response = exportResource.exportStopPlaces(exportParams);
    PublicationDeliveryStructure publicationDeliveryStructure = publicationDeliveryTestHelper.fromResponse(response);
    List<StopPlace> stopPlaces = publicationDeliveryTestHelper.extractStopPlaces(publicationDeliveryStructure);
    assertThat(stopPlaces).as("stop places returned").hasSize(size);
}
Also used : Response(javax.ws.rs.core.Response) StopPlace(org.rutebanken.netex.model.StopPlace) ExportParams(org.rutebanken.tiamat.exporter.params.ExportParams) PublicationDeliveryStructure(org.rutebanken.netex.model.PublicationDeliveryStructure) EmbeddableMultilingualString(org.rutebanken.tiamat.model.EmbeddableMultilingualString) Point(org.locationtech.jts.geom.Point) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Example 3 with PublicationDeliveryStructure

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

the class ExportResourceTest method exportStopPlacesWithEffectiveChangedInPeriod.

@Test
public void exportStopPlacesWithEffectiveChangedInPeriod() throws Exception {
    LocalDateTime validFrom = LocalDateTime.now().minusDays(3);
    StopPlace stopPlace1 = new StopPlace().withId("XYZ:Stopplace:1").withVersion("1").withName(new MultilingualString().withValue("Changed stop1")).withValidBetween(new ValidBetween().withFromDate(validFrom)).withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("59.914353")).withLongitude(new BigDecimal("10.806387"))));
    StopPlace stopPlace2 = new StopPlace().withId("XYZ:Stopplace:2").withVersion("1").withName(new MultilingualString().withValue("Changed stop2")).withValidBetween(new ValidBetween().withFromDate(validFrom.plusDays(1))).withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("22.914353")).withLongitude(new BigDecimal("11.806387"))));
    PublicationDeliveryStructure publicationDelivery = publicationDeliveryTestHelper.createPublicationDeliveryWithStopPlace(stopPlace1, stopPlace2);
    publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery);
    UriInfo uriInfoMock = Mockito.mock(UriInfo.class);
    Mockito.when(uriInfoMock.getAbsolutePathBuilder()).thenReturn(JerseyUriBuilder.fromPath("http://test"));
    ChangedStopPlaceSearchDto search = new ChangedStopPlaceSearchDto(null, null, 0, 1);
    Response response = exportResource.exportStopPlacesWithEffectiveChangedInPeriod(search, newExportParamsBuilder().build(), uriInfoMock);
    List<StopPlace> changedStopPlaces = publicationDeliveryTestHelper.extractStopPlaces(response);
    Assert.assertEquals(1, changedStopPlaces.size());
    Assert.assertEquals(stopPlace1.getName().getValue(), changedStopPlaces.get(0).getName().getValue());
    Link link = response.getLink("next");
    Assert.assertNotNull(link);
}
Also used : LocalDateTime(java.time.LocalDateTime) StopPlace(org.rutebanken.netex.model.StopPlace) PublicationDeliveryStructure(org.rutebanken.netex.model.PublicationDeliveryStructure) SimplePoint_VersionStructure(org.rutebanken.netex.model.SimplePoint_VersionStructure) ValidBetween(org.rutebanken.netex.model.ValidBetween) LocationStructure(org.rutebanken.netex.model.LocationStructure) BigDecimal(java.math.BigDecimal) Response(javax.ws.rs.core.Response) MultilingualString(org.rutebanken.netex.model.MultilingualString) EmbeddableMultilingualString(org.rutebanken.tiamat.model.EmbeddableMultilingualString) ChangedStopPlaceSearchDto(org.rutebanken.tiamat.dtoassembling.dto.ChangedStopPlaceSearchDto) UriInfo(javax.ws.rs.core.UriInfo) Link(javax.ws.rs.core.Link) Test(org.junit.Test) TiamatIntegrationTest(org.rutebanken.tiamat.TiamatIntegrationTest)

Example 4 with PublicationDeliveryStructure

use of org.rutebanken.netex.model.PublicationDeliveryStructure 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 5 with PublicationDeliveryStructure

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

the class ExportResourceTest method insertTestStopsWithTopographicPlace.

private void insertTestStopsWithTopographicPlace() throws JAXBException, IOException, SAXException {
    if (testStopInserted) {
        return;
    }
    testStopInserted = true;
    StopPlace stopPlace = new StopPlace().withId("XYZ:Stopplace:1").withVersion("1").withName(new MultilingualString().withValue("Ă˜stre gravlund")).withCentroid(new SimplePoint_VersionStructure().withLocation(new LocationStructure().withLatitude(new BigDecimal("59.914353")).withLongitude(new BigDecimal("10.806387"))));
    PublicationDeliveryStructure publicationDelivery = publicationDeliveryTestHelper.createPublicationDeliveryWithStopPlace(stopPlace);
    publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery);
}
Also used : StopPlace(org.rutebanken.netex.model.StopPlace) PublicationDeliveryStructure(org.rutebanken.netex.model.PublicationDeliveryStructure) SimplePoint_VersionStructure(org.rutebanken.netex.model.SimplePoint_VersionStructure) MultilingualString(org.rutebanken.netex.model.MultilingualString) EmbeddableMultilingualString(org.rutebanken.tiamat.model.EmbeddableMultilingualString) LocationStructure(org.rutebanken.netex.model.LocationStructure) BigDecimal(java.math.BigDecimal)

Aggregations

PublicationDeliveryStructure (org.rutebanken.netex.model.PublicationDeliveryStructure)81 Test (org.junit.Test)66 TiamatIntegrationTest (org.rutebanken.tiamat.TiamatIntegrationTest)64 StopPlace (org.rutebanken.netex.model.StopPlace)54 MultilingualString (org.rutebanken.netex.model.MultilingualString)43 BigDecimal (java.math.BigDecimal)36 LocationStructure (org.rutebanken.netex.model.LocationStructure)36 SimplePoint_VersionStructure (org.rutebanken.netex.model.SimplePoint_VersionStructure)36 ImportParams (org.rutebanken.tiamat.importer.ImportParams)31 Quay (org.rutebanken.netex.model.Quay)22 Quays_RelStructure (org.rutebanken.netex.model.Quays_RelStructure)21 ArrayList (java.util.ArrayList)15 ObjectFactory (org.rutebanken.netex.model.ObjectFactory)15 ByteArrayOutputStream (java.io.ByteArrayOutputStream)13 LocalDateTime (java.time.LocalDateTime)13 ValidBetween (org.rutebanken.netex.model.ValidBetween)13 ByteArrayInputStream (java.io.ByteArrayInputStream)12 SiteFrame (org.rutebanken.netex.model.SiteFrame)12 Response (javax.ws.rs.core.Response)10 JAXBElement (javax.xml.bind.JAXBElement)10