Search in sources :

Example 1 with NetexMapper

use of org.rutebanken.tiamat.netex.mapping.NetexMapper in project tiamat by entur.

the class TariffZoneImportHandler method handleTariffZones.

public void handleTariffZones(SiteFrame netexSiteFrame, ImportParams importParams, AtomicInteger tariffZoneImportedCounter, SiteFrame responseSiteframe) {
    if (publicationDeliveryHelper.hasTariffZones(netexSiteFrame) && importParams.importType != ImportType.ID_MATCH) {
        List<org.rutebanken.tiamat.model.TariffZone> tiamatTariffZones = netexSiteFrame.getTariffZones().getTariffZone().stream().filter(this::isTariffZone).map(jaxbElement -> (TariffZone) jaxbElement.getValue()).map(netexMapper::mapToTiamatModel).collect(Collectors.toList());
        List<org.rutebanken.tiamat.model.FareZone> tiamatFareZones = netexSiteFrame.getTariffZones().getTariffZone().stream().filter(this::isFareZone).map(jaxbElement -> (FareZone) jaxbElement.getValue()).map(netexMapper::mapToTiamatModel).collect(Collectors.toList());
        logger.debug("Mapped {} tariff zones from netex to internal model", tiamatTariffZones.size());
        List<JAXBElement<? extends Zone_VersionStructure>> importedTariffZones = tariffZoneImporter.importTariffZones(tiamatTariffZones).stream().map(tariffZone -> new ObjectFactory().createTariffZone(tariffZone)).collect(Collectors.toList());
        logger.debug("Got {} imported tariffZones ", importedTariffZones.size());
        List<JAXBElement<? extends Zone_VersionStructure>> importedFareZones = fareZoneImporter.importFareZones(tiamatFareZones).stream().map(fareZone -> new ObjectFactory().createFareZone(fareZone)).collect(Collectors.toList());
        if (!importedTariffZones.isEmpty()) {
            responseSiteframe.withTariffZones(new TariffZonesInFrame_RelStructure().withTariffZone(importedTariffZones));
        }
        if (!importedFareZones.isEmpty()) {
            responseSiteframe.withTariffZones(new TariffZonesInFrame_RelStructure().withTariffZone(importedFareZones));
        }
    }
}
Also used : FareZone(org.rutebanken.netex.model.FareZone) ImportParams(org.rutebanken.tiamat.importer.ImportParams) Logger(org.slf4j.Logger) SiteFrame(org.rutebanken.netex.model.SiteFrame) TariffZone(org.rutebanken.netex.model.TariffZone) TariffZoneImporter(org.rutebanken.tiamat.importer.TariffZoneImporter) PublicationDeliveryHelper(org.rutebanken.tiamat.netex.mapping.PublicationDeliveryHelper) JAXBElement(javax.xml.bind.JAXBElement) FareZoneImporter(org.rutebanken.tiamat.importer.FareZoneImporter) LoggerFactory(org.slf4j.LoggerFactory) NetexMapper(org.rutebanken.tiamat.netex.mapping.NetexMapper) Collectors(java.util.stream.Collectors) Component(org.springframework.stereotype.Component) List(java.util.List) TariffZonesInFrame_RelStructure(org.rutebanken.netex.model.TariffZonesInFrame_RelStructure) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Zone_VersionStructure(org.rutebanken.netex.model.Zone_VersionStructure) ObjectFactory(org.rutebanken.netex.model.ObjectFactory) ImportType(org.rutebanken.tiamat.importer.ImportType) TariffZone(org.rutebanken.netex.model.TariffZone) TariffZonesInFrame_RelStructure(org.rutebanken.netex.model.TariffZonesInFrame_RelStructure) ObjectFactory(org.rutebanken.netex.model.ObjectFactory) FareZone(org.rutebanken.netex.model.FareZone) JAXBElement(javax.xml.bind.JAXBElement) Zone_VersionStructure(org.rutebanken.netex.model.Zone_VersionStructure)

Aggregations

List (java.util.List)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Collectors (java.util.stream.Collectors)1 JAXBElement (javax.xml.bind.JAXBElement)1 FareZone (org.rutebanken.netex.model.FareZone)1 ObjectFactory (org.rutebanken.netex.model.ObjectFactory)1 SiteFrame (org.rutebanken.netex.model.SiteFrame)1 TariffZone (org.rutebanken.netex.model.TariffZone)1 TariffZonesInFrame_RelStructure (org.rutebanken.netex.model.TariffZonesInFrame_RelStructure)1 Zone_VersionStructure (org.rutebanken.netex.model.Zone_VersionStructure)1 FareZoneImporter (org.rutebanken.tiamat.importer.FareZoneImporter)1 ImportParams (org.rutebanken.tiamat.importer.ImportParams)1 ImportType (org.rutebanken.tiamat.importer.ImportType)1 TariffZoneImporter (org.rutebanken.tiamat.importer.TariffZoneImporter)1 NetexMapper (org.rutebanken.tiamat.netex.mapping.NetexMapper)1 PublicationDeliveryHelper (org.rutebanken.tiamat.netex.mapping.PublicationDeliveryHelper)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Component (org.springframework.stereotype.Component)1