Class AbstractTagCloudGenerator
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.apache.cocoon.xml.AbstractXMLProducer
-
- org.apache.cocoon.generation.AbstractGenerator
-
- org.apache.cocoon.generation.ServiceableGenerator
-
- org.ametys.plugins.tagcloud.generators.AbstractTagCloudGenerator
-
- All Implemented Interfaces:
Poolable
,Recyclable
,Disposable
,Component
,Contextualizable
,LogEnabled
,Serviceable
,Generator
,SitemapModelComponent
,XMLProducer
- Direct Known Subclasses:
TagCloudOnTagsGenerator
,TagCloudOnWordsGenerator
public abstract class AbstractTagCloudGenerator extends ServiceableGenerator implements Contextualizable
Generator for tag clouds
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractTagCloudGenerator.ItemOccurrenceComparator
Compares two terms by descending occurrence count.protected static interface
AbstractTagCloudGenerator.TagCloudItem
Abstract class for a tag cloud item
-
Field Summary
Fields Modifier and Type Field Description protected TagCloudCacheManager
_cacheManager
The cache managerprotected Context
_context
The contextprotected AmetysObjectResolver
_resolver
The Ametys object resolverprotected org.apache.solr.client.solrj.SolrClient
_solrClient
The solr client.protected SolrClientProvider
_solrClientProvider
The solr client provider.protected static Comparator<AbstractTagCloudGenerator.TagCloudItem>
OCCURRENCE_COMPARATOR
Compares tag cloud items-
Fields inherited from class org.apache.cocoon.generation.ServiceableGenerator
manager
-
Fields inherited from class org.apache.cocoon.generation.AbstractGenerator
objectModel, parameters, resolver, source
-
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
-
-
Constructor Summary
Constructors Constructor Description AbstractTagCloudGenerator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
_addContentTypeQuery(Collection<Query> queries, String[] cTypes)
Add content types term query to the queries.protected void
_addPagesQuery(Collection<Query> queries, String[] pageIds)
Add pages term query to the queriesprotected int
_getFontSize(int nb, int min, int max)
Get the font sizeprotected void
_saxAdditionalAttributes(AbstractTagCloudGenerator.TagCloudItem item, AttributesImpl attrs)
Sax additional attributes for itemprotected void
_saxContentTypeCriteria(String[] cTypes)
SAX the content types criteriaprotected void
_saxFormParameters(String[] cTypes, String[] pages)
SAX teh form search criteriaprotected void
_saxSitemapCriteria(String[] pages)
SAX the pages criteriaprotected org.apache.solr.client.solrj.SolrQuery
build(Query query)
Build aSolrQuery
from a Query object.void
contextualize(Context context)
void
generate()
protected abstract List<AbstractTagCloudGenerator.TagCloudItem>
getTagCloudItems(String siteName, String lang, ModelAwareDataHolder serviceParameters)
Get the tag cloud itemsprotected void
saxTagCloudItem(AbstractTagCloudGenerator.TagCloudItem item, int min, int max)
Sax a tag cloud itemvoid
service(ServiceManager serviceManager)
-
Methods inherited from class org.apache.cocoon.generation.ServiceableGenerator
dispose
-
Methods inherited from class org.apache.cocoon.generation.AbstractGenerator
recycle, setup
-
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
setConsumer, setContentHandler, setLexicalHandler
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
-
-
-
-
Field Detail
-
OCCURRENCE_COMPARATOR
protected static final Comparator<AbstractTagCloudGenerator.TagCloudItem> OCCURRENCE_COMPARATOR
Compares tag cloud items
-
_resolver
protected AmetysObjectResolver _resolver
The Ametys object resolver
-
_cacheManager
protected TagCloudCacheManager _cacheManager
The cache manager
-
_solrClientProvider
protected SolrClientProvider _solrClientProvider
The solr client provider.
-
_solrClient
protected org.apache.solr.client.solrj.SolrClient _solrClient
The solr client.
-
-
Constructor Detail
-
AbstractTagCloudGenerator
public AbstractTagCloudGenerator()
-
-
Method Detail
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classServiceableGenerator
- Throws:
ServiceException
-
generate
public void generate() throws IOException, SAXException, ProcessingException
- Specified by:
generate
in interfaceGenerator
- Throws:
IOException
SAXException
ProcessingException
-
getTagCloudItems
protected abstract List<AbstractTagCloudGenerator.TagCloudItem> getTagCloudItems(String siteName, String lang, ModelAwareDataHolder serviceParameters) throws IOException, ProcessingException
Get the tag cloud items- Parameters:
siteName
- The site namelang
- The languageserviceParameters
- The service parameters- Returns:
- The list og tag cloud item
- Throws:
IOException
- if an error occurs when manipulating filesProcessingException
- if an error occurs during the retrieving of the tag cloud items
-
saxTagCloudItem
protected void saxTagCloudItem(AbstractTagCloudGenerator.TagCloudItem item, int min, int max) throws SAXException
Sax a tag cloud item- Parameters:
item
- The tag cloud item to saxmin
- The min number of occurrencemax
- The max number of occurrence- Throws:
SAXException
- if an error occurs while saxing
-
build
protected org.apache.solr.client.solrj.SolrQuery build(Query query) throws QuerySyntaxException
Build aSolrQuery
from a Query object.- Parameters:
query
- the Query object.- Returns:
- The SolrQuery.
- Throws:
QuerySyntaxException
- if an error occurs.
-
_saxAdditionalAttributes
protected void _saxAdditionalAttributes(AbstractTagCloudGenerator.TagCloudItem item, AttributesImpl attrs) throws SAXException
Sax additional attributes for item- Parameters:
item
- The tag cloud itemattrs
- The attributes- Throws:
SAXException
- if an error occurs while saxing
-
_addContentTypeQuery
protected void _addContentTypeQuery(Collection<Query> queries, String[] cTypes)
Add content types term query to the queries.- Parameters:
queries
- The query collection.cTypes
- the content types. Can be empty or null
-
_addPagesQuery
protected void _addPagesQuery(Collection<Query> queries, String[] pageIds)
Add pages term query to the queries- Parameters:
queries
- The query collection.pageIds
- The page IDs.
-
_saxFormParameters
protected void _saxFormParameters(String[] cTypes, String[] pages) throws SAXException
SAX teh form search criteria- Parameters:
cTypes
- the content typespages
- the pages- Throws:
SAXException
- if an error occurred while SAXing
-
_getFontSize
protected int _getFontSize(int nb, int min, int max)
Get the font size- Parameters:
nb
- the number of occurrencemin
- the min number of occurrencemax
- the max number of occurrence- Returns:
- the font size
-
_saxContentTypeCriteria
protected void _saxContentTypeCriteria(String[] cTypes) throws SAXException
SAX the content types criteria- Parameters:
cTypes
- the content types- Throws:
SAXException
- if an error occurred while SAXing
-
_saxSitemapCriteria
protected void _saxSitemapCriteria(String[] pages) throws SAXException
SAX the pages criteria- Parameters:
pages
- the pages- Throws:
SAXException
- if an error occurred while SAXing
-
-