use of org.rutebanken.netex.model.Authority in project OpenTripPlanner by opentripplanner.
the class RouteMapperTest method mapRouteWithAgencySpecified.
@Test
public void mapRouteWithAgencySpecified() {
NetexImportDataIndex netexIndex = new NetexImportDataIndex();
OtpTransitServiceBuilder transitBuilder = new OtpTransitServiceBuilder();
Network network = new Network().withId(NETWORK_ID).withTransportOrganisationRef(createJaxbElement(new OrganisationRefStructure().withRef(AUTHORITY_ID)));
netexIndex.networkById.add(network);
netexIndex.authoritiesById.add(new Authority().withId(AUTHORITY_ID));
transitBuilder.getAgenciesById().add(createAgency());
Line line = createExampleLine();
RouteMapper routeMapper = new RouteMapper(MappingSupport.ID_FACTORY, transitBuilder.getAgenciesById(), transitBuilder.getOperatorsById(), netexIndex.readOnlyView(), TIME_ZONE);
Route route = routeMapper.mapRoute(line);
assertEquals(AUTHORITY_ID, route.getAgency().getId().getId());
}
use of org.rutebanken.netex.model.Authority in project OpenTripPlanner by opentripplanner.
the class AuthorityToAgencyMapperTest method mapAgency.
@Test
public void mapAgency() {
// Given
Authority authority = authority(ID, NAME, URL, PHONE);
// When mapped
Agency a = mapper.mapAuthorityToAgency(authority);
// Then expect
assertEquals(ID, a.getId().getId());
assertEquals(NAME, a.getName());
assertEquals(TIME_ZONE, a.getTimezone());
assertEquals(URL, a.getUrl());
assertEquals(PHONE, a.getPhone());
}
use of org.rutebanken.netex.model.Authority in project OpenTripPlanner by opentripplanner.
the class AuthorityToAgencyMapperTest method mapAgencyWithoutOptionalElements.
@Test
public void mapAgencyWithoutOptionalElements() {
// Given
Authority authority = authority(ID, NAME, null, null);
// When mapped
Agency a = mapper.mapAuthorityToAgency(authority);
// Then expect
assertNull(a.getUrl());
assertNull(a.getPhone());
}
use of org.rutebanken.netex.model.Authority 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();
}
};
}
use of org.rutebanken.netex.model.Authority in project OpenTripPlanner by opentripplanner.
the class NetexMapper method mapAuthorities.
private void mapAuthorities(NetexImportDataIndexReadOnlyView netexIndex) {
AuthorityToAgencyMapper agencyMapper = new AuthorityToAgencyMapper(idFactory, netexIndex.getTimeZone());
for (Authority authority : netexIndex.getAuthoritiesById().localValues()) {
Agency agency = agencyMapper.mapAuthorityToAgency(authority);
transitBuilder.getAgenciesById().add(agency);
}
}
Aggregations