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
.TaxonDescription
;
26 import eu
.etaxonomy
.cdm
.model
.description
.TaxonNameDescription
;
27 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
28 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
29 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
30 import eu
.etaxonomy
.cdm
.model
.term
.DefinedTerm
;
31 import eu
.etaxonomy
.cdm
.model
.term
.TermTree
;
32 import eu
.etaxonomy
.cdm
.persistence
.dao
.initializer
.IBeanInitializer
;
33 import eu
.etaxonomy
.cdm
.persistence
.dto
.DescriptionBaseDto
;
34 import eu
.etaxonomy
.cdm
.persistence
.dto
.MergeResult
;
35 import eu
.etaxonomy
.cdm
.persistence
.dto
.TaxonNodeDto
;
36 import eu
.etaxonomy
.cdm
.persistence
.dto
.TermDto
;
37 import eu
.etaxonomy
.cdm
.persistence
.query
.OrderHint
;
39 public interface IDescriptionService
extends IIdentifiableEntityService
<DescriptionBase
> {
42 * Returns description elements of type <TYPE>, belonging to a given
43 * description, optionally filtered by one or more features
46 * The description which these description elements belong to
47 * (can be null to count all description elements)
48 * @param descriptionType
49 * A filter DescriptionElements which belong to of a specific
50 * class of Descriptions
52 * Restrict the results to those description elements which are
53 * scoped by one of the Features passed (can be null or empty)
55 * A filter for DescriptionElements of a specific class
57 * The maximum number of description elements returned (can be
58 * null for all description elements)
60 * The offset (in pageSize chunks) from the start of the result
62 * @param propertyPaths
63 * Properties to initialize in the returned entities, following
64 * the syntax described in
65 * {@link IBeanInitializer#initialize(Object, List)}
67 * @return a Pager containing DescriptionElementBase instances
69 public <T
extends DescriptionElementBase
> Pager
<T
> pageDescriptionElements(
70 DescriptionBase description
, Class
<?
extends DescriptionBase
> descriptionType
,
71 Set
<Feature
> features
, Class
<T
> type
, boolean includeUnpublished
,
72 Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
75 * Returns description elements of type <TYPE>, belonging to a given
76 * description, optionally filtered by one or more features
79 * The description which these description elements belong to
80 * (can be null to count all description elements)
82 * Restrict the results to those description elements which are
83 * scoped by one of the Features passed (can be null or empty)
85 * A filter DescriptionElements of a specific class
87 * The maximum number of description elements returned (can be
88 * null for all description elements)
90 * The offset (in pageSize chunks) from the start of the result
92 * @param propertyPaths
93 * Properties to initialize in the returned entities, following
94 * the syntax described in
95 * {@link IBeanInitializer#initialize(Object, List)}
96 * @return a List of DescriptionElementBase instances
98 public <T
extends DescriptionElementBase
> List
<T
> listDescriptionElements(
99 DescriptionBase description
, Class
<?
extends DescriptionBase
> descriptionType
,
100 Set
<Feature
> features
, Class
<T
> type
, boolean includeUnpublished
,
101 Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
104 * Returns a List of TaxonDescription instances, optionally filtered by parameters passed to this method
106 * @param taxon The taxon which the description refers to (can be null for all TaxonDescription instances)
107 * @param scopes Restrict the results to those descriptions which are scoped by one of the Scope instances passed (can be null or empty)
108 * @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)
109 * @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)
110 * @param descriptionTypes Restrict the results to those descriptions of the given types (can be null or empty)
111 * @param pageSize The maximum number of descriptions returned (can be null for all descriptions)
112 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
113 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
114 * @return a Pager containing TaxonDescription instances
116 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
);
120 * @see {@link #pageTaxonDescriptions(Taxon, Set, Set, Integer, Integer, List)}
124 * @param geographicalScope
127 * @param propertyPaths
130 public List
<TaxonDescription
> listTaxonDescriptions(Taxon taxon
, Set
<DefinedTerm
> scopes
, Set
<NamedArea
> geographicalScope
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
135 * @see {@link #pageMarkedTaxonDescriptions(Taxon, Set, Set, Set, Integer, Integer, List)}
139 * @param geographicalScope
142 * @param propertyPaths
145 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
);
148 * Returns a List of TaxonNameDescription instances, optionally filtered by the name which they refer to
150 * @param name Restrict the results to those descriptions that refer to a specific name (can be null for all TaxonNameDescription instances)
151 * @param pageSize The maximum number of descriptions returned (can be null for all descriptions)
152 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
153 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
154 * @return a Pager containing TaxonName instances
156 * FIXME candidate for harmonization - rename to pageTaxonNameDescriptions
158 public Pager
<TaxonNameDescription
> getTaxonNameDescriptions(TaxonName name
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
161 * Returns a Paged List of DescriptionElementBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
163 * @param clazz filter the results by class (or pass null to return all DescriptionElementBase instances)
165 * @param pageSize The maximum number of descriptionElements returned (can be null for all matching descriptionElements)
166 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
168 * Supports path like <code>orderHints.propertyNames</code> which
169 * include *-to-one properties like createdBy.username or
170 * authorTeam.persistentTitleCache
171 * @param propertyPaths properties to be initialized
172 * @return a Pager DescriptionElementBase instances
173 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
175 public <S
extends DescriptionElementBase
> Pager
<S
> searchElements(Class
<S
> clazz
, String queryString
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
178 * Provides access to all DescriptionElements associated with the given Taxon
179 * via a TaxonDescrition.
182 * The Taxon to return Description elements for
184 * Restrict the results to those description elements which are
185 * scoped by one of the Features passed (can be null or empty)
187 * A filter for DescriptionElements of a specific class
189 * The maximum number of description elements returned (can be
190 * null for all description elements)
192 * The offset (in pageSize chunks) from the start of the result
194 * @param propertyPaths
195 * Properties to initialize in the returned entities, following
196 * the syntax described in
197 * {@link IBeanInitializer#initialize(Object, List)}
198 * @return a List containing all matching DescriptionElementBase instances
200 * @deprecated use {@link #listDescriptionElementsForTaxon(Taxon, Set, Class, Integer, Integer, List)} instead
203 public <T
extends DescriptionElementBase
> List
<T
> getDescriptionElementsForTaxon(
204 Taxon taxon
, Set
<Feature
> features
, Class
<T
> type
, boolean includeUnpublished
,
205 Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
208 * Provides access to all DescriptionElements associated with the given Taxon
209 * via a TaxonDescrition.
212 * The Taxon to return Description elements for
214 * Restrict the results to those description elements which are
215 * scoped by one of the Features passed (can be null or empty)
217 * A filter for DescriptionElements of a specific class
218 * @param includeUnpublished
219 * If true factual data in a description not being published
222 * The maximum number of description elements returned (can be
223 * null for all description elements)
225 * The offset (in pageSize chunks) from the start of the result
227 * @param propertyPaths
228 * Properties to initialize in the returned entities, following
229 * the syntax described in
230 * {@link IBeanInitializer#initialize(Object, List)}
231 * @return a List containing all matching DescriptionElementBase instances
234 public <T
extends DescriptionElementBase
> List
<T
> listDescriptionElementsForTaxon(
235 Taxon taxon
, Set
<Feature
> features
, Class
<T
> type
, boolean includePublished
,
236 Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
239 * Provides access to all DescriptionElements associated with the given Taxon
240 * via a TaxonDescrition.
243 * The Taxon to return Description elements for
245 * Restrict the results to those description elements which are
246 * scoped by one of the Features passed (can be null or empty)
248 * A filter for DescriptionElements of a specific class
249 * @param includeUnpublished
250 * If true factual data in a description not being published
253 * The maximum number of description elements returned
255 * The offset (in pageSize chunks) from the start of the result
257 * @param propertyPaths
258 * Properties to initialize in the returned entities, following
259 * the syntax described in
260 * {@link IBeanInitializer#initialize(Object, List)}
261 * @return a Pager for all matching DescriptionElementBase instances
264 public <T
extends DescriptionElementBase
> Pager
<T
> pageDescriptionElementsForTaxon(
265 Taxon taxon
, Set
<Feature
> features
, Class
<T
> type
, boolean includeUnpublished
,
266 Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
269 * Generate a string representation of the structured <code>description</code> supplied in natural language
270 * The <code>featureTree</code> will be used to structure the NaturalLanguageDescription.
271 * This method does not require a initialization strategy so there is no <code>propertyPaths</code> parameter.
273 public String
generateNaturalLanguageDescription(TermTree featureTree
,TaxonDescription description
, List
<Language
> preferredLanguages
, String separator
);
276 * Preliminary method to test whether a description contains structured data.
277 * @deprecated The means of determining this fact may change soon, so this method is
278 annotated as being deprecated.
282 public boolean hasStructuredData(DescriptionBase
<?
> description
);
285 * Add the collection of {@link DescriptionElementBase description elements} to the <code>targetDescription</code>.
286 * Remove the description elements from the description they are currently associated with.
288 * @param descriptionElements
289 * @param targetDescription
290 * @param isPaste if true, the elements are only copied (cloned) and not removed from the
294 public UpdateResult
moveDescriptionElementsToDescription(Collection
<DescriptionElementBase
> descriptionElements
, DescriptionBase targetDescription
, boolean isPaste
, boolean setNameInSource
);
297 * Pager method to get all {@link NamedAreas} instances which are currently used
298 * by {@link Distribution} elements.
301 * The maximum number of description elements returned
303 * The offset (in pageSize chunks) from the start of the result
305 * @param propertyPaths
306 * Properties to initialize in the returned entities, following
307 * the syntax described in
308 * {@link IBeanInitializer#initialize(Object, List)}
309 * @return a Pager for all NamedAreas instances which are currently in use.
312 public Pager
<TermDto
> pageNamedAreasInUse(boolean includeAllParents
, Integer pageSize
,
316 * Deletes the description and prior removes it from taxon, specimen or descriptive dataset.
318 public DeleteResult
deleteDescription(DescriptionBase
<?
> description
);
320 public DeleteResult
deleteDescription(UUID descriptionUuid
);
322 public UpdateResult
moveTaxonDescriptions(Taxon sourceTaxon
, Taxon targetTaxon
, boolean setNameInSource
);
324 public UpdateResult
moveTaxonDescriptions(UUID sourceTaxonUuid
, UUID targetTaxonUuid
, boolean setNameInSource
);
326 public UpdateResult
moveDescriptionElementsToDescription(Set
<UUID
> descriptionElementUUIDs
, UUID targetDescriptionUuid
,
327 boolean isCopy
, boolean setNameInSource
);
329 public UpdateResult
moveDescriptionElementsToDescription(Set
<UUID
> descriptionElementUUIDs
, UUID targetTaxonUuid
,
330 String moveMessage
, boolean isCopy
, boolean setNameInSource
, boolean useDefaultDescription
, boolean createNewCurrentDeterminations
);
332 public UpdateResult
moveTaxonDescription(UUID descriptionUuid
, UUID targetTaxonUuid
, boolean setNameInSource
);
334 public List
<MergeResult
<DescriptionBase
>> mergeDescriptionElements(Collection
<TaxonDistributionDTO
> descriptionElements
,
335 boolean returnTransientEntity
);
337 public UpdateResult
mergeDescriptions(Collection
<DescriptionBaseDto
> descriptions
, UUID descriptiveDataSetUuid
);
339 public UpdateResult
moveDescriptionElementsToDescription(Set
<UUID
> descriptionElementUUIDs
,
340 DescriptionBase targetDescription
, boolean isCopy
, boolean setNameInSource
);
342 public DeleteResult
isDeletable(UUID descriptionUuid
);
344 public DescriptionBaseDto
loadDto(UUID descriptionUuid
);
345 public List
<DescriptionBaseDto
> loadDtos(Set
<UUID
> descriptionUuid
);
347 public List
<DescriptionBaseDto
> loadDtosForTaxon(UUID taxonUuid
);
350 * Find the taxon node for the taxon associated to the specimen in classification with classificationUuid
352 public TaxonNodeDto
findTaxonNodeDtoForIndividualAssociation(UUID specimenUuid
, UUID classificationUuid
);