2 * Copyright (C) 2008 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
7 package eu
.etaxonomy
.cdm
.persistence
.dao
.occurrence
;
9 import java
.util
.Collection
;
10 import java
.util
.List
;
11 import java
.util
.UUID
;
13 import org
.springframework
.dao
.DataAccessException
;
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
;
40 * @author a.babadshanjan
43 public interface IOccurrenceDao
extends IIdentifiableDao
<SpecimenOrObservationBase
> {
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
51 public long count(Class
<?
extends SpecimenOrObservationBase
> clazz
,TaxonName determinedAs
);
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.
59 * @param determinedAs the taxon name that these specimens are determined to belong to
61 * Supports path like <code>orderHints.propertyNames</code> which
62 * include *-to-one properties like createdBy.username or
63 * authorTeam.persistentTitleCache
65 * @throws DataAccessException
67 public List
<SpecimenOrObservationBase
> list(Class
<?
extends SpecimenOrObservationBase
> type
, TaxonName determinedAs
,
68 Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
71 * Returns the number of occurences belonging to a certain subclass - which must extend SpecimenOrObservationBase
72 * @param clazz optionally restrict the counted occurrences to those of a certain subclass of SpecimenOrObservationBase
73 * @param determinedAs the taxon concept that these specimens are determined to belong to
76 public long count(Class
<?
extends SpecimenOrObservationBase
> clazz
,TaxonBase determinedAs
);
79 * Returns a sublist of SpecimenOrObservationBase instances stored in the database. A maximum
80 * of 'limit' objects are returned, starting at object with index 'start'. Only occurrences which
81 * have been determined to belong to the supplied concept are returned.
84 * @param determinedAs the taxon concept that these specimens are determined to belong to
86 * Supports path like <code>orderHints.propertyNames</code> which
87 * include *-to-one properties like createdBy.username or
88 * authorTeam.persistentTitleCache
90 * @throws DataAccessException
92 public List
<SpecimenOrObservationBase
> list(Class
<?
extends SpecimenOrObservationBase
> type
, TaxonBase determinedAs
,
93 Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
96 * Queries the database for specimens which match the given criteria<br>
97 * <b>Note:</b> Specifying a taxon will already check the name of this
98 * taxon, its synonymy and the synonym names for determinations of the
99 * specimen. So specifying a taxon name is only necessary if it does not
100 * belong to the before-mentioned group of names.
105 * the queryString to match
107 * the {@link SpecimenOrObservationType} to match
108 * @param associatedTaxon
109 * the taxon these specimens are in any way associated to via
110 * determination, type designations, individuals associations,
112 * @param associatedTaxonName
113 * the taxon name that the specimens have been determined as
115 * determines how the query string should be matched
117 * the maximum number of entities returned (can be null to return
121 * Supports path like <code>orderHints.propertyNames</code> which
122 * include *-to-one properties like createdBy.username or
123 * authorTeam.persistentTitleCache
124 * @param propertyPaths
125 * @return a list of specimens that match the given parameters
127 public <T
extends SpecimenOrObservationBase
> List
<T
> findOccurrences(Class
<T
> clazz
, String queryString
,
128 String significantIdentifier
, SpecimenOrObservationType type
, Taxon determinedAs
,
129 TaxonName associatedTaxonName
, MatchMode matchmode
, Integer limit
, Integer start
,
130 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
133 * @see IOccurrenceDao#findOccurrences(Class, String, String, SpecimenOrObservationType, Taxon, TaxonName, MatchMode, Integer, Integer, List, List)
136 * @param significantIdentifier
138 * @param determinedAs
139 * @param associatedTaxonName
144 * @param propertyPaths
147 public <T
extends SpecimenOrObservationBase
> List
<UuidAndTitleCache
<SpecimenOrObservationBase
>> findOccurrencesUuidAndTitleCache(
148 Class
<T
> clazz
, String queryString
,
149 String significantIdentifier
, SpecimenOrObservationType type
, Taxon determinedAs
,
150 TaxonName associatedTaxonName
, MatchMode matchmode
, Integer limit
, Integer start
,
151 List
<OrderHint
> orderHints
);
154 * Returns the number of specimens that match the given parameters
155 * <b>Note:</b> Specifying a taxon will already check the name of this
156 * taxon, its synonymy and the synonym names for determinations of the
157 * specimen. So specifying a taxon name is only necessary if it does not
158 * belong to the before-mentioned group of names.
163 * the queryString to match
165 * the {@link SpecimenOrObservationType} to match
166 * @param associatedTaxon
167 * the taxon these specimens are in any way associated to via
168 * determination, type designations, individuals associations,
170 * @param associatedTaxonName
171 * the taxon name that the specimens have been determined as
173 * determines how the query string should be matched
175 * the maximum number of entities returned (can be null to return
179 * Supports path like <code>orderHints.propertyNames</code> which
180 * include *-to-one properties like createdBy.username or
181 * authorTeam.persistentTitleCache
182 * @return the number of found specimens
184 public <T
extends SpecimenOrObservationBase
> long countOccurrences(Class
<T
> clazz
, String queryString
,
185 String significantIdentifier
, SpecimenOrObservationType recordBasis
, Taxon associatedTaxon
,
186 TaxonName associatedTaxonName
, MatchMode matchmode
, Integer limit
, Integer start
,
187 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
190 * Returns a count of Media that are associated with a given occurence
192 * @param occurence the occurence associated with these media
193 * @return a count of media instances
195 public long countMedia(SpecimenOrObservationBase occurence
);
198 * Returns a List of Media that are associated with a given occurence
200 * @param occurence the occurence associated with these media
201 * @param pageSize The maximum number of media returned (can be null for all related media)
202 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
203 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
204 * @return a List of media instances
206 public List
<Media
> getMedia(SpecimenOrObservationBase occurence
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
209 * Returns a count of determinations that have been made for a given occurence and for a given taxon concept
211 * @param occurence the occurence associated with these determinations (can be null for all occurrences)
212 * @param taxonbase the taxon concept associated with these determinations (can be null for all taxon concepts)
213 * @return a count of determination events
215 public long countDeterminations(SpecimenOrObservationBase occurence
,TaxonBase taxonbase
);
218 * Returns a List of determinations that have been made for a given occurence and for a given taxon concept
220 * @param occurence the occurence associated with these determinations (can be null for all occurrences)
221 * @param taxonbase the taxon concept associated with these determinations (can be null for all taxon concepts)
222 * @param pageSize The maximum number of determinations returned (can be null for all related determinations)
223 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
224 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
225 * @return a List of determination instances
227 public List
<DeterminationEvent
> getDeterminations(SpecimenOrObservationBase occurence
,TaxonBase taxonbase
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
230 * Returns a count of derivation events that have involved creating new DerivedUnits from this occurence
232 * @param occurence the occurence that was a source of these derivation events
233 * @return a count of derivation events
235 public long countDerivationEvents(SpecimenOrObservationBase occurence
);
238 * Returns a list of derivation events that have involved creating new DerivedUnits from this occurence
240 * @param occurence the occurence that was a source of these derivation events
241 * @param pageSize The maximum number of derivation events returned (can be null for all related derivation events)
242 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
243 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
244 * @return a List of derivation events
246 public List
<DerivationEvent
> getDerivationEvents(SpecimenOrObservationBase occurence
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
249 * Retrieves the {@link UUID} and the string representation (title cache) of all
250 * {@link FieldUnit}s found in the data base.
251 * @return a list of {@link UuidAndTitleCache}
253 public List
<UuidAndTitleCache
<FieldUnit
>> getFieldUnitUuidAndTitleCache();
256 * Retrieves the {@link UUID} and the string representation (title cache) of all
257 * {@link DerivedUnit}s found in the data base.
258 * @return a list of {@link UuidAndTitleCache}
260 public List
<UuidAndTitleCache
<DerivedUnit
>> getDerivedUnitUuidAndTitleCache(Integer limit
, String pattern
);
263 * Lists all instances of {@link SpecimenOrObservationBase} which are determined as the <code>taxon name</code> specified as parameter.
267 * @param associatedTaxonName
271 * @param propertyPaths
274 public <T
extends SpecimenOrObservationBase
> List
<T
> listByAssociatedTaxonName(Class
<T
> type
,
275 TaxonName associatedTaxonName
, Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
278 * Lists all instances of {@link SpecimenOrObservationBase} which are associated with the <code>taxon</code> specified as parameter.
279 * SpecimenOrObservationBase instances can be associated to taxa in multiple ways, all these possible relations are taken into account:
281 * <li>The {@link IndividualsAssociation} elements in a {@link TaxonDescription} contain {@link DerivedUnit}s</li>
282 * <li>{@link SpecimenTypeDesignation}s may be associated with any {@link HomotypicalGroup} related to the specific {@link Taxon}.</li>
283 * <li>A {@link Taxon} or a {@link TaxonName} may be referenced by the {@link DeterminationEvent} of the {@link SpecimenOrObservationBase}</li>
288 * @param associatedTaxon
292 * @param propertyPaths
295 public <T
extends SpecimenOrObservationBase
> List
<T
> listByAssociatedTaxon(Class
<T
> type
, Taxon associatedTaxon
,
296 Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
299 * @see IOccurrenceDao#listByAssociatedTaxon(Class, Taxon, Integer, Integer, List, List)
301 * @param associatedTaxon
305 * @param propertyPaths
308 public <T
extends SpecimenOrObservationBase
> List
<UuidAndTitleCache
<SpecimenOrObservationBase
>> listUuidAndTitleCacheByAssociatedTaxon(Class
<T
> type
, Taxon associatedTaxon
,
309 Integer limit
, Integer start
, List
<OrderHint
> orderHints
);
312 * The method will search for specimen associated with the taxon nodes.<br>
313 * It will search for 3 possible association types:
315 * - via IndividualAssociations of the taxon<br>
316 * - via TypeDesignations of the taxon name<br>
317 * - via Determinations of the taxon or taxon name<br>
319 * (more are covered in
320 * {@link IOccurrenceDao#findOccurrences(Class, String, String, SpecimenOrObservationType, Taxon, TaxonName, MatchMode, Integer, Integer, List, List)}
321 * @param taxonNodeUuids a list of {@link UUID}s of the taxon nodes
324 * @return a collection of {@link SpecimenNodeWrapper} containing the {@link TaxonNode}
325 * and the corresponding {@link UuidAndTitleCache} object for the specimen found for this taxon node
327 public Collection
<SpecimenNodeWrapper
> listUuidAndTitleCacheByAssociatedTaxon(List
<UUID
> taxonNodeUuids
,
328 Integer limit
, Integer start
);
331 * Retrieves all {@link IndividualsAssociation} with the given specimen.<br>
332 * @param specimen the specimen for which the associations are retrieved
336 * @param propertyPaths
337 * @return collection of all associations
339 public Collection
<IndividualsAssociation
> listIndividualsAssociations(SpecimenOrObservationBase
<?
> specimen
, Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
342 * Retrieves all {@link SpecimenTypeDesignation}s which have the given specimen as a type specimen.
343 * @param specimen the type specimen
347 * @param propertyPaths
348 * @return collection of all designations with the given type specimen
352 * Retrieves all {@link DeterminationEvent}s which have the given specimen set as identified unit.
357 * @param propertyPaths
358 * @return collection of all determinations with the given specimen
360 public Collection
<DeterminationEvent
> listDeterminationEvents(SpecimenOrObservationBase
<?
> specimen
, Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
363 * Retrieves all {@link SpecimenTypeDesignation}s which have the given specimen as a type specimen.
364 * @param specimen the type specimen
368 * @param propertyPaths
369 * @return collection of all designations with the given type specimen
371 public Collection
<SpecimenTypeDesignation
> listTypeDesignations(SpecimenOrObservationBase
<?
> specimen
, Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
374 * Retrieves all {@link DescriptionBase}s that have the given specimen set as described specimen.
375 * @param specimen the described specimen
379 * @param propertyPaths
380 * @return collection of all descriptions with the given described specimen
382 public Collection
<DescriptionBase
<?
>> listDescriptionsWithDescriptionSpecimen(SpecimenOrObservationBase
<?
> specimen
, Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
385 * Retrieves all {@link SpecimenOrObservationBase}s that have the given {@link SpecimenOrObservationType}.
390 * @param propertyPaths
391 * @return collection of specimen with the given type
393 public Collection
<SpecimenOrObservationBase
> listBySpecimenOrObservationType(SpecimenOrObservationType type
, Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
397 * Returns all {@link FieldUnit}s that are referencing this {@link GatheringEvent}
398 * @param gatheringEventUuid the {@link UUID} of the gathering event
402 * @param propertyPaths
403 * @return a list of field units referencing the gathering event
405 public List
<FieldUnit
> getFieldUnitsForGatheringEvent(UUID gatheringEventUuid
, Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
409 * Returns {@link DerivedUNit} that has the accession number
410 * @param accessionNumber
411 * @param propertyPaths
412 * @return a derived unit
414 public List
<DerivedUnit
> getByGeneticAccessionNumber(String accessionNumberString
, List
<String
> propertyPaths
);