Project

General

Profile

Download (31.5 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.FieldUnitDTO;
29
import eu.etaxonomy.cdm.api.service.dto.PreservedSpecimenDTO;
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.service.util.TaxonRelationshipEdge;
34
import eu.etaxonomy.cdm.model.common.Language;
35
import eu.etaxonomy.cdm.model.description.DescriptionBase;
36
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
37
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
38
import eu.etaxonomy.cdm.model.description.TaxonDescription;
39
import eu.etaxonomy.cdm.model.location.Country;
40
import eu.etaxonomy.cdm.model.media.Media;
41
import eu.etaxonomy.cdm.model.molecular.DnaSample;
42
import eu.etaxonomy.cdm.model.molecular.Sequence;
43
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
44
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
45
import eu.etaxonomy.cdm.model.name.TaxonName;
46
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent;
47
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
48
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
49
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
50
import eu.etaxonomy.cdm.model.occurrence.GatheringEvent;
51
import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen;
52
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
53
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
54
import eu.etaxonomy.cdm.model.taxon.Taxon;
55
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
56
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
57
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
58
import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;
59
import eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper;
60
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
61
import eu.etaxonomy.cdm.persistence.query.OrderHint;
62

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

    
69
    public Country getCountryByIso(String iso639);
70

    
71
    public List<Country> getCountryByName(String name);
72

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

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

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

    
152
    /**
153
     * Returns all media attached to this occurence and its children. Also takes
154
     * {@link MediaSpecimen} and molecular images into account.
155
     *
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
160
     */
161
    public Pager<Media> getMediainHierarchy(SpecimenOrObservationBase rootOccurence, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
162

    
163
    /**
164
     * Returns a count of determinations that have been made for a given occurence and for a given taxon concept
165
     *
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
169
     */
170
    public int countDeterminations(SpecimenOrObservationBase occurence,TaxonBase taxonbase);
171

    
172
    /**
173
     * Returns a List of determinations that have been made for a given occurence
174
     *
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
180
     */
181
    public Pager<DeterminationEvent> getDeterminations(SpecimenOrObservationBase occurence, TaxonBase taxonBase, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
182

    
183
    /**
184
     * Returns a list of derivation events that have involved creating new DerivedUnits from this occurence
185
     *
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
190
     */
191
    public Pager<DerivationEvent> getDerivationEvents(SpecimenOrObservationBase occurence, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
192

    
193
    /**
194
     * Returns a Paged List of SpecimenOrObservationBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
195
     *
196
     * @param clazz filter the results by class (or pass null to return all SpecimenOrObservationBase instances)
197
     * @param queryString
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)
200
     * @param orderHints
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>
207
     */
208
    @Override
209
    public Pager<SpecimenOrObservationBase> search(Class<? extends SpecimenOrObservationBase> clazz, String query, Integer pageSize,Integer pageNumber, List<OrderHint> orderHints,List<String> propertyPaths);
210

    
211
    /**
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}
215
     */
216
    public List<UuidAndTitleCache<FieldUnit>> getFieldUnitUuidAndTitleCache();
217

    
218
    /**
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}
222
     */
223
    public List<UuidAndTitleCache<DerivedUnit>> getDerivedUnitUuidAndTitleCache(Integer limit, String pattern);
224

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

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

    
229
    /**
230
     * Lists all instances of {@link SpecimenOrObservationBase} which are
231
     * associated with the <code>taxon</code> specified as parameter.
232
     * SpecimenOrObservationBase instances can be associated to taxa in multiple
233
     * ways, all these possible relations are taken into account:
234
     * <ul>
235
     * <li>The {@link IndividualsAssociation} elements in a
236
     * {@link TaxonDescription} contain {@link DerivedUnit}s</li>
237
     * <li>{@link SpecimenTypeDesignation}s may be associated with any
238
     * {@link HomotypicalGroup} related to the specific {@link Taxon}.</li>
239
     * <li>A {@link Taxon} may be referenced by the {@link DeterminationEvent}
240
     * of the {@link SpecimenOrObservationBase}</li>
241
     * </ul>
242
     * Further more there also can be taxa which are associated with the taxon
243
     * in question (parameter associatedTaxon) by {@link TaxonRelationship}s. If
244
     * the parameter <code>includeRelationships</code> is containing elements,
245
     * these according {@TaxonRelationshipType}s and
246
     * directional information will be used to collect further
247
     * {@link SpecimenOrObservationBase} instances found this way.
248
     *
249
     * @param <T>
250
     * @param type
251
     * @param associatedTaxon
252
     * @param Set<TaxonRelationshipVector> includeRelationships. TaxonRelationships will not be taken into account if this is <code>NULL</code>.
253
     * @param maxDepth TODO
254
     * @param pageSize
255
     * @param pageNumber
256
     * @param orderHints
257
     * @param propertyPaths
258
     * @return
259
     */
260
    public <T extends SpecimenOrObservationBase> List<T> listByAssociatedTaxon(Class<T> type, Set<TaxonRelationshipEdge> includeRelationships,
261
            Taxon associatedTaxon, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
262

    
263
    /**
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>
269
     * <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
274
     * @param limit
275
     * @param start
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
279
     */
280
    public Collection<SpecimenNodeWrapper> listUuidAndTitleCacheByAssociatedTaxon(List<UUID> taxonNodeUuids,
281
            Integer limit, Integer start);
282

    
283

    
284
    /**
285
     * Lists all instances of {@link FieldUnit} which are
286
     * associated <b>directly or indirectly</b>with the <code>taxon</code> specified
287
     * as parameter. "Indirectly" means that a sub derivate of the FieldUnit is
288
     * directly associated with the given taxon.
289
     * SpecimenOrObservationBase instances can be associated to taxa in multiple
290
     * ways, all these possible relations are taken into account:
291
     * <ul>
292
     * <li>The {@link IndividualsAssociation} elements in a
293
     * {@link TaxonDescription} contain {@link DerivedUnit}s</li>
294
     * <li>{@link SpecimenTypeDesignation}s may be associated with any
295
     * {@link HomotypicalGroup} related to the specific {@link Taxon}.</li>
296
     * <li>A {@link Taxon} may be referenced by the {@link DeterminationEvent}
297
     * of the {@link SpecimenOrObservationBase}</li>
298
     * </ul>
299
     * Further more there also can be taxa which are associated with the taxon
300
     * in question (parameter associatedTaxon) by {@link TaxonRelationship}s. If
301
     * the parameter <code>includeRelationships</code> is containing elements,
302
     * these according {@TaxonRelationshipType}s and
303
     * directional information will be used to collect further
304
     * {@link SpecimenOrObservationBase} instances found this way.
305
     *
306
     * @param <T>
307
     * @param type
308
     * @param associatedTaxon
309
     * @param Set<TaxonRelationshipVector> includeRelationships. TaxonRelationships will not be taken into account if this is <code>NULL</code>.
310
     * @param maxDepth TODO
311
     * @param pageSize
312
     * @param pageNumber
313
     * @param orderHints
314
     * @param propertyPaths
315
     * @return
316
     */
317
    public Collection<SpecimenOrObservationBase> listFieldUnitsByAssociatedTaxon(Taxon associatedTaxon, List<OrderHint> orderHints, List<String> propertyPaths);
318

    
319
    /**
320
     * See {@link #listFieldUnitsByAssociatedTaxon(Set, Taxon, Integer, Integer, Integer, List, List)}
321
     */
322
    public Pager<SpecimenOrObservationBase> pageFieldUnitsByAssociatedTaxon(Set<TaxonRelationshipEdge> includeRelationships,
323
            Taxon associatedTaxon, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
324

    
325
    /**
326
     * See {@link #listByAssociatedTaxon(Class, Set, Taxon, Integer, Integer, Integer, List, List)}
327
     *
328
     * @param type
329
     * @param includeRelationships
330
     * @param associatedTaxon
331
     * @param maxDepth
332
     * @param pageSize
333
     * @param pageNumber
334
     * @param orderHints
335
     * @param propertyPaths
336
     * @return a Pager
337
     */
338
    public <T extends SpecimenOrObservationBase> Pager<T> pageByAssociatedTaxon(Class<T> type, Set<TaxonRelationshipEdge> includeRelationships,
339
            Taxon associatedTaxon, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
340

    
341
    /**
342
     * Retrieves all {@link FieldUnit}s for the {@link SpecimenOrObservationBase} with the given {@link UUID}.<br>
343
     * @param specimenUuid the UUID of the specimen
344
     * @param propertyPaths the property path
345
     * @return either a collection of FieldUnits this specimen was derived from, the FieldUnit itself
346
     * if this was a FieldUnit or an empty collection if no FieldUnits were found
347
     */
348
    public Collection<FieldUnit> getFieldUnits(UUID specimenUuid, List<String> propertyPaths);
349

    
350
    /**
351
     * @param clazz
352
     * @param queryString
353
     * @param languages
354
     * @param highlightFragments
355
     * @param pageSize
356
     * @param pageNumber
357
     * @param orderHints
358
     * @param propertyPaths
359
     * @return
360
     * @throws CorruptIndexException
361
     * @throws IOException
362
     * @throws ParseException
363
     */
364
    Pager<SearchResult<SpecimenOrObservationBase>> findByFullText(Class<? extends SpecimenOrObservationBase> clazz,
365
            String queryString, Rectangle boundingBox, List<Language> languages, boolean highlightFragments,
366
            Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths)
367
            throws IOException, LuceneParseException;
368
    /**
369
     * See {@link #listByAssociatedTaxon(Class, Set, String, Integer, Integer, Integer, List, List)}
370
     *
371
     * @param type
372
     * @param includeRelationships
373
     * @param associatedTaxon
374
     * @param maxDepth
375
     * @param pageSize
376
     * @param pageNumber
377
     * @param orderHints
378
     * @param propertyPaths
379
     * @return a Pager
380
     */
381
    public <T extends SpecimenOrObservationBase> Pager<T>  pageByAssociatedTaxon(Class<T> type, Set<TaxonRelationshipEdge> includeRelationships,
382
            String taxonUUID, Integer maxDepth, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
383

    
384
    /**
385
     * Moves the given {@link Sequence} from one {@link DnaSample} to another
386
     * @param from the DnaSample from which the sequence will be removed
387
     * @param to the DnaSample which to which the sequence will be added
388
     * @param sequence the Sequence to move
389
     * @return <code>true</code> if successfully moved, <code>false</code> otherwise
390
     */
391
    public UpdateResult moveSequence(DnaSample from, DnaSample to, Sequence sequence);
392

    
393

    
394
    /**
395
     * @param fromUuid
396
     * @param toUuid
397
     * @param sequenceUuid
398
     * @return
399
     */
400
    public UpdateResult moveSequence(UUID fromUuid, UUID toUuid, UUID sequenceUuid);
401

    
402
    /**
403
     * Moves the given {@link DerivedUnit} from one {@link SpecimenOrObservationBase} to another.
404
     * @param from the SpecimenOrObservationBase from which the DerivedUnit will be removed
405
     * @param to the SpecimenOrObservationBase to which the DerivedUnit will be added
406
     * @param derivate the DerivedUnit to move
407
     * @return <code>true</code> if successfully moved, <code>false</code> otherwise
408
     */
409
    public UpdateResult moveDerivate(UUID specimenFromUuid, UUID specimenToUuid, UUID derivateUuid);
410

    
411
    /**
412
     * @param from
413
     * @param to
414
     * @param derivate
415
     * @return
416
     */
417
    public boolean moveDerivate(SpecimenOrObservationBase<?> from, SpecimenOrObservationBase<?> to, DerivedUnit derivate);
418

    
419
    /**
420
     * Assembles a {@link FieldUnitDTO} for the given field unit uuid which is associated to the {@link Taxon}.<br>
421
     * <br>
422
     * For the meaning of "associated" see also {@link #listFieldUnitsByAssociatedTaxon(Set, Taxon, Integer, Integer, Integer, List, List)}
423
     * @param fieldUnit
424
     * @param associatedTaxonUuid
425
     * @return a DTO with all the assembled information
426
     */
427
    public FieldUnitDTO assembleFieldUnitDTO(FieldUnit fieldUnit, UUID associatedTaxonUuid);
428

    
429
    /**
430
     * Assembles a {@link PreservedSpecimenDTO} for the given derived unit.
431
     * @param derivedUnit
432
     * @return a DTO with all the assembled information
433
     */
434
    public PreservedSpecimenDTO assemblePreservedSpecimenDTO(DerivedUnit derivedUnit);
435

    
436
    /**
437
     * Deletes the specified specimen according to the setting in the {@link SpecimenDeleteConfigurator}.<br>
438
     * @param specimen the specimen which shoul be deleted
439
     * @param config specifies options if and how the specimen should be deleted like e.g. including all
440
     * of its children
441
     * @return the {@link DeleteResult} which holds information about the outcome of this operation
442
     */
443
    public DeleteResult delete(SpecimenOrObservationBase<?> specimen, SpecimenDeleteConfigurator config);
444

    
445
    /**
446
     * Deletes the specified specimen belonging to the given {@link UUID}
447
     * according to the setting in the {@link SpecimenDeleteConfigurator}.
448
     *
449
     * @param specimen
450
     *            the specimen which shoul be deleted
451
     * @param config
452
     *            specifies options if and how the specimen should be deleted
453
     *            like e.g. including all of its children
454
     * @return the {@link DeleteResult} which holds information about the
455
     *         outcome of this operation
456
     */
457
    public DeleteResult delete(UUID specimenUuid, SpecimenDeleteConfigurator config);
458

    
459
    /**
460
     * Retrieves all {@link IndividualsAssociation} with the given specimen.<br>
461
     * @param specimen the specimen for which the associations are retrieved
462
     * @param limit
463
     * @param start
464
     * @param orderHints
465
     * @param propertyPaths
466
     * @return collection of all associations
467
     */
468
    public Collection<IndividualsAssociation> listIndividualsAssociations(SpecimenOrObservationBase<?> specimen, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
469

    
470

    
471
    /**
472
     * Retrieves all taxa linked via {@link IndividualsAssociation} with the given specimen.<br>
473
     * @param specimen the specimen which is linked to the taxa
474
     * @param limit
475
     * @param start
476
     * @param orderHints
477
     * @param propertyPaths
478
     * @return a collection of associated taxa
479
     */
480
    public Collection<TaxonBase<?>> listIndividualsAssociationTaxa(SpecimenOrObservationBase<?> specimen, Integer limit,
481
            Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
482

    
483
    /**
484
     * Retrieves all associated taxa for the given specimen (via type designations, determination, individuals associations)
485
     * @param specimen
486
     * @param limit
487
     * @param start
488
     * @param orderHints
489
     * @param propertyPaths
490
     * @return
491
     */
492
    public Collection<TaxonBase<?>> listAssociatedTaxa(SpecimenOrObservationBase<?> specimen, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
493

    
494
    /**
495
     * Retrieves all taxa that the given specimen is determined as
496
     * @param specimen
497
     * @param limit
498
     * @param start
499
     * @param orderHints
500
     * @param propertyPaths
501
     * @return collection of all taxa the given specimen is determined as
502
     */
503
    public Collection<TaxonBase<?>> listDeterminedTaxa(SpecimenOrObservationBase<?> specimen, Integer limit, Integer start,
504
            List<OrderHint> orderHints, List<String> propertyPaths);
505

    
506
    /**
507
     * Retrieves all {@link DeterminationEvent}s which have the given specimen set as identified unit.
508
     * @param specimen
509
     * @param limit
510
     * @param start
511
     * @param orderHints
512
     * @param propertyPaths
513
     * @return collection of all determination events with the given specimen
514
     */
515
    public Collection<DeterminationEvent> listDeterminationEvents(SpecimenOrObservationBase<?> specimen, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
516

    
517
    /**
518
     * Retrieves all taxa with a {@link SpecimenTypeDesignation} with the given specimen as a type specimen.
519
     * @param specimen the type specimen
520
     * @param specimen
521
     * @param limit
522
     * @param start
523
     * @param orderHints
524
     * @param propertyPaths
525
     * @return a collection of all taxa where the given specimen is the type specimen
526
     */
527
    public Collection<TaxonBase<?>> listTypeDesignationTaxa(DerivedUnit specimen, Integer limit,
528
            Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
529

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

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

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

    
563
    /**
564
     * Gets all description elements that are used for describing the character
565
     * states of the given specimen
566
     *
567
     * @param specimen
568
     *            the specimen for which the character state description
569
     *            elements should be retrieved
570
     * @return a collection of all character state description elements for this
571
     *         specimen
572
     */
573
    public Collection<DescriptionElementBase> getCharacterDataForSpecimen(SpecimenOrObservationBase<?> specimen);
574

    
575
    /**
576
     * Gets all description elements that are used for describing the character
577
     * states of the given specimen
578
     *
579
     * @param specimenUuid
580
     *            the specimen {@link UUID} for which the character state description
581
     *            elements should be retrieved
582
     * @return a collection of all character state description elements for this
583
     *         specimen
584
     */
585
    public Collection<DescriptionElementBase> getCharacterDataForSpecimen(UUID specimenUuid);
586

    
587
    /**
588
     * Returns the most significant identifier for the given {@link DerivedUnit}.
589
     * @param derivedUnit the derived unit to check
590
     * @return the identifier string
591
     */
592
    public String getMostSignificantIdentifier(DerivedUnit derivedUnit);
593

    
594
    /**
595
     * Returns the number of specimens that match the given parameters
596
     * <br>
597
     * <b>NOTE - issue #6484:</b> the parameters {@link FindOccurrencesConfigurator#getAssignmentStatus()}
598
     * and {@link FindOccurrencesConfigurator#isRetrieveIndirectlyAssociatedSpecimens()} are not evaluated
599
     * in the count method
600
     * @param clazz the class to match
601
     * @param queryString the queryString to match
602
     * @param type the {@link SpecimenOrObservationType} to match
603
     * @param associatedTaxon the taxon these specimens are in any way associated to via
604
     * determination, type designations, individuals associations, etc.
605
     * @param matchmode determines how the query string should be matched
606
     * @param limit
607
     *            the maximum number of entities returned (can be null to return
608
     *            all entities)
609
     * @param start
610
     * @param orderHints
611
     *            Supports path like <code>orderHints.propertyNames</code> which
612
     *            include *-to-one properties like createdBy.username or
613
     *            authorTeam.persistentTitleCache
614
     * @return the number of found specimens
615
     */
616
    public int countOccurrences(IIdentifiableEntityServiceConfigurator<SpecimenOrObservationBase> config);
617

    
618
    /**
619
     * Return the all {@link SpecimenOrObservationBase}s of the complete
620
     * derivative hierarchy i.e. all parent and child derivatives and the given
621
     * specimen itself.
622
     *
623
     * @param specimen
624
     *            a specimen or observation
625
     * @return the derivative hierarchy as an unordered list of all specimens or observation
626
     */
627
    public List<SpecimenOrObservationBase<?>> getAllHierarchyDerivatives(SpecimenOrObservationBase<?> specimen);
628

    
629
    /**
630
     * Returns all child derivatives of the given specimen.
631
     * @param specimen a specimen or observation
632
     * @return an unordered list of all child derivatives
633
     */
634
    public List<DerivedUnit> getAllChildDerivatives(SpecimenOrObservationBase<?> specimen);
635

    
636
    /**
637
     * Returns all child derivatives of the given specimen.
638
     * @param specimen the UUID of a specimen or observation
639
     * @return an unordered list of all child derivatives
640
     */
641
    public List<DerivedUnit> getAllChildDerivatives(UUID specimenUuid);
642

    
643
    /**
644
     * Returns all {@link FieldUnit}s that are referencing this {@link GatheringEvent}
645
     * @param gatheringEventUuid the {@link UUID} of the gathering event
646
     * @return a list of field units referencing the gathering event
647
     */
648
    public List<FieldUnit> getFieldUnitsForGatheringEvent(UUID gatheringEventUuid);
649

    
650

    
651
    /**
652
     * Returns a list of {@link UuidAndTitleCache} for the specimens found with the
653
     * given configurator
654
     * @param config the configurator for the search
655
     * @return a list of UuidAndTitleCache object
656
     */
657
    @Transactional(readOnly = true)
658
    public Pager<UuidAndTitleCache<SpecimenOrObservationBase>> findByTitleUuidAndTitleCache(
659
            FindOccurrencesConfigurator config);
660

    
661
}
(51-51/105)