Changeset 4597


Ignore:
Timestamp:
02/28/14 12:37:17 (10 years ago)
Author:
Twan Goosen
Message:

Added method to vlo config to get all facets, including collection facet. using this when sanitising input in web app

Location:
vlo/branches/vlo-3.0
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • vlo/branches/vlo-3.0/vlo-commons/src/main/java/eu/clarin/cmdi/vlo/config/VloConfig.java

    r4584 r4597  
    697697
    698698    /**
     699     *
     700     * @return all facet fields, including collection facet (arbitrary order unspecified)
     701     * @see #getFacetFields()
     702     * @see #getCollectionFacet()
     703     */
     704    public List<String> getAllFacetFields() {
     705        final ArrayList<String> allFacets = new ArrayList<String>(facetField);
     706        allFacets.add(getCollectionFacet());
     707        return allFacets;
     708    }
     709
     710    /**
    699711     * Set the value of the FacetFields parameter<br><br>
    700712     *
  • vlo/branches/vlo-3.0/vlo-commons/src/test/java/eu/clarin/cmdi/vlo/config/DefaultVloConfigFactoryTest.java

    r4584 r4597  
    66import java.util.ArrayList;
    77import java.util.Arrays;
     8import java.util.HashSet;
    89import java.util.List;
     10import java.util.Set;
     11import static org.hamcrest.CoreMatchers.hasItems;
    912import static org.junit.Assert.*;
    1013import org.junit.Before;
     
    698701    }
    699702
     703    @Test
     704    public void testGetAllFacetsField() {
     705        final String[] expItems = new String[]{
     706            "language",
     707            "resourceClass",
     708            "modality",
     709            "continent",
     710            "genre",
     711            "country",
     712            "subject",
     713            "organisation",
     714            "format",
     715            "dataProvider",
     716            "nationalProject",
     717            "keywords",
     718            "collection"};
     719        List<String> result = config.getAllFacetFields();
     720       
     721        //order is not important in this case
     722        assertThat(result, hasItems(expItems));
     723    }
     724
    700725    /**
    701726     * Test of setFacetFields method, of class VloConfig
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/config/VloSpringConfig.java

    r4584 r4597  
    7878    @Bean
    7979    public SolrFacetQueryFactory facetQueryFactory() {
    80         final ArrayList<String> facets = Lists.newArrayList(vloConfig().getFacetFields());
    81         //TODO: get collections facet from config
    82         facets.add(vloConfig().getCollectionFacet());
    83 
    84         return new SolrFacetQueryFactoryImpl(facets);
     80        return new SolrFacetQueryFactoryImpl(vloConfig().getAllFacetFields());
    8581    }
    8682
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/service/impl/SolrDaoImpl.java

    r4572 r4597  
    5555            // present the facets from the config file as a list to a new set
    5656            Set<String> facetsDefined;
    57             facetsDefined = new HashSet<String>(config.getFacetFields());
     57            facetsDefined = new HashSet<String>(config.getAllFacetFields());
    5858
    5959            // check the filters in the query by name
Note: See TracChangeset for help on using the changeset viewer.