2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.cdm
.api
.service
;
11 import java
.util
.Collection
;
12 import java
.util
.List
;
14 import java
.util
.UUID
;
16 import eu
.etaxonomy
.cdm
.api
.service
.dto
.TaxonDistributionDTO
;
17 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
18 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
19 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
20 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
21 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
22 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionType
;
23 import eu
.etaxonomy
.cdm
.model
.description
.Distribution
;
24 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
25 import eu
.etaxonomy
.cdm
.model
.description
.PresenceAbsenceTerm
;
26 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
27 import eu
.etaxonomy
.cdm
.model
.description
.TaxonNameDescription
;
28 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
29 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
30 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
31 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
32 import eu
.etaxonomy
.cdm
.model
.term
.DefinedTerm
;
33 import eu
.etaxonomy
.cdm
.model
.term
.TermTree
;
34 import eu
.etaxonomy
.cdm
.model
.term
.TermVocabulary
;
35 import eu
.etaxonomy
.cdm
.persistence
.dao
.initializer
.IBeanInitializer
;
36 import eu
.etaxonomy
.cdm
.persistence
.dto
.DescriptionBaseDto
;
37 import eu
.etaxonomy
.cdm
.persistence
.dto
.MergeResult
;
38 import eu
.etaxonomy
.cdm
.persistence
.dto
.TaxonNodeDto
;
39 import eu
.etaxonomy
.cdm
.persistence
.dto
.TermDto
;
40 import eu
.etaxonomy
.cdm
.persistence
.query
.OrderHint
;
42 public interface IDescriptionService
extends IIdentifiableEntityService
<DescriptionBase
> {
46 * @deprecated use TermService#getVocabulary(VocabularyType) instead
49 public TermVocabulary
<Feature
> getDefaultFeatureVocabulary();
52 * List the descriptions of type <T>, filtered using the following parameters
54 * @param type The type of description returned (Taxon, TaxonName, or Specimen)
55 * @param hasMedia Restrict the description to those that do (true) or don't (false) contain <i>elements</i> that have one or more media (can be null)
56 * @param hasText Restrict the description to those that do (true) or don't (false) contain TextData <i>elements</i> that have some textual content (can be null)
57 * @param feature Restrict the description to those <i>elements</i> which are scoped by one of the Features passed (can be null or empty)
58 * @param pageSize The maximum number of descriptions returned (can be null for all descriptions)
59 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
60 * @param orderHints may be null
61 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
62 * @return a Pager containing DescriptionBase instances
64 public Pager
<DescriptionBase
> page(Class
<?
extends DescriptionBase
> type
, Boolean hasMedia
, Boolean hasText
, Set
<Feature
> feature
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
67 * Count the descriptions of type <TYPE>, filtered using the following parameters
69 * @param type The type of description returned (Taxon, TaxonName, or Specimen)
70 * @param hasMedia Restrict the description to those that do (true) or don't (false) contain <i>elements</i> that have one or more media (can be null)
71 * @param hasText Restrict the description to those that do (true) or don't (false) contain TextData <i>elements</i> that have some textual content (can be null)
72 * @param feature Restrict the description to those <i>elements</i> which are scoped by one of the Features passed (can be null or empty)
73 * @return a count of DescriptionBase instances
75 public long count(Class
<?
extends DescriptionBase
> type
, Boolean hasImages
, Boolean hasText
, Set
<Feature
> feature
);
78 * Returns description elements of type <TYPE>, belonging to a given
79 * description, optionally filtered by one or more features
82 * The description which these description elements belong to
83 * (can be null to count all description elements)
84 * @param descriptionType
85 * A filter DescriptionElements which belong to of a specific
86 * class of Descriptions
88 * Restrict the results to those description elements which are
89 * scoped by one of the Features passed (can be null or empty)
91 * A filter for DescriptionElements of a specific class
93 * The maximum number of description elements returned (can be
94 * null for all description elements)
96 * The offset (in pageSize chunks) from the start of the result
98 * @param propertyPaths
99 * Properties to initialize in the returned entities, following
100 * the syntax described in
101 * {@link IBeanInitializer#initialize(Object, List)}
102 * @return a Pager containing DescriptionElementBase instances
105 * {@link #pageDescriptionElements(DescriptionBase, Set, Class, Integer, Integer, List)}
109 public <T
extends DescriptionElementBase
> Pager
<T
> getDescriptionElements(DescriptionBase description
,Set
<Feature
> features
, Class
<T
> type
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
113 * Returns description elements of type <TYPE>, belonging to a given
114 * description, optionally filtered by one or more features
117 * The description which these description elements belong to
118 * (can be null to count all description elements)
119 * @param descriptionType
120 * A filter DescriptionElements which belong to of a specific
121 * class of Descriptions
123 * Restrict the results to those description elements which are
124 * scoped by one of the Features passed (can be null or empty)
126 * A filter for DescriptionElements of a specific class
128 * The maximum number of description elements returned (can be
129 * null for all description elements)
131 * The offset (in pageSize chunks) from the start of the result
133 * @param propertyPaths
134 * Properties to initialize in the returned entities, following
135 * the syntax described in
136 * {@link IBeanInitializer#initialize(Object, List)}
138 * @return a Pager containing DescriptionElementBase instances
140 public <T
extends DescriptionElementBase
> Pager
<T
> pageDescriptionElements(DescriptionBase description
, Class
<?
extends DescriptionBase
> descriptionType
, Set
<Feature
> features
, Class
<T
> type
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
143 * Returns description elements of type <TYPE>, belonging to a given
144 * description, optionally filtered by one or more features
147 * The description which these description elements belong to
148 * (can be null to count all description elements)
150 * Restrict the results to those description elements which are
151 * scoped by one of the Features passed (can be null or empty)
153 * A filter for DescriptionElements of a specific class
155 * The maximum number of description elements returned (can be
156 * null for all description elements)
158 * The offset (in pageSize chunks) from the start of the result
160 * @param propertyPaths
161 * Properties to initialize in the returned entities, following
162 * the syntax described in
163 * {@link IBeanInitializer#initialize(Object, List)}
164 * @return a List of DescriptionElementBase instances
165 * @deprecated use {@link #listDescriptionElements(DescriptionBase, Class, Set, Class, Integer, Integer, List)} instead
168 public <T
extends DescriptionElementBase
> List
<T
> listDescriptionElements(DescriptionBase description
,Set
<Feature
> features
, Class
<T
> type
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
171 * Returns description elements of type <TYPE>, belonging to a given
172 * description, optionally filtered by one or more features
175 * The description which these description elements belong to
176 * (can be null to count all description elements)
178 * Restrict the results to those description elements which are
179 * scoped by one of the Features passed (can be null or empty)
181 * A filter DescriptionElements of a for specific class
183 * The maximum number of description elements returned (can be
184 * null for all description elements)
186 * The offset (in pageSize chunks) from the start of the result
188 * @param propertyPaths
189 * Properties to initialize in the returned entities, following
190 * the syntax described in
191 * {@link IBeanInitializer#initialize(Object, List)}
192 * @return a List of DescriptionElementBase instances
194 public <T
extends DescriptionElementBase
> List
<T
> listDescriptionElements(DescriptionBase description
, Class
<?
extends DescriptionBase
> descriptionType
, Set
<Feature
> features
, Class
<T
> type
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
198 * Returns a List of TaxonDescription instances, optionally filtered by parameters passed to this method
200 * @param taxon The taxon which the description refers to (can be null for all TaxonDescription instances)
201 * @param scopes Restrict the results to those descriptions which are scoped by one of the Scope instances passed (can be null or empty)
202 * @param geographicalScope Restrict the results to those descriptions which have a geographical scope that overlaps with the NamedArea instances passed (can be null or empty)
203 * @param pageSize The maximum number of descriptions returned (can be null for all descriptions)
204 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
205 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
206 * @return a Pager containing TaxonDescription instances
208 * @see #pageMarkedTaxonDescriptions(Taxon, Set, Set, Set, Integer, Integer, List)
210 public Pager
<TaxonDescription
> pageTaxonDescriptions(Taxon taxon
, Set
<DefinedTerm
> scopes
, Set
<NamedArea
> geographicalScope
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
213 * Returns a List of TaxonDescription instances, optionally filtered by parameters passed to this method
215 * @param taxon The taxon which the description refers to (can be null for all TaxonDescription instances)
216 * @param scopes Restrict the results to those descriptions which are scoped by one of the Scope instances passed (can be null or empty)
217 * @param geographicalScope Restrict the results to those descriptions which have a geographical scope that overlaps with the NamedArea instances passed (can be null or empty)
218 * @param markerType Restrict the results to those descriptions which are marked as true by one of the given marker types (can be null or empty)
219 * @param descriptionTypes Restrict the results to those descriptions of the given types (can be null or empty)
220 * @param pageSize The maximum number of descriptions returned (can be null for all descriptions)
221 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
222 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
223 * @return a Pager containing TaxonDescription instances
225 public Pager
<TaxonDescription
> pageTaxonDescriptions(Taxon taxon
, Set
<DefinedTerm
> scopes
, Set
<NamedArea
> geographicalScope
, Set
<MarkerType
> markerTypes
, Set
<DescriptionType
> descriptionTypes
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
229 * @see {@link #pageTaxonDescriptions(Taxon, Set, Set, Integer, Integer, List)}
233 * @param geographicalScope
236 * @param propertyPaths
239 public List
<TaxonDescription
> listTaxonDescriptions(Taxon taxon
, Set
<DefinedTerm
> scopes
, Set
<NamedArea
> geographicalScope
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
244 * @see {@link #pageMarkedTaxonDescriptions(Taxon, Set, Set, Set, Integer, Integer, List)}
248 * @param geographicalScope
251 * @param propertyPaths
254 public List
<TaxonDescription
> listTaxonDescriptions(Taxon taxon
, Set
<DefinedTerm
> scopes
, Set
<NamedArea
> geographicalScope
, Set
<MarkerType
> markerTypes
, Set
<DescriptionType
> descriptionTypes
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
257 * Returns all {@link Media} attached to a taxon via TaxonDescription.elements.media.
258 * @param taxonUuid the taxons uuid, if null media for all taxa are returned
259 * @param limitToGalleries if true only media in TaxonDescriptions with imageGallery flag=true are returned
260 * @param markerTypes only media for TaxonDescriptions with marker of type markerType and marker.flag=true are returned, one matching marker type is sufficient
263 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
266 public List
<Media
> listTaxonDescriptionMedia(UUID taxonUuid
, boolean limitToGalleries
, Set
<MarkerType
> markerTypes
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
269 * Returns count for all {@link Media} attached to a taxon via TaxonDescription.elements.media.
270 * @param taxonUuid the taxons uuid, if null media for all taxa are returned
271 * @param limitToGalleries if true only media in TaxonDescriptions with imageGallery flag=true are returned
272 * @param markerTypes only media for TaxonDescriptions with marker of type markerType and marker.flag=true are returned, one matching marker type is sufficient
275 public int countTaxonDescriptionMedia(UUID taxonUuid
, boolean limitToGalleries
, Set
<MarkerType
> markerTypes
);
280 * Returns a List of TaxonNameDescription instances, optionally filtered by the name which they refer to
282 * @param name Restrict the results to those descriptions that refer to a specific name (can be null for all TaxonNameDescription instances)
283 * @param pageSize The maximum number of descriptions returned (can be null for all descriptions)
284 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
285 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
286 * @return a Pager containing TaxonName instances
288 * FIXME candidate for harmonization - rename to pageTaxonNameDescriptions
290 public Pager
<TaxonNameDescription
> getTaxonNameDescriptions(TaxonName name
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
294 * Returns a List of distinct TaxonDescription instances which have Distribution elements that refer to one of the NamedArea instances passed (optionally
295 * filtered by a type of PresenceAbsenceTerm e.g. PRESENT / ABSENT / NATIVE / CULTIVATED etc)
297 * @param namedAreas The set of NamedArea instances
298 * @param presence Restrict the descriptions to those which have Distribution elements are of this status (can be null)
299 * @param pageSize The maximum number of descriptions returned (can be null for all descriptions)
300 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
301 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
302 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
303 * @return a Pager containing TaxonDescription instances
305 public Pager
<TaxonDescription
> searchDescriptionByDistribution(Set
<NamedArea
> namedAreas
, PresenceAbsenceTerm presence
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
308 * Returns a Paged List of DescriptionElementBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
310 * @param clazz filter the results by class (or pass null to return all DescriptionElementBase instances)
312 * @param pageSize The maximum number of descriptionElements returned (can be null for all matching descriptionElements)
313 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
315 * Supports path like <code>orderHints.propertyNames</code> which
316 * include *-to-one properties like createdBy.username or
317 * authorTeam.persistentTitleCache
318 * @param propertyPaths properties to be initialized
319 * @return a Pager DescriptionElementBase instances
320 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
322 public <S
extends DescriptionElementBase
> Pager
<S
> searchElements(Class
<S
> clazz
, String queryString
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
325 * Returns a List of Media that are associated with a given description element
327 * @param descriptionElement the description element associated with these media
328 * @param pageSize The maximum number of media returned (can be null for all related media)
329 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
330 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
331 * @return a Pager containing media instances
333 * FIXME candidate for harmonization - rename to pageMedia
335 public Pager
<Media
> getMedia(DescriptionElementBase descriptionElement
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
338 * Provides access to all DescriptionElements associated with the given Taxon
339 * via a TaxonDescrition.
342 * The Taxon to return Description elements for
344 * Restrict the results to those description elements which are
345 * scoped by one of the Features passed (can be null or empty)
347 * A filter for DescriptionElements of a specific class
349 * The maximum number of description elements returned (can be
350 * null for all description elements)
352 * The offset (in pageSize chunks) from the start of the result
354 * @param propertyPaths
355 * Properties to initialize in the returned entities, following
356 * the syntax described in
357 * {@link IBeanInitializer#initialize(Object, List)}
358 * @return a List containing all matching DescriptionElementBase instances
360 * @deprecated use {@link #listDescriptionElementsForTaxon(Taxon, Set, Class, Integer, Integer, List)} instead
363 public <T
extends DescriptionElementBase
> List
<T
> getDescriptionElementsForTaxon(Taxon taxon
, Set
<Feature
> features
, Class
<T
> type
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
366 * Provides access to all DescriptionElements associated with the given Taxon
367 * via a TaxonDescrition.
370 * The Taxon to return Description elements for
372 * Restrict the results to those description elements which are
373 * scoped by one of the Features passed (can be null or empty)
375 * A filter for DescriptionElements of a specific class
377 * The maximum number of description elements returned (can be
378 * null for all description elements)
380 * The offset (in pageSize chunks) from the start of the result
382 * @param propertyPaths
383 * Properties to initialize in the returned entities, following
384 * the syntax described in
385 * {@link IBeanInitializer#initialize(Object, List)}
386 * @return a List containing all matching DescriptionElementBase instances
389 public <T
extends DescriptionElementBase
> List
<T
> listDescriptionElementsForTaxon(Taxon taxon
, Set
<Feature
> features
, Class
<T
> type
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
392 * Provides access to all DescriptionElements associated with the given Taxon
393 * via a TaxonDescrition.
396 * The Taxon to return Description elements for
398 * Restrict the results to those description elements which are
399 * scoped by one of the Features passed (can be null or empty)
401 * A filter for DescriptionElements of a specific class
403 * The maximum number of description elements returned
405 * The offset (in pageSize chunks) from the start of the result
407 * @param propertyPaths
408 * Properties to initialize in the returned entities, following
409 * the syntax described in
410 * {@link IBeanInitializer#initialize(Object, List)}
411 * @return a Pager for all matching DescriptionElementBase instances
414 public <T
extends DescriptionElementBase
> Pager
<T
> pageDescriptionElementsForTaxon(Taxon taxon
, Set
<Feature
> features
, Class
<T
> type
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
417 * Generate a string representation of the structured <code>description</code> supplied in natural language
418 * The <code>featureTree</code> will be used to structure the NaturalLanguageDescription.
419 * This method does not require a initialization strategy so there is no <code>propertyPaths</code> parameter.
421 public String
generateNaturalLanguageDescription(TermTree featureTree
,TaxonDescription description
, List
<Language
> preferredLanguages
, String separator
);
424 * Preliminary method to test whether a description contains structured data.
425 * @deprecated The means of determining this fact may change soon, so this method is
426 annotated as being deprecated.
430 public boolean hasStructuredData(DescriptionBase
<?
> description
);
433 * Add the collection of {@link DescriptionElementBase description elements} to the <code>targetDescription</code>.
434 * Remove the description elements from the description they are currently associated with.
436 * @param descriptionElements
437 * @param targetDescription
438 * @param isPaste if true, the elements are only copied (cloned) and not removed from the
442 public UpdateResult
moveDescriptionElementsToDescription(Collection
<DescriptionElementBase
> descriptionElements
, DescriptionBase targetDescription
, boolean isPaste
, boolean setNameInSource
);
445 * Pager method to get all {@link NamedAreas} instances which are currently used
446 * by {@link Distribution} elements.
449 * The maximum number of description elements returned
451 * The offset (in pageSize chunks) from the start of the result
453 * @param propertyPaths
454 * Properties to initialize in the returned entities, following
455 * the syntax described in
456 * {@link IBeanInitializer#initialize(Object, List)}
457 * @return a Pager for all NamedAreas instances which are currently in use.
460 public Pager
<TermDto
> pageNamedAreasInUse(boolean includeAllParents
, Integer pageSize
,
464 * Deletes the description and prior removes it from taxon, specimen or descriptive dataset.
466 public DeleteResult
deleteDescription(DescriptionBase
<?
> description
);
468 public DeleteResult
deleteDescription(UUID descriptionUuid
);
470 public UpdateResult
moveTaxonDescriptions(Taxon sourceTaxon
, Taxon targetTaxon
, boolean setNameInSource
);
472 public UpdateResult
moveTaxonDescriptions(UUID sourceTaxonUuid
, UUID targetTaxonUuid
, boolean setNameInSource
);
474 public UpdateResult
moveDescriptionElementsToDescription(Set
<UUID
> descriptionElementUUIDs
, UUID targetDescriptionUuid
,
475 boolean isCopy
, boolean setNameInSource
);
477 public UpdateResult
moveDescriptionElementsToDescription(Set
<UUID
> descriptionElementUUIDs
, UUID targetTaxonUuid
,
478 String moveMessage
, boolean isCopy
, boolean setNameInSource
, boolean useDefaultDescription
, boolean createNewCurrentDeterminations
);
480 public UpdateResult
moveTaxonDescription(UUID descriptionUuid
, UUID targetTaxonUuid
, boolean setNameInSource
);
482 public List
<MergeResult
<DescriptionBase
>> mergeDescriptionElements(Collection
<TaxonDistributionDTO
> descriptionElements
,
483 boolean returnTransientEntity
);
485 public UpdateResult
mergeDescriptions(Collection
<DescriptionBaseDto
> descriptions
, UUID descriptiveDataSetUuid
);
487 public UpdateResult
moveDescriptionElementsToDescription(Set
<UUID
> descriptionElementUUIDs
,
488 DescriptionBase targetDescription
, boolean isCopy
, boolean setNameInSource
);
490 public DeleteResult
isDeletable(UUID descriptionUuid
);
492 public DescriptionBaseDto
loadDto(UUID descriptionUuid
);
493 public List
<DescriptionBaseDto
> loadDtos(Set
<UUID
> descriptionUuid
);
495 public List
<DescriptionBaseDto
> loadDtosForTaxon(UUID taxonUuid
);
498 * Find the taxon node for the taxon associated to the specimen in classification with classificationUuid
500 public TaxonNodeDto
findTaxonNodeDtoForIndividualAssociation(UUID specimenUuid
, UUID classificationUuid
);