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

File FlavorQuery.java

 

Coverage histogram

../../../../img/srcFileCovDistChart0.png
83% of files have more coverage

Code metrics

0
15
8
1
110
46
8
0.53
1.88
8
1

Classes

Class Line # Actions
FlavorQuery 32 15 0% 8 23
0.00%
 

Contributing tests

No tests hitting this source file were found.

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.platform.flavor;
21   
22    import org.xwiki.extension.Extension;
23    import org.xwiki.extension.rating.RatingExtension;
24    import org.xwiki.extension.repository.search.ExtensionQuery;
25   
26    /**
27    * A query to an extension repository returning only flavors.
28    *
29    * @version $Id: 4c327ab94c86e7736c3236c6cacd3053316e8019 $
30    * @since 7.1M2
31    */
 
32    public class FlavorQuery extends ExtensionQuery
33    {
34    /**
35    * No filtering. Usually return all flavors.
36    */
 
37  0 toggle public FlavorQuery()
38    {
39  0 super();
40  0 init();
41    }
42   
43    /**
44    * @param query the query to execute
45    */
 
46  0 toggle public FlavorQuery(String query)
47    {
48  0 super(query);
49  0 init();
50    }
51   
52    /**
53    * @param query the query to duplicate
54    */
 
55  0 toggle public FlavorQuery(ExtensionQuery query)
56    {
57  0 super(query);
58  0 init();
59    }
60   
 
61  0 toggle private void init()
62    {
63  0 addFilter(Extension.FIELD_CATEGORY, "flavor", ExtensionQuery.COMPARISON.EQUAL);
64    }
65   
66    /**
67    * Add a filter on the flavors' name.
68    * @param name name of the flavor to find
69    * @return this query.
70    */
 
71  0 toggle public FlavorQuery filterByName(String name)
72    {
73  0 addFilter(Extension.FIELD_NAME, name, COMPARISON.MATCH);
74  0 return this;
75    }
76   
77    /**
78    * Add a filter on the flavors' summary.
79    * @param summary a summary to find on the extension repository
80    * @return this query.
81    */
 
82  0 toggle public FlavorQuery filterBySummary(String summary)
83    {
84  0 addFilter(Extension.FIELD_SUMMARY, summary, COMPARISON.MATCH);
85  0 return this;
86    }
87   
88    /**
89    * Order the results by name.
90    * @param order asc or desc
91    * @return this query.
92    */
 
93  0 toggle public FlavorQuery orderByName(ORDER order)
94    {
95  0 addSort(Extension.FIELD_NAME, order);
96  0 return this;
97    }
98   
99    /**
100    * Order the results by rating.
101    * @param order asc or desc
102    * @return this query.
103    */
 
104  0 toggle public FlavorQuery orderByRating(ORDER order)
105    {
106  0 addSort(RatingExtension.FIELD_AVERAGE_VOTE, order);
107  0 return this;
108    }
109   
110    }