Search in sources :

Example 6 with Cacheable

use of org.onebusaway.container.cache.Cacheable in project onebusaway-application-modules by camsys.

the class AgencyBeanServiceImpl method getAgencyForId.

@Cacheable
public AgencyBean getAgencyForId(String id) {
    AgencyNarrative agency = _narrativeService.getAgencyForId(id);
    if (agency == null)
        return null;
    AgencyBean bean = new AgencyBean();
    bean.setId(id);
    bean.setLang(agency.getLang());
    bean.setName(agency.getName());
    bean.setPhone(agency.getPhone());
    bean.setEmail(agency.getEmail());
    bean.setTimezone(agency.getTimezone());
    bean.setUrl(agency.getUrl());
    bean.setDisclaimer(agency.getDisclaimer());
    bean.setPrivateService(agency.isPrivateService());
    bean.setFareUrl(agency.getFareUrl());
    bean.setEmail(agency.getEmail());
    return bean;
}
Also used : AgencyNarrative(org.onebusaway.transit_data_federation.model.narrative.AgencyNarrative) AgencyBean(org.onebusaway.transit_data.model.AgencyBean) Cacheable(org.onebusaway.container.cache.Cacheable)

Example 7 with Cacheable

use of org.onebusaway.container.cache.Cacheable in project onebusaway-application-modules by camsys.

the class UserServiceImpl method getMinApiRequestIntervalForKey.

@Cacheable
@Transactional
@Override
public Long getMinApiRequestIntervalForKey(String key, @CacheableArgument(cacheRefreshIndicator = true) boolean forceRefresh) {
    UserIndexKey indexKey = new UserIndexKey(UserIndexTypes.API_KEY, key);
    UserIndex userIndex = getUserIndexForId(indexKey);
    if (userIndex == null) {
        return null;
    }
    User user = userIndex.getUser();
    UserBean bean = getUserAsBean(user);
    return bean.getMinApiRequestInterval();
}
Also used : UserIndex(org.onebusaway.users.model.UserIndex) UserIndexKey(org.onebusaway.users.model.UserIndexKey) User(org.onebusaway.users.model.User) UserBean(org.onebusaway.users.client.model.UserBean) Cacheable(org.onebusaway.container.cache.Cacheable) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with Cacheable

use of org.onebusaway.container.cache.Cacheable in project onebusaway-application-modules by camsys.

the class ConfigurationServiceImpl method getConfiguration.

@Override
@Cacheable
public Map<String, Object> getConfiguration(@CacheableArgument(cacheRefreshIndicator = true) boolean forceRefresh, String contextPath) {
    Map<String, Object> config = new HashMap<String, Object>();
    for (ConfigurationSource source : _sources) {
        Map<String, Object> sourceConfig = source.getConfiguration(contextPath);
        config.putAll(sourceConfig);
    }
    return config;
}
Also used : ConfigurationSource(org.onebusaway.presentation.services.configuration.ConfigurationSource) HashMap(java.util.HashMap) Cacheable(org.onebusaway.container.cache.Cacheable)

Example 9 with Cacheable

use of org.onebusaway.container.cache.Cacheable in project onebusaway-application-modules by camsys.

the class AgencyServiceImpl method getAgencyIdsAndCoverageAreas.

@Cacheable
public Map<String, CoordinateBounds> getAgencyIdsAndCoverageAreas() {
    Map<String, CoordinateBounds> boundsByAgencyId = new HashMap<String, CoordinateBounds>();
    for (AgencyEntry agency : _graph.getAllAgencies()) {
        CoordinateBounds bounds = new CoordinateBounds();
        for (RouteCollectionEntry routeCollection : agency.getRouteCollections()) {
            for (RouteEntry route : routeCollection.getChildren()) {
                for (TripEntry trip : route.getTrips()) {
                    for (StopTimeEntry stopTime : trip.getStopTimes()) {
                        StopEntry stop = stopTime.getStop();
                        bounds.addPoint(stop.getStopLat(), stop.getStopLon());
                    }
                }
            }
        }
        boundsByAgencyId.put(agency.getId(), bounds);
    }
    return boundsByAgencyId;
}
Also used : RouteEntry(org.onebusaway.transit_data_federation.services.transit_graph.RouteEntry) HashMap(java.util.HashMap) StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) RouteCollectionEntry(org.onebusaway.transit_data_federation.services.transit_graph.RouteCollectionEntry) CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds) AgencyEntry(org.onebusaway.transit_data_federation.services.transit_graph.AgencyEntry) Cacheable(org.onebusaway.container.cache.Cacheable)

Example 10 with Cacheable

use of org.onebusaway.container.cache.Cacheable in project onebusaway-application-modules by camsys.

the class RouteServiceImpl method getStopsForRouteCollection.

@Override
@Cacheable
public Collection<AgencyAndId> getStopsForRouteCollection(AgencyAndId id) {
    Set<AgencyAndId> stopIds = new HashSet<AgencyAndId>();
    RouteCollectionEntry routeCollectionEntry = _transitGraphDao.getRouteCollectionForId(id);
    for (RouteEntry route : routeCollectionEntry.getChildren()) {
        List<TripEntry> trips = route.getTrips();
        for (TripEntry trip : trips) {
            List<StopTimeEntry> stopTimes = trip.getStopTimes();
            for (StopTimeEntry stopTime : stopTimes) stopIds.add(stopTime.getStop().getId());
        }
    }
    return new ArrayList<AgencyAndId>(stopIds);
}
Also used : RouteEntry(org.onebusaway.transit_data_federation.services.transit_graph.RouteEntry) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry) ArrayList(java.util.ArrayList) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) RouteCollectionEntry(org.onebusaway.transit_data_federation.services.transit_graph.RouteCollectionEntry) HashSet(java.util.HashSet) Cacheable(org.onebusaway.container.cache.Cacheable)

Aggregations

Cacheable (org.onebusaway.container.cache.Cacheable)23 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)10 ArrayList (java.util.ArrayList)8 HashSet (java.util.HashSet)7 RouteCollectionEntry (org.onebusaway.transit_data_federation.services.transit_graph.RouteCollectionEntry)6 StopEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopEntry)6 TripEntry (org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)6 HashMap (java.util.HashMap)4 AgencyEntry (org.onebusaway.transit_data_federation.services.transit_graph.AgencyEntry)4 Date (java.util.Date)3 LocalizedServiceId (org.onebusaway.gtfs.model.calendar.LocalizedServiceId)3 ServiceDate (org.onebusaway.gtfs.model.calendar.ServiceDate)3 RouteBean (org.onebusaway.transit_data.model.RouteBean)3 ShapePoints (org.onebusaway.transit_data_federation.model.ShapePoints)3 BlockConfigurationEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)3 BlockEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockEntry)3 FactoryMap (org.onebusaway.collections.FactoryMap)2 NoSuchAgencyServiceException (org.onebusaway.exceptions.NoSuchAgencyServiceException)2 CoordinateBounds (org.onebusaway.geospatial.model.CoordinateBounds)2 CoordinatePoint (org.onebusaway.geospatial.model.CoordinatePoint)2