Class VClassGroupCache
- java.lang.Object
-
- edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache
-
- All Implemented Interfaces:
SearchIndexer.Listener
public class VClassGroupCache extends Object implements SearchIndexer.Listener
This is a cache of classgroups with classes. Each class should have a count of individuals. These counts are cached so they don't have to be recomputed. The cache is updated asynchronously by the thread RebuildGroupCacheThread. A synchronous rebuild can be performed with VClassGroupCache.doSynchronousRebuild() This class should handle the condition where the search engine is not available. It will not throw an exception but it will return a empty list of classes or class groups. VClassGroupCache.doSynchronousRebuild() and the RebuildGroupCacheThread will try to connect to the search engine a couple of times and then give up. As of VIVO release 1.4, the counts come from the search index. If the search index is not built or if there were problems building the index, the class counts from VClassGroupCache will be incorrect.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classVClassGroupCache.RebuildGroupCacheThreadstatic classVClassGroupCache.Setupprotected classVClassGroupCache.VClassGroupCacheChangeListenerListen for changes to what class group classes are in and their display rank.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static voidaddClassCountsToGroup(VClassGroup group, SearchEngine searchEngine)protected static voidaddCountsUsingSearch(List<VClassGroup> groups, SearchEngine searchEngine)Add the Individual count to classes in groups.protected static Map<String,VClass>classMapForGroups(List<VClassGroup> groups)voiddoSynchronousRebuild()VClassgetCachedVClass(String classUri)VClassGroupgetGroup(String vClassGroupURI)List<VClassGroup>getGroups()protected VClassGroupDaogetVCGDao()static VClassGroupCachegetVClassGroupCache(javax.servlet.ServletContext sc)Use getVClassGroupCache(ServletContext) to get a VClassGroupCache.static VClassGroupsForRequestgetVClassGroups(javax.servlet.http.HttpServletRequest req)Use getVClassGroups(HttpServletRequest) to get a language-aware image of the cached groups and classes.protected static booleanisClassNameChange(org.apache.jena.rdf.model.Statement stmt, org.apache.jena.ontology.OntModel jenaOntModel)voidpause()protected static voidrebuildCacheUsingSearch(VClassGroupCache cache)Method that rebuilds the cache.voidreceiveSearchIndexerEvent(SearchIndexer.Event event)Handle notification of events from the IndexBuilder.voidrequestCacheUpdate()protected voidrequestStop()protected voidsetCache(List<VClassGroup> newGroups, Map<String,VClass> classMap)protected static voidsetClassCount(VClassGroup group, String classUri, long individualsInClass)voidunpause()
-
-
-
Method Detail
-
getGroup
public VClassGroup getGroup(String vClassGroupURI)
-
getGroups
public List<VClassGroup> getGroups()
-
setCache
protected void setCache(List<VClassGroup> newGroups, Map<String,VClass> classMap)
-
pause
public void pause()
-
unpause
public void unpause()
-
requestCacheUpdate
public void requestCacheUpdate()
-
requestStop
protected void requestStop()
-
getVCGDao
protected VClassGroupDao getVCGDao()
-
doSynchronousRebuild
public void doSynchronousRebuild()
-
receiveSearchIndexerEvent
public void receiveSearchIndexerEvent(SearchIndexer.Event event)
Handle notification of events from the IndexBuilder.- Specified by:
receiveSearchIndexerEventin interfaceSearchIndexer.Listener
-
getVClassGroupCache
public static VClassGroupCache getVClassGroupCache(javax.servlet.ServletContext sc)
Use getVClassGroupCache(ServletContext) to get a VClassGroupCache.
-
getVClassGroups
public static VClassGroupsForRequest getVClassGroups(javax.servlet.http.HttpServletRequest req)
Use getVClassGroups(HttpServletRequest) to get a language-aware image of the cached groups and classes.
-
rebuildCacheUsingSearch
protected static void rebuildCacheUsingSearch(VClassGroupCache cache) throws SearchEngineException
Method that rebuilds the cache. This will use a WebappDaoFactory and a SearchEngine.- Throws:
SearchEngineException
-
classMapForGroups
protected static Map<String,VClass> classMapForGroups(List<VClassGroup> groups)
-
addCountsUsingSearch
protected static void addCountsUsingSearch(List<VClassGroup> groups, SearchEngine searchEngine) throws SearchEngineException
Add the Individual count to classes in groups.- Throws:
SearchEngineException
-
addClassCountsToGroup
protected static void addClassCountsToGroup(VClassGroup group, SearchEngine searchEngine) throws SearchEngineException
- Throws:
SearchEngineException
-
setClassCount
protected static void setClassCount(VClassGroup group, String classUri, long individualsInClass)
-
isClassNameChange
protected static boolean isClassNameChange(org.apache.jena.rdf.model.Statement stmt, org.apache.jena.ontology.OntModel jenaOntModel)
-
-