Search in sources :

Example 11 with AgencyBean

use of org.onebusaway.transit_data.model.AgencyBean in project onebusaway-application-modules by camsys.

the class RouteBeanServiceImpl method getRouteBeanForRouteCollection.

/**
 **
 * Private Methods
 ***
 */
private RouteBean getRouteBeanForRouteCollection(AgencyAndId id, RouteCollectionNarrative rc) {
    RouteBean.Builder bean = RouteBean.builder();
    bean.setId(ApplicationBeanLibrary.getId(id));
    bean.setShortName(rc.getShortName());
    bean.setLongName(rc.getLongName());
    bean.setColor(rc.getColor());
    bean.setDescription(rc.getDescription());
    bean.setTextColor(rc.getTextColor());
    bean.setType(rc.getType());
    bean.setUrl(rc.getUrl());
    AgencyBean agency = _agencyBeanService.getAgencyForId(id.getAgencyId());
    bean.setAgency(agency);
    return bean.create();
}
Also used : RouteBean(org.onebusaway.transit_data.model.RouteBean) StopsForRouteBean(org.onebusaway.transit_data.model.StopsForRouteBean) AgencyBean(org.onebusaway.transit_data.model.AgencyBean)

Example 12 with AgencyBean

use of org.onebusaway.transit_data.model.AgencyBean 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)

Aggregations

AgencyBean (org.onebusaway.transit_data.model.AgencyBean)12 RouteBean (org.onebusaway.transit_data.model.RouteBean)6 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)5 StopsForRouteBean (org.onebusaway.transit_data.model.StopsForRouteBean)5 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 ArrivalAndDepartureBean (org.onebusaway.transit_data.model.ArrivalAndDepartureBean)4 HashMap (java.util.HashMap)3 StopGroupBean (org.onebusaway.transit_data.model.StopGroupBean)3 StopGroupingBean (org.onebusaway.transit_data.model.StopGroupingBean)3 Date (java.util.Date)2 Before (org.junit.Before)2 Matchers.anyString (org.mockito.Matchers.anyString)2 ArrivalAndDepartureComparator (org.onebusaway.presentation.impl.ArrivalAndDepartureComparator)2 AgencyWithCoverageBean (org.onebusaway.transit_data.model.AgencyWithCoverageBean)2 NameBean (org.onebusaway.transit_data.model.NameBean)2 Builder (org.onebusaway.transit_data.model.RouteBean.Builder)2 StopBean (org.onebusaway.transit_data.model.StopBean)2 TripBean (org.onebusaway.transit_data.model.trips.TripBean)2 TripEntry (org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)2