1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.query.internal

File AbstractHiddenFilter.java

 

Coverage histogram

../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

2
7
3
1
80
37
4
0.57
2.33
3
1.33

Classes

Class Line # Actions
AbstractHiddenFilter 39 7 0% 4 0
1.0100%
 

Contributing tests

This file is covered by 20 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.query.internal;
21   
22    import java.util.List;
23   
24    import javax.inject.Inject;
25    import javax.inject.Named;
26   
27    import org.xwiki.component.annotation.InstantiationStrategy;
28    import org.xwiki.component.descriptor.ComponentInstantiationStrategy;
29    import org.xwiki.component.phase.Initializable;
30    import org.xwiki.configuration.ConfigurationSource;
31   
32    /**
33    * Base class for filtering hidden entities.
34    *
35    * @version $Id: 3a8eb5efe120010ba13f144ce6fec7d3549d828e $
36    * @since 7.2M2
37    */
38    @InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP)
 
39    public abstract class AbstractHiddenFilter extends AbstractWhereQueryFilter implements Initializable
40    {
41    /**
42    * Used to retrieve user preference regarding hidden documents.
43    */
44    @Inject
45    @Named("user")
46    private ConfigurationSource userPreferencesSource;
47   
48    /**
49    * @see #initialize()
50    */
51    private boolean isActive;
52   
53    /**
54    * Sets the #isActive property, based on the user configuration.
55    */
 
56  795 toggle @Override
57    public void initialize()
58    {
59  795 Integer preference = userPreferencesSource.getProperty("displayHiddenDocuments", Integer.class);
60  795 isActive = preference == null || preference != 1;
61    }
62   
 
63  808 toggle @Override
64    public String filterStatement(String statement, String language)
65    {
66  808 String result = statement;
67  808 if (isActive) {
68  806 result = filterHidden(statement, language);
69    }
70  808 return result;
71    }
72   
73    protected abstract String filterHidden(String statement, String language);
74   
 
75  788 toggle @Override
76    public List filterResults(List results)
77    {
78  788 return results;
79    }
80    }