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
.List
;
16 import org
.apache
.log4j
.Logger
;
17 import org
.springframework
.beans
.factory
.annotation
.Autowired
;
18 import org
.springframework
.stereotype
.Service
;
19 import org
.springframework
.transaction
.annotation
.Propagation
;
20 import org
.springframework
.transaction
.annotation
.Transactional
;
22 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
23 import eu
.etaxonomy
.cdm
.api
.service
.pager
.impl
.AbstractPagerImpl
;
24 import eu
.etaxonomy
.cdm
.api
.service
.pager
.impl
.DefaultPagerImpl
;
25 import eu
.etaxonomy
.cdm
.common
.monitor
.IProgressMonitor
;
26 import eu
.etaxonomy
.cdm
.model
.agent
.Address
;
27 import eu
.etaxonomy
.cdm
.model
.agent
.AgentBase
;
28 import eu
.etaxonomy
.cdm
.model
.agent
.Institution
;
29 import eu
.etaxonomy
.cdm
.model
.agent
.InstitutionalMembership
;
30 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
31 import eu
.etaxonomy
.cdm
.model
.agent
.Team
;
32 import eu
.etaxonomy
.cdm
.model
.common
.UuidAndTitleCache
;
33 import eu
.etaxonomy
.cdm
.model
.occurrence
.Collection
;
34 import eu
.etaxonomy
.cdm
.persistence
.dao
.agent
.IAgentDao
;
35 import eu
.etaxonomy
.cdm
.strategy
.cache
.common
.IIdentifiableEntityCacheStrategy
;
44 @Transactional(propagation
= Propagation
.SUPPORTS
, readOnly
= true)
45 public class AgentServiceImpl
extends IdentifiableServiceBase
<AgentBase
,IAgentDao
> implements IAgentService
{
46 private static final Logger logger
= Logger
.getLogger(AgentServiceImpl
.class);
51 public AgentServiceImpl(){
52 if (logger
.isDebugEnabled()) { logger
.debug("Load AgentService Bean"); }
55 public List
<Institution
> searchInstitutionByCode(String code
) {
56 return dao
.getInstitutionByCode(code
);
61 * @see eu.etaxonomy.cdm.api.service.IIdentifiableEntityService#updateTitleCache(java.lang.Integer, eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy)
64 @Transactional(readOnly
= false)
65 public void updateTitleCache(Class
<?
extends AgentBase
> clazz
, Integer stepSize
, IIdentifiableEntityCacheStrategy
<AgentBase
> cacheStrategy
, IProgressMonitor monitor
) {
67 clazz
= AgentBase
.class;
69 super.updateTitleCacheImpl(clazz
, stepSize
, cacheStrategy
, monitor
);
73 protected void setDao(IAgentDao dao
) {
78 public Pager
<InstitutionalMembership
> getInstitutionalMemberships(Person person
, Integer pageSize
, Integer pageNumber
) {
79 Integer numberOfResults
= dao
.countInstitutionalMemberships(person
);
81 List
<InstitutionalMembership
> results
= new ArrayList
<InstitutionalMembership
>();
82 if(numberOfResults
> 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize)
83 results
= dao
.getInstitutionalMemberships(person
, pageSize
, pageNumber
);
86 return new DefaultPagerImpl
<InstitutionalMembership
>(pageNumber
, numberOfResults
, pageSize
, results
);
89 public Pager
<Person
> getMembers(Team team
, Integer pageSize
, Integer pageNumber
) {
90 Integer numberOfResults
= dao
.countMembers(team
);
92 List
<Person
> results
= new ArrayList
<Person
>();
93 if(numberOfResults
> 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize)
94 results
= dao
.getMembers(team
, pageSize
, pageNumber
);
97 return new DefaultPagerImpl
<Person
>(pageNumber
, numberOfResults
, pageSize
, results
);
100 public Pager
<Address
> getAddresses(AgentBase agent
, Integer pageSize
, Integer pageNumber
) {
101 Integer numberOfResults
= dao
.countAddresses(agent
);
103 List
<Address
> results
= new ArrayList
<Address
>();
104 if(numberOfResults
> 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize)
105 results
= dao
.getAddresses(agent
, pageSize
, pageNumber
);
108 return new DefaultPagerImpl
<Address
>(pageNumber
, numberOfResults
, pageSize
, results
);
112 * @see eu.etaxonomy.cdm.api.service.IAgentService#getTeamOrPersonBaseUuidAndNomenclaturalTitle()
114 public List
<UuidAndTitleCache
<Team
>> getTeamUuidAndNomenclaturalTitle() {
115 return dao
.getTeamUuidAndNomenclaturalTitle();
119 public List
<UuidAndTitleCache
<Person
>> getPersonUuidAndTitleCache() {
120 return dao
.getPersonUuidAndTitleCache();
124 public List
<UuidAndTitleCache
<Team
>> getTeamUuidAndTitleCache() {
125 return dao
.getTeamUuidAndTitleCache();
129 * @see eu.etaxonomy.cdm.api.service.IAgentService#getInstitutionUuidAndTitleCache()
132 public List
<UuidAndTitleCache
<Institution
>> getInstitutionUuidAndTitleCache() {
133 return dao
.getInstitutionUuidAndTitleCache();