Project

General

Profile

Download (19.5 KB) Statistics
| Branch: | Tag: | Revision:
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.media.Media;
19
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
20
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
21
import eu.etaxonomy.cdm.model.name.TaxonName;
22
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent;
23
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
24
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
25
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
26
import eu.etaxonomy.cdm.model.occurrence.GatheringEvent;
27
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
28
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
29
import eu.etaxonomy.cdm.model.taxon.Taxon;
30
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
31
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
32
import eu.etaxonomy.cdm.persistence.dao.common.IIdentifiableDao;
33
import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;
34
import eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper;
35
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
36
import eu.etaxonomy.cdm.persistence.query.MatchMode;
37
import eu.etaxonomy.cdm.persistence.query.OrderHint;
38

    
39
/**
40
 * @author a.babadshanjan
41
 * @since 01.09.2008
42
 */
43
public interface IOccurrenceDao extends IIdentifiableDao<SpecimenOrObservationBase> {
44

    
45
    /**
46
     * Returns the number of occurences belonging to a certain subclass - which must extend SpecimenOrObservationBase
47
     * @param clazz optionally restrict the counted occurrences to those of a certain subclass of SpecimenOrObservationBase
48
     * @param determinedAs the taxon name that these specimens are determined to belong to
49
     * @return
50
     */
51
    public int count(Class<? extends SpecimenOrObservationBase> clazz,TaxonName determinedAs);
52

    
53
    /**
54
     * Returns a sublist of SpecimenOrObservationBase instances stored in the database. A maximum
55
     * of 'limit' objects are returned, starting at object with index 'start'. Only occurrences which
56
     * have been determined to belong to the supplied name are returned.
57
     *
58
     * @param type
59
     * @param determinedAs the taxon name that these specimens are determined to belong to
60
     * @param limit
61
     *            the maximum number of entities returned (can be null to return
62
     *            all entities)
63
     * @param start
64
     * @param orderHints
65
     *            Supports path like <code>orderHints.propertyNames</code> which
66
     *            include *-to-one properties like createdBy.username or
67
     *            authorTeam.persistentTitleCache
68
     * @return
69
     * @throws DataAccessException
70
     */
71
    public List<SpecimenOrObservationBase> list(Class<? extends SpecimenOrObservationBase> type, TaxonName determinedAs, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
72

    
73
    /**
74
	 * Returns the number of occurences belonging to a certain subclass - which must extend SpecimenOrObservationBase
75
	 * @param clazz optionally restrict the counted occurrences to those of a certain subclass of SpecimenOrObservationBase
76
	 * @param determinedAs the taxon concept that these specimens are determined to belong to
77
	 * @return
78
	 */
79
	public int count(Class<? extends SpecimenOrObservationBase> clazz,TaxonBase determinedAs);
80

    
81
	/**
82
	 * Returns a sublist of SpecimenOrObservationBase instances stored in the database. A maximum
83
	 * of 'limit' objects are returned, starting at object with index 'start'. Only occurrences which
84
	 * have been determined to belong to the supplied concept are returned.
85
	 *
86
	 * @param type
87
	 * @param determinedAs the taxon concept that these specimens are determined to belong to
88
	 * @param limit
89
	 *            the maximum number of entities returned (can be null to return
90
	 *            all entities)
91
	 * @param start
92
	 * @param orderHints
93
	 *            Supports path like <code>orderHints.propertyNames</code> which
94
	 *            include *-to-one properties like createdBy.username or
95
	 *            authorTeam.persistentTitleCache
96
	 * @return
97
	 * @throws DataAccessException
98
	 */
99
	public List<SpecimenOrObservationBase> list(Class<? extends SpecimenOrObservationBase> type, TaxonBase determinedAs, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
100

    
101
	/**
102
     * Queries the database for specimens which match the given criteria<br>
103
     * <b>Note:</b> Specifying a taxon will already check the name of this
104
     * taxon, its synonymy and the synonym names for determinations of the
105
     * specimen. So specifying a taxon name is only necessary if it does not
106
     * belong to the before-mentioned group of names.
107
     *
108
     * @param clazz
109
     *            the class to match
110
     * @param queryString
111
     *            the queryString to match
112
     * @param type
113
     *            the {@link SpecimenOrObservationType} to match
114
     * @param associatedTaxon
115
     *            the taxon these specimens are in any way associated to via
116
     *            determination, type designations, individuals associations,
117
     *            etc.
118
     * @param associatedTaxonName
119
     *            the taxon name that the specimens have been determined as
120
     * @param matchmode
121
     *            determines how the query string should be matched
122
     * @param limit
123
     *            the maximum number of entities returned (can be null to return
124
     *            all entities)
125
     * @param start
126
     * @param orderHints
127
     *            Supports path like <code>orderHints.propertyNames</code> which
128
     *            include *-to-one properties like createdBy.username or
129
     *            authorTeam.persistentTitleCache
130
     * @param propertyPaths
131
     * @return a list of specimens that match the given parameters
132
     */
133
    public <T extends SpecimenOrObservationBase> List<T> findOccurrences(Class<T> clazz, String queryString,
134
            String significantIdentifier, SpecimenOrObservationType type, Taxon determinedAs,
135
            TaxonName associatedTaxonName, MatchMode matchmode, Integer limit, Integer start,
136
            List<OrderHint> orderHints, List<String> propertyPaths);
137

    
138
    /**
139
     * @see IOccurrenceDao#findOccurrences(Class, String, String, SpecimenOrObservationType, Taxon, TaxonName, MatchMode, Integer, Integer, List, List)
140
     * @param clazz
141
     * @param queryString
142
     * @param significantIdentifier
143
     * @param type
144
     * @param determinedAs
145
     * @param associatedTaxonName
146
     * @param matchmode
147
     * @param limit
148
     * @param start
149
     * @param orderHints
150
     * @param propertyPaths
151
     * @return
152
     */
153
    public <T extends SpecimenOrObservationBase> List<UuidAndTitleCache<SpecimenOrObservationBase>> findOccurrencesUuidAndTitleCache(
154
            Class<T> clazz, String queryString,
155
            String significantIdentifier, SpecimenOrObservationType type, Taxon determinedAs,
156
            TaxonName associatedTaxonName, MatchMode matchmode, Integer limit, Integer start,
157
            List<OrderHint> orderHints);
158

    
159
    /**
160
     * Returns the number of specimens that match the given parameters
161
     * <b>Note:</b> Specifying a taxon will already check the name of this
162
     * taxon, its synonymy and the synonym names for determinations of the
163
     * specimen. So specifying a taxon name is only necessary if it does not
164
     * belong to the before-mentioned group of names.
165
     *
166
     * @param clazz
167
     *            the class to match
168
     * @param queryString
169
     *            the queryString to match
170
     * @param type
171
     *            the {@link SpecimenOrObservationType} to match
172
     * @param associatedTaxon
173
     *            the taxon these specimens are in any way associated to via
174
     *            determination, type designations, individuals associations,
175
     *            etc.
176
     * @param associatedTaxonName
177
     *            the taxon name that the specimens have been determined as
178
     * @param matchmode
179
     *            determines how the query string should be matched
180
     * @param limit
181
     *            the maximum number of entities returned (can be null to return
182
     *            all entities)
183
     * @param start
184
     * @param orderHints
185
     *            Supports path like <code>orderHints.propertyNames</code> which
186
     *            include *-to-one properties like createdBy.username or
187
     *            authorTeam.persistentTitleCache
188
     * @return the number of found specimens
189
     */
190
    public <T extends SpecimenOrObservationBase> int countOccurrences(Class<T> clazz, String queryString,
191
            String significantIdentifier, SpecimenOrObservationType recordBasis, Taxon associatedTaxon,
192
            TaxonName associatedTaxonName, MatchMode matchmode, Integer limit, Integer start,
193
            List<OrderHint> orderHints, List<String> propertyPaths);
194

    
195
	/**
196
     * Returns a count of Media that are associated with a given occurence
197
     *
198
	 * @param occurence the occurence associated with these media
199
     * @return a count of media instances
200
     */
201
	public int countMedia(SpecimenOrObservationBase occurence);
202

    
203
    /**
204
     * Returns a List of Media that are associated with a given occurence
205
     *
206
	 * @param occurence the occurence associated with these media
207
	 * @param pageSize The maximum number of media returned (can be null for all related media)
208
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
209
	 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
210
     * @return a List of media instances
211
     */
212
	public List<Media> getMedia(SpecimenOrObservationBase occurence, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
213

    
214
	/**
215
     * Returns a count of determinations that have been made for a given occurence and for a given taxon concept
216
     *
217
	 * @param occurence the occurence associated with these determinations (can be null for all occurrences)
218
	 * @param taxonbase the taxon concept associated with these determinations (can be null for all taxon concepts)
219
     * @return a count of determination events
220
     */
221
    public int countDeterminations(SpecimenOrObservationBase occurence,TaxonBase taxonbase);
222

    
223
    /**
224
     * Returns a List of determinations that have been made for a given occurence and for a given taxon concept
225
     *
226
	 * @param occurence the occurence associated with these determinations (can be null for all occurrences)
227
	 * @param taxonbase the taxon concept associated with these determinations (can be null for all taxon concepts)
228
	 * @param pageSize The maximum number of determinations returned (can be null for all related determinations)
229
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
230
	 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
231
     * @return a List of determination instances
232
     */
233
	public List<DeterminationEvent> getDeterminations(SpecimenOrObservationBase occurence,TaxonBase taxonbase, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
234

    
235
	/**
236
     * Returns a count of derivation events that have involved creating new DerivedUnits from this occurence
237
     *
238
	 * @param occurence the occurence that was a source of these derivation events
239
     * @return a count of derivation events
240
     */
241
    public int countDerivationEvents(SpecimenOrObservationBase occurence);
242

    
243
    /**
244
     * Returns a list of derivation events that have involved creating new DerivedUnits from this occurence
245
     *
246
	 * @param occurence the occurence that was a source of these derivation events
247
	 * @param pageSize The maximum number of derivation events returned (can be null for all related derivation events)
248
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
249
	 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
250
     * @return a List of derivation events
251
     */
252
	public List<DerivationEvent> getDerivationEvents(SpecimenOrObservationBase occurence, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
253

    
254
    /**
255
     * Retrieves the {@link UUID} and the string representation (title cache) of all
256
     * {@link FieldUnit}s found in the data base.
257
     * @return a list of {@link UuidAndTitleCache}
258
     */
259
	public List<UuidAndTitleCache<FieldUnit>> getFieldUnitUuidAndTitleCache();
260

    
261
    /**
262
     * Retrieves the {@link UUID} and the string representation (title cache) of all
263
     * {@link DerivedUnit}s found in the data base.
264
     * @return a list of {@link UuidAndTitleCache}
265
     */
266
	public List<UuidAndTitleCache<DerivedUnit>> getDerivedUnitUuidAndTitleCache(Integer limit, String pattern);
267

    
268
	/**
269
	 * Lists all instances of {@link SpecimenOrObservationBase} which are determined as the <code>taxon name</code> specified as parameter.
270
	 *
271
	 * @param <T>
272
	 * @param type
273
	 * @param associatedTaxonName
274
	 * @param limit
275
	 * @param start
276
	 * @param orderHints
277
	 * @param propertyPaths
278
	 * @return
279
	 */
280
	public <T extends SpecimenOrObservationBase> List<T> listByAssociatedTaxonName(Class<T> type,
281
            TaxonName associatedTaxonName, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
282

    
283
	/**
284
	 * Lists all instances of {@link SpecimenOrObservationBase} which are associated with the <code>taxon</code> specified as parameter.
285
	 * SpecimenOrObservationBase instances can be associated to taxa in multiple ways, all these possible relations are taken into account:
286
	 * <ul>
287
	 * <li>The {@link IndividualsAssociation} elements in a {@link TaxonDescription} contain {@link DerivedUnit}s</li>
288
	 * <li>{@link SpecimenTypeDesignation}s may be associated with any {@link HomotypicalGroup} related to the specific {@link Taxon}.</li>
289
	 * <li>A {@link Taxon} or a {@link TaxonName} may be referenced by the {@link DeterminationEvent} of the {@link SpecimenOrObservationBase}</li>
290
	 * </ul>
291
	 *
292
	 * @param <T>
293
	 * @param type
294
	 * @param associatedTaxon
295
	 * @param limit
296
	 * @param start
297
	 * @param orderHints
298
	 * @param propertyPaths
299
	 * @return
300
	 */
301
	public <T extends SpecimenOrObservationBase> List<T> listByAssociatedTaxon(Class<T> type, Taxon associatedTaxon,
302
			Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
303

    
304
	/**
305
	 * @see IOccurrenceDao#listByAssociatedTaxon(Class, Taxon, Integer, Integer, List, List)
306
	 * @param type
307
	 * @param associatedTaxon
308
	 * @param limit
309
	 * @param start
310
	 * @param orderHints
311
	 * @param propertyPaths
312
	 * @return
313
	 */
314
	public <T extends SpecimenOrObservationBase> List<UuidAndTitleCache<SpecimenOrObservationBase>> listUuidAndTitleCacheByAssociatedTaxon(Class<T> type, Taxon associatedTaxon,
315
	        Integer limit, Integer start, List<OrderHint> orderHints);
316

    
317
    /**
318
     * The method will search for specimen associated with the taxon nodes.<br>
319
     * It will search for 3 possible association types:
320
     * : <br>
321
     *  - via IndividualAssociations of the taxon<br>
322
     *  - via TypeDesignations of the taxon name<br>
323
     *  - via Determinations of the taxon or taxon name<br>
324
     *  <br>
325
     *  (more are covered in
326
     * {@link IOccurrenceDao#findOccurrences(Class, String, String, SpecimenOrObservationType, Taxon, TaxonName, MatchMode, Integer, Integer, List, List)}
327
     * @param taxonNodeUuids a list of {@link UUID}s of the taxon nodes
328
     * @param limit
329
     * @param start
330
     * @return a collection of {@link SpecimenNodeWrapper} containing the {@link TaxonNode}
331
     * and the corresponding {@link UuidAndTitleCache}  object for the specimen found for this taxon node
332
     */
333
	public Collection<SpecimenNodeWrapper> listUuidAndTitleCacheByAssociatedTaxon(List<UUID> taxonNodeUuids,
334
            Integer limit, Integer start);
335

    
336
    /**
337
     * Retrieves all {@link IndividualsAssociation} with the given specimen.<br>
338
     * @param specimen the specimen for which the associations are retrieved
339
     * @param limit
340
     * @param start
341
     * @param orderHints
342
     * @param propertyPaths
343
     * @return collection of all associations
344
     */
345
	public Collection<IndividualsAssociation> listIndividualsAssociations(SpecimenOrObservationBase<?> specimen, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
346

    
347
	/**
348
	 * Retrieves all {@link SpecimenTypeDesignation}s which have the given specimen as a type specimen.
349
	 * @param specimen the type specimen
350
	 * @param limit
351
	 * @param start
352
	 * @param orderHints
353
	 * @param propertyPaths
354
	 * @return collection of all designations with the given type specimen
355
	 */
356

    
357
	/**
358
     * Retrieves all {@link DeterminationEvent}s which have the given specimen set as identified unit.
359
	 * @param specimen
360
	 * @param limit
361
	 * @param start
362
	 * @param orderHints
363
	 * @param propertyPaths
364
	 * @return collection of all determinations with the given specimen
365
	 */
366
    public Collection<DeterminationEvent> listDeterminationEvents(SpecimenOrObservationBase<?> specimen, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
367

    
368
    /**
369
     * Retrieves all {@link SpecimenTypeDesignation}s which have the given specimen as a type specimen.
370
     * @param specimen the type specimen
371
     * @param limit
372
     * @param start
373
     * @param orderHints
374
     * @param propertyPaths
375
     * @return collection of all designations with the given type specimen
376
     */
377
    public Collection<SpecimenTypeDesignation> listTypeDesignations(SpecimenOrObservationBase<?> specimen, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
378

    
379
    /**
380
     * Retrieves all {@link DescriptionBase}s that have the given specimen set as described specimen.
381
     * @param specimen the described specimen
382
     * @param limit
383
     * @param start
384
     * @param orderHints
385
     * @param propertyPaths
386
     * @return collection of all descriptions with the given described specimen
387
     */
388
    public Collection<DescriptionBase<?>> listDescriptionsWithDescriptionSpecimen(SpecimenOrObservationBase<?> specimen, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
389

    
390
    /**
391
     * Retrieves all {@link SpecimenOrObservationBase}s that have the given {@link SpecimenOrObservationType}.
392
     * @param type
393
     * @param limit
394
     * @param start
395
     * @param orderHints
396
     * @param propertyPaths
397
     * @return collection of specimen with the given type
398
     */
399
    public Collection<SpecimenOrObservationBase> listBySpecimenOrObservationType(SpecimenOrObservationType type, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
400

    
401
    /**
402
     *
403
     * Returns all {@link FieldUnit}s that are referencing this {@link GatheringEvent}
404
     * @param gatheringEventUuid the {@link UUID} of the gathering event
405
     * @param limit
406
     * @param start
407
     * @param orderHints
408
     * @param propertyPaths
409
     * @return a list of field units referencing the gathering event
410
     */
411
    public List<FieldUnit> getFieldUnitsForGatheringEvent(UUID gatheringEventUuid, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
412
}
(2-2/2)