001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.search;
016    
017    import com.browseengine.bobo.api.BrowseFacet;
018    import com.browseengine.bobo.api.FacetAccessible;
019    
020    import com.liferay.portal.kernel.search.facet.collector.FacetCollector;
021    import com.liferay.portal.kernel.search.facet.collector.TermCollector;
022    
023    import java.util.ArrayList;
024    import java.util.List;
025    
026    /**
027     * @author Raymond Augé
028     */
029    public class BoboFacetCollector implements FacetCollector {
030    
031            public BoboFacetCollector(
032                    String fieldName, FacetAccessible facetAccessible) {
033    
034                    _fieldName = fieldName;
035                    _facetAccessible = facetAccessible;
036    
037                    for (BrowseFacet browseFacet : _facetAccessible.getFacets()) {
038                            _termCollectors.add(new BoboTermCollector(browseFacet));
039                    }
040            }
041    
042            public String getFieldName() {
043                    return _fieldName;
044            }
045    
046            public TermCollector getTermCollector(String term) {
047                    return new BoboTermCollector(_facetAccessible.getFacet(term));
048            }
049    
050            public List<TermCollector> getTermCollectors() {
051                    return _termCollectors;
052            }
053    
054            private FacetAccessible _facetAccessible;
055            private String _fieldName;
056            private List<TermCollector> _termCollectors =
057                    new ArrayList<TermCollector>();
058    
059    }