3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.cdm
.api
.service
;
13 import java
.util
.Collection
;
14 import java
.util
.List
;
17 import java
.util
.UUID
;
19 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
20 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
21 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
22 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
23 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
24 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
25 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
26 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
27 import eu
.etaxonomy
.cdm
.model
.description
.FeatureTree
;
28 import eu
.etaxonomy
.cdm
.model
.description
.PresenceAbsenceTermBase
;
29 import eu
.etaxonomy
.cdm
.model
.description
.Scope
;
30 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
31 import eu
.etaxonomy
.cdm
.model
.description
.TaxonNameDescription
;
32 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
33 import eu
.etaxonomy
.cdm
.model
.location
.NamedAreaLevel
;
34 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
35 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
36 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
37 import eu
.etaxonomy
.cdm
.persistence
.dao
.IBeanInitializer
;
38 import eu
.etaxonomy
.cdm
.persistence
.query
.OrderHint
;
40 public interface IDescriptionService
extends IIdentifiableEntityService
<DescriptionBase
> {
45 * @deprecated use TermService#getVocabulary(VocabularyType) instead
47 public TermVocabulary
<Feature
> getDefaultFeatureVocabulary();
50 * @deprecated use TermService#getVocabulary(VocabularyType) instead
52 public TermVocabulary
<Feature
> getFeatureVocabulary(UUID uuid
);
55 * Gets a DescriptionElementBase instance matching the supplied uuid
57 * @param uuid the uuid of the DescriptionElement of interest
58 * @return a DescriptionElement, or null if the DescriptionElement does not exist
60 public DescriptionElementBase
getDescriptionElementByUuid(UUID uuid
);
63 * Loads and existing DescriptionElementBase instance matching the supplied uuid,
64 * and recursively initializes all bean properties given in the
65 * <code>propertyPaths</code> parameter.
67 * For detailed description and examples <b>please refer to:</b>
68 * {@link IBeanInitializer#initialize(Object, List)}
70 * @param uuid the uuid of the DescriptionElement of interest
71 * @return a DescriptionElement, or null if the DescriptionElement does not exist
73 public DescriptionElementBase
loadDescriptionElement(UUID uuid
,List
<String
> propertyPaths
);
76 * Persists a <code>DescriptionElementBase</code>
77 * @param descriptionElement
80 public UUID
saveDescriptionElement(DescriptionElementBase descriptionElement
);
83 * Persists a collection of <code>DescriptionElementBase</code>
84 * @param descriptionElements
87 public Map
<UUID
, DescriptionElementBase
> saveDescriptionElement(Collection
<DescriptionElementBase
> descriptionElements
);
90 * Delete an existing description element
92 * @param descriptionElement the description element to be deleted
93 * @return the unique identifier of the deleted entity
95 public UUID
deleteDescriptionElement(DescriptionElementBase descriptionElement
);
98 * List the descriptions of type <T>, filtered using the following parameters
100 * @param type The type of description returned (Taxon, TaxonName, or Specimen)
101 * @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)
102 * @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)
103 * @param feature Restrict the description to those <i>elements</i> which are scoped by one of the Features passed (can be null or empty)
104 * @param pageSize The maximum number of descriptions returned (can be null for all descriptions)
105 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
106 * @param orderHints may be null
107 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
108 * @return a Pager containing DescriptionBase instances
110 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
);
113 * Count the descriptions of type <TYPE>, filtered using the following parameters
115 * @param type The type of description returned (Taxon, TaxonName, or Specimen)
116 * @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)
117 * @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)
118 * @param feature Restrict the description to those <i>elements</i> which are scoped by one of the Features passed (can be null or empty)
119 * @return a count of DescriptionBase instances
121 public int count(Class
<?
extends DescriptionBase
> type
, Boolean hasImages
, Boolean hasText
, Set
<Feature
> feature
);
124 * Returns description elements of type <TYPE>, belonging to a given description, optionally filtered by one or more features
126 * @param description The description which these description elements belong to (can be null to count all description elements)
127 * @param features Restrict the results to those description elements which are scoped by one of the Features passed (can be null or empty)
128 * @param type The type of description
130 * @param pageSize The maximum number of description elements returned (can be null for all description elements)
131 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
132 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
133 * @return a Pager containing DescriptionElementBase instances
135 * FIXME candidate for harmonization - rename to pageDescriptionElements
137 public Pager
<DescriptionElementBase
> getDescriptionElements(DescriptionBase description
,Set
<Feature
> features
, Class
<?
extends DescriptionElementBase
> type
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
140 * Returns description elements of type <TYPE>, belonging to a given description, optionally filtered by one or more features
142 * @param description The description which these description elements belong to (can be null to count all description elements)
143 * @param features Restrict the results to those description elements which are scoped by one of the Features passed (can be null or empty)
144 * @param type The type of description
146 * @param pageSize The maximum number of description elements returned (can be null for all description elements)
147 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
148 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
149 * @return a List containing DescriptionElementBase instances
151 public List
<DescriptionElementBase
> listDescriptionElements(DescriptionBase description
,Set
<Feature
> features
, Class
<?
extends DescriptionElementBase
> type
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
154 * Return a Pager containing Annotation entities belonging to the DescriptionElementBase instance supplied, optionally filtered by MarkerType
155 * @param annotatedObj The object that "owns" the annotations returned
156 * @param status Only return annotations which are marked with a Marker of this type (can be null to return all annotations)
157 * @param pageSize The maximum number of terms returned (can be null for all annotations)
158 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
159 * @param orderHints may be null
160 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
161 * @return a Pager of Annotation entities
163 public Pager
<Annotation
> getDescriptionElementAnnotations(DescriptionElementBase annotatedObj
, MarkerType status
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
167 * Returns a List of TaxonDescription instances, optionally filtered by parameters passed to this method
169 * @param taxon The taxon which the description refers to (can be null for all TaxonDescription instances)
170 * @param scopes Restrict the results to those descriptions which are scoped by one of the Scope instances passed (can be null or empty)
171 * @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)
172 * @param pageSize The maximum number of descriptions returned (can be null for all descriptions)
173 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
174 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
175 * @return a Pager containing TaxonDescription instances
177 * @see #pageMarkedTaxonDescriptions(Taxon, Set, Set, Set, Integer, Integer, List)
179 public Pager
<TaxonDescription
> pageTaxonDescriptions(Taxon taxon
, Set
<Scope
> scopes
, Set
<NamedArea
> geographicalScope
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
182 * Returns a List of TaxonDescription instances, optionally filtered by parameters passed to this method
184 * @param taxon The taxon which the description refers to (can be null for all TaxonDescription instances)
185 * @param scopes Restrict the results to those descriptions which are scoped by one of the Scope instances passed (can be null or empty)
186 * @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)
187 * @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)
188 * @param pageSize The maximum number of descriptions returned (can be null for all descriptions)
189 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
190 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
191 * @return a Pager containing TaxonDescription instances
193 public Pager
<TaxonDescription
> pageTaxonDescriptions(Taxon taxon
, Set
<Scope
> scopes
, Set
<NamedArea
> geographicalScope
, Set
<MarkerType
> markerTypes
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
196 * @see {@link #pageTaxonDescriptions(Taxon, Set, Set, Integer, Integer, List)}
200 * @param geographicalScope
203 * @param propertyPaths
206 public List
<TaxonDescription
> listTaxonDescriptions(Taxon taxon
, Set
<Scope
> scopes
, Set
<NamedArea
> geographicalScope
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
211 * @see {@link #pageMarkedTaxonDescriptions(Taxon, Set, Set, Set, Integer, Integer, List)}
215 * @param geographicalScope
218 * @param propertyPaths
221 public List
<TaxonDescription
> listTaxonDescriptions(Taxon taxon
, Set
<Scope
> scopes
, Set
<NamedArea
> geographicalScope
, Set
<MarkerType
> markerTypes
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
224 * Returns all {@link Media} attached to a taxon via TaxonDescription.elements.media.
225 * @param taxonUuid the taxons uuid, if null media for all taxa are returned
226 * @param limitToGalleries if true only media in TaxonDescriptions with imageGallery flag=true are returned
227 * @param markerTypes only media for TaxonDescriptions with marker of type markerType and marker.flag=true are returned, one matching marker type is sufficient
230 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
233 public List
<Media
> listTaxonDescriptionMedia(UUID taxonUuid
, boolean limitToGalleries
, Set
<MarkerType
> markerTypes
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
236 * Returns count for all {@link Media} attached to a taxon via TaxonDescription.elements.media.
237 * @param taxonUuid the taxons uuid, if null media for all taxa are returned
238 * @param limitToGalleries if true only media in TaxonDescriptions with imageGallery flag=true are returned
239 * @param markerTypes only media for TaxonDescriptions with marker of type markerType and marker.flag=true are returned, one matching marker type is sufficient
242 public int countTaxonDescriptionMedia(UUID taxonUuid
, boolean limitToGalleries
, Set
<MarkerType
> markerTypes
);
247 * Returns a List of TaxonNameDescription instances, optionally filtered by the name which they refer to
249 * @param name Restrict the results to those descriptions that refer to a specific name (can be null for all TaxonNameDescription instances)
250 * @param pageSize The maximum number of descriptions returned (can be null for all descriptions)
251 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
252 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
253 * @return a Pager containing TaxonNameBase instances
255 * FIXME candidate for harmonization - rename to pageTaxonNameDescriptions
257 public Pager
<TaxonNameDescription
> getTaxonNameDescriptions(TaxonNameBase name
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
261 * Returns a List of distinct TaxonDescription instances which have Distribution elements that refer to one of the NamedArea instances passed (optionally
262 * filtered by a type of PresenceAbsenceTerm e.g. PRESENT / ABSENT / NATIVE / CULTIVATED etc)
264 * @param namedAreas The set of NamedArea instances
265 * @param presence Restrict the descriptions to those which have Distribution elements are of this status (can be null)
266 * @param pageSize The maximum number of descriptions returned (can be null for all descriptions)
267 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
268 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
269 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
270 * @return a Pager containing TaxonDescription instances
272 public Pager
<TaxonDescription
> searchDescriptionByDistribution(Set
<NamedArea
> namedAreas
, PresenceAbsenceTermBase presence
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
275 * Returns a Paged List of DescriptionElementBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
277 * @param clazz filter the results by class (or pass null to return all DescriptionElementBase instances)
279 * @param pageSize The maximum number of descriptionElements returned (can be null for all matching descriptionElements)
280 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
282 * Supports path like <code>orderHints.propertyNames</code> which
283 * include *-to-one properties like createdBy.username or
284 * authorTeam.persistentTitleCache
285 * @param propertyPaths properties to be initialized
286 * @return a Pager DescriptionElementBase instances
287 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
289 public Pager
<DescriptionElementBase
> searchElements(Class
<?
extends DescriptionElementBase
> clazz
, String queryString
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
292 * Returns a List of Media that are associated with a given description element
294 * @param descriptionElement the description element associated with these media
295 * @param pageSize The maximum number of media returned (can be null for all related media)
296 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
297 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
298 * @return a Pager containing media instances
300 * FIXME candidate for harmonization - rename to pageMedia
302 public Pager
<Media
> getMedia(DescriptionElementBase descriptionElement
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
304 public <T
extends DescriptionElementBase
> List
<T
> getDescriptionElementsForTaxon(Taxon taxon
, Set
<Feature
> features
, Class
<?
extends T
> type
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
306 public DistributionTree
getOrderedDistributions(Set
<TaxonDescription
> taxonDescriptions
, Set
<NamedAreaLevel
> levels
, List
<String
> propertyPaths
);
309 * Generate a string representation of the structured <code>description</code> supplied in natural language
310 * The <code>featureTree</code> will be used to structure the NaturalLanguageDescription.
311 * This method does not require a initialization strategy so there is no <code>propertyPaths</code> parameter.
314 * @param preferredLanguages
318 public String
generateNaturalLanguageDescription(FeatureTree featureTree
,TaxonDescription description
, List
<Language
> preferredLanguages
, String separator
);
321 * Preliminary method to test whether a description contains structured data.
322 * @deprecated The means of determining this fact may change soon, so this method is
323 annotated as being deprecated.
328 public boolean hasStructuredData(DescriptionBase
<?
> description
);
331 * Add the collection of {@link DescriptionElementBase description elements} to the <code>targetDescription</code>.
332 * Remove the description elements from the description they are currently associated with.
334 * @param descriptionElements
335 * @param targetDescription
336 * @param isPaste if true, the elements are only copied (cloned) and not removed from the
339 public void moveDescriptionElementsToDescription(Collection
<DescriptionElementBase
> descriptionElements
, DescriptionBase targetDescription
, boolean isPaste
);