Search in sources :

Example 71 with TripEntry

use of org.onebusaway.transit_data_federation.services.transit_graph.TripEntry in project onebusaway-application-modules by camsys.

the class ShapeBeanServiceImpl method getShapeIdsForAgencyId.

@Override
public ListBean<String> getShapeIdsForAgencyId(String agencyId) {
    Set<AgencyAndId> shapeIds = new HashSet<AgencyAndId>();
    for (TripEntry trip : _transitGraphDao.getAllTrips()) {
        AgencyAndId shapeId = trip.getShapeId();
        if (shapeId == null || !shapeId.hasValues())
            continue;
        if (!shapeId.getAgencyId().equals(agencyId))
            continue;
        shapeIds.add(shapeId);
    }
    List<String> ids = new ArrayList<String>();
    for (AgencyAndId shapeId : shapeIds) {
        String id = AgencyAndIdLibrary.convertToString(shapeId);
        ids.add(id);
    }
    Collections.sort(ids);
    return new ListBean<String>(ids, false);
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) ArrayList(java.util.ArrayList) ListBean(org.onebusaway.transit_data.model.ListBean) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry) HashSet(java.util.HashSet)

Example 72 with TripEntry

use of org.onebusaway.transit_data_federation.services.transit_graph.TripEntry in project onebusaway-application-modules by camsys.

the class BundleManagementServiceImpl method removeAndRebuildCache.

/**
 ***********************
 * Private Helper Methods
 ************************
 */
private void removeAndRebuildCache() {
    // give subclasses a chance to do work
    timingHook();
    _log.info("Clearing all caches...");
    for (CacheManager cacheManager : CacheManager.ALL_CACHE_MANAGERS) {
        _log.info("Found " + cacheManager.getName());
        for (String cacheName : cacheManager.getCacheNames()) {
            _log.info(" > Cache: " + cacheName);
            cacheManager.getCache(cacheName).flush();
            cacheManager.clearAllStartingWith(cacheName);
        }
        // why not?
        cacheManager.clearAll();
    }
    // Rebuild cache
    try {
        List<AgencyWithCoverageBean> agenciesWithCoverage = _transitDataService.getAgenciesWithCoverage();
        for (AgencyWithCoverageBean agencyWithCoverage : agenciesWithCoverage) {
            AgencyBean agency = agencyWithCoverage.getAgency();
            ListBean<String> stopIds = _transitDataService.getStopIdsForAgencyId(agency.getId());
            for (String stopId : stopIds.getList()) {
                _transitDataService.getStop(stopId);
            }
            ListBean<String> routeIds = _transitDataService.getRouteIdsForAgencyId(agency.getId());
            for (String routeId : routeIds.getList()) {
                _transitDataService.getStopsForRoute(routeId);
            }
        }
        Set<AgencyAndId> shapeIds = new HashSet<AgencyAndId>();
        for (TripEntry trip : _transitGraphDao.getAllTrips()) {
            AgencyAndId shapeId = trip.getShapeId();
            if (shapeId != null && shapeId.hasValues())
                shapeIds.add(shapeId);
        }
        for (AgencyAndId shapeId : shapeIds) {
            _transitDataService.getShapeForId(AgencyAndIdLibrary.convertToString(shapeId));
        }
        _log.info("cache clearing complete!");
    } catch (Exception e) {
        _log.error("Exception during cache rebuild: ", e.getMessage());
    }
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) AgencyWithCoverageBean(org.onebusaway.transit_data.model.AgencyWithCoverageBean) CacheManager(net.sf.ehcache.CacheManager) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry) AgencyBean(org.onebusaway.transit_data.model.AgencyBean) HashSet(java.util.HashSet)

Example 73 with TripEntry

use of org.onebusaway.transit_data_federation.services.transit_graph.TripEntry in project onebusaway-application-modules by camsys.

the class NarrativeProviderImpl method getNarrativeForStopTimeEntry.

public StopTimeNarrative getNarrativeForStopTimeEntry(StopTimeEntry entry) {
    TripEntry trip = entry.getTrip();
    List<StopTimeNarrative> narratives = _stopTimeNarrativesByTripIdAndStopTimeSequence.get(trip.getId());
    if (narratives == null)
        return null;
    int index = entry.getSequence();
    return narratives.get(index);
}
Also used : StopTimeNarrative(org.onebusaway.transit_data_federation.model.narrative.StopTimeNarrative) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)

Aggregations

TripEntry (org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)73 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)46 BlockTripEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry)39 ArrayList (java.util.ArrayList)20 BlockStopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockStopTimeEntry)18 StopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry)15 StopEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopEntry)14 HashSet (java.util.HashSet)13 TripEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.TripEntryImpl)10 BlockEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockEntry)10 List (java.util.List)9 BlockInstance (org.onebusaway.transit_data_federation.services.blocks.BlockInstance)9 Date (java.util.Date)7 Test (org.junit.Test)7 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)7 BlockConfigurationEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)7 FrequencyEntry (org.onebusaway.transit_data_federation.services.transit_graph.FrequencyEntry)7 Cacheable (org.onebusaway.container.cache.Cacheable)6 RouteEntry (org.onebusaway.transit_data_federation.services.transit_graph.RouteEntry)6 ServiceIdActivation (org.onebusaway.transit_data_federation.services.transit_graph.ServiceIdActivation)6