use of org.onebusaway.container.refresh.Refreshable in project onebusaway-application-modules by camsys.
the class BundleSearchServiceImpl method init.
@PostConstruct
@Refreshable(dependsOn = { RefreshableResources.ROUTE_COLLECTIONS_DATA, RefreshableResources.TRANSIT_GRAPH })
public void init() {
Runnable initThread = new Runnable() {
@Override
public void run() {
while (!_initialized) {
try {
Thread.sleep(1 * 1000);
} catch (InterruptedException e) {
return;
}
}
_log.info("building cache");
Map<String, List<String>> tmpSuggestions = Collections.synchronizedMap(new HashMap<String, List<String>>());
Map<String, List<CoordinateBounds>> agencies = _transitDataService.getAgencyIdsWithCoverageArea();
for (String agency : agencies.keySet()) {
ListBean<RouteBean> routes = _transitDataService.getRoutesForAgencyId(agency);
for (RouteBean route : routes.getList()) {
String shortName = route.getShortName();
generateInputsForString(tmpSuggestions, shortName, "\\s+");
}
ListBean<String> stopIds = _transitDataService.getStopIdsForAgencyId(agency);
for (String stopId : stopIds.getList()) {
if (_transitDataService.stopHasRevenueService(agency, stopId)) {
AgencyAndId agencyAndId = AgencyAndIdLibrary.convertFromString(stopId);
generateInputsForString(tmpSuggestions, agencyAndId.getId(), null);
}
}
}
suggestions = tmpSuggestions;
_log.info("complete");
}
};
new Thread(initThread).start();
}
use of org.onebusaway.container.refresh.Refreshable in project onebusaway-application-modules by camsys.
the class BundleConfigDao method setup.
@PostConstruct
@Refreshable(dependsOn = RefreshableResources.TRANSIT_GRAPH)
public void setup() throws IOException, ClassNotFoundException {
_meta = null;
File path = _bundle.getBundleMetadataPath();
_log.info("looking for metadata file " + path);
if (path.exists()) {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
BundleMetadata meta = null;
try {
meta = mapper.readValue(path, BundleMetadata.class);
} catch (Exception any) {
_log.error("reading metadata failed:", any);
}
if (meta != null) {
_meta = meta;
}
} else {
_log.error(" did not find metadata file " + path);
}
}
use of org.onebusaway.container.refresh.Refreshable in project onebusaway-application-modules by camsys.
the class TransitGraphDaoImpl method setup.
@PostConstruct
@Refreshable(dependsOn = RefreshableResources.TRANSIT_GRAPH)
public void setup() throws IOException, ClassNotFoundException {
File path = _bundle.getTransitGraphPath();
if (_graph != null) {
TransitGraphImpl graph = (TransitGraphImpl) _graph;
graph.empty();
_graph = null;
}
if (path.exists()) {
TransitGraphImpl graph = ObjectSerializationLibrary.readObject(path);
graph.initialize();
_graph = graph;
} else {
_graph = new TransitGraphImpl();
}
}
use of org.onebusaway.container.refresh.Refreshable in project onebusaway-application-modules by camsys.
the class RefreshableCalendarServiceImpl method setup.
@PostConstruct
@Refreshable(dependsOn = RefreshableResources.CALENDAR_DATA)
public void setup() throws IOException, ClassNotFoundException {
File path = _bundle.getCalendarServiceDataPath();
if (path.exists()) {
CalendarServiceData data = ObjectSerializationLibrary.readObject(path);
setData(data);
} else {
setData(new CalendarServiceData());
}
}
use of org.onebusaway.container.refresh.Refreshable in project onebusaway-application-modules by camsys.
the class RouteCollectionSearchServiceImpl method initialize.
@PostConstruct
@Refreshable(dependsOn = RefreshableResources.ROUTE_COLLECTION_SEARCH_DATA)
public void initialize() throws IOException {
File path = _bundle.getRouteSearchIndexPath();
if (path.exists()) {
IndexReader reader = IndexReader.open(path);
_searcher = new IndexSearcher(reader);
} else {
_searcher = null;
}
}
Aggregations