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
.io
.IOException
;
14 import java
.util
.Collection
;
15 import java
.util
.List
;
17 import java
.util
.UUID
;
19 import org
.apache
.lucene
.index
.CorruptIndexException
;
20 import org
.apache
.lucene
.queryParser
.ParseException
;
21 import org
.hibernate
.criterion
.Criterion
;
23 import eu
.etaxonomy
.cdm
.api
.service
.config
.NameDeletionConfigurator
;
24 import eu
.etaxonomy
.cdm
.api
.service
.exception
.ReferencedObjectUndeletableException
;
25 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
26 import eu
.etaxonomy
.cdm
.api
.service
.search
.DocumentSearchResult
;
27 import eu
.etaxonomy
.cdm
.api
.service
.search
.SearchResult
;
28 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
29 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
30 import eu
.etaxonomy
.cdm
.model
.common
.OrderedTermVocabulary
;
31 import eu
.etaxonomy
.cdm
.model
.common
.ReferencedEntityBase
;
32 import eu
.etaxonomy
.cdm
.model
.common
.RelationshipBase
;
33 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
34 import eu
.etaxonomy
.cdm
.model
.common
.UuidAndTitleCache
;
35 import eu
.etaxonomy
.cdm
.model
.name
.HomotypicalGroup
;
36 import eu
.etaxonomy
.cdm
.model
.name
.HybridRelationship
;
37 import eu
.etaxonomy
.cdm
.model
.name
.HybridRelationshipType
;
38 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationship
;
39 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationshipType
;
40 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalStatus
;
41 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalStatusType
;
42 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
43 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
44 import eu
.etaxonomy
.cdm
.model
.name
.SpecimenTypeDesignationStatus
;
45 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
46 import eu
.etaxonomy
.cdm
.model
.name
.TypeDesignationBase
;
47 import eu
.etaxonomy
.cdm
.persistence
.dao
.IBeanInitializer
;
48 import eu
.etaxonomy
.cdm
.persistence
.query
.MatchMode
;
49 import eu
.etaxonomy
.cdm
.persistence
.query
.OrderHint
;
50 import eu
.etaxonomy
.cdm
.strategy
.cache
.TaggedText
;
52 public interface INameService
extends IIdentifiableEntityService
<TaxonNameBase
> {
55 * Deletes a name. Depening on the configurator state links to the name will either be
56 * deleted or throw exceptions.<BR>
57 * If name is <code>null</code> this method has no effect.
60 * @throws ReferencedObjectUndeletableException
62 public UUID
delete(TaxonNameBase name
, NameDeletionConfigurator config
) throws ReferencedObjectUndeletableException
;
65 * Removes the given type designation from the given taxon name and deletes it from
66 * the database if it is not connected to any other name.
67 * If <code>typeDesignation</code> is <code>null</code> all type designations are deleted
68 * from the given taxon name. If <code>name</code> is <code>null</code> all names are removed from
69 * the given type designation. If both are <code>null</code> nothing happens.
70 * @param typeDesignation
74 public void deleteTypeDesignation(TaxonNameBase name
, TypeDesignationBase typeDesignation
);
78 * Saves the given type designations.
79 * @param typeDesignationCollection
82 public Map
<UUID
, TypeDesignationBase
> saveTypeDesignationAll(Collection
<TypeDesignationBase
> typeDesignationCollection
);
84 public Map
<UUID
, ReferencedEntityBase
> saveReferencedEntitiesAll(Collection
<ReferencedEntityBase
> referencedEntityCollection
);
87 * Saves the given homotypical groups.
88 * @param homotypicalGroups
91 public Map
<UUID
, HomotypicalGroup
> saveAllHomotypicalGroups(Collection
<HomotypicalGroup
> homotypicalGroups
);
94 * Returns all nomenclatural status.
99 public List
<NomenclaturalStatus
> getAllNomenclaturalStatus(int limit
, int start
);
102 * Returns all type designations.
107 public List
<TypeDesignationBase
> getAllTypeDesignations(int limit
, int start
);
113 public List
<TaxonNameBase
> getNamesByName(String name
);
116 * Returns all NonViralNames with a name cache that matches the given string
120 public List
<NonViralName
> getNamesByNameCache(String nameCache
);
123 * Returns all NonViralNames with a title cache that matches the given string
124 * using the given match mode and initialization strategy
128 * @param propertyPaths
131 public List
<NonViralName
> findNamesByTitleCache(String titleCache
, MatchMode matchMode
, List
<String
> propertyPaths
);
134 * Returns all NonViralNames with a name cache that matches the given string
135 * using the given match mode and initialization strategy
139 * @param propertyPaths
142 public List
<NonViralName
> findNamesByNameCache(String nameCache
, MatchMode matchMode
, List
<String
> propertyPaths
);
145 * Returns the NonViralName with the given UUID
146 * using the given match mode and initialization strategy
149 * @param propertyPaths
152 public NonViralName
findNameByUuid(UUID uuid
, List
<String
> propertyPaths
);
155 * @param sessionObject An object that is attached to the session before executing the query
158 public List
getNamesByName(String name
, CdmBase sessionObject
);
161 * Fuzzy matching for the taxon name elements. The input name is first atomised using the {@link NonViralNameParserImpl}
162 * into its separate parts (genusOrUninomial,infraGenericEpithet,specificEpithet,infraGenericEpithet,authorshipCache).
163 * Each field is then matched separately with the same accuracy parameter.
165 * @param name taxon name to fuzzy match
166 * @param accuracy value > 0.0 and < 1.0 which determines the accuracy of the result.
167 * @param languages list of languages to consider when matching (currently not used)
168 * @param highlightFragments
169 * @param propertyPaths
170 * @param maxNoOfResults
172 * @throws CorruptIndexException
173 * @throws IOException
174 * @throws ParseException
176 public List
<SearchResult
<TaxonNameBase
>> findByNameFuzzySearch(
179 List
<Language
> languages
,
180 boolean highlightFragments
,
181 List
<String
> propertyPaths
,
182 int maxNoOfResults
) throws CorruptIndexException
, IOException
, ParseException
;
185 * Fuzzy matching for the taxon name elements using only the lucene index.
187 * The input name is first atomised using the {@link NonViralNameParserImpl}
188 * into its separate parts (genusOrUninomial,infraGenericEpithet,specificEpithet,infraGenericEpithet,authorshipCache).
189 * Each field is then matched separately with the same accuracy parameter.
191 * @param name taxon name to fuzzy match
192 * @param accuracy value > 0.0 and < 1.0 which determines the accuracy of the result.
193 * @param languages list of languages to consider when matching (currently not used)
194 * @param highlightFragments
195 * @param maxNoOfResults
197 * @throws CorruptIndexException
198 * @throws IOException
199 * @throws ParseException
201 public List
<DocumentSearchResult
> findByNameFuzzySearch(
204 List
<Language
> languages
,
205 boolean highlightFragments
,
206 int maxNoOfResults
) throws CorruptIndexException
, IOException
, ParseException
;
209 * Exact matching for the taxon name elements using only the lucene index.
211 * The input name is first atomised using the {@link NonViralNameParserImpl}
212 * into its separate parts (genusOrUninomial,infraGenericEpithet,specificEpithet,infraGenericEpithet,authorshipCache).
213 * Each field is then matched separately with the same accuracy parameter.
215 * @param name taxon name to fuzzy match
216 * @param wildcard boolean flag to indicate whether a wildcard '*' should be added at the end of the query
217 * @param languages list of languages to consider when matching (currently not used)
218 * @param highlightFragments
219 * @param maxNoOfResults
221 * @throws CorruptIndexException
222 * @throws IOException
223 * @throws ParseException
226 public List
<DocumentSearchResult
> findByNameExactSearch(
229 List
<Language
> languages
,
230 boolean highlightFragments
,
231 int maxNoOfResults
) throws CorruptIndexException
, IOException
, ParseException
;
233 // TODO: Remove getNamesByName() methods. Use findNamesByTitle() instead.
235 // FIXME candidate for harmonization?
236 public List
findNamesByTitle(String title
);
238 public List
findNamesByTitle(String title
, CdmBase sessionObject
);
240 public List
<HomotypicalGroup
> getAllHomotypicalGroups(int limit
, int start
);
243 public List
<RelationshipBase
> getAllRelationships(int limit
, int start
);
248 * @deprecated use VocabularyService#getVocabulary(VocabularyEnum) instead,
249 * this is not possible since VocabularyService#getVocabulary(VocabularyEnum)
250 * is not returning a OrderedTermVocabulary !!! see also http://dev.e-taxonomy.eu/trac/ticket/3327
253 public OrderedTermVocabulary
<Rank
> getRankVocabulary();
256 * Returns all NomenclaturalStatusTypes
258 * @deprecated use VocabularyService#getVocabulary(VocabularyEnum) instead
261 public TermVocabulary
<NomenclaturalStatusType
> getStatusTypeVocabulary();
264 * Returns TypeDesignationStatus vocabulary
266 * @deprecated use VocabularyService#getVocabulary(VocabularyEnum) instead
269 public TermVocabulary
<SpecimenTypeDesignationStatus
> getSpecimenTypeDesignationStatusVocabulary();
272 * Returns TypeDesignationStatus ordered vocabulary
274 * @deprecated use VocabularyService#getVocabulary(VocabularyEnum) instead
277 public OrderedTermVocabulary
<SpecimenTypeDesignationStatus
> getSpecimenTypeDesignationVocabulary();
280 * Returns all NameRelationshipTypes
282 * @deprecated use VocabularyService#getVocabulary(VocabularyEnum) instead
285 public TermVocabulary
<NameRelationshipType
> getNameRelationshipTypeVocabulary();
288 * Return a List of name relationships in which this name is related to
289 * another name, optionally filtered by relationship type
292 * the name on either the <i>"from side"</i> or on the
293 * <i>"to side"</i> of the relationship, depending on the
294 * <code>direction</code> of the relationship.
296 * the direction of the NameRelationship, may be null to return all relationships
298 * the relationship type (or null to return all relationships)
300 * The maximum number of relationships returned (can be null for
303 * The offset (in pageSize chunks) from the start of the result
307 * @param propertyPaths
308 * properties to initialize - see
309 * {@link IBeanInitializer#initialize(Object, List)}
310 * @return a Pager of NameRelationship instances
312 public List
<NameRelationship
> listNameRelationships(TaxonNameBase name
, NameRelationship
.Direction direction
, NameRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
315 * Return a List of name relationships in which this name is related to another name, optionally filtered
316 * by relationship type
318 * @param name the name on the <i>"from side"</i> of the relationship
319 * @param direction the direction of the NameRelationship
320 * @param type the relationship type (or null to return all relationships)
321 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
322 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
323 * @param orderHints may be null
324 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
325 * @return a Pager of NameRelationship instances
327 public Pager
<NameRelationship
> pageNameRelationships(TaxonNameBase name
, NameRelationship
.Direction direction
, NameRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
330 * Return a List of relationships in which this name is related to another name, optionally filtered
331 * by relationship type
333 * @param name the name on the <i>"from side"</i> of the relationship
334 * @param type the relationship type (or null to return all relationships)
335 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
336 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
337 * @param orderHints may be null
338 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
339 * @return a Pager of NameRelationship instances
340 * @deprecated use {@link #listNameRelationships(TaxonNameBase, eu.etaxonomy.cdm.model.common.RelationshipBase.Direction, NameRelationshipType, Integer, Integer, List, List)} instead
343 public List
<NameRelationship
> listFromNameRelationships(TaxonNameBase name
, NameRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
346 * Return a List of relationships in which this name is related to another name, optionally filtered
347 * by relationship type
349 * @param name the name on the <i>"from side"</i> of the relationship
350 * @param type the relationship type (or null to return all relationships)
351 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
352 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
353 * @param orderHints may be null
354 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
355 * @return a Pager of NameRelationship instances
356 * @deprecated use {@link #pageNameRelationships(TaxonNameBase, eu.etaxonomy.cdm.model.common.RelationshipBase.Direction, NameRelationshipType, Integer, Integer, List, List)} instead
359 public Pager
<NameRelationship
> pageFromNameRelationships(TaxonNameBase name
, NameRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
362 * Return a List of relationships in which another name is related to this name, optionally filtered
363 * by relationship type
365 * @param name the name on the <i>"to side"</i> of the relationship
366 * @param type the relationship type (or null to return all relationships)
367 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
368 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
369 * @param orderHints may be null
370 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
371 * @return a Pager of NameRelationship instances
372 * @deprecated use {@link #listNameRelationships(TaxonNameBase, eu.etaxonomy.cdm.model.common.RelationshipBase.Direction, NameRelationshipType, Integer, Integer, List, List)} instead
375 public List
<NameRelationship
> listToNameRelationships(TaxonNameBase name
, NameRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
378 * Return a List of relationships in which another name is related to this name, optionally filtered
379 * by relationship type
381 * @param name the name on the <i>"to side"</i> of the relationship
382 * @param type the relationship type (or null to return all relationships)
383 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
384 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
385 * @param orderHints may be null
386 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
387 * @return a Pager of NameRelationship instances
388 * @deprecated use {@link #pageNameRelationships(TaxonNameBase, eu.etaxonomy.cdm.model.common.RelationshipBase.Direction, NameRelationshipType, Integer, Integer, List, List)} instead
391 public Pager
<NameRelationship
> pageToNameRelationships(TaxonNameBase name
, NameRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
395 * Return a List of hybrids related to this name, optionally filtered
396 * by hybrid relationship type
398 * @param name the name
399 * @param type the hybrid relationship type (or null to return all hybrids)
400 * @param pageSize The maximum number of hybrid relationships returned (can be null for all relationships)
401 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
402 * @param orderHints may be null
403 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
404 * @return a Pager of HybridRelationship instances
406 public Pager
<HybridRelationship
> getHybridNames(NonViralName name
, HybridRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
409 * Return a List of types related to this name, optionally filtered
410 * by type designation status
412 * @param name the name
413 * @param status the type designation status (or null to return all types)
414 * @param pageSize The maximum number of types returned (can be null for all types)
415 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
416 * @return a Pager of TypeDesignationBase instances
418 public Pager
<TypeDesignationBase
> getTypeDesignations(TaxonNameBase name
,
419 SpecimenTypeDesignationStatus status
, Integer pageSize
, Integer pageNumber
);
421 public Pager
<TypeDesignationBase
> getTypeDesignations(TaxonNameBase name
,
422 SpecimenTypeDesignationStatus status
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
426 * Returns a List of TaxonNameBase instances that match the properties passed
429 * @param infraGenericEpithet
430 * @param specificEpithet
431 * @param infraspecificEpithet
433 * @param pageSize The maximum number of names returned (can be null for all names)
434 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
435 * @param orderHints may be null
436 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
437 * @return a Pager of TaxonNameBase instances
439 public Pager
<TaxonNameBase
> searchNames(String uninomial
, String infraGenericEpithet
, String specificEpithet
, String infraspecificEpithet
, Rank rank
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
442 * Returns a Paged List of TaxonNameBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
444 * @param clazz filter the results by class (or pass null to return all TaxonNameBase instances)
446 * @param pageSize The maximum number of names returned (can be null for all matching names)
447 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
449 * Supports path like <code>orderHints.propertyNames</code> which
450 * include *-to-one properties like createdBy.username or
451 * authorTeam.persistentTitleCache
452 * @param propertyPaths properties to be initialized
453 * @return a Pager TaxonNameBase instances
454 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
457 public Pager
<TaxonNameBase
> search(Class
<?
extends TaxonNameBase
> clazz
, String queryString
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
460 * Returns a map that holds uuid, titleCache pairs of all names in the current database
463 * a <code>Map</code> containing uuid and titleCache of names
465 public List
<UuidAndTitleCache
> getUuidAndTitleCacheOfNames();
468 * Return a Pager of names matching the given query string, optionally filtered by class, optionally with a particular MatchMode
470 * @param clazz filter by class - can be null to include all instances of type T
471 * @param queryString the query string to filter by
472 * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
473 * @param criteria additional criteria to filter by
474 * @param pageSize The maximum number of objects returned (can be null for all objects)
475 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
476 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
478 * Supports path like <code>orderHints.propertyNames</code> which
479 * include *-to-one properties like createdBy.username or
480 * authorTeam.persistentTitleCache
481 * @return a paged list of instances of type T matching the queryString
483 public Pager
<TaxonNameBase
> findByName(Class
<?
extends TaxonNameBase
> clazz
, String queryString
,MatchMode matchmode
, List
<Criterion
> criteria
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
486 * Returns a homotypical group with the given UUID or null if not homotypical group exists with that UUID
488 * @param uuid the uuid of the homotypical group
489 * @return a homotypical group
491 public HomotypicalGroup
findHomotypicalGroup(UUID uuid
);
497 public List
<TaggedText
> getTaggedName(UUID uuid
);