Changeset 6041


Ignore:
Timestamp:
02/24/15 13:07:22 (9 years ago)
Author:
Twan Goosen
Message:

Merged fixes to #553 from trunk

Location:
vlo/branches/vlo-3.1
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • vlo/branches/vlo-3.1

  • vlo/branches/vlo-3.1/CHANGES

    r5360 r6041  
    44* Upgraded a number of dependencies including Solr, Wicket and Spring to a more recent version
    55        <https://trac.clarin.eu/ticket/541>
    6 * A facet containing the language code was added
    7         <https://trac.clarin.eu/ticket/547>
    8 * Removed the obsolete 'imdiBrowserUrl' configuration option
     6* More fields get indexed for the autocomplete/suggestion function in the search box
     7        <https://trac.clarin.eu/ticket/624>
     8* Mapping improvements:
     9        * Fallback to fields defined by pattern (path) if no value is found in a field with a matching concept link
     10                <https://trac.clarin.eu/ticket/554>
     11                <https://trac.clarin.eu/ticket/668>
     12        * Automatic curation of values in the 'organisation' facet
     13                <https://trac.clarin.eu/ticket/683>
     14        * Better support for RFC1766 codes (such as 'en_US' and 'nl_NL')
     15                <https://trac.clarin.eu/ticket/686>
     16        * The 'language' facet is replaced by an (internal) representation based on language code if applicable
     17                <https://trac.clarin.eu/ticket/547>
     18        * Regular expressions for national project mapping
     19                <https://trac.clarin.eu/ticket/681>
     20        * Content language is stored for descriptions
     21                <https://trac.clarin.eu/ticket/667>
     22
    923
    1024VLO 3.0.1 (June 2014)
  • vlo/branches/vlo-3.1/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/pojo/FieldValuesFilter.java

    r4951 r6041  
    2121import java.util.regex.Pattern;
    2222import org.apache.solr.client.solrj.response.FacetField.Count;
     23import org.apache.wicket.util.convert.IConverter;
    2324
    2425/**
     
    6263     *
    6364     * @param count count (name + count) to check
     65     * @param converter optional converter to apply to value before comparison
    6466     * @return true IFF the {@link Count#getCount() } is more than {@link #getMinimalOccurence()
    6567     * } {@link Count#getName() } contains {@link #getName() } (case
    6668     * insensitive)
    6769     */
    68     public boolean matches(Count count) {
    69         return count.getCount() >= minimalOccurence
    70                 && (namePattern == null || namePattern.matcher(count.getName()).find());
     70    public boolean matches(Count count, IConverter<String> converter) {
     71        if (count.getCount() >= minimalOccurence) {
     72            if (namePattern == null) {
     73                // no pattern to compare to, always matches
     74                return true;
     75            } else {
     76                // convert value if converter is provided
     77                final String value;
     78                if (converter == null) {
     79                    value = count.getName();
     80                } else {
     81                    value = converter.convertToString(count.getName(), null);
     82                }
     83                return namePattern.matcher(value).find();
     84            }
     85        } else {
     86            // too few occurences, no match
     87            return false;
     88        }
    7189    }
    7290
  • vlo/branches/vlo-3.1/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/CachingConverter.java

    r6029 r6041  
    6767    public CachingConverter(IConverter<C> converter) {
    6868        this.inner = converter;
     69    }
     70
     71    /**
     72     * Convenience factory method for wrapping a converter
     73     *
     74     * @param <C> The object to convert from and to String
     75     * @param inner converter to wrap, can be null
     76     * @return a new {@link CachingConverter} instance wrapping the inner
     77     * converter, or null if inner is null
     78     */
     79    public static <C> IConverter<C> wrap(IConverter<C> inner) {
     80        if (inner == null) {
     81            return null;
     82        } else {
     83            return new CachingConverter(inner);
     84        }
    6985    }
    7086
  • vlo/branches/vlo-3.1/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/provider/FacetFieldValuesProvider.java

    r6029 r6041  
    5151 */
    5252public class FacetFieldValuesProvider extends SortableDataProvider<FacetField.Count, FieldValuesOrder> implements ListProvider<FacetField.Count> {
    53    
     53
    5454    private final static Logger logger = LoggerFactory.getLogger(FacetFieldValuesProvider.class);
    5555    private final IModel<FacetField> model;
     
    9090        this(model, max, lowPriorityValues, new SortParam<FieldValuesOrder>(FieldValuesOrder.COUNT, false), fieldValueConverterProvider);
    9191    }
    92    
     92
    9393    public FacetFieldValuesProvider(IModel<FacetField> model, int max, SortParam<FieldValuesOrder> sort, FieldValueConverterProvider fieldValueConverterProvider) {
    9494        this(model, max, null, sort, fieldValueConverterProvider);
     
    120120        return null;
    121121    }
    122    
     122
    123123    @Override
    124124    public Iterator<? extends FacetField.Count> iterator(long first, long count) {
     
    126126        return getList().listIterator((int) first);
    127127    }
    128    
     128
    129129    @Override
    130130    public List<? extends FacetField.Count> getList() {
     
    139139        }
    140140    }
    141    
     141
    142142    @Override
    143143    public long size() {
     
    147147        return size;
    148148    }
    149    
     149
    150150    @Override
    151151    public IModel<FacetField.Count> model(FacetField.Count object) {
     
    158158    private Iterable<FacetField.Count> filter(List<FacetField.Count> list) {
    159159        if (hasFilter()) {
     160            final IConverter<String> converter = fieldValueConverterProvider.getConverter(model.getObject().getName());
    160161            return Iterables.filter(list, new Predicate<FacetField.Count>() {
    161162                @Override
    162163                public boolean apply(Count input) {
    163                     return getFilterModel().getObject().matches(input);
     164                    return getFilterModel().getObject().matches(input, converter);
    164165                }
    165166            });
     
    168169        }
    169170    }
    170    
     171
    171172    private Iterable<Count> getFilteredValues() {
    172173        if (filtered == null) {
     
    177178        return filtered;
    178179    }
    179    
     180
    180181    private long getSize() {
    181182        if (hasFilter()) {
     
    189190        }
    190191    }
    191    
     192
    192193    private boolean hasFilter() {
    193194        return getFilterModel() != null && getFilterModel().getObject() != null && !getFilterModel().getObject().isEmpty();
     
    207208        }
    208209    }
    209    
     210
    210211    private Ordering getBaseOrdering() {
    211212        final Ordering ordering;
     
    217218            ordering = Ordering.natural();
    218219        }
    219        
     220
    220221        if (getSort().isAscending()) {
    221222            return ordering;
     
    224225        }
    225226    }
    226    
     227
    227228    protected Locale getLocale() {
    228229        try {
     
    236237        return Locale.getDefault();
    237238    }
    238    
     239
    239240    private final static class CountOrdering extends Ordering<FacetField.Count> {
    240        
     241
    241242        @Override
    242243        public int compare(Count arg0, Count arg1) {
     
    244245        }
    245246    };
    246    
     247
    247248    private final static class NameOrdering extends Ordering<FacetField.Count> implements Serializable {
    248        
     249
    249250        private final Collator collator;
    250251        private final IConverter converter;
    251252        private final Locale locale;
    252        
     253
    253254        public NameOrdering(Locale locale, IConverter<String> converter) {
    254255            collator = Collator.getInstance(locale);
    255256            collator.setStrength(Collator.PRIMARY);
    256             this.converter = new CachingConverter(converter);
     257            this.converter = CachingConverter.wrap(converter);
    257258            this.locale = locale;
    258259        }
    259        
     260
    260261        @Override
    261262        public int compare(Count arg0, Count arg1) {
     
    275276     */
    276277    private static class PriorityOrdering extends Ordering<FacetField.Count> {
    277        
     278
    278279        private final Collection<String> lowPriorityValues;
    279        
     280
    280281        public PriorityOrdering(Collection<String> lowPriorityValues) {
    281282            this.lowPriorityValues = lowPriorityValues;
    282283        }
    283        
     284
    284285        @Override
    285286        public int compare(Count arg0, Count arg1) {
    286            
     287
    287288            if (lowPriorityValues.contains(arg0.getName())) {
    288289                if (!lowPriorityValues.contains(arg1.getName())) {
     
    298299            return 0;
    299300        }
    300        
     301
    301302    };
    302    
     303
    303304    @Override
    304305    public void detach() {
Note: See TracChangeset for help on using the changeset viewer.