use of org.onebusaway.transit_data.model.AgencyWithCoverageBean in project onebusaway-application-modules by camsys.
the class PreCacheTask method run.
@Override
public void run() {
// Clear all existing cache elements
for (String cacheName : _cacheManager.getCacheNames()) {
Cache cache = _cacheManager.getCache(cacheName);
cache.removeAll();
}
try {
List<AgencyWithCoverageBean> agenciesWithCoverage = _service.getAgenciesWithCoverage();
for (AgencyWithCoverageBean agencyWithCoverage : agenciesWithCoverage) {
AgencyBean agency = agencyWithCoverage.getAgency();
System.out.println("agency=" + agency.getId());
ListBean<String> stopIds = _service.getStopIdsForAgencyId(agency.getId());
for (String stopId : stopIds.getList()) {
System.out.println(" stop=" + stopId);
_service.getStop(stopId);
}
ListBean<String> routeIds = _service.getRouteIdsForAgencyId(agency.getId());
for (String routeId : routeIds.getList()) {
System.out.println(" route=" + routeId);
_service.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) {
System.out.println("shape=" + shapeId);
_service.getShapeForId(AgencyAndIdLibrary.convertToString(shapeId));
}
} catch (ServiceException ex) {
_log.error("service exception", ex);
}
}
use of org.onebusaway.transit_data.model.AgencyWithCoverageBean in project onebusaway-application-modules by camsys.
the class LongTermAveragesResource method getAgencyList.
private List<String> getAgencyList() {
try {
List<AgencyWithCoverageBean> agencyBeans = getTDS().getAgenciesWithCoverage();
agencyIds = new ArrayList<String>();
for (AgencyWithCoverageBean agency : agencyBeans) {
agencyIds.add(agency.getAgency().getId());
}
} catch (Exception e) {
_log.error("getAgencyList broke", e);
}
return agencyIds;
}
use of org.onebusaway.transit_data.model.AgencyWithCoverageBean in project onebusaway-application-modules by camsys.
the class RootResource method listAgencies.
@Path("list-agencies")
@GET
@Produces("application/json")
public Response listAgencies() {
List<AgencyWithCoverageBean> agenciesWithCoverage = getTDS().getAgenciesWithCoverage();
List<String> agencyIds = new ArrayList<String>();
for (AgencyWithCoverageBean bean : agenciesWithCoverage) {
agencyIds.add(bean.getAgency().getId());
}
Collections.sort(agencyIds);
StringBuffer json = new StringBuffer();
json.append("[");
for (String agency : agencyIds) {
json.append("\"");
json.append(agency);
json.append("\"");
json.append(",");
}
json.deleteCharAt(json.length() - 1);
json.append("]");
return Response.ok(json.toString()).build();
}
use of org.onebusaway.transit_data.model.AgencyWithCoverageBean in project onebusaway-application-modules by camsys.
the class AgencyResource method getAgencyIdList.
@Path("id-list")
@GET
@Produces("application/json")
public Response getAgencyIdList() {
try {
List<AgencyWithCoverageBean> agencyBeans = getTDS().getAgenciesWithCoverage();
List<String> agencyIds = new ArrayList<String>();
for (AgencyWithCoverageBean agency : agencyBeans) {
agencyIds.add(agency.getAgency().getId());
}
return Response.ok(ok("agency-id-list", agencyIds)).build();
} catch (Exception e) {
_log.error("getAgencyIdList broke", e);
return Response.ok(error("agency-id-list", e)).build();
}
}
use of org.onebusaway.transit_data.model.AgencyWithCoverageBean 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());
}
}
Aggregations