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.
10 package eu
.etaxonomy
.cdm
.api
.service
;
12 import java
.io
.IOException
;
13 import java
.util
.Collection
;
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
.service
.config
.FindOccurrencesConfigurator
;
23 import eu
.etaxonomy
.cdm
.api
.service
.config
.IIdentifiableEntityServiceConfigurator
;
24 import eu
.etaxonomy
.cdm
.api
.service
.config
.SpecimenDeleteConfigurator
;
25 import eu
.etaxonomy
.cdm
.api
.service
.dto
.DerivedUnitDTO
;
26 import eu
.etaxonomy
.cdm
.api
.service
.dto
.FieldUnitDTO
;
27 import eu
.etaxonomy
.cdm
.api
.service
.dto
.MediaDTO
;
28 import eu
.etaxonomy
.cdm
.api
.service
.dto
.RectangleDTO
;
29 import eu
.etaxonomy
.cdm
.api
.service
.dto
.SpecimenOrObservationBaseDTO
;
30 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
31 import eu
.etaxonomy
.cdm
.api
.service
.search
.LuceneParseException
;
32 import eu
.etaxonomy
.cdm
.api
.service
.search
.SearchResult
;
33 import eu
.etaxonomy
.cdm
.api
.util
.TaxonRelationshipEdge
;
34 import eu
.etaxonomy
.cdm
.facade
.DerivedUnitFacade
;
35 import eu
.etaxonomy
.cdm
.facade
.DerivedUnitFacadeNotSupportedException
;
36 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
37 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
38 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
39 import eu
.etaxonomy
.cdm
.model
.description
.IndividualsAssociation
;
40 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
41 import eu
.etaxonomy
.cdm
.model
.location
.Point
;
42 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
43 import eu
.etaxonomy
.cdm
.model
.molecular
.DnaSample
;
44 import eu
.etaxonomy
.cdm
.model
.molecular
.Sequence
;
45 import eu
.etaxonomy
.cdm
.model
.name
.HomotypicalGroup
;
46 import eu
.etaxonomy
.cdm
.model
.name
.SpecimenTypeDesignation
;
47 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
48 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivationEvent
;
49 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
50 import eu
.etaxonomy
.cdm
.model
.occurrence
.DeterminationEvent
;
51 import eu
.etaxonomy
.cdm
.model
.occurrence
.FieldUnit
;
52 import eu
.etaxonomy
.cdm
.model
.occurrence
.GatheringEvent
;
53 import eu
.etaxonomy
.cdm
.model
.occurrence
.MediaSpecimen
;
54 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
55 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationType
;
56 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
57 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
58 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
59 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
60 import eu
.etaxonomy
.cdm
.persistence
.dao
.initializer
.IBeanInitializer
;
61 import eu
.etaxonomy
.cdm
.persistence
.dto
.SpecimenNodeWrapper
;
62 import eu
.etaxonomy
.cdm
.persistence
.dto
.UuidAndTitleCache
;
63 import eu
.etaxonomy
.cdm
.persistence
.query
.OrderHint
;
66 * @author a.babadshanjan
69 public interface IOccurrenceService
70 extends IIdentifiableEntityService
<SpecimenOrObservationBase
> {
73 * Returns a paged list of occurrences that have been determined to belong
74 * to the taxon concept determinedAs, optionally restricted to objects
75 * belonging to a class that that extends SpecimenOrObservationBase. This
76 * will also consider specimens that are determined as a taxon concept
77 * belonging to the synonymy of the given taxon concept.
79 * In contrast to {@link #listByAnyAssociation(Class, Taxon, List)} this
80 * method only takes SpecimenOrObservationBase instances into account which
81 * are actually determined as the taxon specified by
82 * <code>determinedAs</code>.
85 * The type of entities to return (can be null to count all
86 * entities of type <T>)
88 * the taxon concept that the occurrences have been determined to
91 * The maximum number of objects returned (can be null for all
94 * The offset (in pageSize chunks) from the start of the result
95 * set (0 - based, can be null, equivalent of starting at the
96 * beginning of the recordset)
98 * Supports path like <code>orderHints.propertyNames</code> which
99 * include *-to-one properties like createdBy.username or
100 * authorTeam.persistentTitleCache
101 * @param propertyPaths
102 * properties to be initialized
105 public Pager
<SpecimenOrObservationBase
> list(Class
<?
extends SpecimenOrObservationBase
> type
, TaxonBase determinedAs
, Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
108 * Returns a paged list of occurrences that have been determined to belong
109 * to the taxon name determinedAs, optionally restricted to objects
110 * belonging to a class that that extends SpecimenOrObservationBase.
112 * In contrast to {@link #listByAnyAssociation(Class, Taxon, List)} this
113 * method only takes SpecimenOrObservationBase instances into account which
114 * are actually determined as the taxon specified by
115 * <code>determinedAs</code>.
118 * The type of entities to return (can be null to count all
119 * entities of type <T>)
120 * @param determinedAs
121 * the taxon name that the occurrences have been determined to
124 * The maximum number of objects returned (can be null for all
127 * The offset (in pageSize chunks) from the start of the result
128 * set (0 - based, can be null, equivalent of starting at the
129 * beginning of the recordset)
131 * Supports path like <code>orderHints.propertyNames</code> which
132 * include *-to-one properties like createdBy.username or
133 * authorTeam.persistentTitleCache
134 * @param propertyPaths
135 * properties to be initialized
138 public Pager
<SpecimenOrObservationBase
> list(Class
<?
extends SpecimenOrObservationBase
> type
, TaxonName determinedAs
, Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
141 * Returns a List of Media that are associated with a given occurrence
143 * @param occurrence the occurrence associated with these media
144 * @param pageSize The maximum number of media returned (can be null for all related media)
145 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
146 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
147 * @return a Pager of media instances
150 public Pager
<Media
> getMedia(SpecimenOrObservationBase occurence
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
153 * Returns all media attached to this occurence and its children. Also takes
154 * {@link MediaSpecimen} and molecular images into account.
156 * @param occurence the occurence and its children from which the media to get
157 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
158 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
159 * @return a Pager of media instances
161 public Pager
<Media
> getMediaInHierarchy(SpecimenOrObservationBase
<?
> rootOccurence
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
164 * Returns a count of determinations that have been made for a given occurence and for a given taxon concept
166 * @param occurence the occurence associated with these determinations (can be null for all occurrences)
167 * @param taxonbase the taxon concept associated with these determinations (can be null for all taxon concepts)
168 * @return a count of determination events
170 public long countDeterminations(SpecimenOrObservationBase occurence
,TaxonBase taxonbase
);
173 * Returns a List of determinations that have been made for a given occurence
175 * @param occurence the occurence associated with these determinations (can be null for all occurrences)
176 * @param taxonbase the taxon concept associated with these determinations (can be null for all taxon concepts)
177 * @param pageSize The maximum number of determinations returned (can be null for all related determinations)
178 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
179 * @return a Pager of determination instances
181 public Pager
<DeterminationEvent
> getDeterminations(SpecimenOrObservationBase occurence
, TaxonBase taxonBase
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
184 * Returns a list of derivation events that have involved creating new DerivedUnits from this occurence
186 * @param occurence the occurence that was a source of these derivation events
187 * @param pageSize The maximum number of derivation events returned (can be null for all related derivation events)
188 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
189 * @return a Pager of derivation events
191 public Pager
<DerivationEvent
> getDerivationEvents(SpecimenOrObservationBase occurence
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
194 * Returns a Paged List of SpecimenOrObservationBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
196 * @param clazz filter the results by class (or pass null to return all SpecimenOrObservationBase instances)
198 * @param pageSize The maximum number of occurrences returned (can be null for all matching occurrences)
199 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
201 * Supports path like <code>orderHints.propertyNames</code> which
202 * include *-to-one properties like createdBy.username or
203 * authorTeam.persistentTitleCache
204 * @param propertyPaths properties to be initialized
205 * @return a Pager SpecimenOrObservationBase instances
206 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
209 public Pager
<SpecimenOrObservationBase
> search(Class
<?
extends SpecimenOrObservationBase
> clazz
, String query
, Integer pageSize
,Integer pageNumber
, List
<OrderHint
> orderHints
,List
<String
> propertyPaths
);
212 * Retrieves the {@link UUID} and the string representation (title cache) of all
213 * {@link FieldUnit}s found in the data base.
214 * @return a list of {@link UuidAndTitleCache}
216 public List
<UuidAndTitleCache
<FieldUnit
>> getFieldUnitUuidAndTitleCache();
219 * Retrieves the {@link UUID} and the string representation (title cache) of all
220 * {@link DerivedUnit}s found in the data base.
221 * @return a list of {@link UuidAndTitleCache}
223 public List
<UuidAndTitleCache
<DerivedUnit
>> getDerivedUnitUuidAndTitleCache(Integer limit
, String pattern
);
225 public DerivedUnitFacade
getDerivedUnitFacade(DerivedUnit derivedUnit
, List
<String
> propertyPaths
) throws DerivedUnitFacadeNotSupportedException
;
228 * Lists all instances of {@link SpecimenOrObservationBase} which are
229 * associated with the <code>taxon</code> specified as parameter.
230 * SpecimenOrObservationBase instances can be associated to taxa in multiple
231 * ways, all these possible relations are taken into account:
233 * <li>The {@link IndividualsAssociation} elements in a
234 * {@link TaxonDescription} contain {@link DerivedUnit}s</li>
235 * <li>{@link SpecimenTypeDesignation}s may be associated with any
236 * {@link HomotypicalGroup} related to the specific {@link Taxon}.</li>
237 * <li>A {@link Taxon} may be referenced by the {@link DeterminationEvent}
238 * of the {@link SpecimenOrObservationBase}</li>
240 * Further more there also can be taxa which are associated with the taxon
241 * in question (parameter associatedTaxon) by {@link TaxonRelationship}s. If
242 * the parameter <code>includeRelationships</code> is containing elements,
243 * these according {@TaxonRelationshipType}s and
244 * directional information will be used to collect further
245 * {@link SpecimenOrObservationBase} instances found this way.
249 * @param associatedTaxon
250 * @param Set<TaxonRelationshipVector> includeRelationships. TaxonRelationships will not be taken into account if this is <code>NULL</code>.
251 * @param maxDepth TODO
255 * @param propertyPaths
258 public <T
extends SpecimenOrObservationBase
> List
<T
> listByAssociatedTaxon(Class
<T
> type
, Set
<TaxonRelationshipEdge
> includeRelationships
,
259 Taxon associatedTaxon
, Integer maxDepth
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
262 * The method will search for specimen associated with the taxon nodes.<br>
263 * It will search for 3 possible association types: <br>
264 * - via IndividualAssociations of the taxon<br>
265 * - via TypeDesignations of the taxon name<br>
266 * - via Determinations of the taxon or taxon name<br>
268 * more are covered in
269 * {@link IOccurrenceService#findByTitle(IIdentifiableEntityServiceConfigurator)}
270 * @param taxonNodeUuids
271 * a list of {@link UUID}s of the taxon nodes
274 * @return a collection of {@link SpecimenNodeWrapper} containing the
275 * {@link TaxonNode} and the corresponding {@link UuidAndTitleCache}
276 * object for the specimen found for this taxon node
278 public Collection
<SpecimenNodeWrapper
> listUuidAndTitleCacheByAssociatedTaxon(List
<UUID
> taxonNodeUuids
,
279 Integer limit
, Integer start
);
282 * See {@link #listByAssociatedTaxon(Class, Set, Taxon, Integer, Integer, Integer, List, List)}
285 * Restriction to subtype of <code>SpecimenOrObservationBase</code>, can be NULL.
286 * @param includeRelationships
287 * @param associatedTaxon
292 * @param propertyPaths
295 public <T
extends SpecimenOrObservationBase
> Pager
<T
> pageByAssociatedTaxon(Class
<T
> type
, Set
<TaxonRelationshipEdge
> includeRelationships
,
296 Taxon associatedTaxon
, Integer maxDepth
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
299 * Retrieves all {@link FieldUnit}s for the {@link SpecimenOrObservationBase} with the given {@link UUID}.<br>
300 * @param specimenUuid the UUID of the specimen
301 * @param propertyPaths the property path
302 * @return either a collection of FieldUnits this specimen was derived from, the FieldUnit itself
303 * if this was a FieldUnit or an empty collection if no FieldUnits were found
305 public Collection
<FieldUnit
> findFieldUnits(UUID specimenUuid
, List
<String
> propertyPaths
);
308 * Retrieves top most originals for a {@link SpecimenOrObservationBase} in the derivation graph by recursively
309 * walking all {@link DerivationEvent}s.
310 * In most cases item in the returned collection will be {@link FieldUnit FieldUnits} but also DerivedUnits are possible, in
311 * cases where no FieledUnit exists.
313 * @param specimenUuid the UUID of the specimen
314 * @param propertyPaths the property path
315 * @return either a collection of root units
317 public Collection
<SpecimenOrObservationBase
> findRootUnits(UUID specimenUuid
, List
<String
> propertyPaths
);
323 * @param highlightFragments
327 * @param propertyPaths
329 * @throws CorruptIndexException
330 * @throws IOException
331 * @throws ParseException
333 Pager
<SearchResult
<SpecimenOrObservationBase
>> findByFullText(Class
<?
extends SpecimenOrObservationBase
> clazz
,
334 String queryString
, RectangleDTO boundingBox
, List
<Language
> languages
, boolean highlightFragments
,
335 Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
)
336 throws IOException
, LuceneParseException
;
338 * See {@link #listByAssociatedTaxon(Class, Set, String, Integer, Integer, Integer, List, List)}
341 * @param includeRelationships
342 * @param associatedTaxon
347 * @param propertyPaths
350 public <T
extends SpecimenOrObservationBase
> Pager
<T
> pageByAssociatedTaxon(Class
<T
> type
, Set
<TaxonRelationshipEdge
> includeRelationships
,
351 String taxonUUID
, Integer maxDepth
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
354 * Moves the given {@link Sequence} from one {@link DnaSample} to another
355 * @param from the DnaSample from which the sequence will be removed
356 * @param to the DnaSample which to which the sequence will be added
357 * @param sequence the Sequence to move
358 * @return <code>true</code> if successfully moved, <code>false</code> otherwise
360 public UpdateResult
moveSequence(DnaSample from
, DnaSample to
, Sequence sequence
);
366 * @param sequenceUuid
369 public UpdateResult
moveSequence(UUID fromUuid
, UUID toUuid
, UUID sequenceUuid
);
372 * Moves the given {@link DerivedUnit} from one {@link SpecimenOrObservationBase} to another.
373 * @param from the SpecimenOrObservationBase from which the DerivedUnit will be removed
374 * @param to the SpecimenOrObservationBase to which the DerivedUnit will be added
375 * @param derivate the DerivedUnit to move
376 * @return <code>true</code> if successfully moved, <code>false</code> otherwise
378 public UpdateResult
moveDerivate(UUID specimenFromUuid
, UUID specimenToUuid
, UUID derivateUuid
);
386 public boolean moveDerivate(SpecimenOrObservationBase
<?
> from
, SpecimenOrObservationBase
<?
> to
, DerivedUnit derivate
);
389 * Assembles a {@link FieldUnitDTO} for the given field unit.<br>
392 * @return a DTO with all the assembled information
394 public FieldUnitDTO
assembleFieldUnitDTO(FieldUnit fieldUnit
);
397 * Assembles a {@link DerivedUnitDTO} for the given derived unit.
399 * @return a DTO with all the assembled information
401 public SpecimenOrObservationBaseDTO
assembleDerivedUnitDTO(DerivedUnit derivedUnit
);
404 * Deletes the specified specimen according to the setting in the {@link SpecimenDeleteConfigurator}.<br>
405 * @param specimen the specimen which shoul be deleted
406 * @param config specifies options if and how the specimen should be deleted like e.g. including all
408 * @return the {@link DeleteResult} which holds information about the outcome of this operation
410 public DeleteResult
delete(SpecimenOrObservationBase
<?
> specimen
, SpecimenDeleteConfigurator config
);
413 * Deletes the specified specimen belonging to the given {@link UUID}
414 * according to the setting in the {@link SpecimenDeleteConfigurator}.
417 * the specimen which shoul be deleted
419 * specifies options if and how the specimen should be deleted
420 * like e.g. including all of its children
421 * @return the {@link DeleteResult} which holds information about the
422 * outcome of this operation
424 public DeleteResult
delete(UUID specimenUuid
, SpecimenDeleteConfigurator config
);
427 * Retrieves all {@link IndividualsAssociation} with the given specimen.<br>
428 * @param specimen the specimen for which the associations are retrieved
432 * @param propertyPaths
433 * @return collection of all associations
435 public Collection
<IndividualsAssociation
> listIndividualsAssociations(SpecimenOrObservationBase
<?
> specimen
, Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
439 * Retrieves all taxa linked via {@link IndividualsAssociation} with the given specimen.<br>
440 * @param specimen the specimen which is linked to the taxa
444 * @param propertyPaths
445 * @return a collection of associated taxa
447 public Collection
<TaxonBase
<?
>> listIndividualsAssociationTaxa(SpecimenOrObservationBase
<?
> specimen
,
448 Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
450 * @see #listIndividualsAssociationTaxa(SpecimenOrObservationBase, Integer, Integer, List, List)
452 public Collection
<TaxonBase
<?
>> listIndividualsAssociationTaxa(SpecimenOrObservationBase
<?
> specimen
, boolean includeUnpublished
,
453 Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
456 * Retrieves all associated taxa for the given specimen (via type designations, determination, individuals associations)
458 public Collection
<TaxonBase
<?
>> listAssociatedTaxa(SpecimenOrObservationBase
<?
> specimen
, boolean includeUnpublished
,
459 Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
462 * Retrieves all taxa that the given specimen is determined as
467 * @param propertyPaths
468 * @return collection of all taxa the given specimen is determined as
470 public Collection
<TaxonBase
<?
>> listDeterminedTaxa(SpecimenOrObservationBase
<?
> specimen
, boolean includeUnpublished
,
471 Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
474 * Retrieves all {@link DeterminationEvent}s which have the given specimen set as identified unit.
479 * @param propertyPaths
480 * @return collection of all determination events with the given specimen
482 public Collection
<DeterminationEvent
> listDeterminationEvents(SpecimenOrObservationBase
<?
> specimen
, Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
485 * Retrieves all taxa with a {@link SpecimenTypeDesignation} with the given specimen as a type specimen.
486 * @param specimen the type specimen
491 * @param propertyPaths
492 * @return a collection of all taxa where the given specimen is the type specimen
494 public Collection
<TaxonBase
<?
>> listTypeDesignationTaxa(DerivedUnit specimen
,
495 Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
497 * @see #listTypeDesignationTaxa(DerivedUnit, Integer, Integer, List, List)a
499 public Collection
<TaxonBase
<?
>> listTypeDesignationTaxa(DerivedUnit specimen
, boolean includeUnpublished
,
500 Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
503 * Retrieves all {@link SpecimenTypeDesignation}s which have the given specimens as a type specimen.
504 * @param specimens the type specimens
508 * @param propertyPaths
509 * @return map of all designations with the given type specimens
511 public Map
<DerivedUnit
, Collection
<SpecimenTypeDesignation
>> listTypeDesignations(Collection
<DerivedUnit
> specimens
, Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
514 * Retrieves all {@link SpecimenTypeDesignation}s which have the given specimen as a type specimen.
515 * @param specimen the type specimen
519 * @param propertyPaths
520 * @return collection of all designations with the given type specimen
522 public Collection
<SpecimenTypeDesignation
> listTypeDesignations(DerivedUnit specimen
, Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
525 * Retrieves all {@link DescriptionBase}s that have the given specimen set as described specimen.
526 * @param specimen the described specimen
530 * @param propertyPaths
531 * @return collection of all descriptions with the given described specimen
533 public Collection
<DescriptionBase
<?
>> listDescriptionsWithDescriptionSpecimen(SpecimenOrObservationBase
<?
> specimen
, Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
536 * Gets all description elements that are used for describing the character
537 * states of the given specimen
539 * @param specimenUuid
540 * the specimen {@link UUID} for which the character state description
541 * elements should be retrieved
542 * @return a collection of all character state description elements for this
545 public Collection
<DescriptionElementBase
> getCharacterDataForSpecimen(UUID specimenUuid
);
548 * Returns the most significant identifier for the given {@link DerivedUnit}.
549 * @param derivedUnit the derived unit to check
550 * @return the identifier string
553 public String
getMostSignificantIdentifier(UUID derivedUnit
);
556 * Returns the number of specimens that match the given parameters
558 * <b>NOTE - issue #6484:</b> the parameters {@link FindOccurrencesConfigurator#getAssignmentStatus()}
559 * and {@link FindOccurrencesConfigurator#isRetrieveIndirectlyAssociatedSpecimens()} are not evaluated
560 * in the count method
561 * @param clazz the class to match
562 * @param queryString the queryString to match
563 * @param type the {@link SpecimenOrObservationType} to match
564 * @param associatedTaxon the taxon these specimens are in any way associated to via
565 * determination, type designations, individuals associations, etc.
566 * @param matchmode determines how the query string should be matched
568 * the maximum number of entities returned (can be null to return
572 * Supports path like <code>orderHints.propertyNames</code> which
573 * include *-to-one properties like createdBy.username or
574 * authorTeam.persistentTitleCache
575 * @return the number of found specimens
577 public long countOccurrences(IIdentifiableEntityServiceConfigurator
<SpecimenOrObservationBase
> config
);
580 * Return the all {@link SpecimenOrObservationBase}s of the complete
581 * derivative hierarchy i.e. all parent and child derivatives and the given
585 * a specimen or observation
586 * @return the derivative hierarchy as an unordered list of all specimens or observation
588 public List
<SpecimenOrObservationBase
<?
>> getAllHierarchyDerivatives(SpecimenOrObservationBase
<?
> specimen
);
591 * Returns all child derivatives of the given specimen.
592 * @param specimen a specimen or observation
593 * @return an unordered list of all child derivatives
595 public List
<DerivedUnit
> getAllChildDerivatives(SpecimenOrObservationBase
<?
> specimen
);
598 * Returns all child derivatives of the given specimen.
599 * @param specimen the UUID of a specimen or observation
600 * @return an unordered list of all child derivatives
602 public List
<DerivedUnit
> getAllChildDerivatives(UUID specimenUuid
);
605 * Returns all {@link FieldUnit}s that are referencing this {@link GatheringEvent}
606 * @param gatheringEventUuid the {@link UUID} of the gathering event
607 * @return a list of field units referencing the gathering event
609 public List
<FieldUnit
> findFieldUnitsForGatheringEvent(UUID gatheringEventUuid
);
613 * Returns a list of {@link UuidAndTitleCache} for the specimens found with the
615 * @param config the configurator for the search
616 * @return a list of UuidAndTitleCache object
618 @Transactional(readOnly
= true)
619 public Pager
<UuidAndTitleCache
<SpecimenOrObservationBase
>> findByTitleUuidAndTitleCache(
620 FindOccurrencesConfigurator config
);
623 * Returns a list of {@link DerivedUnitDTO} for the specimens found with the
625 * @param config the configurator for the search
626 * @return a list of {@link DerivedUnitDTO} object
628 @Transactional(readOnly
= true)
629 public List
<DerivedUnitDTO
> findByTitleDerivedUnitDTO(
630 FindOccurrencesConfigurator config
);
633 * Collects the <code>FieldUnits</code> which are at the root of the derivation event
634 * graph in which the {@link DnaSample} with the specified <code>accessionNumberString</code>
637 public SpecimenOrObservationBaseDTO
findByGeneticAccessionNumber(String dnaAccessionNumber
, List
<OrderHint
> orderHints
);
640 * Recursively searches all {@link DerivationEvent}s to find all "originals" ({@link SpecimenOrObservationBase})
641 * from which this DerivedUnit was derived until all FieldUnits are found.
643 * <b>NOTE:</b> The recursive search still is a bit incomplete and may miss originals in the rare case where a
644 * derivative has more than one original. (see https://dev.e-taxonomy.eu/redmine/issues/9253)
646 * @param derivedUnitDTO
647 * The DerivedUnitDTO to start the search from.
648 * @param alreadyCollectedSpecimen
649 * A map to hold all originals that have been sees during the recursive walk.
651 * The collection of all Field Units that are accessible from the derivative from where the search was started.
653 public Collection
<SpecimenOrObservationBaseDTO
> findRootUnitDTOs(UUID unitUUID
);
656 * Finds the units which are associated to a taxon
657 * (<code>associatedTaxonUuid</code>) and returns all related root units
658 * with the derivation branches up to the derivatives associated with the
659 * taxon and the full derivation sub-tree of those.
661 * Requirements as stated in the below linked tickets:
663 * <li>The derivation trees (derivatives, sub-derivatives,
664 * sub-sub-derivatives, ....) of each of the root units will be included in
665 * the result items in
666 * ({@link SpecimenOrObservationBaseDTO#getDerivatives()})</li>
667 * <li>.... should contain all derivates of a derivate determined to the
668 * taxon or its name and all elements should be displayed only once.
670 * <li>... also sollen beim DerivateTree eigentlich auch nur die Derivate
671 * angezeigt werden, die über Taxon Association oder Determination an einem
672 * Taxon oder Namen hängen und ihre direkten Eltern und Kinder (+
674 * <li>Also im Endeffekt muss man die Derivate raus suchen, die eine
675 * Assoziation zu dem Taxon haben und dann die direkten Vorgänger und die
676 * Nachfolger finden. Andere Derivate, die von Origin Derivaten abstammen
677 * würden erstmal nicht dazugehören, außer sie sind ebenfalls mit dem Taxon
678 * assoziiert....</li>
684 * <li>https://dev.e-taxonomy.eu/redmine/issues/7599</li>
685 * <li>https://dev.e-taxonomy.eu/redmine/issues/9216</li>
688 * @param includedRelationships
690 * @param associatedTaxonUuid
691 * The uuid of the taxon for which associated derivatives are to be found.
692 * @param propertyPaths
693 * The bean initialization strategy
695 * The list of root units with fully or partially assembled derivation graph.
697 List
<SpecimenOrObservationBaseDTO
> listRootUnitDTOsByAssociatedTaxon(Set
<TaxonRelationshipEdge
> includedRelationships
,
698 UUID associatedTaxonUuid
, boolean includeUnpublished
, List
<String
> propertyPaths
);
702 * Lists all root units which are
703 * associated <b>directly or indirectly</b>with the <code>taxon</code> specified
704 * as parameter. "Indirectly" means that a sub derivate of the FieldUnit is
705 * directly associated with the given taxon.
706 * SpecimenOrObservationBase instances can be associated to taxa in multiple
707 * ways, all these possible relations are taken into account:
709 * <li>The {@link IndividualsAssociation} elements in a
710 * {@link TaxonDescription} contain {@link DerivedUnit}s</li>
711 * <li>{@link SpecimenTypeDesignation}s may be associated with any
712 * {@link HomotypicalGroup} related to the specific {@link Taxon}.</li>
713 * <li>A {@link Taxon} may be referenced by the {@link DeterminationEvent}
714 * of the {@link SpecimenOrObservationBase}</li>
716 * Further more there also can be taxa which are associated with the taxon
717 * in question (parameter associatedTaxon) by {@link TaxonRelationship}s. If
718 * the parameter <code>includeRelationships</code> is containing elements,
719 * these according {@TaxonRelationshipType}s and
720 * directional information will be used to collect further
721 * {@link SpecimenOrObservationBase} instances found this way.
725 * Restriction to a specific subtype, may be null.
726 * @param associatedTaxon
727 * @param Set<TaxonRelationshipVector> includeRelationships. TaxonRelationships will not be taken into account if this is <code>NULL</code>.
728 * @param maxDepth TODO
732 * @param propertyPaths
735 public <T
extends SpecimenOrObservationBase
> Collection
<T
> listRootUnitsByAssociatedTaxon(Class
<T
> type
, Taxon associatedTaxon
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
739 * See {@link #listFieldUnitsByAssociatedTaxon(Set, Taxon, Integer, Integer, Integer, List, List)}
741 public <T
extends SpecimenOrObservationBase
> Pager
<T
> pageRootUnitsByAssociatedTaxon(Class
<T
> type
, Set
<TaxonRelationshipEdge
> includeRelationships
,
742 Taxon associatedTaxon
, Integer maxDepth
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
746 public List
<Point
> findPointsForFieldUnitList(List
<UUID
> fieldUnitUuids
);
749 * Load the FieldUnitDTO for the given <code>derivedUnitUuid</code> with all intermediate derivatives and {@link eu.etaxonomy.cdm.api.service.dto.GatheringEventDTO}
751 * @param derivedUnitUuid
754 FieldUnitDTO
loadFieldUnitDTO(UUID derivedUnitUuid
);
756 Pager
<MediaDTO
> getMediaDTOs(SpecimenOrObservationBase
<?
> occurence
, Integer pageSize
, Integer pageNumber
);
758 Pager
<Media
> getMediaInHierarchy(SpecimenOrObservationBase
<?
> rootOccurence
, boolean collectOriginalMedia
, boolean collectDerivativeMedia
,
759 Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);