Revision ea33ac4f
Added by Andreas Müller almost 6 years ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/agent/IAgentDao.java | ||
---|---|---|
40 | 40 |
* @param person the person |
41 | 41 |
* @return a count of InstitutionalMembership instances |
42 | 42 |
*/ |
43 |
public int countInstitutionalMemberships(Person person);
|
|
43 |
public long countInstitutionalMemberships(Person person);
|
|
44 | 44 |
|
45 | 45 |
/** |
46 | 46 |
* Return a List of members of a given team |
... | ... | |
58 | 58 |
* @param team the team |
59 | 59 |
* @return a count of Person instances |
60 | 60 |
*/ |
61 |
public int countMembers(Team team);
|
|
61 |
public long countMembers(Team team);
|
|
62 | 62 |
|
63 | 63 |
/** |
64 | 64 |
* Return a count of addresses of a given agent |
... | ... | |
66 | 66 |
* @param agent the agent |
67 | 67 |
* @return a count of Address instances |
68 | 68 |
*/ |
69 |
public Integer countAddresses(AgentBase agent);
|
|
69 |
public long countAddresses(AgentBase agent);
|
|
70 | 70 |
|
71 | 71 |
/** |
72 | 72 |
* Return a List of addresses of a given agent |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/common/IIdentifiableDao.java | ||
---|---|---|
49 | 49 |
* @param identifiableEntity The identifiable entity |
50 | 50 |
* @return a count of OriginalSource instances |
51 | 51 |
*/ |
52 |
public int countSources(T identifiableEntity);
|
|
52 |
public long countSources(T identifiableEntity);
|
|
53 | 53 |
|
54 | 54 |
/** |
55 | 55 |
* Return a List of the sources for this identifiable entity |
... | ... | |
68 | 68 |
* @param identifiableEntity The identifiable entity |
69 | 69 |
* @return a count of Rights instances |
70 | 70 |
*/ |
71 |
public int countRights(T identifiableEntity);
|
|
71 |
public long countRights(T identifiableEntity);
|
|
72 | 72 |
|
73 | 73 |
|
74 | 74 |
/** |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/common/ISearchableDao.java | ||
---|---|---|
24 | 24 |
* @return a count of the matching entities |
25 | 25 |
* @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a> |
26 | 26 |
*/ |
27 |
public int count(Class<? extends T> clazz, String queryString);
|
|
27 |
public long count(Class<? extends T> clazz, String queryString);
|
|
28 | 28 |
|
29 | 29 |
/** |
30 | 30 |
* Returns a List of T instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser) |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/common/IVersionableDao.java | ||
---|---|---|
5 | 5 |
* |
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 |
*/
|
|
8 |
*/ |
|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.cdm.persistence.dao.common; |
11 | 11 |
|
... | ... | |
18 | 18 |
import eu.etaxonomy.cdm.model.view.AuditEventRecord; |
19 | 19 |
|
20 | 20 |
public interface IVersionableDao<T extends VersionableEntity> extends ICdmEntityDao<T> { |
21 |
|
|
21 |
|
|
22 | 22 |
/** |
23 | 23 |
* Returns a list of audit events (in order) which affected the state of an entity t. |
24 |
* The events returned either start at the AuditEvent in context and go forward in time
|
|
25 |
* (AuditEventSort.FORWARDS) or backwards in time (AuditEventSort.BACKWARDS). If the
|
|
24 |
* The events returned either start at the AuditEvent in context and go forward in time |
|
25 |
* (AuditEventSort.FORWARDS) or backwards in time (AuditEventSort.BACKWARDS). If the |
|
26 | 26 |
* AuditEventContext is set to null, or to AuditEvent.CURRENT_VIEW, then all relevant |
27 | 27 |
* AuditEvents are returned. |
28 |
*
|
|
28 |
* |
|
29 | 29 |
* @param t The versionable entity which was affected by the audit events |
30 | 30 |
* @param pageSize The maximum number of audit event records returned (can be null for all audit event records) |
31 | 31 |
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based) |
... | ... | |
34 | 34 |
* @return a list of AuditEventRecords, containing the AuditEvent, the state of the entity at that event, and the type of modification |
35 | 35 |
*/ |
36 | 36 |
public List<AuditEventRecord<T>> getAuditEvents(T t, Integer pageSize, Integer pageNumber, AuditEventSort sort, List<String> propertyPaths); |
37 |
|
|
37 |
|
|
38 | 38 |
/** |
39 | 39 |
* Returns a count of audit events which affected the state of an entity t. |
40 |
* The events either start at the AuditEvent in context and go forward in time
|
|
41 |
* (AuditEventSort.FORWARDS) or backwards in time (AuditEventSort.BACKWARDS). If the
|
|
40 |
* The events either start at the AuditEvent in context and go forward in time |
|
41 |
* (AuditEventSort.FORWARDS) or backwards in time (AuditEventSort.BACKWARDS). If the |
|
42 | 42 |
* AuditEventContext is set to null, or to AuditEvent.CURRENT_VIEW, then all relevant |
43 | 43 |
* AuditEvents are considered. |
44 |
*
|
|
44 |
* |
|
45 | 45 |
* @param t The versionable entity which was affected by the audit events |
46 | 46 |
* @param sort should the events considered start now and go forward in time (AuditEventSort.FORWARDS) or backwards (AuditEventSort.BACKWARDS) |
47 | 47 |
* @return a count of audit events |
48 | 48 |
*/ |
49 |
public int countAuditEvents(T t, AuditEventSort sort);
|
|
50 |
|
|
49 |
public long countAuditEvents(T t, AuditEventSort sort);
|
|
50 |
|
|
51 | 51 |
/** |
52 | 52 |
* A convenience method which returns a record of the next (relative to the audit event in context) |
53 | 53 |
* audit event to affect the entity t. |
54 |
*
|
|
54 |
* |
|
55 | 55 |
* @param t The versionable entity affected by these audit events |
56 | 56 |
* @return a record of the next audit event to affect t, or null if the current event is the last to affect t |
57 | 57 |
*/ |
58 | 58 |
public AuditEventRecord<T> getNextAuditEvent(T t); |
59 |
|
|
59 |
|
|
60 | 60 |
/** |
61 | 61 |
* A convenience method which returns a record of the previous (relative to the audit event in context) |
62 | 62 |
* audit event to affect the entity t. |
63 |
*
|
|
63 |
* |
|
64 | 64 |
* @param t The versionable entity affected by these audit events |
65 | 65 |
* @return a record of the previous audit event to affect t, or null if the current event is the first to affect t |
66 | 66 |
*/ |
67 | 67 |
public AuditEventRecord<T> getPreviousAuditEvent(T t); |
68 |
|
|
68 |
|
|
69 | 69 |
/** |
70 | 70 |
* Returns a count of the total number of audit events affecting objects of class T, optionally restricted to objects of |
71 | 71 |
* class clazz, the AuditEvents from and to, inclusive, optionally filtered by other criteria |
72 |
*
|
|
72 |
* |
|
73 | 73 |
* @param clazz Restrict the results returned to objects of this class |
74 | 74 |
* @param from The audit event to start from (or pass null to start from the beginning of the recordset) |
75 | 75 |
* @param to The audit event to continue until (or pass null to return audit events up to the time of the query) |
76 | 76 |
* @param criteria Extra criteria to filter by |
77 | 77 |
* @return the count of audit events |
78 | 78 |
*/ |
79 |
public int countAuditEvents(Class<? extends T> clazz,AuditEvent from,AuditEvent to,List<AuditCriterion> criteria);
|
|
80 |
|
|
79 |
public long countAuditEvents(Class<? extends T> clazz,AuditEvent from,AuditEvent to,List<AuditCriterion> criteria);
|
|
80 |
|
|
81 | 81 |
/** |
82 | 82 |
* Returns a list of all audit events occurring to objects of type T, optionally restricted to objects of type clazz |
83 | 83 |
* between the AuditEvents from and to, inclusive, optionally filtered by other criteria |
84 |
*
|
|
84 |
* |
|
85 | 85 |
* @param clazz Restrict the results returned to objects of this class |
86 | 86 |
* @param from The audit event to start from (inclusive, or pass null to start from the beginning of the recordset) |
87 | 87 |
* @param to The audit event to continue until (exclusive, or pass null to return audit events up to the time of the query) |
88 | 88 |
* @param criteria Extra criteria to filter by |
89 | 89 |
* @param pageSize The maximum number of objects returned (can be null for all matching objects) |
90 |
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based,
|
|
90 |
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based, |
|
91 | 91 |
* can be null, equivalent of starting at the beginning of the recordset) |
92 | 92 |
* @param sort Sort the events either forwards or backwards in time |
93 | 93 |
* @param propertyPaths properties to be initialized |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/description/IIdentificationKeyDao.java | ||
---|---|---|
43 | 43 |
* Returns the number of objects of type IIdentificationKey |
44 | 44 |
* @return |
45 | 45 |
*/ |
46 |
public int count();
|
|
46 |
public long count();
|
|
47 | 47 |
|
48 | 48 |
/** |
49 | 49 |
* Finds IdentificationKeys which cover the Taxon given as parameter |
... | ... | |
76 | 76 |
* IIdentificationKey |
77 | 77 |
* @return |
78 | 78 |
*/ |
79 |
public <T extends IIdentificationKey> Long countByTaxonomicScope(UUID taxonUuid, Class<T> type);
|
|
79 |
public <T extends IIdentificationKey> long countByTaxonomicScope(UUID taxonUuid, Class<T> type);
|
|
80 | 80 |
} |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/agent/AgentDaoImpl.java | ||
---|---|---|
63 | 63 |
} |
64 | 64 |
|
65 | 65 |
@Override |
66 |
public int countInstitutionalMemberships(Person person) {
|
|
66 |
public long countInstitutionalMemberships(Person person) {
|
|
67 | 67 |
AuditEvent auditEvent = getAuditEventFromContext(); |
68 | 68 |
if(auditEvent.equals(AuditEvent.CURRENT_VIEW)) { |
69 | 69 |
Query query = getSession().createQuery("select count(institutionalMembership) from InstitutionalMembership institutionalMembership where institutionalMembership.person = :person"); |
70 | 70 |
query.setParameter("person", person); |
71 |
return ((Long)query.uniqueResult()).intValue();
|
|
71 |
return (Long)query.uniqueResult();
|
|
72 | 72 |
} else { |
73 |
AuditQuery query = getAuditReader().createQuery().forEntitiesAtRevision(InstitutionalMembership.class,auditEvent.getRevisionNumber());
|
|
73 |
AuditQuery query = makeAuditQuery(InstitutionalMembership.class, auditEvent);
|
|
74 | 74 |
query.add(AuditEntity.relatedId("person").eq(person.getId())); |
75 | 75 |
query.addProjection(AuditEntity.id()); |
76 |
return ((Long)query.getSingleResult()).intValue();
|
|
76 |
return (Long)query.getSingleResult();
|
|
77 | 77 |
} |
78 | 78 |
} |
79 | 79 |
|
80 | 80 |
@Override |
81 |
public int countMembers(Team team) {
|
|
81 |
public long countMembers(Team team) {
|
|
82 | 82 |
checkNotInPriorView("AgentDaoImpl.countMembers(Team team)"); |
83 | 83 |
Query query = getSession().createQuery("select count(teamMember) from Team team join team.teamMembers teamMember where team = :team"); |
84 | 84 |
query.setParameter("team", team); |
85 |
return ((Long)query.uniqueResult()).intValue();
|
|
85 |
return (Long)query.uniqueResult();
|
|
86 | 86 |
} |
87 | 87 |
|
88 | 88 |
@Override |
... | ... | |
108 | 108 |
query.setParameter("team", team); |
109 | 109 |
//query.addOrder( Order.asc("sortindex") ); |
110 | 110 |
setPagingParameter(query, pageSize, pageNumber); |
111 |
return query.list(); |
|
111 |
@SuppressWarnings("unchecked") |
|
112 |
List<Person> result = query.list(); |
|
113 |
return result; |
|
112 | 114 |
} |
113 | 115 |
|
114 | 116 |
@Override |
115 |
public Integer countAddresses(AgentBase agent) {
|
|
117 |
public long countAddresses(AgentBase agent) {
|
|
116 | 118 |
checkNotInPriorView("AgentDaoImpl.countAddresses(AgentBase agent)"); |
117 | 119 |
Query query = getSession().createQuery("select count(address) from AgentBase agent join agent.contact.addresses address where agent = :agent"); |
118 | 120 |
query.setParameter("agent", agent); |
119 |
return ((Long)query.uniqueResult()).intValue();
|
|
121 |
return (Long)query.uniqueResult();
|
|
120 | 122 |
} |
121 | 123 |
|
122 | 124 |
@Override |
... | ... | |
125 | 127 |
Query query = getSession().createQuery("select address from AgentBase agent join agent.contact.addresses address where agent = :agent"); |
126 | 128 |
query.setParameter("agent", agent); |
127 | 129 |
setPagingParameter(query, pageSize, pageNumber); |
128 |
return query.list(); |
|
130 |
@SuppressWarnings("unchecked") |
|
131 |
List<Address> result = query.list(); |
|
132 |
return result; |
|
129 | 133 |
} |
130 | 134 |
|
131 | 135 |
|
132 | 136 |
@Override |
133 | 137 |
public List<UuidAndTitleCache<Team>> getTeamUuidAndNomenclaturalTitle() { |
134 |
List<UuidAndTitleCache<Team>> list = new ArrayList<UuidAndTitleCache<Team>>();
|
|
138 |
List<UuidAndTitleCache<Team>> list = new ArrayList<>(); |
|
135 | 139 |
Session session = getSession(); |
136 | 140 |
|
137 | 141 |
Query query = session.createQuery("select uuid, id, nomenclaturalTitle from " + type.getSimpleName() + " where dtype = 'Team'"); |
... | ... | |
140 | 144 |
List<Object[]> result = query.list(); |
141 | 145 |
|
142 | 146 |
for(Object[] object : result){ |
143 |
list.add(new UuidAndTitleCache<Team>(Team.class, (UUID) object[0], (Integer)object[1], (String) object[2]));
|
|
147 |
list.add(new UuidAndTitleCache<>(Team.class, (UUID) object[0], (Integer)object[1], (String) object[2])); |
|
144 | 148 |
} |
145 | 149 |
|
146 | 150 |
return list; |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/IdentifiableDaoBase.java | ||
---|---|---|
186 | 186 |
} |
187 | 187 |
|
188 | 188 |
@Override |
189 |
public int countRights(T identifiableEntity) {
|
|
189 |
public long countRights(T identifiableEntity) {
|
|
190 | 190 |
checkNotInPriorView("IdentifiableDaoBase.countRights(T identifiableEntity)"); |
191 | 191 |
Query query = getSession().createQuery("select count(rights) from " + type.getSimpleName() + " identifiableEntity join identifiableEntity.rights rights where identifiableEntity = :identifiableEntity"); |
192 | 192 |
query.setParameter("identifiableEntity",identifiableEntity); |
193 |
return ((Long)query.uniqueResult()).intValue();
|
|
193 |
return (Long)query.uniqueResult();
|
|
194 | 194 |
} |
195 | 195 |
|
196 | 196 |
@Override |
197 |
public int countSources(T identifiableEntity) {
|
|
197 |
public long countSources(T identifiableEntity) {
|
|
198 | 198 |
checkNotInPriorView("IdentifiableDaoBase.countSources(T identifiableEntity)"); |
199 | 199 |
Query query = getSession().createQuery("SELECT COUNT(source) FROM "+identifiableEntity.getClass().getName() + " ie JOIN ie.sources source WHERE ie = :identifiableEntity"); |
200 | 200 |
query.setParameter("identifiableEntity", identifiableEntity); |
201 |
return ((Long)query.uniqueResult()).intValue();
|
|
201 |
return (Long)query.uniqueResult();
|
|
202 | 202 |
} |
203 | 203 |
|
204 | 204 |
@Override |
... | ... | |
207 | 207 |
Query query = getSession().createQuery("select rights from " + type.getSimpleName() + " identifiableEntity join identifiableEntity.rights rights where identifiableEntity = :identifiableEntity"); |
208 | 208 |
query.setParameter("identifiableEntity",identifiableEntity); |
209 | 209 |
setPagingParameter(query, pageSize, pageNumber); |
210 |
@SuppressWarnings("unchecked") |
|
210 | 211 |
List<Rights> results = query.list(); |
211 | 212 |
defaultBeanInitializer.initializeAll(results, propertyPaths); |
212 | 213 |
return results; |
... | ... | |
218 | 219 |
Query query = getSession().createQuery("select credits from " + type.getSimpleName() + " identifiableEntity join identifiableEntity.credits credits where identifiableEntity = :identifiableEntity"); |
219 | 220 |
query.setParameter("identifiableEntity",identifiableEntity); |
220 | 221 |
setPagingParameter(query, pageSize, pageNumber); |
221 |
return query.list(); |
|
222 |
@SuppressWarnings("unchecked") |
|
223 |
List<Credit> result = query.list(); |
|
224 |
return result; |
|
222 | 225 |
} |
223 | 226 |
|
224 | 227 |
@Override |
... | ... | |
245 | 248 |
query.setString("idInSource", idInSource); |
246 | 249 |
query.setString("idNamespace", idNamespace); |
247 | 250 |
//TODO integrate reference in where |
248 |
return query.list(); |
|
251 |
|
|
252 |
@SuppressWarnings("unchecked") |
|
253 |
List<T> result = query.list(); |
|
254 |
return result; |
|
249 | 255 |
} |
250 | 256 |
|
251 | 257 |
@Override |
... | ... | |
318 | 324 |
} |
319 | 325 |
|
320 | 326 |
@Override |
321 |
public int count(Class<? extends T> clazz, String queryString) {
|
|
327 |
public long count(Class<? extends T> clazz, String queryString) {
|
|
322 | 328 |
checkNotInPriorView("IdentifiableDaoBase.count(Class<? extends T> clazz, String queryString)"); |
323 | 329 |
QueryParser queryParser = new QueryParser(defaultField , new StandardAnalyzer()); |
324 | 330 |
|
... | ... | |
334 | 340 |
fullTextQuery = fullTextSession.createFullTextQuery(query, clazz); |
335 | 341 |
} |
336 | 342 |
|
337 |
Integer result = fullTextQuery.getResultSize();
|
|
343 |
int result = fullTextQuery.getResultSize();
|
|
338 | 344 |
return result; |
339 | 345 |
|
340 | 346 |
} catch (ParseException e) { |
... | ... | |
346 | 352 |
public void optimizeIndex() { |
347 | 353 |
FullTextSession fullTextSession = Search.getFullTextSession(getSession()); |
348 | 354 |
SearchFactory searchFactory = fullTextSession.getSearchFactory(); |
349 |
for(Class clazz : indexedClasses) { |
|
355 |
for(Class<?> clazz : indexedClasses) {
|
|
350 | 356 |
searchFactory.optimize(clazz); // optimize the indices () |
351 | 357 |
} |
352 | 358 |
fullTextSession.flushToIndexes(); |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/VersionableDaoBase.java | ||
---|---|---|
247 | 247 |
} |
248 | 248 |
|
249 | 249 |
@Override |
250 |
public int countAuditEvents(T t, AuditEventSort sort) {
|
|
250 |
public long countAuditEvents(T t, AuditEventSort sort) {
|
|
251 | 251 |
AuditEvent auditEvent = getAuditEventFromContext(); |
252 | 252 |
|
253 | 253 |
AuditQuery query = getAuditReader().createQuery().forRevisionsOfEntity(type, false, true); |
... | ... | |
267 | 267 |
|
268 | 268 |
query.addProjection(AuditEntity.revisionNumber().count()); |
269 | 269 |
|
270 |
return ((Long)query.getSingleResult()).intValue();
|
|
270 |
return (Long)query.getSingleResult();
|
|
271 | 271 |
} |
272 | 272 |
|
273 | 273 |
@Override |
... | ... | |
291 | 291 |
} |
292 | 292 |
|
293 | 293 |
@Override |
294 |
public int countAuditEvents(Class<? extends T> clazz, AuditEvent from, AuditEvent to, List<AuditCriterion> criteria) {
|
|
294 |
public long countAuditEvents(Class<? extends T> clazz, AuditEvent from, AuditEvent to, List<AuditCriterion> criteria) {
|
|
295 | 295 |
AuditQuery query = null; |
296 | 296 |
|
297 | 297 |
if(clazz == null) { |
... | ... | |
312 | 312 |
|
313 | 313 |
query.addProjection(AuditEntity.revisionNumber().count()); |
314 | 314 |
|
315 |
int result = ((Long)query.getSingleResult()).intValue(); |
|
316 |
return result; |
|
315 |
return (Long)query.getSingleResult(); |
|
317 | 316 |
} |
318 | 317 |
|
319 | 318 |
protected void addCriteria(AuditQuery query, List<AuditCriterion> criteria) { |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/DescriptionElementDaoImpl.java | ||
---|---|---|
57 | 57 |
} |
58 | 58 |
|
59 | 59 |
@Override |
60 |
public int count(Class<? extends DescriptionElementBase> clazz, String queryString) {
|
|
60 |
public long count(Class<? extends DescriptionElementBase> clazz, String queryString) {
|
|
61 | 61 |
checkNotInPriorView("DescriptionElementDaoImpl.countTextData(String queryString)"); |
62 | 62 |
QueryParser queryParser = new QueryParser(defaultField, new StandardAnalyzer()); |
63 | 63 |
|
... | ... | |
72 | 72 |
} else { |
73 | 73 |
fullTextQuery = fullTextSession.createFullTextQuery(query, clazz); |
74 | 74 |
} |
75 |
return fullTextQuery.getResultSize();
|
|
75 |
return fullTextQuery.getResultSize(); |
|
76 | 76 |
} catch (ParseException e) { |
77 | 77 |
throw new QueryParseException(e, queryString); |
78 | 78 |
} |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/IdentificationKeyDaoImpl.java | ||
---|---|---|
21 | 21 |
protected IBeanInitializer defaultBeanInitializer; |
22 | 22 |
|
23 | 23 |
@Override |
24 |
public int count() {
|
|
24 |
public long count() {
|
|
25 | 25 |
Query query = getSession().createQuery("select count(key) from eu.etaxonomy.cdm.model.description.IIdentificationKey key"); |
26 | 26 |
|
27 |
List<Long> result = query.list(); |
|
28 |
Integer total = 0; |
|
29 |
for(Long l : result) { |
|
30 |
total += l.intValue(); |
|
27 |
@SuppressWarnings("unchecked") |
|
28 |
List<Long> result = query.list(); |
|
29 |
long total = 0; |
|
30 |
for(long l : result) { |
|
31 |
total += l; |
|
31 | 32 |
} |
32 | 33 |
return total; |
33 | 34 |
} |
... | ... | |
36 | 37 |
public List<IIdentificationKey> list(Integer limit,Integer start, List<String> propertyPaths) { |
37 | 38 |
Query query = getSession().createQuery("select key from eu.etaxonomy.cdm.model.description.IIdentificationKey key order by created desc"); |
38 | 39 |
|
39 |
if(limit != null) { |
|
40 |
if(start != null) { |
|
41 |
query.setFirstResult(start); |
|
42 |
} else { |
|
43 |
query.setFirstResult(0); |
|
44 |
} |
|
45 |
query.setMaxResults(limit); |
|
46 |
} |
|
40 |
addLimitAndStart(query, limit, start); |
|
47 | 41 |
|
48 |
List<IIdentificationKey> results = query.list(); |
|
42 |
@SuppressWarnings("unchecked") |
|
43 |
List<IIdentificationKey> results = query.list(); |
|
49 | 44 |
defaultBeanInitializer.initializeAll(results, propertyPaths); |
50 | 45 |
return results; |
51 | 46 |
} |
52 | 47 |
|
53 |
/* (non-Javadoc) |
|
54 |
* @see eu.etaxonomy.cdm.persistence.dao.description.IIdentificationKeyDao#findKeysConvering(eu.etaxonomy.cdm.model.taxon.TaxonBase, java.lang.Class, java.lang.Integer, java.lang.Integer, java.util.List) |
|
55 |
*/ |
|
56 | 48 |
@Override |
57 | 49 |
public <T extends IIdentificationKey> List<T> findByTaxonomicScope( |
58 | 50 |
UUID taxonUuid, Class<T> type, Integer pageSize, |
... | ... | |
60 | 52 |
|
61 | 53 |
Query query = getSession().createQuery("select key from " + type.getCanonicalName() +" key join key.taxonomicScope ts where ts.uuid = (:taxon_uuid)"); |
62 | 54 |
query.setParameter("taxon_uuid", taxonUuid); |
63 |
List<T> results = query.list(); |
|
55 |
@SuppressWarnings("unchecked") |
|
56 |
List<T> results = query.list(); |
|
64 | 57 |
defaultBeanInitializer.initializeAll(results, propertyPaths); |
65 | 58 |
return results; |
66 | 59 |
} |
67 | 60 |
|
68 |
/* (non-Javadoc) |
|
69 |
* @see eu.etaxonomy.cdm.persistence.dao.description.IIdentificationKeyDao#findKeysConvering(eu.etaxonomy.cdm.model.taxon.TaxonBase, java.lang.Class, java.lang.Integer, java.lang.Integer, java.util.List) |
|
70 |
*/ |
|
71 | 61 |
@Override |
72 |
public <T extends IIdentificationKey> Long countByTaxonomicScope(UUID taxonUuid, Class<T> type) {
|
|
62 |
public <T extends IIdentificationKey> long countByTaxonomicScope(UUID taxonUuid, Class<T> type) {
|
|
73 | 63 |
|
74 | 64 |
Query query = getSession().createQuery("select count(key) from " + type.getCanonicalName() +" key join key.taxonomicScope ts where ts.uuid = (:taxon_uuid)"); |
75 | 65 |
query.setParameter("taxon_uuid", taxonUuid); |
76 |
List<Long> list = query.list(); |
|
77 |
Long count = 0l; |
|
78 |
for(Long perTypeCount : list){ |
|
66 |
@SuppressWarnings("unchecked") |
|
67 |
List<Long> list = query.list(); |
|
68 |
long count = 0; |
|
69 |
for(long perTypeCount : list){ |
|
79 | 70 |
count += perTypeCount; |
80 | 71 |
} |
81 | 72 |
return count; |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/media/MediaDaoHibernateImpl.java | ||
---|---|---|
159 | 159 |
} |
160 | 160 |
|
161 | 161 |
@Override |
162 |
public int countRights(Media media) {
|
|
162 |
public long countRights(Media media) {
|
|
163 | 163 |
checkNotInPriorView("MediaDaoHibernateImpl.countRights(Media t)"); |
164 | 164 |
Query query = getSession().createQuery("select count(rights) from Media media join media.rights rights where media = :media"); |
165 | 165 |
query.setParameter("media",media); |
166 |
return ((Long)query.uniqueResult()).intValue();
|
|
166 |
return (Long)query.uniqueResult();
|
|
167 | 167 |
} |
168 | 168 |
|
169 | 169 |
|
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/name/TaxonNameDaoHibernateImpl.java | ||
---|---|---|
246 | 246 |
|
247 | 247 |
|
248 | 248 |
@Override |
249 |
public int countTypeDesignations(TaxonName name, SpecimenTypeDesignationStatus status) {
|
|
249 |
public long countTypeDesignations(TaxonName name, SpecimenTypeDesignationStatus status) {
|
|
250 | 250 |
checkNotInPriorView("countTypeDesignations(TaxonName name, SpecimenTypeDesignationStatus status)"); |
251 | 251 |
Query query = null; |
252 | 252 |
if(status == null) { |
... | ... | |
256 | 256 |
query.setParameter("status", status); |
257 | 257 |
} |
258 | 258 |
query.setParameter("name",name); |
259 |
return ((Long)query.uniqueResult()).intValue();
|
|
259 |
return (Long)query.uniqueResult();
|
|
260 | 260 |
} |
261 | 261 |
|
262 | 262 |
@Override |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/view/AuditEventDao.java | ||
---|---|---|
5 | 5 |
* |
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 |
*/
|
|
8 |
*/ |
|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.cdm.persistence.dao.hibernate.view; |
11 | 11 |
|
... | ... | |
26 | 26 |
|
27 | 27 |
@Repository |
28 | 28 |
public class AuditEventDao extends DaoBase implements IAuditEventDao { |
29 |
|
|
29 |
|
|
30 | 30 |
protected AuditReader getAuditReader() { |
31 | 31 |
return AuditReaderFactory.get(getSession()); |
32 | 32 |
} |
33 | 33 |
|
34 |
public int count() { |
|
34 |
@Override |
|
35 |
public long count() { |
|
35 | 36 |
Query query = getSession().createQuery("select count(auditEvent) from AuditEvent auditEvent"); |
36 |
|
|
37 |
return ((Long)query.uniqueResult()).intValue();
|
|
37 |
|
|
38 |
return (Long)query.uniqueResult();
|
|
38 | 39 |
} |
39 | 40 |
|
40 |
public boolean exists(UUID uuid) { |
|
41 |
@Override |
|
42 |
public boolean exists(UUID uuid) { |
|
41 | 43 |
Query query = getSession().createQuery("select auditEvent from AuditEvent auditEvent where auditEvent.uuid = :uuid"); |
42 | 44 |
query.setParameter("uuid", uuid); |
43 | 45 |
return null != (AuditEvent)query.uniqueResult(); |
44 | 46 |
} |
45 | 47 |
|
46 |
public AuditEvent findById(Integer id) { |
|
48 |
@Override |
|
49 |
public AuditEvent findById(Integer id) { |
|
47 | 50 |
Query query = getSession().createQuery("select auditEvent from AuditEvent auditEvent where auditEvent.id = :id"); |
48 | 51 |
query.setParameter("id", id); |
49 | 52 |
return (AuditEvent)query.uniqueResult(); |
50 | 53 |
} |
51 | 54 |
|
52 |
public AuditEvent findByUuid(UUID uuid) { |
|
55 |
@Override |
|
56 |
public AuditEvent findByUuid(UUID uuid) { |
|
53 | 57 |
Query query = getSession().createQuery("select auditEvent from AuditEvent auditEvent where auditEvent.uuid = :uuid"); |
54 | 58 |
query.setParameter("uuid", uuid); |
55 | 59 |
return (AuditEvent)query.uniqueResult(); |
56 | 60 |
} |
57 | 61 |
|
58 |
public AuditEvent getNextAuditEvent(AuditEvent auditEvent) { |
|
62 |
@Override |
|
63 |
public AuditEvent getNextAuditEvent(AuditEvent auditEvent) { |
|
59 | 64 |
Query query = getSession().createQuery("select auditEvent from AuditEvent auditEvent where auditEvent.revisionNumber = :revisionNumber + 1"); |
60 | 65 |
query.setParameter("revisionNumber", auditEvent.getRevisionNumber()); |
61 | 66 |
return (AuditEvent) query.uniqueResult(); |
62 | 67 |
} |
63 | 68 |
|
64 |
public AuditEvent getPreviousAuditEvent(AuditEvent auditEvent) { |
|
69 |
@Override |
|
70 |
public AuditEvent getPreviousAuditEvent(AuditEvent auditEvent) { |
|
65 | 71 |
Query query = getSession().createQuery("select auditEvent from AuditEvent auditEvent where auditEvent.revisionNumber = :revisionNumber - 1"); |
66 | 72 |
query.setParameter("revisionNumber", auditEvent.getRevisionNumber()); |
67 | 73 |
return (AuditEvent) query.uniqueResult(); |
68 | 74 |
} |
69 | 75 |
|
70 |
public List<AuditEvent> list(Integer pageNumber, Integer pageSize, AuditEventSort sort) { |
|
76 |
@Override |
|
77 |
public List<AuditEvent> list(Integer pageNumber, Integer pageSize, AuditEventSort sort) { |
|
71 | 78 |
if(sort == null) { |
72 | 79 |
sort = AuditEventSort.BACKWARDS; |
73 | 80 |
} |
74 |
|
|
81 |
|
|
75 | 82 |
Query query = null; |
76 |
|
|
83 |
|
|
77 | 84 |
if(sort.equals(AuditEventSort.FORWARDS)) { |
78 | 85 |
query = getSession().createQuery("select auditEvent from AuditEvent auditEvent order by auditEvent.timestamp asc"); |
79 | 86 |
} else { |
80 | 87 |
query = getSession().createQuery("select auditEvent from AuditEvent auditEvent order by auditEvent.timestamp desc"); |
81 | 88 |
} |
82 |
|
|
89 |
|
|
83 | 90 |
if(pageSize != null) { |
84 | 91 |
query.setMaxResults(pageSize); |
85 | 92 |
if(pageNumber != null) { |
... | ... | |
88 | 95 |
query.setFirstResult(0); |
89 | 96 |
} |
90 | 97 |
} |
91 |
|
|
92 |
return (List<AuditEvent>)query.list();
|
|
98 |
|
|
99 |
return query.list(); |
|
93 | 100 |
} |
94 | 101 |
|
95 |
public AuditEvent findByDate(DateTime dateTime) { |
|
102 |
@Override |
|
103 |
public AuditEvent findByDate(DateTime dateTime) { |
|
96 | 104 |
Number id = getAuditReader().getRevisionNumberForDate(dateTime.toDate()); |
97 |
AuditEvent auditEvent =(AuditEvent)getSession().load(AuditEvent.class, id);
|
|
105 |
AuditEvent auditEvent =getSession().load(AuditEvent.class, id); |
|
98 | 106 |
Hibernate.initialize(auditEvent); |
99 | 107 |
return auditEvent; |
100 | 108 |
} |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/media/IMediaDao.java | ||
---|---|---|
54 | 54 |
* @return a count of Rights instances |
55 | 55 |
*/ |
56 | 56 |
@Override |
57 |
public int countRights(Media t);
|
|
57 |
public long countRights(Media t);
|
|
58 | 58 |
|
59 | 59 |
/** |
60 | 60 |
* Return a List of the rights for this media entity |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/name/ITaxonNameDao.java | ||
---|---|---|
121 | 121 |
* the type designation status (or null to return all types) |
122 | 122 |
* @return a count of TypeDesignationBase instances |
123 | 123 |
*/ |
124 |
public int countTypeDesignations(TaxonName name,
|
|
124 |
public long countTypeDesignations(TaxonName name,
|
|
125 | 125 |
SpecimenTypeDesignationStatus status); |
126 | 126 |
|
127 | 127 |
/** |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/view/IAuditEventDao.java | ||
---|---|---|
5 | 5 |
* |
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 |
*/
|
|
8 |
*/ |
|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.cdm.persistence.view; |
11 | 11 |
|
... | ... | |
19 | 19 |
|
20 | 20 |
|
21 | 21 |
public interface IAuditEventDao { |
22 |
|
|
22 |
|
|
23 | 23 |
/** |
24 | 24 |
* Find the AuditEvent with an identifier equal to the parameter |
25 |
*
|
|
25 |
* |
|
26 | 26 |
* @param id |
27 | 27 |
* @return an AuditEvent, or null if there is no AuditEvent with that identifier |
28 | 28 |
*/ |
29 | 29 |
public AuditEvent findById(Integer id); |
30 |
|
|
30 |
|
|
31 | 31 |
/** |
32 | 32 |
* Find the AuditEvent with a uuid (surrogate key) equal to the uuid supplied |
33 |
*
|
|
33 |
* |
|
34 | 34 |
* @param uuid |
35 | 35 |
* @return an AuditEvent, or null if there is no AuditEvent with a uuid which matches |
36 | 36 |
*/ |
37 | 37 |
public AuditEvent findByUuid(UUID uuid); |
38 |
|
|
38 |
|
|
39 | 39 |
/** |
40 | 40 |
* Count the AuditEvents in this database |
41 |
*
|
|
41 |
* |
|
42 | 42 |
* @return the total number of AuditEvents in this database |
43 | 43 |
*/ |
44 |
public int count();
|
|
45 |
|
|
44 |
public long count();
|
|
45 |
|
|
46 | 46 |
/** |
47 | 47 |
* Returns a sublist of AuditEvent instances stored in the database. |
48 | 48 |
* A maximum of 'limit' objects are returned, starting at object with index 'start'. |
49 |
*
|
|
49 |
* |
|
50 | 50 |
* @param limit the maximum number of entities returned (can be null to return all entities) |
51 | 51 |
* @param start |
52 |
* @param sort Whether the list is sorted going forward in time (AuditEventSort.FORWARDS)
|
|
52 |
* @param sort Whether the list is sorted going forward in time (AuditEventSort.FORWARDS) |
|
53 | 53 |
* or backwards (AuditEventSort.BACKWARDS) |
54 | 54 |
* @return a List of AuditEvent instances |
55 |
*/
|
|
55 |
*/ |
|
56 | 56 |
public List<AuditEvent> list(Integer limit, Integer start,AuditEventSort sort); |
57 |
|
|
57 |
|
|
58 | 58 |
/** |
59 | 59 |
* Returns the AuditEvent immediately proceeding the audit event passed as an argument |
60 |
*
|
|
60 |
* |
|
61 | 61 |
* @param auditEvent |
62 |
* @return the AuditEvent immediately proceeding, or null if the AuditEvent passed is
|
|
62 |
* @return the AuditEvent immediately proceeding, or null if the AuditEvent passed is |
|
63 | 63 |
* the most recent event |
64 | 64 |
*/ |
65 | 65 |
public AuditEvent getNextAuditEvent(AuditEvent auditEvent); |
66 |
|
|
66 |
|
|
67 | 67 |
/** |
68 | 68 |
* Returns the AuditEvent immediately preceding the audit event passed as an argument |
69 |
*
|
|
69 |
* |
|
70 | 70 |
* @param auditEvent |
71 |
* @return the AuditEvent immediately preceding, or null if the AuditEvent passed is
|
|
71 |
* @return the AuditEvent immediately preceding, or null if the AuditEvent passed is |
|
72 | 72 |
* the first event in the database |
73 | 73 |
*/ |
74 | 74 |
public AuditEvent getPreviousAuditEvent(AuditEvent auditEvent); |
75 |
|
|
75 |
|
|
76 | 76 |
/** |
77 | 77 |
* Checks whether an AuditEvent with a matching uuid exists in the database |
78 |
*
|
|
78 |
* |
|
79 | 79 |
* @param uuid |
80 | 80 |
* @return true if an AuditEvent with a matching uuid exists in the database, false otherwise |
81 | 81 |
*/ |
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/FreeTextSearchIntegration.java | ||
---|---|---|
90 | 90 |
|
91 | 91 |
@Test |
92 | 92 |
public void testCountTextData() { |
93 |
int matches = descriptionElementDao.count(TextData.class,"Lorem");
|
|
93 |
long matches = descriptionElementDao.count(TextData.class,"Lorem");
|
|
94 | 94 |
assertEquals("countTextData should return 4",4,matches); |
95 | 95 |
} |
96 | 96 |
|
... | ... | |
108 | 108 |
|
109 | 109 |
@Test |
110 | 110 |
public void testSearchCount() { |
111 |
int numberOfResults = taxonDao.count(null,"Arum");
|
|
111 |
long numberOfResults = taxonDao.count(null,"Arum");
|
|
112 | 112 |
assertEquals("countTaxa should return 46",46,numberOfResults); |
113 | 113 |
|
114 | 114 |
} |
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/agent/AgentDaoImplTest.java | ||
---|---|---|
77 | 77 |
Team team = (Team)agentDao.findByUuid(uuid); |
78 | 78 |
assert team != null : "team must exist"; |
79 | 79 |
|
80 |
int numberOfMembers = agentDao.countMembers(team);
|
|
80 |
long numberOfMembers = agentDao.countMembers(team);
|
|
81 | 81 |
assertEquals("countMembers should return 5",5,numberOfMembers); |
82 | 82 |
} |
83 | 83 |
|
... | ... | |
106 | 106 |
Person person = (Person)agentDao.findByUuid(personUuid); |
107 | 107 |
assert person != null : "person must exist"; |
108 | 108 |
|
109 |
int numberOfInstitutionalMemberships = agentDao.countInstitutionalMemberships(person);
|
|
109 |
long numberOfInstitutionalMemberships = agentDao.countInstitutionalMemberships(person);
|
|
110 | 110 |
assertEquals("countInstitutionalMemberships should return 3",3,numberOfInstitutionalMemberships); |
111 | 111 |
} |
112 | 112 |
|
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/name/TaxonNameDaoHibernateImplTest.java | ||
---|---|---|
165 | 165 |
TaxonName acherontiaLachesis = taxonNameDao.findByUuid(acherontiaLachesisUuid); |
166 | 166 |
assert acherontiaLachesis != null : "name must exist"; |
167 | 167 |
|
168 |
int count = taxonNameDao.countTypeDesignations(acherontiaLachesis, null);
|
|
168 |
long count = taxonNameDao.countTypeDesignations(acherontiaLachesis, null);
|
|
169 | 169 |
|
170 | 170 |
assertEquals("countTypeDesignations should return 1",1,count); |
171 | 171 |
} |
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImplTest.java | ||
---|---|---|
898 | 898 |
TaxonBase<?> taxon = taxonDao.findByUuid(sphingidae); |
899 | 899 |
assert taxon != null : "taxon cannot be null"; |
900 | 900 |
|
901 |
int numberOfAuditEvents = taxonDao.countAuditEvents(taxon, null);
|
|
901 |
long numberOfAuditEvents = taxonDao.countAuditEvents(taxon, null);
|
|
902 | 902 |
assertEquals("countAuditEvents should return 2",numberOfAuditEvents,2); |
903 | 903 |
} |
904 | 904 |
|
... | ... | |
1098 | 1098 |
public void testGetAuditEventsByTypeWithRestrictions() { |
1099 | 1099 |
commitAndStartNewTransaction(new String[]{"AUDITEVENT", "TAXONBASE_AUD"}); |
1100 | 1100 |
|
1101 |
List<String> propertyPaths = new ArrayList<String>();
|
|
1101 |
List<String> propertyPaths = new ArrayList<>(); |
|
1102 | 1102 |
propertyPaths.add("name"); |
1103 | 1103 |
propertyPaths.add("createdBy"); |
1104 | 1104 |
propertyPaths.add("updatedBy"); |
... | ... | |
1106 | 1106 |
List<AuditCriterion> criteria = new ArrayList<>(); |
1107 | 1107 |
criteria.add(AuditEntity.property("lsid_lsid").isNotNull()); |
1108 | 1108 |
|
1109 |
int count = taxonDao.countAuditEvents(TaxonBase.class, null, null, null);
|
|
1109 |
long count = taxonDao.countAuditEvents(TaxonBase.class, null, null, null);
|
|
1110 | 1110 |
|
1111 | 1111 |
List<AuditEventRecord<TaxonBase>> auditEvents = taxonDao.getAuditEvents(TaxonBase.class, previousAuditEvent, mostRecentAuditEvent, criteria,null, null, AuditEventSort.FORWARDS, propertyPaths); |
1112 | 1112 |
assertNotNull("getAuditEvents should return a list",auditEvents); |
... | ... | |
1134 | 1134 |
propertyPaths.add("name"); |
1135 | 1135 |
propertyPaths.add("createdBy"); |
1136 | 1136 |
propertyPaths.add("updatedBy"); |
1137 |
int count = taxonDao.countAuditEvents(TaxonBase.class, null, null, null);
|
|
1137 |
long count = taxonDao.countAuditEvents(TaxonBase.class, null, null, null);
|
|
1138 | 1138 |
List<AuditEventRecord<TaxonBase>> auditEvents = taxonDao.getAuditEvents(TaxonBase.class, previousAuditEvent, mostRecentAuditEvent, null,null, null, AuditEventSort.FORWARDS, propertyPaths); |
1139 | 1139 |
assertNotNull("getAuditEvents should return a list", auditEvents); |
1140 | 1140 |
assertFalse("the list should not be empty", auditEvents.isEmpty()); |
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/BaseController.java | ||
---|---|---|
202 | 202 |
pagerParameters.normalizeAndValidate(response); |
203 | 203 |
|
204 | 204 |
start = pagerParameters.getPageIndex() * pagerParameters.getPageSize(); |
205 |
List sub_c = subCollection(c, start, pagerParameters.getPageSize()); |
|
206 |
Pager p = new DefaultPagerImpl(pageNumber, c.size(), pagerParameters.getPageSize(), sub_c);
|
|
205 |
List<? extends CdmBase> sub_c = subCollection(c, start, pagerParameters.getPageSize());
|
|
206 |
Pager<? extends CdmBase> p = new DefaultPagerImpl<>(pageNumber, c.size(), pagerParameters.getPageSize(), sub_c);
|
|
207 | 207 |
return p; |
208 | 208 |
} |
209 | 209 |
} |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/AgentServiceImpl.java | ||
---|---|---|
86 | 86 |
|
87 | 87 |
@Override |
88 | 88 |
public Pager<InstitutionalMembership> getInstitutionalMemberships(Person person, Integer pageSize, Integer pageNumber) { |
89 |
Integer numberOfResults = dao.countInstitutionalMemberships(person);
|
|
89 |
long numberOfResults = dao.countInstitutionalMemberships(person);
|
|
90 | 90 |
|
91 |
List<InstitutionalMembership> results = new ArrayList<InstitutionalMembership>();
|
|
91 |
List<InstitutionalMembership> results = new ArrayList<>(); |
|
92 | 92 |
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize) |
93 | 93 |
results = dao.getInstitutionalMemberships(person, pageSize, pageNumber); |
94 | 94 |
} |
95 | 95 |
|
96 |
return new DefaultPagerImpl<InstitutionalMembership>(pageNumber, numberOfResults, pageSize, results);
|
|
96 |
return new DefaultPagerImpl<>(pageNumber, numberOfResults, pageSize, results); |
|
97 | 97 |
} |
98 | 98 |
|
99 | 99 |
@Override |
100 | 100 |
public Pager<Person> getMembers(Team team, Integer pageSize, Integer pageNumber) { |
101 |
Integer numberOfResults = dao.countMembers(team);
|
|
101 |
long numberOfResults = dao.countMembers(team);
|
|
102 | 102 |
|
103 |
List<Person> results = new ArrayList<Person>();
|
|
103 |
List<Person> results = new ArrayList<>(); |
|
104 | 104 |
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize) |
105 | 105 |
results = dao.getMembers(team, pageSize, pageNumber); |
106 | 106 |
} |
107 | 107 |
|
108 |
return new DefaultPagerImpl<Person>(pageNumber, numberOfResults, pageSize, results);
|
|
108 |
return new DefaultPagerImpl<>(pageNumber, numberOfResults, pageSize, results); |
|
109 | 109 |
} |
110 | 110 |
|
111 | 111 |
@Override |
112 | 112 |
public Pager<Address> getAddresses(AgentBase agent, Integer pageSize, Integer pageNumber) { |
113 |
Integer numberOfResults = dao.countAddresses(agent);
|
|
113 |
long numberOfResults = dao.countAddresses(agent);
|
|
114 | 114 |
|
115 |
List<Address> results = new ArrayList<Address>();
|
|
115 |
List<Address> results = new ArrayList<>(); |
|
116 | 116 |
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize) |
117 | 117 |
results = dao.getAddresses(agent, pageSize, pageNumber); |
118 | 118 |
} |
119 | 119 |
|
120 |
return new DefaultPagerImpl<Address>(pageNumber, numberOfResults, pageSize, results);
|
|
120 |
return new DefaultPagerImpl<>(pageNumber, numberOfResults, pageSize, results); |
|
121 | 121 |
} |
122 | 122 |
|
123 | 123 |
@Override |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/AuditEventService.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
26 | 26 |
@Service |
27 | 27 |
@Transactional(readOnly = true) |
28 | 28 |
public class AuditEventService implements IAuditEventService { |
29 |
|
|
29 |
|
|
30 | 30 |
IAuditEventDao dao; |
31 |
|
|
31 |
|
|
32 | 32 |
@Autowired |
33 | 33 |
public void setDao(IAuditEventDao dao) { |
34 | 34 |
this.dao = dao; |
35 | 35 |
} |
36 | 36 |
|
37 |
public boolean exists(UUID uuid) { |
|
37 |
@Override |
|
38 |
public boolean exists(UUID uuid) { |
|
38 | 39 |
return dao.exists(uuid); |
39 | 40 |
} |
40 | 41 |
|
41 |
public AuditEvent find(Integer id) { |
|
42 |
@Override |
|
43 |
public AuditEvent find(Integer id) { |
|
42 | 44 |
return dao.findById(id); |
43 | 45 |
} |
44 | 46 |
|
45 |
public AuditEvent find(UUID uuid) { |
|
47 |
@Override |
|
48 |
public AuditEvent find(UUID uuid) { |
|
46 | 49 |
return dao.findByUuid(uuid); |
47 | 50 |
} |
48 | 51 |
|
49 |
public AuditEvent getNextAuditEvent(AuditEvent auditEvent) { |
|
52 |
@Override |
|
53 |
public AuditEvent getNextAuditEvent(AuditEvent auditEvent) { |
|
50 | 54 |
return dao.getNextAuditEvent(auditEvent); |
51 | 55 |
} |
52 | 56 |
|
53 |
public AuditEvent getPreviousAuditEvent(AuditEvent auditEvent) { |
|
57 |
@Override |
|
58 |
public AuditEvent getPreviousAuditEvent(AuditEvent auditEvent) { |
|
54 | 59 |
return dao.getPreviousAuditEvent(auditEvent); |
55 | 60 |
} |
56 | 61 |
|
57 |
public Pager<AuditEvent> list(Integer pageNumber, Integer pageSize, AuditEventSort sort) { |
|
58 |
Integer numberOfResults = dao.count(); |
|
59 |
|
|
60 |
List<AuditEvent> results = new ArrayList<AuditEvent>(); |
|
62 |
@Override |
|
63 |
public Pager<AuditEvent> list(Integer pageNumber, Integer pageSize, AuditEventSort sort) { |
|
64 |
long numberOfResults = dao.count(); |
|
65 |
|
|
66 |
List<AuditEvent> results = new ArrayList<>(); |
|
61 | 67 |
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize) |
62 |
results = dao.list(pageNumber, pageSize, sort);
|
|
68 |
results = dao.list(pageNumber, pageSize, sort); |
|
63 | 69 |
} |
64 |
|
|
65 |
return new DefaultPagerImpl<AuditEvent>(pageNumber, numberOfResults, pageSize, results);
|
|
70 |
|
|
71 |
return new DefaultPagerImpl<>(pageNumber, numberOfResults, pageSize, results); |
|
66 | 72 |
} |
67 | 73 |
|
68 |
public AuditEvent find(DateTime dateTime) { |
|
74 |
@Override |
|
75 |
public AuditEvent find(DateTime dateTime) { |
|
69 | 76 |
return dao.findByDate(dateTime); |
70 | 77 |
} |
71 | 78 |
} |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DescriptionServiceImpl.java | ||
---|---|---|
180 | 180 |
Set<Feature> features, Class<T> type, Integer pageSize, Integer pageNumber, List<String> propertyPaths) { |
181 | 181 |
|
182 | 182 |
List<T> results = listDescriptionElements(description, descriptionType, features, type, pageSize, pageNumber, propertyPaths); |
183 |
return new DefaultPagerImpl<T>(pageNumber, results.size(), pageSize, results);
|
|
183 |
return new DefaultPagerImpl<>(pageNumber, results.size(), pageSize, results); |
|
184 | 184 |
} |
185 | 185 |
|
186 | 186 |
@Override |
... | ... | |
389 | 389 |
*/ |
390 | 390 |
@Override |
391 | 391 |
public Pager<DescriptionElementBase> searchElements(Class<? extends DescriptionElementBase> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) { |
392 |
Integer numberOfResults = descriptionElementDao.count(clazz, queryString);
|
|
392 |
long numberOfResults = descriptionElementDao.count(clazz, queryString);
|
|
393 | 393 |
|
394 |
List<DescriptionElementBase> results = new ArrayList<DescriptionElementBase>();
|
|
394 |
List<DescriptionElementBase> results = new ArrayList<>(); |
|
395 | 395 |
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize) |
396 | 396 |
results = descriptionElementDao.search(clazz, queryString, pageSize, pageNumber, orderHints, propertyPaths); |
397 | 397 |
} |
398 | 398 |
|
399 |
return new DefaultPagerImpl<DescriptionElementBase>(pageNumber, numberOfResults, pageSize, results);
|
|
399 |
return new DefaultPagerImpl<>(pageNumber, numberOfResults, pageSize, results); |
|
400 | 400 |
} |
401 | 401 |
|
402 | 402 |
/** |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IdentifiableServiceBase.java | ||
---|---|---|
69 | 69 |
@Override |
70 | 70 |
@Transactional(readOnly = true) |
71 | 71 |
public Pager<Rights> getRights(T t, Integer pageSize, Integer pageNumber, List<String> propertyPaths) { |
72 |
Integer numberOfResults = dao.countRights(t);
|
|
72 |
long numberOfResults = dao.countRights(t);
|
|
73 | 73 |
|
74 | 74 |
List<Rights> results = new ArrayList<>(); |
75 | 75 |
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize) |
... | ... | |
82 | 82 |
@Override |
83 | 83 |
@Transactional(readOnly = true) |
84 | 84 |
public Pager<IdentifiableSource> getSources(T t, Integer pageSize, Integer pageNumber, List<String> propertyPaths) { |
85 |
Integer numberOfResults = dao.countSources(t);
|
|
85 |
long numberOfResults = dao.countSources(t);
|
|
86 | 86 |
|
87 | 87 |
List<IdentifiableSource> results = new ArrayList<>(); |
88 | 88 |
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize) |
... | ... | |
221 | 221 |
@Transactional(readOnly = true) |
222 | 222 |
@Override |
223 | 223 |
public Pager<T> search(Class<? extends T> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) { |
224 |
Integer numberOfResults = dao.count(clazz,queryString);
|
|
224 |
long numberOfResults = dao.count(clazz,queryString);
|
|
225 | 225 |
|
226 | 226 |
List<T> results = new ArrayList<>(); |
227 | 227 |
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize) |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IdentificationKeyServiceImpl.java | ||
---|---|---|
28 | 28 |
|
29 | 29 |
@Override |
30 | 30 |
public Pager<IIdentificationKey> page(Integer pageSize, Integer pageNumber, List<String> propertyPaths) { |
31 |
Integer numberOfResults = dao.count();
|
|
32 |
List<IIdentificationKey> results = new ArrayList<IIdentificationKey>();
|
|
31 |
long numberOfResults = dao.count();
|
|
32 |
List<IIdentificationKey> results = new ArrayList<>(); |
|
33 | 33 |
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize) |
34 | 34 |
Integer limit = PagerUtils.limitFor(pageSize); |
35 | 35 |
Integer start = PagerUtils.startFor(pageSize, pageNumber); |
36 | 36 |
results = dao.list(limit, start, propertyPaths); |
37 | 37 |
} |
38 |
return new DefaultPagerImpl<IIdentificationKey>(pageNumber, numberOfResults, pageSize, results);
|
|
38 |
return new DefaultPagerImpl<>(pageNumber, numberOfResults, pageSize, results); |
|
39 | 39 |
} |
40 | 40 |
|
41 | 41 |
|
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/MediaServiceImpl.java | ||
---|---|---|
77 | 77 |
|
78 | 78 |
@Override |
79 | 79 |
public Pager<Rights> getRights(Media t, Integer pageSize, Integer pageNumber, List<String> propertyPaths) { |
80 |
Integer numberOfResults = dao.countRights(t);
|
|
80 |
long numberOfResults = dao.countRights(t);
|
|
81 | 81 |
|
82 | 82 |
List<Rights> results = new ArrayList<>(); |
83 | 83 |
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize) |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/NameServiceImpl.java | ||
---|---|---|
796 | 796 |
@Override |
797 | 797 |
public Pager<TypeDesignationBase> getTypeDesignations(TaxonName name, SpecimenTypeDesignationStatus status, |
798 | 798 |
Integer pageSize, Integer pageNumber, List<String> propertyPaths){ |
799 |
Integer numberOfResults = dao.countTypeDesignations(name, status);
|
|
799 |
long numberOfResults = dao.countTypeDesignations(name, status);
|
|
800 | 800 |
|
801 |
List<TypeDesignationBase> results = new ArrayList<TypeDesignationBase>();
|
|
802 |
if(AbstractPagerImpl.hasResultsInRange(numberOfResults.longValue(), pageNumber, pageSize)) {
|
|
801 |
List<TypeDesignationBase> results = new ArrayList<>(); |
|
802 |
if(AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize)) { |
|
803 | 803 |
results = dao.getTypeDesignations(name, null, status, pageSize, pageNumber, propertyPaths); |
804 | 804 |
} |
805 | 805 |
|
806 |
return new DefaultPagerImpl<TypeDesignationBase>(pageNumber, numberOfResults, pageSize, results);
|
|
806 |
return new DefaultPagerImpl<>(pageNumber, numberOfResults, pageSize, results); |
|
807 | 807 |
} |
808 | 808 |
|
809 | 809 |
/** |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/OccurrenceServiceImpl.java | ||
---|---|---|
385 | 385 |
} |
386 | 386 |
//dao.list() does the paging of the field units. Passing the field units directly to the Pager would not work |
387 | 387 |
List<SpecimenOrObservationBase> fieldUnits = dao.list(fieldUnitUuids, pageSize, pageNumber, orderHints, propertyPaths); |
388 |
return new DefaultPagerImpl<SpecimenOrObservationBase>(pageNumber, fieldUnitUuids.size(), pageSize, fieldUnits);
|
|
388 |
return new DefaultPagerImpl<>(pageNumber, fieldUnitUuids.size(), pageSize, fieldUnits); |
|
389 | 389 |
} |
390 | 390 |
|
391 | 391 |
@Override |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/VersionableServiceBase.java | ||
---|---|---|
35 | 35 |
@Override |
36 | 36 |
@Transactional(readOnly = true) |
37 | 37 |
public Pager<AuditEventRecord<T>> pageAuditEvents(T t, Integer pageSize, Integer pageNumber, AuditEventSort sort, List<String> propertyPaths) { |
38 |
Integer numberOfResults = dao.countAuditEvents(t, sort);
|
|
38 |
long numberOfResults = dao.countAuditEvents(t, sort);
|
|
39 | 39 |
|
40 |
List<AuditEventRecord<T>> results = new ArrayList<AuditEventRecord<T>>();
|
|
40 |
List<AuditEventRecord<T>> results = new ArrayList<>(); |
|
41 | 41 |
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize) |
42 | 42 |
results = dao.getAuditEvents(t, pageSize, pageNumber, sort,propertyPaths); |
43 | 43 |
} |
44 | 44 |
|
45 |
return new DefaultPagerImpl<AuditEventRecord<T>>(pageNumber, numberOfResults, pageSize, results);
|
|
45 |
return new DefaultPagerImpl<>(pageNumber, numberOfResults, pageSize, results); |
|
46 | 46 |
} |
47 | 47 |
|
48 | 48 |
@Override |
... | ... | |
60 | 60 |
@Override |
61 | 61 |
@Transactional(readOnly = true) |
62 | 62 |
public Pager<AuditEventRecord<T>> pageAuditEvents(Class<? extends T> clazz,AuditEvent from,AuditEvent to, List<AuditCriterion> criteria, Integer pageSize, Integer pageNumber, AuditEventSort sort,List<String> propertyPaths) { |
63 |
Integer numberOfResults = dao.countAuditEvents(clazz, from, to, criteria);
|
|
63 |
long numberOfResults = dao.countAuditEvents(clazz, from, to, criteria);
|
|
64 | 64 |
|
65 |
List<AuditEventRecord<T>> results = new ArrayList<AuditEventRecord<T>>();
|
|
65 |
List<AuditEventRecord<T>> results = new ArrayList<>(); |
|
66 | 66 |
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize) |
67 | 67 |
results = dao.getAuditEvents(clazz,from,to,criteria, pageSize, pageNumber, sort,propertyPaths); |
68 | 68 |
} |
69 | 69 |
|
70 |
return new DefaultPagerImpl<AuditEventRecord<T>>(pageNumber, numberOfResults, pageSize, results);
|
|
70 |
return new DefaultPagerImpl<>(pageNumber, numberOfResults, pageSize, results); |
|
71 | 71 |
} |
72 | 72 |
|
73 | 73 |
/** |
Also available in: Unified diff
use long instead of int (cont.)