Changeset 4973


Ignore:
Timestamp:
04/14/14 15:09:07 (10 years ago)
Author:
Twan Goosen
Message:

Added breadcrumbs rendering for content search filter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/BreadCrumbPanel.java

    r4963 r4973  
    1717package eu.clarin.cmdi.vlo.wicket.panels;
    1818
     19import eu.clarin.cmdi.vlo.FacetConstants;
    1920import eu.clarin.cmdi.vlo.pojo.FacetSelection;
    2021import eu.clarin.cmdi.vlo.pojo.QueryFacetsSelection;
     
    9495
    9596            @Override
    96             protected void populateItem(Item<Map.Entry<String, FacetSelection>> item) {
     97            protected void populateItem(final Item<Map.Entry<String, FacetSelection>> item) {
    9798                final IModel<Map.Entry<String, FacetSelection>> selectionModel = item.getModel();
    9899                // add a label for the selected facet value(s)
     
    102103                    public <C> IConverter<C> getConverter(Class<C> type) {
    103104                        // converter to render the value(s) nicely
    104                         return (IConverter<C>) selectionConverter;
     105                        return (IConverter<C>) new SelectionConverter(item.getModelObject().getKey());
    105106                    }
    106107
     
    145146     * collection (if singleton, show its value; if multiple, comma separated)
    146147     */
    147     private final static IConverter<FacetSelection> selectionConverter = new IConverter<FacetSelection>() {
     148    private class SelectionConverter implements IConverter<FacetSelection> {
     149
     150        private final String facet;
     151
     152        public SelectionConverter(String facet) {
     153            this.facet = facet;
     154        }
    148155
    149156        @Override
     
    154161        @Override
    155162        public String convertToString(FacetSelection selection, Locale locale) {
     163            switch (selection.getSelectionType()) {
     164                case AND:
     165                    return getCollectionString(selection, " and ");
     166                case OR:
     167                    return getCollectionString(selection, " or ");
     168                case NOT:
     169                    return "not [" + getCollectionString(selection, " or ") + "]";
     170                case NOT_EMPTY:
     171                    return getAnyValueString();
     172                default:
     173                    return facet;
     174            }
     175
     176        }
     177
     178        private String getAnyValueString() {
     179            if (FacetConstants.FIELD_SEARCH_SERVICE.equals(facet)) {
     180                return "Content searchable";
     181            }
     182            return "any " + facet;
     183        }
     184
     185        public String getCollectionString(FacetSelection selection, String valueSeparator) {
    156186            final Collection<String> value = selection.getValues();
    157187            //TODO: include selection type
     
    164194                final StringBuilder sb = new StringBuilder(iterator.next());
    165195                while (iterator.hasNext()) {
    166                     sb.append(", ").append(iterator.next());
     196                    sb.append(valueSeparator).append(iterator.next());
    167197                }
    168198                return sb.toString();
Note: See TracChangeset for help on using the changeset viewer.