use of org.rutebanken.netex.model.FareZoneRefStructure in project tiamat by entur.
the class FareZoneMapper method mapBtoA.
@Override
public void mapBtoA(org.rutebanken.tiamat.model.FareZone tiamatFareZone, FareZone netexFareZone, MappingContext context) {
super.mapBtoA(tiamatFareZone, netexFareZone, context);
if (tiamatFareZone.getTransportOrganisationRef() != null) {
final JAXBElement<AuthorityRefStructure> authorityRef = objectFactory.createAuthorityRef(new AuthorityRefStructure().withRef(tiamatFareZone.getTransportOrganisationRef()));
netexFareZone.withTransportOrganisationRef(authorityRef);
}
if (!tiamatFareZone.getNeighbours().isEmpty()) {
final List<FareZoneRefStructure> fareZoneRefs = tiamatFareZone.getNeighbours().stream().map(tariffZoneRef -> new FareZoneRefStructure().withRef(tariffZoneRef.getRef())).collect(Collectors.toList());
final FareZoneRefs_RelStructure fareZoneRefsRelStructure = new FareZoneRefs_RelStructure().withFareZoneRef(fareZoneRefs);
netexFareZone.withNeighbours(fareZoneRefsRelStructure);
}
if (!tiamatFareZone.getFareZoneMembers().isEmpty()) {
List<JAXBElement<? extends PointRefStructure>> fareZoneMember = tiamatFareZone.getFareZoneMembers().stream().map(members -> convertStopPlaceRefToScheduledStopPointRef(members.getRef())).filter(Objects::nonNull).map(spRef -> new ObjectFactory().createScheduledStopPointRef(new ScheduledStopPointRefStructure().withRef(spRef))).collect(Collectors.toList());
PointRefs_RelStructure pointRefsRelStructure = new PointRefs_RelStructure().withPointRef(fareZoneMember);
netexFareZone.withMembers(pointRefsRelStructure);
}
}
use of org.rutebanken.netex.model.FareZoneRefStructure in project tiamat by entur.
the class FareZoneMapper method mapAtoB.
@Override
public void mapAtoB(FareZone netexFareZone, org.rutebanken.tiamat.model.FareZone tiamatFareZone, MappingContext context) {
super.mapAtoB(netexFareZone, tiamatFareZone, context);
if (netexFareZone.getTransportOrganisationRef() != null && netexFareZone.getTransportOrganisationRef().getValue() != null) {
tiamatFareZone.setTransportOrganisationRef(netexFareZone.getTransportOrganisationRef().getValue().getRef());
}
if (netexFareZone.getNeighbours() != null && !netexFareZone.getNeighbours().getFareZoneRef().isEmpty()) {
Set<TariffZoneRef> tiamatNeighbours = new HashSet<>();
final List<FareZoneRefStructure> fareZoneRef = netexFareZone.getNeighbours().getFareZoneRef();
for (FareZoneRefStructure fareZoneRefStructure : fareZoneRef) {
tiamatNeighbours.add(new TariffZoneRef(fareZoneRefStructure.getRef()));
}
tiamatFareZone.setNeighbours(tiamatNeighbours);
}
if (netexFareZone.getScopingMethod() != null && netexFareZone.getScopingMethod().equals(ScopingMethodEnumeration.EXPLICIT_STOPS) && netexFareZone.getMembers() != null && !netexFareZone.getMembers().getPointRef().isEmpty()) {
var fareZoneMembers = netexFareZone.getMembers().getPointRef().stream().map(jaxbElement -> convertScheduledStopPointRefToStopPlaceRef(jaxbElement.getValue().getRef())).filter(Objects::nonNull).map(StopPlaceReference::new).collect(Collectors.toSet());
tiamatFareZone.setFareZoneMembers(fareZoneMembers);
}
}
Aggregations