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);
}
}
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);
}
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);
}
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()));
}
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);
}
Aggregations