Revision fde7c010
Added by Andreas Kohlbecker almost 6 years ago
src/main/java/eu/etaxonomy/cdm/service/CdmFilterablePagingProvider.java | ||
---|---|---|
119 | 119 |
/** |
120 | 120 |
* {@inheritDoc} |
121 | 121 |
*/ |
122 |
@SuppressWarnings("unchecked") |
|
122 | 123 |
@Override |
123 | 124 |
public List<V> findEntities(int firstRow, String filter) { |
124 | 125 |
|
126 |
checkNotMixed(); |
|
127 |
|
|
125 | 128 |
Integer pageIndex = firstRow / pageSize; |
126 | 129 |
Pager<V> page; |
127 |
if(!restrictions.isEmpty() && criteria.isEmpty()){
|
|
130 |
if(!restrictions.isEmpty()){ |
|
128 | 131 |
page = (Pager<V>) service.findByTitleWithRestrictions( |
129 | 132 |
type, |
130 | 133 |
filter, |
... | ... | |
135 | 138 |
orderHints, |
136 | 139 |
initStrategy |
137 | 140 |
); |
138 |
} else if(restrictions.isEmpty() && !criteria.isEmpty()){
|
|
141 |
} else { |
|
139 | 142 |
page = (Pager<V>) service.findByTitle( |
140 | 143 |
type, |
141 | 144 |
filter, |
... | ... | |
146 | 149 |
orderHints, |
147 | 150 |
initStrategy |
148 | 151 |
); |
149 |
} else { |
|
150 |
// this will never be reaced sind the size() method is always called before. |
|
151 |
throw new RuntimeException("Citeria and Restrictions must not be used at the same time"); |
|
152 | 152 |
} |
153 |
|
|
153 | 154 |
if(logger.isTraceEnabled()){ |
154 | 155 |
logger.trace("findEntities() - page: " + page.getCurrentIndex() + "/" + page.getPagesAvailable() + " totalRecords: " + page.getCount() + "\n" + page.getRecords()); |
155 | 156 |
} |
... | ... | |
159 | 160 |
/** |
160 | 161 |
* {@inheritDoc} |
161 | 162 |
*/ |
163 |
@SuppressWarnings("unchecked") |
|
162 | 164 |
@Override |
163 | 165 |
public int size(String filter) { |
164 | 166 |
|
167 |
checkNotMixed(); |
|
168 |
|
|
165 | 169 |
Pager<V> page; |
166 |
if(!restrictions.isEmpty() && criteria.isEmpty()){
|
|
170 |
if(!restrictions.isEmpty()){ |
|
167 | 171 |
page = (Pager<V>) service.findByTitleWithRestrictions( |
168 | 172 |
type, |
169 | 173 |
filter, |
... | ... | |
174 | 178 |
null, |
175 | 179 |
null |
176 | 180 |
); |
177 |
} else if(restrictions.isEmpty() && !criteria.isEmpty()){
|
|
181 |
} else { |
|
178 | 182 |
page = (Pager<V>) service.findByTitle( |
179 | 183 |
type, |
180 | 184 |
filter, |
... | ... | |
185 | 189 |
null, |
186 | 190 |
null |
187 | 191 |
); |
188 |
} else { |
|
189 |
throw new RuntimeException("Citeria and Restrictions must not be used at the same time"); |
|
190 | 192 |
} |
191 | 193 |
|
192 | 194 |
if(logger.isTraceEnabled()){ |
... | ... | |
195 | 197 |
return page.getCount().intValue(); |
196 | 198 |
} |
197 | 199 |
|
200 |
/** |
|
201 |
* |
|
202 |
*/ |
|
203 |
protected void checkNotMixed() { |
|
204 |
if(!restrictions.isEmpty() && !criteria.isEmpty()){ |
|
205 |
throw new RuntimeException("Citeria and Restrictions must not be used at the same time"); |
|
206 |
} |
|
207 |
} |
|
208 |
|
|
198 | 209 |
/** |
199 | 210 |
* @return the pageSize |
200 | 211 |
*/ |
Also available in: Unified diff
ref #7523 fixing bug in CdmFilterablePagingProvider