Project

General

Profile

Download (37.8 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
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.
8
*/
9

    
10
package eu.etaxonomy.cdm.api.service;
11

    
12
import java.io.IOException;
13
import java.util.Collection;
14
import java.util.List;
15
import java.util.Map;
16
import java.util.Set;
17
import java.util.UUID;
18

    
19
import org.apache.lucene.index.CorruptIndexException;
20
import org.hibernate.search.spatial.impl.Rectangle;
21
import org.springframework.transaction.annotation.Transactional;
22

    
23
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
24
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
25
import eu.etaxonomy.cdm.api.service.config.FindOccurrencesConfigurator;
26
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
27
import eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator;
28
import eu.etaxonomy.cdm.api.service.dto.DerivedUnitDTO;
29
import eu.etaxonomy.cdm.api.service.dto.FieldUnitDTO;
30
import eu.etaxonomy.cdm.api.service.dto.MediaDTO;
31
import eu.etaxonomy.cdm.api.service.dto.SpecimenOrObservationBaseDTO;
32
import eu.etaxonomy.cdm.api.service.pager.Pager;
33
import eu.etaxonomy.cdm.api.service.search.LuceneParseException;
34
import eu.etaxonomy.cdm.api.service.search.SearchResult;
35
import eu.etaxonomy.cdm.api.util.TaxonRelationshipEdge;
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;
64

    
65
/**
66
 * @author a.babadshanjan
67
 * @since 01.09.2008
68
 */
69
public interface IOccurrenceService
70
        extends IIdentifiableEntityService<SpecimenOrObservationBase> {
71

    
72
    /**
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.
78
     * <p>
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>.
83
     *
84
     * @param type
85
     *            The type of entities to return (can be null to count all
86
     *            entities of type <T>)
87
     * @param determinedAs
88
     *            the taxon concept that the occurrences have been determined to
89
     *            belong to
90
     * @param pageSize
91
     *            The maximum number of objects returned (can be null for all
92
     *            matching objects)
93
     * @param pageNumber
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)
97
     * @param orderHints
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
103
     * @return
104
     */
105
    public Pager<SpecimenOrObservationBase> list(Class<? extends SpecimenOrObservationBase> type, TaxonBase determinedAs, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
106

    
107
    /**
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.
111
     * <p>
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>.
116
     *
117
     * @param type
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
122
     *            belong to
123
     * @param pageSize
124
     *            The maximum number of objects returned (can be null for all
125
     *            matching objects)
126
     * @param pageNumber
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)
130
     * @param orderHints
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
136
     * @return
137
     */
138
    public Pager<SpecimenOrObservationBase> list(Class<? extends SpecimenOrObservationBase> type, TaxonName determinedAs, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
139

    
140
    /**
141
     * Returns a List of Media that are associated with a given occurence
142
     *
143
     * @param occurence the occurence 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
148
     */
149
    public Pager<Media> getMedia(SpecimenOrObservationBase occurence, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
150

    
151
    /**
152
     * Returns all media attached to this occurence and its children. Also takes
153
     * {@link MediaSpecimen} and molecular images into account.
154
     *
155
     * @param occurence the occurence and its children from which the media to get
156
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
157
     * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
158
     * @return a Pager of media instances
159
     */
160
    public Pager<Media> getMediaInHierarchy(SpecimenOrObservationBase<?> rootOccurence, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
161

    
162
    /**
163
     * Returns a count of determinations that have been made for a given occurence and for a given taxon concept
164
     *
165
     * @param occurence the occurence associated with these determinations (can be null for all occurrences)
166
     * @param taxonbase the taxon concept associated with these determinations (can be null for all taxon concepts)
167
     * @return a count of determination events
168
     */
169
    public long countDeterminations(SpecimenOrObservationBase occurence,TaxonBase taxonbase);
170

    
171
    /**
172
     * Returns a List of determinations that have been made for a given occurence
173
     *
174
     * @param occurence the occurence associated with these determinations (can be null for all occurrences)
175
     * @param taxonbase the taxon concept associated with these determinations (can be null for all taxon concepts)
176
     * @param pageSize The maximum number of determinations returned (can be null for all related determinations)
177
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
178
     * @return a Pager of determination instances
179
     */
180
    public Pager<DeterminationEvent> getDeterminations(SpecimenOrObservationBase occurence, TaxonBase taxonBase, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
181

    
182
    /**
183
     * Returns a list of derivation events that have involved creating new DerivedUnits from this occurence
184
     *
185
     * @param occurence the occurence that was a source of these derivation events
186
     * @param pageSize The maximum number of derivation events returned (can be null for all related derivation events)
187
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
188
     * @return a Pager of derivation events
189
     */
190
    public Pager<DerivationEvent> getDerivationEvents(SpecimenOrObservationBase occurence, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
191

    
192
    /**
193
     * Returns a Paged List of SpecimenOrObservationBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
194
     *
195
     * @param clazz filter the results by class (or pass null to return all SpecimenOrObservationBase instances)
196
     * @param queryString
197
     * @param pageSize The maximum number of occurrences returned (can be null for all matching occurrences)
198
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
199
     * @param orderHints
200
     *            Supports path like <code>orderHints.propertyNames</code> which
201
     *            include *-to-one properties like createdBy.username or
202
     *            authorTeam.persistentTitleCache
203
     * @param propertyPaths properties to be initialized
204
     * @return a Pager SpecimenOrObservationBase instances
205
     * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
206
     */
207
    @Override
208
    public Pager<SpecimenOrObservationBase> search(Class<? extends SpecimenOrObservationBase> clazz, String query, Integer pageSize,Integer pageNumber, List<OrderHint> orderHints,List<String> propertyPaths);
209

    
210
    /**
211
     * Retrieves the {@link UUID} and the string representation (title cache) of all
212
     * {@link FieldUnit}s found in the data base.
213
     * @return a list of {@link UuidAndTitleCache}
214
     */
215
    public List<UuidAndTitleCache<FieldUnit>> getFieldUnitUuidAndTitleCache();
216

    
217
    /**
218
     * Retrieves the {@link UUID} and the string representation (title cache) of all
219
     * {@link DerivedUnit}s found in the data base.
220
     * @return a list of {@link UuidAndTitleCache}
221
     */
222
    public List<UuidAndTitleCache<DerivedUnit>> getDerivedUnitUuidAndTitleCache(Integer limit, String pattern);
223

    
224
    public DerivedUnitFacade getDerivedUnitFacade(DerivedUnit derivedUnit, List<String> propertyPaths) throws DerivedUnitFacadeNotSupportedException;
225

    
226
    public List<DerivedUnitFacade> listDerivedUnitFacades(DescriptionBase description, List<String> propertyPaths);
227

    
228
    /**
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:
233
     * <ul>
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>
240
     * </ul>
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.
247
     *
248
     * @param <T>
249
     * @param type
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
253
     * @param pageSize
254
     * @param pageNumber
255
     * @param orderHints
256
     * @param propertyPaths
257
     * @return
258
     */
259
    public <T extends SpecimenOrObservationBase> List<T> listByAssociatedTaxon(Class<T> type, Set<TaxonRelationshipEdge> includeRelationships,
260
            Taxon associatedTaxon, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
261

    
262
    /**
263
     * The method will search for specimen associated with the taxon nodes.<br>
264
     * It will search for 3 possible association types: <br>
265
     * - via IndividualAssociations of the taxon<br>
266
     *  - via TypeDesignations of the taxon name<br>
267
     *  - via Determinations of the taxon or taxon name<br>
268
     * <br>
269
     * more are covered in
270
     * {@link IOccurrenceService#findByTitle(IIdentifiableEntityServiceConfigurator)}
271
     * @param taxonNodeUuids
272
     *            a list of {@link UUID}s of the taxon nodes
273
     * @param limit
274
     * @param start
275
     * @return a collection of {@link SpecimenNodeWrapper} containing the
276
     *         {@link TaxonNode} and the corresponding {@link UuidAndTitleCache}
277
     *         object for the specimen found for this taxon node
278
     */
279
    public Collection<SpecimenNodeWrapper> listUuidAndTitleCacheByAssociatedTaxon(List<UUID> taxonNodeUuids,
280
            Integer limit, Integer start);
281

    
282

    
283
    /**
284
     * @deprecated replace by {@link #listRootUnitsByAssociatedTaxon(Class, Taxon, List, List)}
285
     */
286
    @Deprecated
287
    public Collection<FieldUnit> listFieldUnitsByAssociatedTaxon(Taxon associatedTaxon, List<OrderHint> orderHints, List<String> propertyPaths);
288

    
289

    
290
    /**
291
     * See {@link #listByAssociatedTaxon(Class, Set, Taxon, Integer, Integer, Integer, List, List)}
292
     *
293
     * @param type
294
     *  Restriction to subtype of <code>SpecimenOrObservationBase</code>, can be NULL.
295
     * @param includeRelationships
296
     * @param associatedTaxon
297
     * @param maxDepth
298
     * @param pageSize
299
     * @param pageNumber
300
     * @param orderHints
301
     * @param propertyPaths
302
     * @return a Pager
303
     */
304
    public <T extends SpecimenOrObservationBase> Pager<T> pageByAssociatedTaxon(Class<T> type, Set<TaxonRelationshipEdge> includeRelationships,
305
            Taxon associatedTaxon, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
306

    
307
    /**
308
     * Retrieves all {@link FieldUnit}s for the {@link SpecimenOrObservationBase} with the given {@link UUID}.<br>
309
     * @param specimenUuid the UUID of the specimen
310
     * @param propertyPaths the property path
311
     * @return either a collection of FieldUnits this specimen was derived from, the FieldUnit itself
312
     * if this was a FieldUnit or an empty collection if no FieldUnits were found
313
     */
314
    public Collection<FieldUnit> findFieldUnits(UUID specimenUuid, List<String> propertyPaths);
315

    
316
    /**
317
     * Retrieves top most originals for a {@link SpecimenOrObservationBase} in the derivation graph by recursively
318
     * walking all {@link DerivationEvent}s.
319
     * In most cases item in the returned collection will be {@link FieldUnit FieldUnits} but also DerivedUnits are possible, in
320
     * cases where no FieledUnit exists.
321
     *
322
     * @param specimenUuid the UUID of the specimen
323
     * @param propertyPaths the property path
324
     * @return either a collection of root units
325
     */
326
    public Collection<SpecimenOrObservationBase> findRootUnits(UUID specimenUuid, List<String> propertyPaths);
327

    
328
    /**
329
     * @param clazz
330
     * @param queryString
331
     * @param languages
332
     * @param highlightFragments
333
     * @param pageSize
334
     * @param pageNumber
335
     * @param orderHints
336
     * @param propertyPaths
337
     * @return
338
     * @throws CorruptIndexException
339
     * @throws IOException
340
     * @throws ParseException
341
     */
342
    Pager<SearchResult<SpecimenOrObservationBase>> findByFullText(Class<? extends SpecimenOrObservationBase> clazz,
343
            String queryString, Rectangle boundingBox, List<Language> languages, boolean highlightFragments,
344
            Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths)
345
            throws IOException, LuceneParseException;
346
    /**
347
     * See {@link #listByAssociatedTaxon(Class, Set, String, Integer, Integer, Integer, List, List)}
348
     *
349
     * @param type
350
     * @param includeRelationships
351
     * @param associatedTaxon
352
     * @param maxDepth
353
     * @param pageSize
354
     * @param pageNumber
355
     * @param orderHints
356
     * @param propertyPaths
357
     * @return a Pager
358
     */
359
    public <T extends SpecimenOrObservationBase> Pager<T>  pageByAssociatedTaxon(Class<T> type, Set<TaxonRelationshipEdge> includeRelationships,
360
            String taxonUUID, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
361

    
362
    /**
363
     * Moves the given {@link Sequence} from one {@link DnaSample} to another
364
     * @param from the DnaSample from which the sequence will be removed
365
     * @param to the DnaSample which to which the sequence will be added
366
     * @param sequence the Sequence to move
367
     * @return <code>true</code> if successfully moved, <code>false</code> otherwise
368
     */
369
    public UpdateResult moveSequence(DnaSample from, DnaSample to, Sequence sequence);
370

    
371

    
372
    /**
373
     * @param fromUuid
374
     * @param toUuid
375
     * @param sequenceUuid
376
     * @return
377
     */
378
    public UpdateResult moveSequence(UUID fromUuid, UUID toUuid, UUID sequenceUuid);
379

    
380
    /**
381
     * Moves the given {@link DerivedUnit} from one {@link SpecimenOrObservationBase} to another.
382
     * @param from the SpecimenOrObservationBase from which the DerivedUnit will be removed
383
     * @param to the SpecimenOrObservationBase to which the DerivedUnit will be added
384
     * @param derivate the DerivedUnit to move
385
     * @return <code>true</code> if successfully moved, <code>false</code> otherwise
386
     */
387
    public UpdateResult moveDerivate(UUID specimenFromUuid, UUID specimenToUuid, UUID derivateUuid);
388

    
389
    /**
390
     * @param from
391
     * @param to
392
     * @param derivate
393
     * @return
394
     */
395
    public boolean moveDerivate(SpecimenOrObservationBase<?> from, SpecimenOrObservationBase<?> to, DerivedUnit derivate);
396

    
397
    /**
398
     * Assembles a {@link FieldUnitDTO} for the given field unit.<br>
399
     *
400
     * @param fieldUnit
401
     * @return a DTO with all the assembled information
402
     */
403
    public FieldUnitDTO assembleFieldUnitDTO(FieldUnit fieldUnit);
404

    
405
    /**
406
     * Assembles a {@link DerivedUnitDTO} for the given derived unit.
407
     * @param derivedUnit
408
     * @return a DTO with all the assembled information
409
     */
410
    public SpecimenOrObservationBaseDTO assembleDerivedUnitDTO(DerivedUnit derivedUnit);
411

    
412
    /**
413
     * Deletes the specified specimen according to the setting in the {@link SpecimenDeleteConfigurator}.<br>
414
     * @param specimen the specimen which shoul be deleted
415
     * @param config specifies options if and how the specimen should be deleted like e.g. including all
416
     * of its children
417
     * @return the {@link DeleteResult} which holds information about the outcome of this operation
418
     */
419
    public DeleteResult delete(SpecimenOrObservationBase<?> specimen, SpecimenDeleteConfigurator config);
420

    
421
    /**
422
     * Deletes the specified specimen belonging to the given {@link UUID}
423
     * according to the setting in the {@link SpecimenDeleteConfigurator}.
424
     *
425
     * @param specimen
426
     *            the specimen which shoul be deleted
427
     * @param config
428
     *            specifies options if and how the specimen should be deleted
429
     *            like e.g. including all of its children
430
     * @return the {@link DeleteResult} which holds information about the
431
     *         outcome of this operation
432
     */
433
    public DeleteResult delete(UUID specimenUuid, SpecimenDeleteConfigurator config);
434

    
435
    /**
436
     * Retrieves all {@link IndividualsAssociation} with the given specimen.<br>
437
     * @param specimen the specimen for which the associations are retrieved
438
     * @param limit
439
     * @param start
440
     * @param orderHints
441
     * @param propertyPaths
442
     * @return collection of all associations
443
     */
444
    public Collection<IndividualsAssociation> listIndividualsAssociations(SpecimenOrObservationBase<?> specimen, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
445

    
446

    
447
    /**
448
     * Retrieves all taxa linked via {@link IndividualsAssociation} with the given specimen.<br>
449
     * @param specimen the specimen which is linked to the taxa
450
     * @param limit
451
     * @param start
452
     * @param orderHints
453
     * @param propertyPaths
454
     * @return a collection of associated taxa
455
     */
456
    public Collection<TaxonBase<?>> listIndividualsAssociationTaxa(SpecimenOrObservationBase<?> specimen,
457
            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
458
    /**
459
      * @see #listIndividualsAssociationTaxa(SpecimenOrObservationBase, Integer, Integer, List, List)
460
      */
461
    public Collection<TaxonBase<?>> listIndividualsAssociationTaxa(SpecimenOrObservationBase<?> specimen, boolean includeUnpublished,
462
            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
463

    
464
    /**
465
     * Retrieves all associated taxa for the given specimen (via type designations, determination, individuals associations)
466
     * @param specimen
467
     * @param limit
468
     * @param start
469
     * @param orderHints
470
     * @param propertyPaths
471
     * @return
472
     */
473
    public Collection<TaxonBase<?>> listAssociatedTaxa(SpecimenOrObservationBase<?> specimen, boolean includeUnpublished,
474
            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
475
    /**
476
     * @see #listAssociatedTaxa(SpecimenOrObservationBase, Integer, Integer, List, List)axa
477
     */
478
    public Collection<TaxonBase<?>> listAssociatedTaxa(SpecimenOrObservationBase<?> specimen,
479
            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
480

    
481
    /**
482
     * Retrieves all taxa that the given specimen is determined as
483
     * @param specimen
484
     * @param limit
485
     * @param start
486
     * @param orderHints
487
     * @param propertyPaths
488
     * @return collection of all taxa the given specimen is determined as
489
     */
490
    public Collection<TaxonBase<?>> listDeterminedTaxa(SpecimenOrObservationBase<?> specimen, boolean includeUnpublished,
491
            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
492
    /**
493
     * @see #listDeterminedTaxa(SpecimenOrObservationBase, Integer, Integer, List, List)
494
     */
495
    public Collection<TaxonBase<?>> listDeterminedTaxa(SpecimenOrObservationBase<?> specimen,
496
            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
497

    
498
    /**
499
     * Retrieves all {@link DeterminationEvent}s which have the given specimen set as identified unit.
500
     * @param specimen
501
     * @param limit
502
     * @param start
503
     * @param orderHints
504
     * @param propertyPaths
505
     * @return collection of all determination events with the given specimen
506
     */
507
    public Collection<DeterminationEvent> listDeterminationEvents(SpecimenOrObservationBase<?> specimen, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
508

    
509
    /**
510
     * Retrieves all taxa with a {@link SpecimenTypeDesignation} with the given specimen as a type specimen.
511
     * @param specimen the type specimen
512
     * @param specimen
513
     * @param limit
514
     * @param start
515
     * @param orderHints
516
     * @param propertyPaths
517
     * @return a collection of all taxa where the given specimen is the type specimen
518
     */
519
    public Collection<TaxonBase<?>> listTypeDesignationTaxa(DerivedUnit specimen,
520
            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
521
    /**
522
     * @see #listTypeDesignationTaxa(DerivedUnit, Integer, Integer, List, List)a
523
     */
524
    public Collection<TaxonBase<?>> listTypeDesignationTaxa(DerivedUnit specimen, boolean includeUnpublished,
525
            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
526

    
527
    /**
528
     * Retrieves all {@link SpecimenTypeDesignation}s which have the given specimens as a type specimen.
529
     * @param specimens the type specimens
530
     * @param limit
531
     * @param start
532
     * @param orderHints
533
     * @param propertyPaths
534
     * @return map of all designations with the given type specimens
535
     */
536
    public Map<DerivedUnit, Collection<SpecimenTypeDesignation>> listTypeDesignations(Collection<DerivedUnit> specimens, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
537

    
538
    /**
539
     * Retrieves all {@link SpecimenTypeDesignation}s which have the given specimen as a type specimen.
540
     * @param specimen the type specimen
541
     * @param limit
542
     * @param start
543
     * @param orderHints
544
     * @param propertyPaths
545
     * @return collection of all designations with the given type specimen
546
     */
547
    public Collection<SpecimenTypeDesignation> listTypeDesignations(DerivedUnit specimen, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
548

    
549
    /**
550
     * Retrieves all {@link DescriptionBase}s that have the given specimen set as described specimen.
551
     * @param specimen the described specimen
552
     * @param limit
553
     * @param start
554
     * @param orderHints
555
     * @param propertyPaths
556
     * @return collection of all descriptions with the given described specimen
557
     */
558
    public Collection<DescriptionBase<?>> listDescriptionsWithDescriptionSpecimen(SpecimenOrObservationBase<?> specimen, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
559

    
560
    /**
561
     * Gets all description elements that are used for describing the character
562
     * states of the given specimen
563
     *
564
     * @param specimenUuid
565
     *            the specimen {@link UUID} for which the character state description
566
     *            elements should be retrieved
567
     * @return a collection of all character state description elements for this
568
     *         specimen
569
     */
570
    public Collection<DescriptionElementBase> getCharacterDataForSpecimen(UUID specimenUuid);
571

    
572
    /**
573
     * Returns the most significant identifier for the given {@link DerivedUnit}.
574
     * @param derivedUnit the derived unit to check
575
     * @return the identifier string
576
     */
577

    
578
    public String getMostSignificantIdentifier(UUID derivedUnit);
579

    
580
    /**
581
     * Returns the number of specimens that match the given parameters
582
     * <br>
583
     * <b>NOTE - issue #6484:</b> the parameters {@link FindOccurrencesConfigurator#getAssignmentStatus()}
584
     * and {@link FindOccurrencesConfigurator#isRetrieveIndirectlyAssociatedSpecimens()} are not evaluated
585
     * in the count method
586
     * @param clazz the class to match
587
     * @param queryString the queryString to match
588
     * @param type the {@link SpecimenOrObservationType} to match
589
     * @param associatedTaxon the taxon these specimens are in any way associated to via
590
     * determination, type designations, individuals associations, etc.
591
     * @param matchmode determines how the query string should be matched
592
     * @param limit
593
     *            the maximum number of entities returned (can be null to return
594
     *            all entities)
595
     * @param start
596
     * @param orderHints
597
     *            Supports path like <code>orderHints.propertyNames</code> which
598
     *            include *-to-one properties like createdBy.username or
599
     *            authorTeam.persistentTitleCache
600
     * @return the number of found specimens
601
     */
602
    public long countOccurrences(IIdentifiableEntityServiceConfigurator<SpecimenOrObservationBase> config);
603

    
604
    /**
605
     * Return the all {@link SpecimenOrObservationBase}s of the complete
606
     * derivative hierarchy i.e. all parent and child derivatives and the given
607
     * specimen itself.
608
     *
609
     * @param specimen
610
     *            a specimen or observation
611
     * @return the derivative hierarchy as an unordered list of all specimens or observation
612
     */
613
    public List<SpecimenOrObservationBase<?>> getAllHierarchyDerivatives(SpecimenOrObservationBase<?> specimen);
614

    
615
    /**
616
     * Returns all child derivatives of the given specimen.
617
     * @param specimen a specimen or observation
618
     * @return an unordered list of all child derivatives
619
     */
620
    public List<DerivedUnit> getAllChildDerivatives(SpecimenOrObservationBase<?> specimen);
621

    
622
    /**
623
     * Returns all child derivatives of the given specimen.
624
     * @param specimen the UUID of a specimen or observation
625
     * @return an unordered list of all child derivatives
626
     */
627
    public List<DerivedUnit> getAllChildDerivatives(UUID specimenUuid);
628

    
629
    /**
630
     * Returns all {@link FieldUnit}s that are referencing this {@link GatheringEvent}
631
     * @param gatheringEventUuid the {@link UUID} of the gathering event
632
     * @return a list of field units referencing the gathering event
633
     */
634
    public List<FieldUnit> findFieldUnitsForGatheringEvent(UUID gatheringEventUuid);
635

    
636

    
637
    /**
638
     * Returns a list of {@link UuidAndTitleCache} for the specimens found with the
639
     * given configurator
640
     * @param config the configurator for the search
641
     * @return a list of UuidAndTitleCache object
642
     */
643
    @Transactional(readOnly = true)
644
    public Pager<UuidAndTitleCache<SpecimenOrObservationBase>> findByTitleUuidAndTitleCache(
645
            FindOccurrencesConfigurator config);
646

    
647
    /**
648
     * Returns a list of {@link DerivedUnitDTO} for the specimens found with the
649
     * given configurator
650
     * @param config the configurator for the search
651
     * @return a list of {@link DerivedUnitDTO} object
652
     */
653
    @Transactional(readOnly = true)
654
    public List<DerivedUnitDTO> findByTitleDerivedUnitDTO(
655
            FindOccurrencesConfigurator config);
656

    
657

    
658
    /**
659
     * Collects the <code>FieldUnits</code> which are at the root of the derivation event
660
     * graph in which the {@link DerivedUnit} with the specified <code>findByAccessionNumber</code>
661
     * is found.
662
     *
663
     * @deprecated method name unclear and thus replaced by {@link #findByGeneticAccessionNumber(String, List)}
664
     */
665
    @Deprecated
666
    SpecimenOrObservationBaseDTO findByAccessionNumber(String accessionNumberString, List<OrderHint> orderHints);
667

    
668
    /**
669
     * Collects the <code>FieldUnits</code> which are at the root of the derivation event
670
     * graph in which the {@link DnaSample} with the specified <code>accessionNumberString</code>
671
     * is found.
672
     */
673
    SpecimenOrObservationBaseDTO findByGeneticAccessionNumber(String dnaAccessionNumber, List<OrderHint> orderHints);
674

    
675
    /**
676
     * Recursively searches all {@link DerivationEvent}s to find all "originals" ({@link SpecimenOrObservationBase})
677
     * from which this DerivedUnit was derived until all FieldUnits are found.
678
     * <p>
679
     * <b>NOTE:</b> The recursive search still is a bit incomplete and may miss originals in the rare case where a
680
     * derivative has more than one original. (see https://dev.e-taxonomy.eu/redmine/issues/9253)
681
     *
682
     * @param derivedUnitDTO
683
     *      The DerivedUnitDTO to start the search from.
684
     * @param alreadyCollectedSpecimen
685
     *      A map to hold all originals that have been sees during the recursive walk.
686
     * @return
687
     *      The collection of all Field Units that are accessible from the derivative from where the search was started.
688
     */
689
    public Collection<SpecimenOrObservationBaseDTO> findRootUnitDTOs(UUID unitUUID);
690

    
691
    /**
692
     * Finds the units which are associated to a taxon
693
     * (<code>associatedTaxonUuid</code>) and returns all related root units
694
     * with the derivation branches up to the derivatives associated with the
695
     * taxon and the full derivation sub-tree of those.
696
     * <p>
697
     * Requirements as stated in the below linked tickets:
698
     * <ol>
699
     * <li>The derivation trees (derivatives, sub-derivatives,
700
     * sub-sub-derivatives, ....) of each of the root units will be included in
701
     * the result items in
702
     * ({@link SpecimenOrObservationBaseDTO#getDerivatives()})</li>
703
     * <li>.... should contain all derivates of a derivate determined to the
704
     * taxon or its name and all elements should be displayed only once.
705
     * ....</li>
706
     * <li>... also sollen beim DerivateTree eigentlich auch nur die Derivate
707
     * angezeigt werden, die über Taxon Association oder Determination an einem
708
     * Taxon oder Namen hängen und ihre direkten Eltern und Kinder (+
709
     * KindesKinder…).
710
     * <li>Also im Endeffekt muss man die Derivate raus suchen, die eine
711
     * Assoziation zu dem Taxon haben und dann die direkten Vorgänger und die
712
     * Nachfolger finden. Andere Derivate, die von Origin Derivaten abstammen
713
     * würden erstmal nicht dazugehören, außer sie sind ebenfalls mit dem Taxon
714
     * assoziiert....</li>
715
     * <ul>
716
     *
717
     * Related tickets:
718
     *
719
     * <ul>
720
     * <li>https://dev.e-taxonomy.eu/redmine/issues/7599</li>
721
     * <li>https://dev.e-taxonomy.eu/redmine/issues/9216</li>
722
     * </ul>
723
     *
724
     * @param includedRelationships
725
     *  TODO
726
     * @param associatedTaxonUuid
727
     *  The uuid of the taxon for which associated derivatives are to be found.
728
     * @param propertyPaths
729
     *  The bean initialization strategy
730
     * @return
731
     *  The list of root units with fully or partially assembled derivation graph.
732
     */
733
    List<SpecimenOrObservationBaseDTO> listRootUnitDTOsByAssociatedTaxon(Set<TaxonRelationshipEdge> includedRelationships,
734
            UUID associatedTaxonUuid, List<String> propertyPaths);
735

    
736

    
737
    /**
738
     * Lists all root units which are
739
     * associated <b>directly or indirectly</b>with the <code>taxon</code> specified
740
     * as parameter. "Indirectly" means that a sub derivate of the FieldUnit is
741
     * directly associated with the given taxon.
742
     * SpecimenOrObservationBase instances can be associated to taxa in multiple
743
     * ways, all these possible relations are taken into account:
744
     * <ul>
745
     * <li>The {@link IndividualsAssociation} elements in a
746
     * {@link TaxonDescription} contain {@link DerivedUnit}s</li>
747
     * <li>{@link SpecimenTypeDesignation}s may be associated with any
748
     * {@link HomotypicalGroup} related to the specific {@link Taxon}.</li>
749
     * <li>A {@link Taxon} may be referenced by the {@link DeterminationEvent}
750
     * of the {@link SpecimenOrObservationBase}</li>
751
     * </ul>
752
     * Further more there also can be taxa which are associated with the taxon
753
     * in question (parameter associatedTaxon) by {@link TaxonRelationship}s. If
754
     * the parameter <code>includeRelationships</code> is containing elements,
755
     * these according {@TaxonRelationshipType}s and
756
     * directional information will be used to collect further
757
     * {@link SpecimenOrObservationBase} instances found this way.
758
     *
759
     * @param <T>
760
     * @param type
761
     *  Restriction to a specific subtype, may be null.
762
     * @param associatedTaxon
763
     * @param Set<TaxonRelationshipVector> includeRelationships. TaxonRelationships will not be taken into account if this is <code>NULL</code>.
764
     * @param maxDepth TODO
765
     * @param pageSize
766
     * @param pageNumber
767
     * @param orderHints
768
     * @param propertyPaths
769
     * @return
770
     */
771
    public <T extends SpecimenOrObservationBase> Collection<T> listRootUnitsByAssociatedTaxon(Class<T> type, Taxon associatedTaxon, List<OrderHint> orderHints, List<String> propertyPaths);
772

    
773

    
774
    /**
775
     * See {@link #listFieldUnitsByAssociatedTaxon(Set, Taxon, Integer, Integer, Integer, List, List)}
776
     */
777
    public <T extends SpecimenOrObservationBase> Pager<T> pageRootUnitsByAssociatedTaxon(Class<T> type, Set<TaxonRelationshipEdge> includeRelationships,
778
            Taxon associatedTaxon, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
779

    
780

    
781

    
782
    public List<Point> findPointsForFieldUnitList(List<UUID> fieldUnitUuids);
783

    
784
    /**
785
     * Load the FieldUnitDTO for the given <code>derivedUnitUuid</code> with all intermediate derivatives and {@link eu.etaxonomy.cdm.api.service.dto.GatheringEventDTO}
786

    
787
     * @param derivedUnitUuid
788
     * @return
789
     */
790
    FieldUnitDTO loadFieldUnitDTO(UUID derivedUnitUuid);
791

    
792
    Pager<MediaDTO> getMediaDTOs(SpecimenOrObservationBase<?> occurence, Integer pageSize, Integer pageNumber);
793

    
794
}
(44-44/95)