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
.ArrayList
;
14 import java
.util
.Collection
;
15 import java
.util
.HashSet
;
16 import java
.util
.Iterator
;
17 import java
.util
.List
;
20 import java
.util
.UUID
;
22 import org
.apache
.log4j
.Logger
;
23 import org
.hibernate
.criterion
.Criterion
;
24 import org
.springframework
.beans
.factory
.annotation
.Autowired
;
25 import org
.springframework
.beans
.factory
.annotation
.Qualifier
;
26 import org
.springframework
.stereotype
.Service
;
27 import org
.springframework
.transaction
.annotation
.Propagation
;
28 import org
.springframework
.transaction
.annotation
.Transactional
;
30 import eu
.etaxonomy
.cdm
.api
.service
.config
.NameDeletionConfigurator
;
31 import eu
.etaxonomy
.cdm
.api
.service
.exception
.ReferencedObjectUndeletableException
;
32 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
33 import eu
.etaxonomy
.cdm
.api
.service
.pager
.impl
.AbstractPagerImpl
;
34 import eu
.etaxonomy
.cdm
.api
.service
.pager
.impl
.DefaultPagerImpl
;
35 import eu
.etaxonomy
.cdm
.common
.monitor
.IProgressMonitor
;
36 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
37 import eu
.etaxonomy
.cdm
.model
.common
.DescriptionElementSource
;
38 import eu
.etaxonomy
.cdm
.model
.common
.OrderedTermVocabulary
;
39 import eu
.etaxonomy
.cdm
.model
.common
.ReferencedEntityBase
;
40 import eu
.etaxonomy
.cdm
.model
.common
.RelationshipBase
;
41 import eu
.etaxonomy
.cdm
.model
.common
.RelationshipBase
.Direction
;
42 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
43 import eu
.etaxonomy
.cdm
.model
.common
.UuidAndTitleCache
;
44 import eu
.etaxonomy
.cdm
.model
.name
.HomotypicalGroup
;
45 import eu
.etaxonomy
.cdm
.model
.name
.HybridRelationship
;
46 import eu
.etaxonomy
.cdm
.model
.name
.HybridRelationshipType
;
47 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationship
;
48 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationshipType
;
49 import eu
.etaxonomy
.cdm
.model
.name
.NameTypeDesignation
;
50 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalStatus
;
51 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalStatusType
;
52 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
53 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
54 import eu
.etaxonomy
.cdm
.model
.name
.SpecimenTypeDesignationStatus
;
55 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
56 import eu
.etaxonomy
.cdm
.model
.name
.TypeDesignationBase
;
57 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnitBase
;
58 import eu
.etaxonomy
.cdm
.persistence
.dao
.common
.ICdmGenericDao
;
59 import eu
.etaxonomy
.cdm
.persistence
.dao
.common
.IOrderedTermVocabularyDao
;
60 import eu
.etaxonomy
.cdm
.persistence
.dao
.common
.IReferencedEntityDao
;
61 import eu
.etaxonomy
.cdm
.persistence
.dao
.common
.ITermVocabularyDao
;
62 import eu
.etaxonomy
.cdm
.persistence
.dao
.name
.IHomotypicalGroupDao
;
63 import eu
.etaxonomy
.cdm
.persistence
.dao
.name
.INomenclaturalStatusDao
;
64 import eu
.etaxonomy
.cdm
.persistence
.dao
.name
.ITaxonNameDao
;
65 import eu
.etaxonomy
.cdm
.persistence
.dao
.name
.ITypeDesignationDao
;
66 import eu
.etaxonomy
.cdm
.persistence
.query
.MatchMode
;
67 import eu
.etaxonomy
.cdm
.persistence
.query
.OrderHint
;
68 import eu
.etaxonomy
.cdm
.strategy
.cache
.TaggedText
;
69 import eu
.etaxonomy
.cdm
.strategy
.cache
.common
.IIdentifiableEntityCacheStrategy
;
73 @Transactional(propagation
= Propagation
.SUPPORTS
, readOnly
= true)
74 public class NameServiceImpl
extends IdentifiableServiceBase
<TaxonNameBase
,ITaxonNameDao
> implements INameService
{
75 static private final Logger logger
= Logger
.getLogger(NameServiceImpl
.class);
78 protected ITermVocabularyDao vocabularyDao
;
80 protected IOrderedTermVocabularyDao orderedVocabularyDao
;
82 @Qualifier("refEntDao")
83 protected IReferencedEntityDao
<ReferencedEntityBase
> referencedEntityDao
;
85 private INomenclaturalStatusDao nomStatusDao
;
87 private ITypeDesignationDao typeDesignationDao
;
89 private IHomotypicalGroupDao homotypicalGroupDao
;
91 private ICdmGenericDao genericDao
;
96 public NameServiceImpl(){
97 if (logger
.isDebugEnabled()) { logger
.debug("Load NameService Bean"); }
100 //********************* METHODS ****************************************************************//
103 * @see eu.etaxonomy.cdm.api.service.ServiceBase#delete(eu.etaxonomy.cdm.model.common.CdmBase)
106 public UUID
delete(TaxonNameBase name
){
107 NameDeletionConfigurator config
= new NameDeletionConfigurator();
109 return delete(name
, config
);
110 } catch (ReferencedObjectUndeletableException e
) {
111 //TODO throw DeleteException - current implementation is preliminary for testing
112 throw new RuntimeException(e
);
117 * @see eu.etaxonomy.cdm.api.service.INameService#delete(eu.etaxonomy.cdm.model.name.TaxonNameBase, eu.etaxonomy.cdm.api.service.NameDeletionConfigurator)
120 public UUID
delete(TaxonNameBase name
, NameDeletionConfigurator config
) throws ReferencedObjectUndeletableException
{
125 //remove references to this name
126 removeNameRelationshipsByDeleteConfig(name
, config
);
128 //check if this name is still used somewhere
131 if (! name
.getNameRelations().isEmpty()){
132 String message
= "Name can't be deleted as it is used in name relationship(s). Remove name relationships prior to deletion.";
133 throw new ReferencedObjectUndeletableException(message
);
138 if (! name
.getTaxonBases().isEmpty()){
139 String message
= "Name can't be deleted as it is used in concept(s). Remove or change concept prior to deletion.";
140 throw new ReferencedObjectUndeletableException(message
);
143 //hybrid relationships
144 if (name
.isInstanceOf(NonViralName
.class)){
145 NonViralName nvn
= CdmBase
.deproxy(name
, NonViralName
.class);
146 // if (! nvn.getHybridChildRelations().isEmpty()){
147 // String message = "Name can't be deleted as it is a child in (a) hybrid relationship(s). Remove hybrid relationships prior to deletion.";
148 // throw new RuntimeException(message);
150 if (! nvn
.getHybridParentRelations().isEmpty()){
151 String message
= "Name can't be deleted as it is a parent in (a) hybrid relationship(s). Remove hybrid relationships prior to deletion.";
152 throw new ReferencedObjectUndeletableException(message
);
156 //all type designation relationships are removed as they belong to the name
157 deleteTypeDesignation(name
, null);
158 // //type designations
159 // if (! name.getTypeDesignations().isEmpty()){
160 // String message = "Name can't be deleted as it has types. Remove types prior to deletion.";
161 // throw new ReferrencedObjectUndeletableException(message);
164 //check references with only reverse mapping
165 Set
<CdmBase
> referencingObjects
= genericDao
.getReferencingObjects(name
);
166 for (CdmBase referencingObject
: referencingObjects
){
167 //DerivedUnitBase?.storedUnder
168 if (referencingObject
.isInstanceOf(DerivedUnitBase
.class)){
169 String message
= "Name can't be deleted as it is used as derivedUnit#storedUnder by %s. Remove 'stored under' prior to deleting this name";
170 message
= String
.format(message
, CdmBase
.deproxy(referencingObject
, DerivedUnitBase
.class).getTitleCache());
171 throw new ReferencedObjectUndeletableException(message
);
173 //DescriptionElementSource#nameUsedInSource
174 if (referencingObject
.isInstanceOf(DescriptionElementSource
.class)){
175 String message
= "Name can't be deleted as it is used as descriptionElementSource#nameUsedInSource";
176 throw new ReferencedObjectUndeletableException(message
);
178 //NameTypeDesignation#typeName
179 if (referencingObject
.isInstanceOf(NameTypeDesignation
.class)){
180 String message
= "Name can't be deleted as it is used as a name type in a NameTypeDesignation";
181 throw new ReferencedObjectUndeletableException(message
);
184 //TaxonNameDescriptions#taxonName
185 //deleted via cascade?
187 //NomenclaturalStatus
188 //deleted via cascade?
192 //TODO inline references
195 return name
.getUuid();
199 * @see eu.etaxonomy.cdm.api.service.INameService#deleteTypeDesignation(eu.etaxonomy.cdm.model.name.TaxonNameBase, eu.etaxonomy.cdm.model.name.TypeDesignationBase)
202 public void deleteTypeDesignation(TaxonNameBase name
, TypeDesignationBase typeDesignation
){
203 if (name
== null && typeDesignation
== null){
205 }else if (name
!= null && typeDesignation
!= null){
206 removeSingleDesignation(name
, typeDesignation
);
207 }else if (name
!= null){
208 Set
<TypeDesignationBase
> designationSet
= new HashSet
<TypeDesignationBase
>(name
.getTypeDesignations());
209 for (Object o
: designationSet
){
210 TypeDesignationBase desig
= CdmBase
.deproxy(o
, TypeDesignationBase
.class);
211 removeSingleDesignation(name
, desig
);
213 }else if (typeDesignation
!= null){
214 Set
<TaxonNameBase
> nameSet
= new HashSet
<TaxonNameBase
>(typeDesignation
.getTypifiedNames());
215 for (Object o
: nameSet
){
216 TaxonNameBase singleName
= CdmBase
.deproxy(o
, TaxonNameBase
.class);
217 removeSingleDesignation(singleName
, typeDesignation
);
224 * @param typeDesignation
226 private void removeSingleDesignation(TaxonNameBase name
, TypeDesignationBase typeDesignation
) {
227 name
.removeTypeDesignation(typeDesignation
);
228 if (typeDesignation
.getTypifiedNames().isEmpty()){
229 typeDesignation
.removeType();
230 typeDesignationDao
.delete(typeDesignation
);
240 private void removeNameRelationshipsByDeleteConfig(TaxonNameBase name
, NameDeletionConfigurator config
) {
241 if (config
.isRemoveAllNameRelationships()){
242 Set
<NameRelationship
> rels
= name
.getNameRelations();
243 for (NameRelationship rel
: rels
){
244 name
.removeNameRelationship(rel
);
247 //relations to this name
248 Set
<NameRelationship
> rels
= name
.getRelationsToThisName();
249 for (NameRelationship rel
: rels
){
250 if (config
.isIgnoreHasBasionym() && NameRelationshipType
.BASIONYM().equals(rel
.getType() )){
251 name
.removeNameRelationship(rel
);
252 }else if (config
.isIgnoreHasReplacedSynonym() && NameRelationshipType
.REPLACED_SYNONYM().equals(rel
.getType())){
253 name
.removeNameRelationship(rel
);
256 //relations from this name
257 rels
= name
.getRelationsFromThisName();
258 for (NameRelationship rel
: rels
){
259 if (config
.isIgnoreIsBasionymFor() && NameRelationshipType
.BASIONYM().equals(rel
.getType()) ){
260 name
.removeNameRelationship(rel
);
261 }else if (config
.isIgnoreIsReplacedSynonymFor() && NameRelationshipType
.REPLACED_SYNONYM().equals(rel
.getType())){
262 name
.removeNameRelationship(rel
);
269 //********************* METHODS ****************************************************************//
272 public List
getNamesByName(String name
){
273 return super.findCdmObjectsByTitle(name
);
276 public List
<NonViralName
> getNamesByNameCache(String nameCache
){
277 List result
= dao
.findByName(nameCache
, MatchMode
.EXACT
, null, null, null, null);
281 public List
getNamesByName(String name
, CdmBase sessionObject
){
282 return super.findCdmObjectsByTitle(name
, sessionObject
);
285 public List
findNamesByTitle(String title
){
286 return super.findCdmObjectsByTitle(title
);
289 public List
findNamesByTitle(String title
, CdmBase sessionObject
){
290 return super.findCdmObjectsByTitle(title
, sessionObject
);
293 @Transactional(readOnly
= false)
294 public Map
<UUID
, HomotypicalGroup
> saveAllHomotypicalGroups(Collection
<HomotypicalGroup
> homotypicalGroups
){
295 return homotypicalGroupDao
.saveAll(homotypicalGroups
);
298 @Transactional(readOnly
= false)
299 public Map
<UUID
, TypeDesignationBase
> saveTypeDesignationAll(Collection
<TypeDesignationBase
> typeDesignationCollection
){
300 return typeDesignationDao
.saveAll(typeDesignationCollection
);
303 @Transactional(readOnly
= false)
304 public Map
<UUID
, ReferencedEntityBase
> saveReferencedEntitiesAll(Collection
<ReferencedEntityBase
> referencedEntityCollection
){
305 return referencedEntityDao
.saveAll(referencedEntityCollection
);
308 public List
<TaxonNameBase
> getAllNames(int limit
, int start
){
309 return dao
.list(limit
, start
);
312 public List
<NomenclaturalStatus
> getAllNomenclaturalStatus(int limit
, int start
){
313 return nomStatusDao
.list(limit
, start
);
316 public List
<TypeDesignationBase
> getAllTypeDesignations(int limit
, int start
){
317 return typeDesignationDao
.getAllTypeDesignations(limit
, start
);
320 * FIXME Candidate for harmonization
321 * homotypicalGroupService.list
323 public List
<HomotypicalGroup
> getAllHomotypicalGroups(int limit
, int start
){
324 return homotypicalGroupDao
.list(limit
, start
);
328 * FIXME Candidate for harmonization
332 public List
<RelationshipBase
> getAllRelationships(int limit
, int start
){
333 return dao
.getRelationships(limit
, start
);
337 * FIXME Candidate for harmonization
338 * is this the same as termService.getVocabulary(VocabularyEnum.Rank)
340 * @see eu.etaxonomy.cdm.api.service.INameService#getRankVocabulary()
342 public OrderedTermVocabulary
<Rank
> getRankVocabulary() {
343 String uuidString
= "ef0d1ce1-26e3-4e83-b47b-ca74eed40b1b";
344 UUID uuid
= UUID
.fromString(uuidString
);
345 OrderedTermVocabulary
<Rank
> rankVocabulary
=
346 (OrderedTermVocabulary
)orderedVocabularyDao
.findByUuid(uuid
);
347 return rankVocabulary
;
351 * FIXME Candidate for harmonization
352 * is this the same as termService.getVocabulary(VocabularyEnum.NameRelationshipType)
354 * @see eu.etaxonomy.cdm.api.service.INameService#getNameRelationshipTypeVocabulary()
356 public TermVocabulary
<NameRelationshipType
> getNameRelationshipTypeVocabulary() {
357 String uuidString
= "6878cb82-c1a4-4613-b012-7e73b413c8cd";
358 UUID uuid
= UUID
.fromString(uuidString
);
359 TermVocabulary
<NameRelationshipType
> nameRelTypeVocabulary
=
360 (TermVocabulary
)vocabularyDao
.findByUuid(uuid
);
361 return nameRelTypeVocabulary
;
365 * FIXME Candidate for harmonization
366 * is this the same as termService.getVocabulary(VocabularyEnum.StatusType)
368 * @see eu.etaxonomy.cdm.api.service.INameService#getStatusTypeVocabulary()
370 public TermVocabulary
<NomenclaturalStatusType
> getStatusTypeVocabulary() {
371 String uuidString
= "bb28cdca-2f8a-4f11-9c21-517e9ae87f1f";
372 UUID uuid
= UUID
.fromString(uuidString
);
373 TermVocabulary
<NomenclaturalStatusType
> nomStatusTypeVocabulary
=
374 (TermVocabulary
)vocabularyDao
.findByUuid(uuid
);
375 return nomStatusTypeVocabulary
;
379 * FIXME Candidate for harmonization
380 * is this the same as termService.getVocabulary(VocabularyEnum.SpecimenTypeDesignationStatus)
382 * @see eu.etaxonomy.cdm.api.service.INameService#getTypeDesignationStatusVocabulary()
384 public TermVocabulary
<SpecimenTypeDesignationStatus
> getSpecimenTypeDesignationStatusVocabulary() {
385 String uuidString
= "ab177bd7-d3c8-4e58-a388-226fff6ba3c2";
386 UUID uuid
= UUID
.fromString(uuidString
);
387 TermVocabulary
<SpecimenTypeDesignationStatus
> typeDesigStatusVocabulary
=
388 (TermVocabulary
)vocabularyDao
.findByUuid(uuid
);
389 return typeDesigStatusVocabulary
;
393 * FIXME Candidate for harmonization
394 * is this the same as termService.getVocabulary(VocabularyEnum.SpecimenTypeDesignationStatus)
395 * and also seems to duplicate the above method, differing only in the DAO used and the return type
397 * @see eu.etaxonomy.cdm.api.service.INameService#getTypeDesignationStatusVocabulary()
399 public OrderedTermVocabulary
<SpecimenTypeDesignationStatus
> getSpecimenTypeDesignationVocabulary() {
400 String uuidString
= "ab177bd7-d3c8-4e58-a388-226fff6ba3c2";
401 UUID uuid
= UUID
.fromString(uuidString
);
402 OrderedTermVocabulary
<SpecimenTypeDesignationStatus
> typeDesignationVocabulary
=
403 (OrderedTermVocabulary
)orderedVocabularyDao
.findByUuid(uuid
);
404 return typeDesignationVocabulary
;
409 protected void setDao(ITaxonNameDao dao
) {
413 public Pager
<HybridRelationship
> getHybridNames(NonViralName name
, HybridRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
) {
414 Integer numberOfResults
= dao
.countHybridNames(name
, type
);
416 List
<HybridRelationship
> results
= new ArrayList
<HybridRelationship
>();
417 if(AbstractPagerImpl
.hasResultsInRange(numberOfResults
, pageNumber
, pageSize
)) { // no point checking again
418 results
= dao
.getHybridNames(name
, type
, pageSize
, pageNumber
,orderHints
,propertyPaths
);
421 return new DefaultPagerImpl
<HybridRelationship
>(pageNumber
, numberOfResults
, pageSize
, results
);
425 * @see eu.etaxonomy.cdm.api.service.INameService#listNameRelationships(eu.etaxonomy.cdm.model.name.TaxonNameBase, eu.etaxonomy.cdm.model.common.RelationshipBase.Direction, eu.etaxonomy.cdm.model.name.NameRelationshipType, java.lang.Integer, java.lang.Integer, java.util.List, java.util.List)
428 public List
<NameRelationship
> listNameRelationships(TaxonNameBase name
, Direction direction
, NameRelationshipType type
, Integer pageSize
,
429 Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
) {
431 Integer numberOfResults
= dao
.countNameRelationships(name
, NameRelationship
.Direction
.relatedFrom
, type
);
433 List
<NameRelationship
> results
= new ArrayList
<NameRelationship
>();
434 if (AbstractPagerImpl
.hasResultsInRange(numberOfResults
, pageNumber
, pageSize
)) { // no point checking again
435 results
= dao
.getNameRelationships(name
, direction
, type
, pageSize
, pageNumber
, orderHints
, propertyPaths
);
441 * @see eu.etaxonomy.cdm.api.service.INameService#pageNameRelationships(eu.etaxonomy.cdm.model.name.TaxonNameBase, eu.etaxonomy.cdm.model.common.RelationshipBase.Direction, eu.etaxonomy.cdm.model.name.NameRelationshipType, java.lang.Integer, java.lang.Integer, java.util.List, java.util.List)
444 public Pager
<NameRelationship
> pageNameRelationships(TaxonNameBase name
, Direction direction
, NameRelationshipType type
, Integer pageSize
,
445 Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
) {
446 List
<NameRelationship
> results
= listNameRelationships(name
, direction
, type
, pageSize
, pageNumber
, orderHints
, propertyPaths
);
447 return new DefaultPagerImpl
<NameRelationship
>(pageNumber
, results
.size(), pageSize
, results
);
450 public List
<NameRelationship
> listFromNameRelationships(TaxonNameBase name
, NameRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
) {
451 return listNameRelationships(name
, Direction
.relatedFrom
, type
, pageSize
, pageNumber
, orderHints
, propertyPaths
);
454 public Pager
<NameRelationship
> pageFromNameRelationships(TaxonNameBase name
, NameRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
) {
455 List
<NameRelationship
> results
= listNameRelationships(name
, Direction
.relatedFrom
, type
, pageSize
, pageNumber
, orderHints
, propertyPaths
);
456 return new DefaultPagerImpl
<NameRelationship
>(pageNumber
, results
.size(), pageSize
, results
);
459 public List
<NameRelationship
> listToNameRelationships(TaxonNameBase name
, NameRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
) {
460 return listNameRelationships(name
, Direction
.relatedTo
, type
, pageSize
, pageNumber
, orderHints
, propertyPaths
);
463 public Pager
<NameRelationship
> pageToNameRelationships(TaxonNameBase name
, NameRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
) {
464 List
<NameRelationship
> results
= listNameRelationships(name
, Direction
.relatedTo
, type
, pageSize
, pageNumber
, orderHints
, propertyPaths
);
465 return new DefaultPagerImpl
<NameRelationship
>(pageNumber
, results
.size(), pageSize
, results
);
468 public Pager
<TypeDesignationBase
> getTypeDesignations(TaxonNameBase name
, SpecimenTypeDesignationStatus status
,
469 Integer pageSize
, Integer pageNumber
) {
470 return getTypeDesignations(name
, status
, pageSize
, pageNumber
, null);
473 public Pager
<TypeDesignationBase
> getTypeDesignations(TaxonNameBase name
, SpecimenTypeDesignationStatus status
,
474 Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
){
475 Integer numberOfResults
= dao
.countTypeDesignations(name
, status
);
477 List
<TypeDesignationBase
> results
= new ArrayList
<TypeDesignationBase
>();
478 if(numberOfResults
> 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize)
479 results
= dao
.getTypeDesignations(name
, status
, pageSize
, pageNumber
, propertyPaths
);
482 return new DefaultPagerImpl
<TypeDesignationBase
>(pageNumber
, numberOfResults
, pageSize
, results
);
486 * FIXME Candidate for harmonization
489 public Pager
<TaxonNameBase
> searchNames(String uninomial
,String infraGenericEpithet
, String specificEpithet
, String infraspecificEpithet
, Rank rank
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
,
490 List
<String
> propertyPaths
) {
491 Integer numberOfResults
= dao
.countNames(uninomial
, infraGenericEpithet
, specificEpithet
, infraspecificEpithet
, rank
);
493 List
<TaxonNameBase
> results
= new ArrayList
<TaxonNameBase
>();
494 if(numberOfResults
> 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize)
495 results
= dao
.searchNames(uninomial
, infraGenericEpithet
, specificEpithet
, infraspecificEpithet
, rank
, pageSize
, pageNumber
, orderHints
, propertyPaths
);
498 return new DefaultPagerImpl
<TaxonNameBase
>(pageNumber
, numberOfResults
, pageSize
, results
);
502 * @see eu.etaxonomy.cdm.api.service.INameService#getUuidAndTitleCacheOfNames()
504 public List
<UuidAndTitleCache
> getUuidAndTitleCacheOfNames() {
505 return dao
.getUuidAndTitleCacheOfNames();
508 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
) {
509 Integer numberOfResults
= dao
.countByName(clazz
, queryString
, matchmode
, criteria
);
511 List
<TaxonNameBase
> results
= new ArrayList
<TaxonNameBase
>();
512 if(numberOfResults
> 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize)
513 results
= dao
.findByName(clazz
, queryString
, matchmode
, criteria
, pageSize
, pageNumber
, orderHints
, propertyPaths
);
516 return new DefaultPagerImpl
<TaxonNameBase
>(pageNumber
, numberOfResults
, pageSize
, results
);
519 public HomotypicalGroup
findHomotypicalGroup(UUID uuid
) {
520 return homotypicalGroupDao
.findByUuid(uuid
);
525 * @see eu.etaxonomy.cdm.api.service.IIdentifiableEntityService#updateTitleCache(java.lang.Integer, eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy)
528 public void updateTitleCache(Class
<?
extends TaxonNameBase
> clazz
, Integer stepSize
, IIdentifiableEntityCacheStrategy
<TaxonNameBase
> cacheStrategy
, IProgressMonitor monitor
) {
530 clazz
= TaxonNameBase
.class;
532 super.updateTitleCacheImpl(clazz
, stepSize
, cacheStrategy
, monitor
);
537 protected void setOtherCachesNull(TaxonNameBase name
) {
538 if (name
.isInstanceOf(NonViralName
.class)){
539 NonViralName nvn
= CdmBase
.deproxy(name
, NonViralName
.class);
540 if (! nvn
.isProtectedNameCache()){
541 nvn
.setNameCache(null, false);
543 if (! nvn
.isProtectedAuthorshipCache()){
544 nvn
.setAuthorshipCache(null, false);
546 if (! nvn
.isProtectedFullTitleCache()){
547 nvn
.setFullTitleCache(null, false);
553 * @see eu.etaxonomy.cdm.api.service.INameService#getTaggedName(eu.etaxonomy.cdm.model.name.TaxonNameBase)
556 public List
<TaggedText
> getTaggedName(UUID uuid
) {
557 TaxonNameBase taxonNameBase
= dao
.load(uuid
);
558 List taggedName
= taxonNameBase
.getTaggedName();