2 * Copyright (C) 2009 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.cdm
.api
.service
;
11 import java
.io
.IOException
;
12 import java
.util
.Collection
;
13 import java
.util
.EnumSet
;
14 import java
.util
.List
;
17 import java
.util
.UUID
;
19 import org
.apache
.lucene
.index
.CorruptIndexException
;
20 import org
.springframework
.transaction
.annotation
.Transactional
;
22 import eu
.etaxonomy
.cdm
.api
.dto
.DerivedUnitDTO
;
23 import eu
.etaxonomy
.cdm
.api
.dto
.FieldUnitDTO
;
24 import eu
.etaxonomy
.cdm
.api
.dto
.MediaDTO
;
25 import eu
.etaxonomy
.cdm
.api
.dto
.SpecimenOrObservationBaseDTO
;
26 import eu
.etaxonomy
.cdm
.api
.filter
.TaxonOccurrenceRelationType
;
27 import eu
.etaxonomy
.cdm
.api
.service
.config
.FindOccurrencesConfigurator
;
28 import eu
.etaxonomy
.cdm
.api
.service
.config
.IIdentifiableEntityServiceConfigurator
;
29 import eu
.etaxonomy
.cdm
.api
.service
.config
.SpecimenDeleteConfigurator
;
30 import eu
.etaxonomy
.cdm
.api
.service
.dto
.RectangleDTO
;
31 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
32 import eu
.etaxonomy
.cdm
.api
.service
.search
.LuceneParseException
;
33 import eu
.etaxonomy
.cdm
.api
.service
.search
.SearchResult
;
34 import eu
.etaxonomy
.cdm
.api
.util
.TaxonRelationshipEdge
;
35 import eu
.etaxonomy
.cdm
.facade
.DerivedUnitFacade
;
36 import eu
.etaxonomy
.cdm
.facade
.DerivedUnitFacadeNotSupportedException
;
37 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
38 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
39 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
40 import eu
.etaxonomy
.cdm
.model
.description
.IndividualsAssociation
;
41 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
42 import eu
.etaxonomy
.cdm
.model
.location
.Point
;
43 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
44 import eu
.etaxonomy
.cdm
.model
.molecular
.DnaSample
;
45 import eu
.etaxonomy
.cdm
.model
.molecular
.Sequence
;
46 import eu
.etaxonomy
.cdm
.model
.name
.HomotypicalGroup
;
47 import eu
.etaxonomy
.cdm
.model
.name
.SpecimenTypeDesignation
;
48 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
49 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivationEvent
;
50 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
51 import eu
.etaxonomy
.cdm
.model
.occurrence
.DeterminationEvent
;
52 import eu
.etaxonomy
.cdm
.model
.occurrence
.FieldUnit
;
53 import eu
.etaxonomy
.cdm
.model
.occurrence
.GatheringEvent
;
54 import eu
.etaxonomy
.cdm
.model
.occurrence
.MediaSpecimen
;
55 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
56 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationType
;
57 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
58 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
59 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
60 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
61 import eu
.etaxonomy
.cdm
.persistence
.dao
.initializer
.IBeanInitializer
;
62 import eu
.etaxonomy
.cdm
.persistence
.dto
.SpecimenNodeWrapper
;
63 import eu
.etaxonomy
.cdm
.persistence
.dto
.UuidAndTitleCache
;
64 import eu
.etaxonomy
.cdm
.persistence
.query
.OrderHint
;
67 * @author a.babadshanjan
70 public interface IOccurrenceService
71 extends IIdentifiableEntityService
<SpecimenOrObservationBase
> {
74 * Returns a paged list of occurrences that have been determined to belong
75 * to the taxon concept determinedAs, optionally restricted to objects
76 * belonging to a class that extends SpecimenOrObservationBase. This
77 * will also consider specimens that are determined as a taxon concept
78 * belonging to the synonymy of the given taxon concept.
80 * In contrast to {@link #listByAnyAssociation(Class, Taxon, List)} this
81 * method only takes SpecimenOrObservationBase instances into account which
82 * are actually determined as the taxon specified by
83 * <code>determinedAs</code>.
86 * The type of entities to return (can be null to count all
87 * entities of type <T>)
89 * the taxon concept that the occurrences have been determined to
92 * The maximum number of objects returned (can be null for all
95 * The offset (in pageSize chunks) from the start of the result
96 * set (0 - based, can be null, equivalent of starting at the
97 * beginning of the recordset)
99 * Supports path like <code>orderHints.propertyNames</code> which
100 * include *-to-one properties like createdBy.username or
101 * authorTeam.persistentTitleCache
102 * @param propertyPaths
103 * properties to be initialized
106 public Pager
<SpecimenOrObservationBase
> list(Class
<?
extends SpecimenOrObservationBase
> type
, TaxonBase determinedAs
, Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
109 * Returns a paged list of occurrences that have been determined to belong
110 * to the taxon name determinedAs, optionally restricted to objects
111 * belonging to a class that that extends SpecimenOrObservationBase.
113 * In contrast to {@link #listByAnyAssociation(Class, Taxon, List)} this
114 * method only takes SpecimenOrObservationBase instances into account which
115 * are actually determined as the taxon specified by
116 * <code>determinedAs</code>.
119 * The type of entities to return (can be null to count all
120 * entities of type <T>)
121 * @param determinedAs
122 * the taxon name that the occurrences have been determined to
125 * The maximum number of objects returned (can be null for all
128 * The offset (in pageSize chunks) from the start of the result
129 * set (0 - based, can be null, equivalent of starting at the
130 * beginning of the recordset)
132 * Supports path like <code>orderHints.propertyNames</code> which
133 * include *-to-one properties like createdBy.username or
134 * authorTeam.persistentTitleCache
135 * @param propertyPaths
136 * properties to be initialized
139 public Pager
<SpecimenOrObservationBase
> list(Class
<?
extends SpecimenOrObservationBase
> type
, TaxonName determinedAs
, Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
142 * Returns a List of Media that are associated with a given occurrence
144 * @param occurrence the occurrence associated with these media
145 * @param pageSize The maximum number of media returned (can be null for all related media)
146 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
147 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
148 * @return a Pager of media instances
151 public Pager
<Media
> getMedia(SpecimenOrObservationBase occurence
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
154 * Returns all media attached to this occurence and its children. Also takes
155 * {@link MediaSpecimen} and molecular images into account.
157 * @param occurence the occurence and its children from which the media to get
158 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
159 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
160 * @return a Pager of media instances
162 public Pager
<Media
> getMediaInHierarchy(SpecimenOrObservationBase
<?
> rootOccurence
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
165 * Returns a count of determinations that have been made for a given occurence and for a given taxon concept
167 * @param occurence the occurence associated with these determinations (can be null for all occurrences)
168 * @param taxonbase the taxon concept associated with these determinations (can be null for all taxon concepts)
169 * @return a count of determination events
171 public long countDeterminations(SpecimenOrObservationBase occurence
,TaxonBase taxonbase
);
174 * Returns a List of determinations that have been made for a given occurence
176 * @param occurence the occurence associated with these determinations (can be null for all occurrences)
177 * @param taxonbase the taxon concept associated with these determinations (can be null for all taxon concepts)
178 * @param pageSize The maximum number of determinations returned (can be null for all related determinations)
179 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
180 * @return a Pager of determination instances
182 public Pager
<DeterminationEvent
> getDeterminations(SpecimenOrObservationBase occurence
, TaxonBase taxonBase
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
185 * Returns a list of derivation events that have involved creating new DerivedUnits from this occurence
187 * @param occurence the occurence that was a source of these derivation events
188 * @param pageSize The maximum number of derivation events returned (can be null for all related derivation events)
189 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
190 * @return a Pager of derivation events
192 public Pager
<DerivationEvent
> getDerivationEvents(SpecimenOrObservationBase occurence
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
195 * Returns a Paged List of SpecimenOrObservationBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
197 * @param clazz filter the results by class (or pass null to return all SpecimenOrObservationBase instances)
199 * @param pageSize The maximum number of occurrences returned (can be null for all matching occurrences)
200 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
202 * Supports path like <code>orderHints.propertyNames</code> which
203 * include *-to-one properties like createdBy.username or
204 * authorTeam.persistentTitleCache
205 * @param propertyPaths properties to be initialized
206 * @return a Pager SpecimenOrObservationBase instances
207 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
210 public Pager
<SpecimenOrObservationBase
> search(Class
<?
extends SpecimenOrObservationBase
> clazz
, String query
, Integer pageSize
,Integer pageNumber
, List
<OrderHint
> orderHints
,List
<String
> propertyPaths
);
213 * Retrieves the {@link UUID} and the string representation (title cache) of all
214 * {@link FieldUnit}s found in the data base.
215 * @return a list of {@link UuidAndTitleCache}
217 public List
<UuidAndTitleCache
<FieldUnit
>> getFieldUnitUuidAndTitleCache();
220 * Retrieves the {@link UUID} and the string representation (title cache) of all
221 * {@link DerivedUnit}s found in the data base.
222 * @return a list of {@link UuidAndTitleCache}
224 public List
<UuidAndTitleCache
<DerivedUnit
>> getDerivedUnitUuidAndTitleCache(Integer limit
, String pattern
);
226 public DerivedUnitFacade
getDerivedUnitFacade(DerivedUnit derivedUnit
, List
<String
> propertyPaths
) throws DerivedUnitFacadeNotSupportedException
;
229 * Lists all instances of {@link SpecimenOrObservationBase} which are
230 * associated with the <code>taxon</code> specified as parameter.
231 * SpecimenOrObservationBase instances can be associated to taxa in multiple
232 * ways, all these possible relations are taken into account:
234 * <li>The {@link IndividualsAssociation} elements in a
235 * {@link TaxonDescription} contain {@link DerivedUnit}s</li>
236 * <li>{@link SpecimenTypeDesignation}s may be associated with any
237 * {@link HomotypicalGroup} related to the specific {@link Taxon}.</li>
238 * <li>A {@link Taxon} may be referenced by the {@link DeterminationEvent}
239 * of the {@link SpecimenOrObservationBase}</li>
241 * Further more there also can be taxa which are associated with the taxon
242 * in question (parameter associatedTaxon) by {@link TaxonRelationship}s. If
243 * the parameter <code>includeRelationships</code> is containing elements,
244 * these according {@TaxonRelationshipType}s and
245 * directional information will be used to collect further
246 * {@link SpecimenOrObservationBase} instances found this way.
250 * @param associatedTaxon
251 * @param Set<TaxonRelationshipVector> includeRelationships. TaxonRelationships will not be taken into account if this is <code>NULL</code>.
252 * @param maxDepth TODO
256 * @param propertyPaths
259 public <T
extends SpecimenOrObservationBase
> List
<T
> listByAssociatedTaxon(Class
<T
> type
, Set
<TaxonRelationshipEdge
> includeRelationships
,
260 Taxon associatedTaxon
, boolean includeUnpublished
, EnumSet
<TaxonOccurrenceRelationType
> taxonOccurrenceRelTypes
,
261 Integer maxDepth
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
264 * The method will search for specimen associated with the taxon nodes.<br>
265 * It will search for 3 possible association types: <br>
266 * - via IndividualAssociations of the taxon<br>
267 * - via TypeDesignations of the taxon name<br>
268 * - via Determinations of the taxon or taxon name<br>
270 * more are covered in
271 * {@link IOccurrenceService#findByTitle(IIdentifiableEntityServiceConfigurator)}
272 * @param taxonNodeUuids
273 * a list of {@link UUID}s of the taxon nodes
276 * @return a collection of {@link SpecimenNodeWrapper} containing the
277 * {@link TaxonNode} and the corresponding {@link UuidAndTitleCache}
278 * object for the specimen found for this taxon node
280 public Collection
<SpecimenNodeWrapper
> listUuidAndTitleCacheByAssociatedTaxon(List
<UUID
> taxonNodeUuids
,
281 Integer limit
, Integer start
);
284 * See {@link #listByAssociatedTaxon(Class, Set, Taxon, Integer, Integer, Integer, List, List)}
287 * Restriction to subtype of <code>SpecimenOrObservationBase</code>, can be NULL.
288 * @param includeRelationships
289 * @param associatedTaxon
294 * @param propertyPaths
297 public <T
extends SpecimenOrObservationBase
> Pager
<T
> pageByAssociatedTaxon(Class
<T
> type
, Set
<TaxonRelationshipEdge
> includeRelationships
,
298 Taxon associatedTaxon
, boolean includeUnpublished
, EnumSet
<TaxonOccurrenceRelationType
> taxonOccurrenceRelTypes
,
299 Integer maxDepth
, Integer pageSize
, Integer pageNumber
,
300 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
303 * Retrieves all {@link FieldUnit}s for the {@link SpecimenOrObservationBase} with the given {@link UUID}.<br>
304 * @param specimenUuid the UUID of the specimen
305 * @param propertyPaths the property path
306 * @return either a collection of FieldUnits this specimen was derived from, the FieldUnit itself
307 * if this was a FieldUnit or an empty collection if no FieldUnits were found
309 public Collection
<FieldUnit
> findFieldUnits(UUID specimenUuid
, List
<String
> propertyPaths
);
312 * Retrieves top most originals for a {@link SpecimenOrObservationBase} in the derivation graph by recursively
313 * walking all {@link DerivationEvent}s.
314 * In most cases item in the returned collection will be {@link FieldUnit FieldUnits} but also DerivedUnits are possible, in
315 * cases where no FieledUnit exists.
317 * @param specimenUuid the UUID of the specimen
318 * @param propertyPaths the property path
319 * @return either a collection of root units
321 public Collection
<SpecimenOrObservationBase
> findRootUnits(UUID specimenUuid
, List
<String
> propertyPaths
);
327 * @param highlightFragments
331 * @param propertyPaths
333 * @throws CorruptIndexException
334 * @throws IOException
335 * @throws ParseException
337 Pager
<SearchResult
<SpecimenOrObservationBase
>> findByFullText(Class
<?
extends SpecimenOrObservationBase
> clazz
,
338 String queryString
, RectangleDTO boundingBox
, List
<Language
> languages
, boolean highlightFragments
,
339 Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
)
340 throws IOException
, LuceneParseException
;
343 * Moves the given {@link Sequence} from one {@link DnaSample} to another
344 * @param from the DnaSample from which the sequence will be removed
345 * @param to the DnaSample which to which the sequence will be added
346 * @param sequence the Sequence to move
347 * @return <code>true</code> if successfully moved, <code>false</code> otherwise
349 public UpdateResult
moveSequence(DnaSample from
, DnaSample to
, Sequence sequence
);
355 * @param sequenceUuid
358 public UpdateResult
moveSequence(UUID fromUuid
, UUID toUuid
, UUID sequenceUuid
);
361 * Moves the given {@link DerivedUnit} from one {@link SpecimenOrObservationBase} to another.
362 * @param from the SpecimenOrObservationBase from which the DerivedUnit will be removed
363 * @param to the SpecimenOrObservationBase to which the DerivedUnit will be added
364 * @param derivate the DerivedUnit to move
365 * @return <code>true</code> if successfully moved, <code>false</code> otherwise
367 public UpdateResult
moveDerivate(UUID specimenFromUuid
, UUID specimenToUuid
, UUID derivateUuid
);
375 public boolean moveDerivate(SpecimenOrObservationBase
<?
> from
, SpecimenOrObservationBase
<?
> to
, DerivedUnit derivate
);
378 * Assembles a {@link FieldUnitDTO} for the given field unit.<br>
381 * @return a DTO with all the assembled information
383 public FieldUnitDTO
assembleFieldUnitDTO(FieldUnit fieldUnit
);
386 * Assembles a {@link DerivedUnitDTO} for the given derived unit.
388 * @return a DTO with all the assembled information
390 public SpecimenOrObservationBaseDTO
assembleDerivedUnitDTO(DerivedUnit derivedUnit
);
393 * Deletes the specified specimen according to the setting in the {@link SpecimenDeleteConfigurator}.<br>
394 * @param specimen the specimen which shoul be deleted
395 * @param config specifies options if and how the specimen should be deleted like e.g. including all
397 * @return the {@link DeleteResult} which holds information about the outcome of this operation
399 public DeleteResult
delete(SpecimenOrObservationBase
<?
> specimen
, SpecimenDeleteConfigurator config
);
402 * Deletes the specified specimen belonging to the given {@link UUID}
403 * according to the setting in the {@link SpecimenDeleteConfigurator}.
406 * the specimen which shoul be deleted
408 * specifies options if and how the specimen should be deleted
409 * like e.g. including all of its children
410 * @return the {@link DeleteResult} which holds information about the
411 * outcome of this operation
413 public DeleteResult
delete(UUID specimenUuid
, SpecimenDeleteConfigurator config
);
416 * Retrieves all {@link IndividualsAssociation} with the given specimen.<br>
417 * @param specimen the specimen for which the associations are retrieved
421 * @param propertyPaths
422 * @return collection of all associations
424 public Collection
<IndividualsAssociation
> listIndividualsAssociations(SpecimenOrObservationBase
<?
> specimen
, Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
428 * Retrieves all taxa linked via {@link IndividualsAssociation} with the given specimen.<br>
429 * @param specimen the specimen which is linked to the taxa
433 * @param propertyPaths
434 * @return a collection of associated taxa
436 public Collection
<TaxonBase
<?
>> listIndividualsAssociationTaxa(SpecimenOrObservationBase
<?
> specimen
, boolean includeUnpublished
,
437 Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
440 * Retrieves all associated taxa for the given specimen (via type designations, determination, individuals associations)
442 public Collection
<TaxonBase
<?
>> listAssociatedTaxa(SpecimenOrObservationBase
<?
> specimen
, boolean includeUnpublished
,
443 Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
446 * Retrieves all taxa that the given specimen is determined as
451 * @param propertyPaths
452 * @return collection of all taxa the given specimen is determined as
454 public Collection
<TaxonBase
<?
>> listDeterminedTaxa(SpecimenOrObservationBase
<?
> specimen
, boolean includeUnpublished
,
455 Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
458 * Retrieves all {@link DeterminationEvent}s which have the given specimen set as identified unit.
463 * @param propertyPaths
464 * @return collection of all determination events with the given specimen
466 public Collection
<DeterminationEvent
> listDeterminationEvents(SpecimenOrObservationBase
<?
> specimen
, Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
469 * Retrieves all taxa with a {@link SpecimenTypeDesignation} with the given specimen as a type specimen.
470 * @param specimen the type specimen
475 * @param propertyPaths
476 * @return a collection of all taxa where the given specimen is the type specimen
478 public Collection
<TaxonBase
<?
>> listTypeDesignationTaxa(DerivedUnit specimen
, boolean includeUnpublished
,
479 Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
482 * Retrieves all {@link SpecimenTypeDesignation}s which have the given specimens as a type specimen.
483 * @param specimens the type specimens
487 * @param propertyPaths
488 * @return map of all designations with the given type specimens
491 public Map
<DerivedUnit
, Collection
<SpecimenTypeDesignation
>> listTypeDesignations(Collection
<DerivedUnit
> specimens
, Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
494 * Retrieves all {@link SpecimenTypeDesignation}s which have the given specimen as a type specimen.
495 * @param specimen the type specimen
499 * @param propertyPaths
500 * @return collection of all designations with the given type specimen
502 public Collection
<SpecimenTypeDesignation
> listTypeDesignations(DerivedUnit specimen
, Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
505 * Retrieves all {@link DescriptionBase}s that have the given specimen set as described specimen.
506 * @param specimen the described specimen
510 * @param propertyPaths
511 * @return collection of all descriptions with the given described specimen
513 public Collection
<DescriptionBase
<?
>> listDescriptionsWithDescriptionSpecimen(SpecimenOrObservationBase
<?
> specimen
, Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
516 * Gets all description elements that are used for describing the character
517 * states of the given specimen
519 * @param specimenUuid
520 * the specimen {@link UUID} for which the character state description
521 * elements should be retrieved
522 * @return a collection of all character state description elements for this
525 public Collection
<DescriptionElementBase
> getCharacterDataForSpecimen(UUID specimenUuid
);
528 * Returns the most significant identifier for the given {@link DerivedUnit}.
529 * @param derivedUnit the derived unit to check
530 * @return the identifier string
533 public String
getMostSignificantIdentifier(UUID derivedUnit
);
536 * Returns the number of specimens that match the given parameters
538 * <b>NOTE - issue #6484:</b> the parameters {@link FindOccurrencesConfigurator#getAssignmentStatus()}
539 * and {@link FindOccurrencesConfigurator#isRetrieveIndirectlyAssociatedSpecimens()} are not evaluated
540 * in the count method
541 * @param clazz the class to match
542 * @param queryString the queryString to match
543 * @param type the {@link SpecimenOrObservationType} to match
544 * @param associatedTaxon the taxon these specimens are in any way associated to via
545 * determination, type designations, individuals associations, etc.
546 * @param matchmode determines how the query string should be matched
548 * the maximum number of entities returned (can be null to return
552 * Supports path like <code>orderHints.propertyNames</code> which
553 * include *-to-one properties like createdBy.username or
554 * authorTeam.persistentTitleCache
555 * @return the number of found specimens
557 public long countOccurrences(FindOccurrencesConfigurator config
);
560 * Return the all {@link SpecimenOrObservationBase}s of the complete
561 * derivative hierarchy i.e. all parent and child derivatives and the given
565 * a specimen or observation
566 * @return the derivative hierarchy as an unordered list of all specimens or observation
568 public List
<SpecimenOrObservationBase
<?
>> getAllHierarchyDerivatives(SpecimenOrObservationBase
<?
> specimen
);
571 * Returns all child derivatives of the given specimen.
572 * @param specimen a specimen or observation
573 * @return an unordered list of all child derivatives
575 public List
<DerivedUnit
> getAllChildDerivatives(SpecimenOrObservationBase
<?
> specimen
);
578 * Returns all child derivatives of the given specimen.
579 * @param specimen the UUID of a specimen or observation
580 * @return an unordered list of all child derivatives
582 public List
<DerivedUnit
> getAllChildDerivatives(UUID specimenUuid
);
585 * Returns all {@link FieldUnit}s that are referencing this {@link GatheringEvent}
586 * @param gatheringEventUuid the {@link UUID} of the gathering event
587 * @return a list of field units referencing the gathering event
589 public List
<FieldUnit
> findFieldUnitsForGatheringEvent(UUID gatheringEventUuid
);
592 * Returns a list of {@link UuidAndTitleCache} for the specimens found with the
594 * @param config the configurator for the search
595 * @return a list of UuidAndTitleCache object
597 @Transactional(readOnly
= true)
598 public Pager
<UuidAndTitleCache
<SpecimenOrObservationBase
>> findByTitleUuidAndTitleCache(
599 FindOccurrencesConfigurator config
);
602 * Returns a list of {@link DerivedUnitDTO} for the specimens found with the
604 * @param config the configurator for the search
605 * @return a list of {@link DerivedUnitDTO} object
607 @Transactional(readOnly
= true)
608 public List
<DerivedUnitDTO
> findByTitleDerivedUnitDTO(
609 FindOccurrencesConfigurator config
);
612 * Collects the <code>FieldUnits</code> which are at the root of the derivation event
613 * graph in which the {@link DnaSample} with the specified <code>accessionNumberString</code>
616 public SpecimenOrObservationBaseDTO
findByGeneticAccessionNumber(String dnaAccessionNumber
, List
<OrderHint
> orderHints
);
619 * Recursively searches all {@link DerivationEvent}s to find all "originals" ({@link SpecimenOrObservationBase})
620 * from which this DerivedUnit was derived until all FieldUnits are found.
622 * <b>NOTE:</b> The recursive search still is a bit incomplete and may miss originals in the rare case where a
623 * derivative has more than one original. (see https://dev.e-taxonomy.eu/redmine/issues/9253)
625 * @param derivedUnitDTO
626 * The DerivedUnitDTO to start the search from.
627 * @param alreadyCollectedSpecimen
628 * A map to hold all originals that have been sees during the recursive walk.
630 * The collection of all Field Units that are accessible from the derivative from where the search was started.
632 public Collection
<SpecimenOrObservationBaseDTO
<?
>> findRootUnitDTOs(UUID unitUUID
);
635 * Finds the units which are associated to a taxon
636 * (<code>associatedTaxonUuid</code>) and returns all related root units
637 * with the derivation branches up to the derivatives associated with the
638 * taxon and the full derivation sub-tree of those.
640 * Requirements as stated in the below linked tickets:
642 * <li>The derivation trees (derivatives, sub-derivatives,
643 * sub-sub-derivatives, ....) of each of the root units will be included in
644 * the result items in
645 * ({@link SpecimenOrObservationBaseDTO#getDerivatives()})</li>
646 * <li>.... should contain all derivates of a derivate determined to the
647 * taxon or its name and all elements should be displayed only once.
649 * <li>... also sollen beim DerivateTree eigentlich auch nur die Derivate
650 * angezeigt werden, die über Taxon Association oder Determination an einem
651 * Taxon oder Namen hängen und ihre direkten Eltern und Kinder (+
652 * KindesKinder…).</li>
653 * <li>Also im Endeffekt muss man die Derivate raus suchen, die eine
654 * Assoziation zu dem Taxon haben und dann die direkten Vorgänger und die
655 * Nachfolger finden. Andere Derivate, die von Origin Derivaten abstammen
656 * würden erstmal nicht dazugehören, außer sie sind ebenfalls mit dem Taxon
657 * assoziiert....</li>
663 * <li>https://dev.e-taxonomy.eu/redmine/issues/7599</li>
664 * <li>https://dev.e-taxonomy.eu/redmine/issues/9216</li>
667 * @param associatedTaxonUuid the associated taxon uuid
668 * The uuid of the taxon for which associated derivatives are to be found.
669 * @param includedRelationships
670 * if also specimen of related taxa are to be loaded the taxon relationships
671 * can be defined here<BR>
672 * TODO needed? it currently does not seem to be in use
673 * @param includeUnpublished
674 * if <code>false</code> units marked as publish=false are not added
675 * TODO maybe not yet fully implemented
676 * @param propertyPaths
677 * The bean initialization strategy
679 * The list of root units with fully or partially assembled derivation graph.
681 public List
<SpecimenOrObservationBaseDTO
> listRootUnitDTOsByAssociatedTaxon(
682 UUID associatedTaxonUuid
, Set
<TaxonRelationshipEdge
> includedRelationships
,
683 boolean includeUnpublished
, EnumSet
<TaxonOccurrenceRelationType
> taxonOccurrenceRelTypes
,
684 List
<String
> propertyPaths
);
687 * Lists all root units which are
688 * associated <b>directly or indirectly</b>with the <code>taxon</code> specified
689 * as parameter. "Indirectly" means that a sub derivate of the FieldUnit is
690 * directly associated with the given taxon.
691 * SpecimenOrObservationBase instances can be associated to taxa in multiple
692 * ways, all these possible relations are taken into account:
694 * <li>The {@link IndividualsAssociation} elements in a
695 * {@link TaxonDescription} contain {@link DerivedUnit}s</li>
696 * <li>{@link SpecimenTypeDesignation}s may be associated with any
697 * {@link HomotypicalGroup} related to the specific {@link Taxon}.</li>
698 * <li>A {@link Taxon} may be referenced by the {@link DeterminationEvent}
699 * of the {@link SpecimenOrObservationBase}</li>
701 * Further more there also can be taxa which are associated with the taxon
702 * in question (parameter associatedTaxon) by {@link TaxonRelationship}s. If
703 * the parameter <code>includeRelationships</code> is containing elements,
704 * these according {@TaxonRelationshipType}s and
705 * directional information will be used to collect further
706 * {@link SpecimenOrObservationBase} instances found this way.
710 * Restriction to a specific subtype, may be null.
711 * @param associatedTaxon
712 * @param Set<TaxonRelationshipVector> includeRelationships. TaxonRelationships will not be taken into account if this is <code>NULL</code>.
713 * @param maxDepth TODO
717 * @param propertyPaths
720 public <T
extends SpecimenOrObservationBase
> Collection
<T
> listRootUnitsByAssociatedTaxon(
721 Class
<T
> type
, Taxon associatedTaxon
, boolean includeUnpublished
,
722 EnumSet
<TaxonOccurrenceRelationType
> taxonOccurrenceRelTypes
,
723 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
726 * See {@link #listFieldUnitsByAssociatedTaxon(Set, Taxon, Integer, Integer, Integer, List, List)}
728 public <T
extends SpecimenOrObservationBase
> Pager
<T
> pageRootUnitsByAssociatedTaxon(Class
<T
> type
, Set
<TaxonRelationshipEdge
> includeRelationships
,
729 Taxon associatedTaxon
, boolean includeUnpublished
, EnumSet
<TaxonOccurrenceRelationType
> taxonOccurrenceRelTypes
,
730 Integer maxDepth
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
732 public List
<Point
> findPointsForFieldUnitList(List
<UUID
> fieldUnitUuids
);
735 * Load the FieldUnitDTO for the given <code>derivedUnitUuid</code> with all intermediate derivatives and {@link eu.etaxonomy.cdm.api.dto.GatheringEventDTO}
737 public FieldUnitDTO
loadFieldUnitDTO(UUID derivedUnitUuid
);
739 public Pager
<MediaDTO
> getMediaDTOs(SpecimenOrObservationBase
<?
> occurence
, Integer pageSize
, Integer pageNumber
);
741 public Pager
<Media
> getMediaInHierarchy(SpecimenOrObservationBase
<?
> rootOccurence
, boolean collectOriginalMedia
, boolean collectDerivativeMedia
,
742 Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);