diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/capabilitymap/CapabilityMapRequestHandler.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/capabilitymap/CapabilityMapRequestHandler.java index 0054324e..4b1b0481 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/capabilitymap/CapabilityMapRequestHandler.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/capabilitymap/CapabilityMapRequestHandler.java @@ -50,10 +50,10 @@ public class CapabilityMapRequestHandler implements VisualizationRequestHandler @Override public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log, Dataset dataSource) throws MalformedQueryParametersException { - ConceptLabelMap conceptLabelMap = VisualizationCaches.conceptToLabel.get(vitroRequest.getRDFService()); - ConceptPeopleMap conceptPeopleMap = VisualizationCaches.conceptToPeopleMap.get(vitroRequest.getRDFService()); - OrganizationPeopleMap organizationPeopleMap = VisualizationCaches.organisationToPeopleMap.get(vitroRequest.getRDFService()); - Map organizationLabels = VisualizationCaches.organizationLabels.get(vitroRequest.getRDFService()); + ConceptLabelMap conceptLabelMap = VisualizationCaches.conceptToLabel.getNoWait(vitroRequest.getRDFService()); + ConceptPeopleMap conceptPeopleMap = VisualizationCaches.conceptToPeopleMap.getNoWait(vitroRequest.getRDFService()); + OrganizationPeopleMap organizationPeopleMap = VisualizationCaches.organisationToPeopleMap.getNoWait(vitroRequest.getRDFService()); + Map organizationLabels = VisualizationCaches.organizationLabels.getNoWait(vitroRequest.getRDFService()); String data = vitroRequest.getParameter("data"); if (!StringUtils.isEmpty(data)) { diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/utilities/CachingRDFServiceExecutor.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/utilities/CachingRDFServiceExecutor.java index bd211d7d..b2265510 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/utilities/CachingRDFServiceExecutor.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/visualization/utilities/CachingRDFServiceExecutor.java @@ -61,6 +61,26 @@ public class CachingRDFServiceExecutor { * @param rdfService an RDF service to use, in foreground mode, if the background service is missing */ public synchronized T get(RDFService rdfService) { + return get(rdfService, false); + } + + /** + * Return the cached results if present, or start the task. + * Will wait for completion if the cache is not already populated, otherwise the refresh will happen in the background. + * + * @param rdfService an RDF service to use, in foreground mode, if the background service is missing + */ + public synchronized T getNoWait(RDFService rdfService) { + return get(rdfService, true); + } + + /** + * Return the cached results if present, or start the task. + * Will wait for completion if the cache is not already populated, otherwise the refresh will happen in the background. + * + * @param rdfService an RDF service to use, in foreground mode, if the background service is missing + */ + public synchronized T get(RDFService rdfService, boolean allowWaits) { // First, check if there are results from the previous background task, and update the cache if (backgroundTask != null && backgroundTask.isDone()) { completeBackgroundTask(); @@ -77,7 +97,7 @@ public class CachingRDFServiceExecutor { startBackgroundTask(rdfService); // See if we expect it to complete in time, and if so, wait for it - if (isExpectedToCompleteIn(waitFor)) { + if (allowWaits && isExpectedToCompleteIn(waitFor)) { completeBackgroundTask(waitFor); } }