1
|
/**
|
2
|
* Copyright (C) 2008 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*/
|
6
|
|
7
|
package eu.etaxonomy.cdm.persistence.dao.occurrence;
|
8
|
|
9
|
import java.util.Collection;
|
10
|
import java.util.List;
|
11
|
import java.util.UUID;
|
12
|
|
13
|
import org.springframework.dao.DataAccessException;
|
14
|
|
15
|
import eu.etaxonomy.cdm.model.description.DescriptionBase;
|
16
|
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
|
17
|
import eu.etaxonomy.cdm.model.description.TaxonDescription;
|
18
|
import eu.etaxonomy.cdm.model.location.Point;
|
19
|
import eu.etaxonomy.cdm.model.media.Media;
|
20
|
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
|
21
|
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
|
22
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
23
|
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent;
|
24
|
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
|
25
|
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
|
26
|
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
|
27
|
import eu.etaxonomy.cdm.model.occurrence.GatheringEvent;
|
28
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
29
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
|
30
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
31
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
32
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
33
|
import eu.etaxonomy.cdm.persistence.dao.common.IIdentifiableDao;
|
34
|
import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;
|
35
|
import eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper;
|
36
|
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
|
37
|
import eu.etaxonomy.cdm.persistence.query.MatchMode;
|
38
|
import eu.etaxonomy.cdm.persistence.query.OrderHint;
|
39
|
|
40
|
/**
|
41
|
* @author a.babadshanjan
|
42
|
* @since 01.09.2008
|
43
|
*/
|
44
|
public interface IOccurrenceDao extends IIdentifiableDao<SpecimenOrObservationBase> {
|
45
|
|
46
|
/**
|
47
|
* Returns the number of occurences belonging to a certain subclass - which must extend SpecimenOrObservationBase
|
48
|
* @param clazz optionally restrict the counted occurrences to those of a certain subclass of SpecimenOrObservationBase
|
49
|
* @param determinedAs the taxon name that these specimens are determined to belong to
|
50
|
* @return
|
51
|
*/
|
52
|
public long count(Class<? extends SpecimenOrObservationBase> clazz,TaxonName determinedAs);
|
53
|
|
54
|
/**
|
55
|
* Returns a sublist of SpecimenOrObservationBase instances stored in the database. A maximum
|
56
|
* of 'limit' objects are returned, starting at object with index 'start'. Only occurrences which
|
57
|
* have been determined to belong to the supplied name are returned.
|
58
|
*
|
59
|
* @param type
|
60
|
* @param determinedAs the taxon name that these specimens are determined to belong to
|
61
|
* @param orderHints
|
62
|
* Supports path like <code>orderHints.propertyNames</code> which
|
63
|
* include *-to-one properties like createdBy.username or
|
64
|
* authorTeam.persistentTitleCache
|
65
|
* @return
|
66
|
* @throws DataAccessException
|
67
|
*/
|
68
|
public List<SpecimenOrObservationBase> list(Class<? extends SpecimenOrObservationBase> type, TaxonName determinedAs,
|
69
|
Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
|
70
|
|
71
|
/**
|
72
|
* Returns the number of occurences belonging to a certain subclass - which must extend SpecimenOrObservationBase
|
73
|
* @param clazz optionally restrict the counted occurrences to those of a certain subclass of SpecimenOrObservationBase
|
74
|
* @param determinedAs the taxon concept that these specimens are determined to belong to
|
75
|
* @return
|
76
|
*/
|
77
|
public long count(Class<? extends SpecimenOrObservationBase> clazz,TaxonBase determinedAs);
|
78
|
|
79
|
/**
|
80
|
* Returns a sublist of SpecimenOrObservationBase instances stored in the database. A maximum
|
81
|
* of 'limit' objects are returned, starting at object with index 'start'. Only occurrences which
|
82
|
* have been determined to belong to the supplied concept are returned.
|
83
|
*
|
84
|
* @param type
|
85
|
* @param determinedAs the taxon concept that these specimens are determined to belong to
|
86
|
* @param orderHints
|
87
|
* Supports path like <code>orderHints.propertyNames</code> which
|
88
|
* include *-to-one properties like createdBy.username or
|
89
|
* authorTeam.persistentTitleCache
|
90
|
* @return
|
91
|
* @throws DataAccessException
|
92
|
*/
|
93
|
public List<SpecimenOrObservationBase> list(Class<? extends SpecimenOrObservationBase> type, TaxonBase determinedAs,
|
94
|
Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
|
95
|
|
96
|
/**
|
97
|
* Queries the database for specimens which match the given criteria<br>
|
98
|
* <b>Note:</b> Specifying a taxon will already check the name of this
|
99
|
* taxon, its synonymy and the synonym names for determinations of the
|
100
|
* specimen. So specifying a taxon name is only necessary if it does not
|
101
|
* belong to the before-mentioned group of names.
|
102
|
*
|
103
|
* @param clazz
|
104
|
* the class to match
|
105
|
* @param queryString
|
106
|
* the queryString to match
|
107
|
* @param type
|
108
|
* the {@link SpecimenOrObservationType} to match
|
109
|
* @param associatedTaxon
|
110
|
* the taxon these specimens are in any way associated to via
|
111
|
* determination, type designations, individuals associations,
|
112
|
* etc.
|
113
|
* @param associatedTaxonName
|
114
|
* the taxon name that the specimens have been determined as
|
115
|
* @param matchmode
|
116
|
* determines how the query string should be matched
|
117
|
* @param limit
|
118
|
* the maximum number of entities returned (can be null to return
|
119
|
* all entities)
|
120
|
* @param start
|
121
|
* @param orderHints
|
122
|
* Supports path like <code>orderHints.propertyNames</code> which
|
123
|
* include *-to-one properties like createdBy.username or
|
124
|
* authorTeam.persistentTitleCache
|
125
|
* @param propertyPaths
|
126
|
* @return a list of specimens that match the given parameters
|
127
|
*/
|
128
|
public <T extends SpecimenOrObservationBase> List<T> findOccurrences(Class<T> clazz, String queryString,
|
129
|
String significantIdentifier, SpecimenOrObservationType type, Taxon determinedAs,
|
130
|
TaxonName associatedTaxonName, MatchMode matchmode, Integer limit, Integer start,
|
131
|
List<OrderHint> orderHints, List<String> propertyPaths);
|
132
|
|
133
|
/**
|
134
|
* @see IOccurrenceDao#findOccurrences(Class, String, String, SpecimenOrObservationType, Taxon, TaxonName, MatchMode, Integer, Integer, List, List)
|
135
|
* @param clazz
|
136
|
* @param queryString
|
137
|
* @param significantIdentifier
|
138
|
* @param type
|
139
|
* @param determinedAs
|
140
|
* @param associatedTaxonName
|
141
|
* @param matchmode
|
142
|
* @param limit
|
143
|
* @param start
|
144
|
* @param orderHints
|
145
|
* @param propertyPaths
|
146
|
* @return
|
147
|
*/
|
148
|
public <T extends SpecimenOrObservationBase> List<UuidAndTitleCache<SpecimenOrObservationBase>> findOccurrencesUuidAndTitleCache(
|
149
|
Class<T> clazz, String queryString,
|
150
|
String significantIdentifier, SpecimenOrObservationType type, Taxon determinedAs,
|
151
|
TaxonName associatedTaxonName, MatchMode matchmode, Integer limit, Integer start,
|
152
|
List<OrderHint> orderHints);
|
153
|
|
154
|
/**
|
155
|
* Returns the number of specimens that match the given parameters
|
156
|
* <b>Note:</b> Specifying a taxon will already check the name of this
|
157
|
* taxon, its synonymy and the synonym names for determinations of the
|
158
|
* specimen. So specifying a taxon name is only necessary if it does not
|
159
|
* belong to the before-mentioned group of names.
|
160
|
*
|
161
|
* @param clazz
|
162
|
* the class to match
|
163
|
* @param queryString
|
164
|
* the queryString to match
|
165
|
* @param type
|
166
|
* the {@link SpecimenOrObservationType} to match
|
167
|
* @param associatedTaxon
|
168
|
* the taxon these specimens are in any way associated to via
|
169
|
* determination, type designations, individuals associations,
|
170
|
* etc.
|
171
|
* @param associatedTaxonName
|
172
|
* the taxon name that the specimens have been determined as
|
173
|
* @param matchmode
|
174
|
* determines how the query string should be matched
|
175
|
* @param limit
|
176
|
* the maximum number of entities returned (can be null to return
|
177
|
* all entities)
|
178
|
* @param start
|
179
|
* @param orderHints
|
180
|
* Supports path like <code>orderHints.propertyNames</code> which
|
181
|
* include *-to-one properties like createdBy.username or
|
182
|
* authorTeam.persistentTitleCache
|
183
|
* @return the number of found specimens
|
184
|
*/
|
185
|
public <T extends SpecimenOrObservationBase> long countOccurrences(Class<T> clazz, String queryString,
|
186
|
String significantIdentifier, SpecimenOrObservationType recordBasis, Taxon associatedTaxon,
|
187
|
TaxonName associatedTaxonName, MatchMode matchmode, Integer limit, Integer start,
|
188
|
List<OrderHint> orderHints, List<String> propertyPaths);
|
189
|
|
190
|
/**
|
191
|
* Returns a count of Media that are associated with a given occurence
|
192
|
*
|
193
|
* @param occurence the occurence associated with these media
|
194
|
* @return a count of media instances
|
195
|
*/
|
196
|
public long countMedia(SpecimenOrObservationBase occurence);
|
197
|
|
198
|
/**
|
199
|
* Returns a List of Media that are associated with a given occurence
|
200
|
*
|
201
|
* @param occurence the occurence associated with these media
|
202
|
* @param pageSize The maximum number of media returned (can be null for all related media)
|
203
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
204
|
* @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
|
205
|
* @return a List of media instances
|
206
|
*/
|
207
|
public List<Media> getMedia(SpecimenOrObservationBase occurence, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
|
208
|
|
209
|
/**
|
210
|
* Returns a count of determinations that have been made for a given occurence and for a given taxon concept
|
211
|
*
|
212
|
* @param occurence the occurence associated with these determinations (can be null for all occurrences)
|
213
|
* @param taxonbase the taxon concept associated with these determinations (can be null for all taxon concepts)
|
214
|
* @return a count of determination events
|
215
|
*/
|
216
|
public long countDeterminations(SpecimenOrObservationBase occurence,TaxonBase taxonbase);
|
217
|
|
218
|
/**
|
219
|
* Returns a List of determinations that have been made for a given occurence and for a given taxon concept
|
220
|
*
|
221
|
* @param occurence the occurence associated with these determinations (can be null for all occurrences)
|
222
|
* @param taxonbase the taxon concept associated with these determinations (can be null for all taxon concepts)
|
223
|
* @param pageSize The maximum number of determinations returned (can be null for all related determinations)
|
224
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
225
|
* @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
|
226
|
* @return a List of determination instances
|
227
|
*/
|
228
|
public List<DeterminationEvent> getDeterminations(SpecimenOrObservationBase occurence,TaxonBase taxonbase, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
|
229
|
|
230
|
/**
|
231
|
* Returns a count of derivation events that have involved creating new DerivedUnits from this occurence
|
232
|
*
|
233
|
* @param occurence the occurence that was a source of these derivation events
|
234
|
* @return a count of derivation events
|
235
|
*/
|
236
|
public long countDerivationEvents(SpecimenOrObservationBase occurence);
|
237
|
|
238
|
/**
|
239
|
* Returns a list of derivation events that have involved creating new DerivedUnits from this occurence
|
240
|
*
|
241
|
* @param occurence the occurence that was a source of these derivation events
|
242
|
* @param pageSize The maximum number of derivation events returned (can be null for all related derivation events)
|
243
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
244
|
* @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
|
245
|
* @return a List of derivation events
|
246
|
*/
|
247
|
public List<DerivationEvent> getDerivationEvents(SpecimenOrObservationBase occurence, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
|
248
|
|
249
|
/**
|
250
|
* Retrieves the {@link UUID} and the string representation (title cache) of all
|
251
|
* {@link FieldUnit}s found in the data base.
|
252
|
* @return a list of {@link UuidAndTitleCache}
|
253
|
*/
|
254
|
public List<UuidAndTitleCache<FieldUnit>> getFieldUnitUuidAndTitleCache();
|
255
|
|
256
|
/**
|
257
|
* Retrieves the {@link UUID} and the string representation (title cache) of all
|
258
|
* {@link DerivedUnit}s found in the data base.
|
259
|
* @return a list of {@link UuidAndTitleCache}
|
260
|
*/
|
261
|
public List<UuidAndTitleCache<DerivedUnit>> getDerivedUnitUuidAndTitleCache(Integer limit, String pattern);
|
262
|
|
263
|
/**
|
264
|
* Lists all instances of {@link SpecimenOrObservationBase} which are determined as the <code>taxon name</code> specified as parameter.
|
265
|
*
|
266
|
* @param <T>
|
267
|
* @param type
|
268
|
* @param associatedTaxonName
|
269
|
* @param limit
|
270
|
* @param start
|
271
|
* @param orderHints
|
272
|
* @param propertyPaths
|
273
|
* @return
|
274
|
*/
|
275
|
public <T extends SpecimenOrObservationBase> List<T> listByAssociatedTaxonName(Class<T> type,
|
276
|
TaxonName associatedTaxonName, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
|
277
|
|
278
|
/**
|
279
|
* Lists all instances of {@link SpecimenOrObservationBase} which are associated with the <code>taxon</code> specified as parameter.
|
280
|
* SpecimenOrObservationBase instances can be associated to taxa in multiple ways, all these possible relations are taken into account:
|
281
|
* <ul>
|
282
|
* <li>The {@link IndividualsAssociation} elements in a {@link TaxonDescription} contain {@link DerivedUnit}s</li>
|
283
|
* <li>{@link SpecimenTypeDesignation}s may be associated with any {@link HomotypicalGroup} related to the specific {@link Taxon}.</li>
|
284
|
* <li>A {@link Taxon} or a {@link TaxonName} may be referenced by the {@link DeterminationEvent} of the {@link SpecimenOrObservationBase}</li>
|
285
|
* </ul>
|
286
|
*
|
287
|
* @param <T>
|
288
|
* @param type
|
289
|
* @param associatedTaxon
|
290
|
* @param limit
|
291
|
* @param start
|
292
|
* @param orderHints
|
293
|
* @param propertyPaths
|
294
|
* @return
|
295
|
*/
|
296
|
public <T extends SpecimenOrObservationBase> List<T> listByAssociatedTaxon(Class<T> type, Taxon associatedTaxon,
|
297
|
Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
|
298
|
|
299
|
/**
|
300
|
* @see IOccurrenceDao#listByAssociatedTaxon(Class, Taxon, Integer, Integer, List, List)
|
301
|
* @param type
|
302
|
* @param associatedTaxon
|
303
|
* @param limit
|
304
|
* @param start
|
305
|
* @param orderHints
|
306
|
* @param propertyPaths
|
307
|
* @return
|
308
|
*/
|
309
|
public <T extends SpecimenOrObservationBase> List<UuidAndTitleCache<SpecimenOrObservationBase>> listUuidAndTitleCacheByAssociatedTaxon(Class<T> type, Taxon associatedTaxon,
|
310
|
Integer limit, Integer start, List<OrderHint> orderHints);
|
311
|
|
312
|
/**
|
313
|
* The method will search for specimen associated with the taxon nodes.<br>
|
314
|
* It will search for 3 possible association types:
|
315
|
* : <br>
|
316
|
* - via IndividualAssociations of the taxon<br>
|
317
|
* - via TypeDesignations of the taxon name<br>
|
318
|
* - via Determinations of the taxon or taxon name<br>
|
319
|
* <br>
|
320
|
* (more are covered in
|
321
|
* {@link IOccurrenceDao#findOccurrences(Class, String, String, SpecimenOrObservationType, Taxon, TaxonName, MatchMode, Integer, Integer, List, List)}
|
322
|
* @param taxonNodeUuids a list of {@link UUID}s of the taxon nodes
|
323
|
* @param limit
|
324
|
* @param start
|
325
|
* @return a collection of {@link SpecimenNodeWrapper} containing the {@link TaxonNode}
|
326
|
* and the corresponding {@link UuidAndTitleCache} object for the specimen found for this taxon node
|
327
|
*/
|
328
|
public Collection<SpecimenNodeWrapper> listUuidAndTitleCacheByAssociatedTaxon(List<UUID> taxonNodeUuids,
|
329
|
Integer limit, Integer start);
|
330
|
|
331
|
/**
|
332
|
* Retrieves all {@link IndividualsAssociation} with the given specimen.<br>
|
333
|
* @param specimen the specimen for which the associations are retrieved
|
334
|
* @param limit
|
335
|
* @param start
|
336
|
* @param orderHints
|
337
|
* @param propertyPaths
|
338
|
* @return collection of all associations
|
339
|
*/
|
340
|
public Collection<IndividualsAssociation> listIndividualsAssociations(SpecimenOrObservationBase<?> specimen, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
|
341
|
|
342
|
/**
|
343
|
* Retrieves all {@link SpecimenTypeDesignation}s which have the given specimen as a type specimen.
|
344
|
* @param specimen the type specimen
|
345
|
* @param limit
|
346
|
* @param start
|
347
|
* @param orderHints
|
348
|
* @param propertyPaths
|
349
|
* @return collection of all designations with the given type specimen
|
350
|
*/
|
351
|
|
352
|
/**
|
353
|
* Retrieves all {@link DeterminationEvent}s which have the given specimen set as identified unit.
|
354
|
* @param specimen
|
355
|
* @param limit
|
356
|
* @param start
|
357
|
* @param orderHints
|
358
|
* @param propertyPaths
|
359
|
* @return collection of all determinations with the given specimen
|
360
|
*/
|
361
|
public Collection<DeterminationEvent> listDeterminationEvents(SpecimenOrObservationBase<?> specimen, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
|
362
|
|
363
|
/**
|
364
|
* Retrieves all {@link SpecimenTypeDesignation}s which have the given specimen as a type specimen.
|
365
|
* @param specimen the type specimen
|
366
|
* @param limit
|
367
|
* @param start
|
368
|
* @param orderHints
|
369
|
* @param propertyPaths
|
370
|
* @return collection of all designations with the given type specimen
|
371
|
*/
|
372
|
public Collection<SpecimenTypeDesignation> listTypeDesignations(SpecimenOrObservationBase<?> specimen, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
|
373
|
|
374
|
/**
|
375
|
* Retrieves all {@link DescriptionBase}s that have the given specimen set as described specimen.
|
376
|
* @param specimen the described specimen
|
377
|
* @param limit
|
378
|
* @param start
|
379
|
* @param orderHints
|
380
|
* @param propertyPaths
|
381
|
* @return collection of all descriptions with the given described specimen
|
382
|
*/
|
383
|
public Collection<DescriptionBase<?>> listDescriptionsWithDescriptionSpecimen(SpecimenOrObservationBase<?> specimen, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
|
384
|
|
385
|
/**
|
386
|
* Retrieves all {@link SpecimenOrObservationBase}s that have the given {@link SpecimenOrObservationType}.
|
387
|
* @param type
|
388
|
* @param limit
|
389
|
* @param start
|
390
|
* @param orderHints
|
391
|
* @param propertyPaths
|
392
|
* @return collection of specimen with the given type
|
393
|
*/
|
394
|
public Collection<SpecimenOrObservationBase> listBySpecimenOrObservationType(SpecimenOrObservationType type, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
|
395
|
|
396
|
/**
|
397
|
*
|
398
|
* Returns all {@link FieldUnit}s that are referencing this {@link GatheringEvent}
|
399
|
* @param gatheringEventUuid the {@link UUID} of the gathering event
|
400
|
* @param limit
|
401
|
* @param start
|
402
|
* @param orderHints
|
403
|
* @param propertyPaths
|
404
|
* @return a list of field units referencing the gathering event
|
405
|
*/
|
406
|
public List<FieldUnit> findFieldUnitsForGatheringEvent(UUID gatheringEventUuid, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
|
407
|
|
408
|
/**
|
409
|
*
|
410
|
* Returns {@link DerivedUnit} that has the accession number and is determined to a taxon
|
411
|
* @param accessionNumber
|
412
|
* @param propertyPaths
|
413
|
* @return a derived unit
|
414
|
*/
|
415
|
public List<DerivedUnit> findByGeneticAccessionNumber(String accessionNumberString, List<String> propertyPaths);
|
416
|
|
417
|
/**
|
418
|
* @param derivedUnitUuid
|
419
|
* @return
|
420
|
*/
|
421
|
public List<SpecimenOrObservationBase> findOriginalsForDerivedUnit(UUID derivedUnitUuid, List<String> propertyPaths);
|
422
|
|
423
|
/**
|
424
|
* @param fieldUnitUuids
|
425
|
* @return
|
426
|
*/
|
427
|
public List<Point> findPointsForFieldUnitList(List<UUID> fieldUnitUuids);
|
428
|
}
|