Revision 28291ec8
Added by Andreas Müller almost 7 years ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/agent/IAgentDao.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
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. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.cdm.persistence.dao.agent; |
|
11 |
|
|
12 |
import java.util.List; |
|
13 |
|
|
14 |
import eu.etaxonomy.cdm.model.agent.Address; |
|
15 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
|
16 |
import eu.etaxonomy.cdm.model.agent.Institution; |
|
17 |
import eu.etaxonomy.cdm.model.agent.InstitutionalMembership; |
|
18 |
import eu.etaxonomy.cdm.model.agent.Person; |
|
19 |
import eu.etaxonomy.cdm.model.agent.Team; |
|
20 |
import eu.etaxonomy.cdm.persistence.dao.common.IIdentifiableDao; |
|
21 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
|
22 |
|
|
23 |
public interface IAgentDao extends IIdentifiableDao<AgentBase> { |
|
24 |
|
|
25 |
public List<Institution> getInstitutionByCode(String code); |
|
26 |
|
|
27 |
/** |
|
28 |
* Return a List of the institutional memberships of a given person |
|
29 |
* |
|
30 |
* @param person the person |
|
31 |
* @param pageSize The maximum number of institutional memberships returned (can be null for all memberships) |
|
32 |
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based) |
|
33 |
* @return a List of InstitutionalMembership instances |
|
34 |
*/ |
|
35 |
public List<InstitutionalMembership> getInstitutionalMemberships(Person person, Integer pageSize, Integer pageNumber); |
|
36 |
|
|
37 |
/** |
|
38 |
* Return a count of institutional memberships held by a person |
|
39 |
* |
|
40 |
* @param person the person |
|
41 |
* @return a count of InstitutionalMembership instances |
|
42 |
*/ |
|
43 |
public int countInstitutionalMemberships(Person person); |
|
44 |
|
|
45 |
/** |
|
46 |
* Return a List of members of a given team |
|
47 |
* |
|
48 |
* @param team the team |
|
49 |
* @param pageSize The maximum number of people returned (can be null for all members) |
|
50 |
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based) |
|
51 |
* @return a List of Person instances |
|
52 |
*/ |
|
53 |
public List<Person> getMembers(Team team, Integer pageSize, Integer pageNumber); |
|
54 |
|
|
55 |
/** |
|
56 |
* Return a count of members of a given team |
|
57 |
* |
|
58 |
* @param team the team |
|
59 |
* @return a count of Person instances |
|
60 |
*/ |
|
61 |
public int countMembers(Team team); |
|
62 |
|
|
63 |
/** |
|
64 |
* Return a count of addresses of a given agent |
|
65 |
* |
|
66 |
* @param agent the agent |
|
67 |
* @return a count of Address instances |
|
68 |
*/ |
|
69 |
public Integer countAddresses(AgentBase agent); |
|
70 |
|
|
71 |
/** |
|
72 |
* Return a List of addresses of a given agent |
|
73 |
* |
|
74 |
* @param agent the agent |
|
75 |
* @param pageSize The maximum number of addresses returned (can be null for all addresses) |
|
76 |
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based) |
|
77 |
* @return a List of Address instances |
|
78 |
*/ |
|
79 |
public List<Address> getAddresses(AgentBase agent, Integer pageSize,Integer pageNumber); |
|
80 |
|
|
81 |
/** |
|
82 |
* Returns a list of <code>UuidAndTitleCache</code> containing all <code>Person</code>s |
|
83 |
* |
|
84 |
* @return a list of <code>UuidAndTitleCache</code> instances |
|
85 |
*/ |
|
86 |
public List<UuidAndTitleCache<Person>> getPersonUuidAndTitleCache(); |
|
87 |
|
|
88 |
/** |
|
89 |
* Returns a list of <code>UuidAndTitleCache</code> containing all <code>TeamOrPersonBase</code> obejcts |
|
90 |
* with their respective nomenclaturalTitle instead of regular titleCache |
|
91 |
* |
|
92 |
* @return a list of <code>UuidAndTitleCache</code> instances |
|
93 |
*/ |
|
94 |
public List<UuidAndTitleCache<Team>> getTeamUuidAndNomenclaturalTitle(); |
|
95 |
|
|
96 |
/** |
|
97 |
* Returns a list of <code>UuidAndTitleCache</code> containing all <code>TeamOrPersonBase</code> obejcts |
|
98 |
* with their respective titleCache |
|
99 |
* |
|
100 |
* @return a list of <code>UuidAndTitleCache</code> instances |
|
101 |
*/ |
|
102 |
public List<UuidAndTitleCache<Team>> getTeamUuidAndTitleCache(); |
|
103 |
|
|
104 |
/** |
|
105 |
* @return |
|
106 |
*/ |
|
107 |
public List<UuidAndTitleCache<Institution>> getInstitutionUuidAndTitleCache(); |
|
108 |
|
|
109 |
/** |
|
110 |
* @return |
|
111 |
*/ |
|
112 |
List<Person> getPersonsUsedAsUser(); |
|
113 |
} |
|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
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. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.cdm.persistence.dao.agent; |
|
11 |
|
|
12 |
import java.util.List; |
|
13 |
|
|
14 |
import eu.etaxonomy.cdm.model.agent.Address; |
|
15 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
|
16 |
import eu.etaxonomy.cdm.model.agent.Institution; |
|
17 |
import eu.etaxonomy.cdm.model.agent.InstitutionalMembership; |
|
18 |
import eu.etaxonomy.cdm.model.agent.Person; |
|
19 |
import eu.etaxonomy.cdm.model.agent.Team; |
|
20 |
import eu.etaxonomy.cdm.persistence.dao.common.IIdentifiableDao; |
|
21 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
|
22 |
|
|
23 |
public interface IAgentDao extends IIdentifiableDao<AgentBase> { |
|
24 |
|
|
25 |
public List<Institution> getInstitutionByCode(String code); |
|
26 |
|
|
27 |
/** |
|
28 |
* Return a List of the institutional memberships of a given person |
|
29 |
* |
|
30 |
* @param person the person |
|
31 |
* @param pageSize The maximum number of institutional memberships returned (can be null for all memberships) |
|
32 |
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based) |
|
33 |
* @return a List of InstitutionalMembership instances |
|
34 |
*/ |
|
35 |
public List<InstitutionalMembership> getInstitutionalMemberships(Person person, Integer pageSize, Integer pageNumber); |
|
36 |
|
|
37 |
/** |
|
38 |
* Return a count of institutional memberships held by a person |
|
39 |
* |
|
40 |
* @param person the person |
|
41 |
* @return a count of InstitutionalMembership instances |
|
42 |
*/ |
|
43 |
public int countInstitutionalMemberships(Person person); |
|
44 |
|
|
45 |
/** |
|
46 |
* Return a List of members of a given team |
|
47 |
* |
|
48 |
* @param team the team |
|
49 |
* @param pageSize The maximum number of people returned (can be null for all members) |
|
50 |
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based) |
|
51 |
* @return a List of Person instances |
|
52 |
*/ |
|
53 |
public List<Person> getMembers(Team team, Integer pageSize, Integer pageNumber); |
|
54 |
|
|
55 |
/** |
|
56 |
* Return a count of members of a given team |
|
57 |
* |
|
58 |
* @param team the team |
|
59 |
* @return a count of Person instances |
|
60 |
*/ |
|
61 |
public int countMembers(Team team); |
|
62 |
|
|
63 |
/** |
|
64 |
* Return a count of addresses of a given agent |
|
65 |
* |
|
66 |
* @param agent the agent |
|
67 |
* @return a count of Address instances |
|
68 |
*/ |
|
69 |
public Integer countAddresses(AgentBase agent); |
|
70 |
|
|
71 |
/** |
|
72 |
* Return a List of addresses of a given agent |
|
73 |
* |
|
74 |
* @param agent the agent |
|
75 |
* @param pageSize The maximum number of addresses returned (can be null for all addresses) |
|
76 |
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based) |
|
77 |
* @return a List of Address instances |
|
78 |
*/ |
|
79 |
public List<Address> getAddresses(AgentBase agent, Integer pageSize,Integer pageNumber); |
|
80 |
|
|
81 |
/** |
|
82 |
* Returns a list of <code>UuidAndTitleCache</code> containing all <code>Person</code>s |
|
83 |
* |
|
84 |
* @return a list of <code>UuidAndTitleCache</code> instances |
|
85 |
*/ |
|
86 |
public List<UuidAndTitleCache<Person>> getPersonUuidAndTitleCache(); |
|
87 |
|
|
88 |
/** |
|
89 |
* Returns a list of <code>UuidAndTitleCache</code> containing all <code>TeamOrPersonBase</code> obejcts |
|
90 |
* with their respective nomenclaturalTitle instead of regular titleCache |
|
91 |
* |
|
92 |
* @return a list of <code>UuidAndTitleCache</code> instances |
|
93 |
*/ |
|
94 |
public List<UuidAndTitleCache<Team>> getTeamUuidAndNomenclaturalTitle(); |
|
95 |
|
|
96 |
/** |
|
97 |
* Returns a list of <code>UuidAndTitleCache</code> containing all <code>TeamOrPersonBase</code> obejcts |
|
98 |
* with their respective titleCache |
|
99 |
* |
|
100 |
* @return a list of <code>UuidAndTitleCache</code> instances |
|
101 |
*/ |
|
102 |
public List<UuidAndTitleCache<Team>> getTeamUuidAndTitleCache(); |
|
103 |
|
|
104 |
/** |
|
105 |
* @return |
|
106 |
*/ |
|
107 |
public List<UuidAndTitleCache<Institution>> getInstitutionUuidAndTitleCache(); |
|
108 |
} |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/agent/AgentDaoImpl.java | ||
---|---|---|
164 | 164 |
return getUuidAndTitleCache(query); |
165 | 165 |
} |
166 | 166 |
|
167 |
@Override |
|
168 |
public List<Person> getPersonsUsedAsUser(){ |
|
169 |
Query query = getSession().createQuery("SELECT ab.uuid, ob.idInSource FROM Person ab JOIN ab.sources ob WHERE ob.idNamespace LIKE 'User'"); |
|
170 |
List<Person> result = query.list(); |
|
171 |
return result; |
|
172 |
} |
|
173 |
|
|
174 | 167 |
} |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/AgentServiceImpl.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2007 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
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. |
|
9 |
*/ |
|
10 |
|
|
11 |
package eu.etaxonomy.cdm.api.service; |
|
12 |
|
|
13 |
import java.util.ArrayList; |
|
14 |
import java.util.List; |
|
15 |
import java.util.UUID; |
|
16 |
|
|
17 |
import org.apache.log4j.Logger; |
|
18 |
import org.springframework.beans.factory.annotation.Autowired; |
|
19 |
import org.springframework.stereotype.Service; |
|
20 |
import org.springframework.transaction.annotation.Transactional; |
|
21 |
|
|
22 |
import eu.etaxonomy.cdm.api.service.pager.Pager; |
|
23 |
import eu.etaxonomy.cdm.api.service.pager.impl.DefaultPagerImpl; |
|
24 |
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor; |
|
25 |
import eu.etaxonomy.cdm.model.agent.Address; |
|
26 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
|
27 |
import eu.etaxonomy.cdm.model.agent.Institution; |
|
28 |
import eu.etaxonomy.cdm.model.agent.InstitutionalMembership; |
|
29 |
import eu.etaxonomy.cdm.model.agent.Person; |
|
30 |
import eu.etaxonomy.cdm.model.agent.Team; |
|
31 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
|
32 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
33 |
import eu.etaxonomy.cdm.persistence.dao.agent.IAgentDao; |
|
34 |
import eu.etaxonomy.cdm.persistence.dao.common.ICdmGenericDao; |
|
35 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
|
36 |
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy; |
|
37 |
import eu.etaxonomy.cdm.strategy.merge.ConvertMergeStrategy; |
|
38 |
import eu.etaxonomy.cdm.strategy.merge.DefaultMergeStrategy; |
|
39 |
import eu.etaxonomy.cdm.strategy.merge.IMergeStrategy; |
|
40 |
import eu.etaxonomy.cdm.strategy.merge.MergeException; |
|
41 |
import eu.etaxonomy.cdm.strategy.merge.MergeMode; |
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
/** |
|
46 |
* @author a.mueller |
|
47 |
* |
|
48 |
*/ |
|
49 |
@Service |
|
50 |
@Transactional(readOnly = true) |
|
51 |
public class AgentServiceImpl extends IdentifiableServiceBase<AgentBase,IAgentDao> implements IAgentService { |
|
52 |
private static final Logger logger = Logger.getLogger(AgentServiceImpl.class); |
|
53 |
|
|
54 |
@Autowired |
|
55 |
ICdmGenericDao genericDao; |
|
56 |
|
|
57 |
@Override |
|
58 |
@Autowired |
|
59 |
protected void setDao(IAgentDao dao) { |
|
60 |
assert dao != null; |
|
61 |
this.dao = dao; |
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* Constructor |
|
66 |
*/ |
|
67 |
public AgentServiceImpl(){ |
|
68 |
if (logger.isDebugEnabled()) { logger.debug("Load AgentService Bean"); } |
|
69 |
} |
|
70 |
|
|
71 |
|
|
72 |
@Override |
|
73 |
@Transactional(readOnly = false) |
|
74 |
public void updateTitleCache(Class<? extends AgentBase> clazz, Integer stepSize, IIdentifiableEntityCacheStrategy<AgentBase> cacheStrategy, IProgressMonitor monitor) { |
|
75 |
if (clazz == null){ |
|
76 |
clazz = AgentBase.class; |
|
77 |
} |
|
78 |
super.updateTitleCacheImpl(clazz, stepSize, cacheStrategy, monitor); |
|
79 |
} |
|
80 |
|
|
81 |
@Override |
|
82 |
public List<Institution> searchInstitutionByCode(String code) { |
|
83 |
return dao.getInstitutionByCode(code); |
|
84 |
} |
|
85 |
|
|
86 |
@Override |
|
87 |
public Pager<InstitutionalMembership> getInstitutionalMemberships(Person person, Integer pageSize, Integer pageNumber) { |
|
88 |
Integer numberOfResults = dao.countInstitutionalMemberships(person); |
|
89 |
|
|
90 |
List<InstitutionalMembership> results = new ArrayList<InstitutionalMembership>(); |
|
91 |
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize) |
|
92 |
results = dao.getInstitutionalMemberships(person, pageSize, pageNumber); |
|
93 |
} |
|
94 |
|
|
95 |
return new DefaultPagerImpl<InstitutionalMembership>(pageNumber, numberOfResults, pageSize, results); |
|
96 |
} |
|
97 |
|
|
98 |
@Override |
|
99 |
public Pager<Person> getMembers(Team team, Integer pageSize, Integer pageNumber) { |
|
100 |
Integer numberOfResults = dao.countMembers(team); |
|
101 |
|
|
102 |
List<Person> results = new ArrayList<Person>(); |
|
103 |
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize) |
|
104 |
results = dao.getMembers(team, pageSize, pageNumber); |
|
105 |
} |
|
106 |
|
|
107 |
return new DefaultPagerImpl<Person>(pageNumber, numberOfResults, pageSize, results); |
|
108 |
} |
|
109 |
|
|
110 |
@Override |
|
111 |
public Pager<Address> getAddresses(AgentBase agent, Integer pageSize, Integer pageNumber) { |
|
112 |
Integer numberOfResults = dao.countAddresses(agent); |
|
113 |
|
|
114 |
List<Address> results = new ArrayList<Address>(); |
|
115 |
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize) |
|
116 |
results = dao.getAddresses(agent, pageSize, pageNumber); |
|
117 |
} |
|
118 |
|
|
119 |
return new DefaultPagerImpl<Address>(pageNumber, numberOfResults, pageSize, results); |
|
120 |
} |
|
121 |
|
|
122 |
@Override |
|
123 |
public List<UuidAndTitleCache<Team>> getTeamUuidAndNomenclaturalTitle() { |
|
124 |
return dao.getTeamUuidAndNomenclaturalTitle(); |
|
125 |
} |
|
126 |
|
|
127 |
@Override |
|
128 |
public List<UuidAndTitleCache<Person>> getPersonUuidAndTitleCache() { |
|
129 |
return dao.getPersonUuidAndTitleCache(); |
|
130 |
} |
|
131 |
|
|
132 |
@Override |
|
133 |
public List<UuidAndTitleCache<Team>> getTeamUuidAndTitleCache() { |
|
134 |
return dao.getTeamUuidAndTitleCache(); |
|
135 |
} |
|
136 |
|
|
137 |
@Override |
|
138 |
public List<UuidAndTitleCache<Institution>> getInstitutionUuidAndTitleCache() { |
|
139 |
return dao.getInstitutionUuidAndTitleCache(); |
|
140 |
} |
|
141 |
|
|
142 |
@Override |
|
143 |
@Transactional(readOnly = false) |
|
144 |
public DeleteResult delete(UUID agentUUID){ |
|
145 |
AgentBase base = dao.load(agentUUID); |
|
146 |
DeleteResult result = this.isDeletable(base, null); |
|
147 |
|
|
148 |
if (result.isOk()){ |
|
149 |
if (base instanceof Team){ |
|
150 |
Team baseTeam = (Team) base; |
|
151 |
List<Person> members = baseTeam.getTeamMembers(); |
|
152 |
List<Person> temp = new ArrayList<Person>(); |
|
153 |
for (Person member:members){ |
|
154 |
temp.add(member); |
|
155 |
} |
|
156 |
for (Person member: temp){ |
|
157 |
members.remove(member); |
|
158 |
} |
|
159 |
} |
|
160 |
saveOrUpdate(base); |
|
161 |
|
|
162 |
dao.delete(base); |
|
163 |
|
|
164 |
} |
|
165 |
|
|
166 |
return result; |
|
167 |
} |
|
168 |
|
|
169 |
@Override |
|
170 |
public DeleteResult delete(AgentBase agent){ |
|
171 |
return delete(agent.getUuid()); |
|
172 |
} |
|
173 |
|
|
174 |
@Override |
|
175 |
@Transactional(readOnly = false) |
|
176 |
public UpdateResult convertTeam2Person(UUID teamUuid) throws MergeException { |
|
177 |
Team team = CdmBase.deproxy(dao.load(teamUuid), Team.class); |
|
178 |
return convertTeam2Person(team); |
|
179 |
} |
|
180 |
|
|
181 |
@Override |
|
182 |
public UpdateResult convertTeam2Person(Team team) throws MergeException { |
|
183 |
UpdateResult result = new UpdateResult(); |
|
184 |
Person newPerson = null; |
|
185 |
team = CdmBase.deproxy(team, Team.class); |
|
186 |
if (team.getTeamMembers().size() > 1){ |
|
187 |
throw new IllegalArgumentException("Team must not have more than 1 member to be convertable into a person"); |
|
188 |
}else if (team.getTeamMembers().size() == 1){ |
|
189 |
newPerson = team.getTeamMembers().get(0); |
|
190 |
IMergeStrategy strategy = DefaultMergeStrategy.NewInstance(TeamOrPersonBase.class); |
|
191 |
strategy.setDefaultCollectionMergeMode(MergeMode.FIRST); |
|
192 |
genericDao.merge(newPerson, team, strategy); |
|
193 |
}else if (team.getTeamMembers().isEmpty()){ |
|
194 |
newPerson = Person.NewInstance(); |
|
195 |
genericDao.save(newPerson); |
|
196 |
IMergeStrategy strategy = DefaultMergeStrategy.NewInstance(TeamOrPersonBase.class); |
|
197 |
strategy.setDefaultMergeMode(MergeMode.SECOND); |
|
198 |
strategy.setDefaultCollectionMergeMode(MergeMode.SECOND); |
|
199 |
genericDao.merge(newPerson, team, strategy); |
|
200 |
}else{ |
|
201 |
throw new IllegalStateException("Unhandled state of team members collection"); |
|
202 |
} |
|
203 |
result.setCdmEntity(newPerson); |
|
204 |
return result; |
|
205 |
} |
|
206 |
|
|
207 |
@Override |
|
208 |
@Transactional(readOnly = false) |
|
209 |
public UpdateResult convertPerson2Team(UUID personUuid) throws MergeException, IllegalArgumentException { |
|
210 |
Person person = CdmBase.deproxy(dao.load(personUuid), Person.class); |
|
211 |
return convertPerson2Team(person); |
|
212 |
} |
|
213 |
|
|
214 |
@Override |
|
215 |
public UpdateResult convertPerson2Team(Person person) throws MergeException, IllegalArgumentException { |
|
216 |
UpdateResult result = new UpdateResult(); |
|
217 |
Team team = Team.NewInstance(); |
|
218 |
ConvertMergeStrategy strategy = ConvertMergeStrategy.NewInstance(TeamOrPersonBase.class); |
|
219 |
strategy.setDefaultMergeMode(MergeMode.SECOND); |
|
220 |
strategy.setDefaultCollectionMergeMode(MergeMode.SECOND); |
|
221 |
strategy.setDeleteSecondObject(true); |
|
222 |
|
|
223 |
|
|
224 |
if (! genericDao.isMergeable(team, person, strategy)){ |
|
225 |
throw new MergeException("Person can not be transformed into team."); |
|
226 |
} |
|
227 |
try { |
|
228 |
this.save(team); |
|
229 |
team.setProtectedNomenclaturalTitleCache(false); |
|
230 |
team.setProtectedTitleCache(true); |
|
231 |
team.setTitleCache(person.getTitleCache(), true); |
|
232 |
genericDao.merge(team, person, strategy); |
|
233 |
//team.addTeamMember(person); |
|
234 |
|
|
235 |
//this.save(team); |
|
236 |
// team.setNomenclaturalTitle(person.getNomenclaturalTitle(), true); |
|
237 |
} catch (Exception e) { |
|
238 |
throw new MergeException("Unhandled merge exception", e); |
|
239 |
} |
|
240 |
result.setCdmEntity(team); |
|
241 |
return result; |
|
242 |
} |
|
243 |
|
|
244 |
@Override |
|
245 |
@Transactional(readOnly = false) |
|
246 |
public List<Person> getAllAgentsUsedAsUser(){ |
|
247 |
return dao.getPersonsUsedAsUser(); |
|
248 |
} |
|
249 |
|
|
250 |
|
|
251 |
} |
|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2007 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
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. |
|
9 |
*/ |
|
10 |
|
|
11 |
package eu.etaxonomy.cdm.api.service; |
|
12 |
|
|
13 |
import java.util.ArrayList; |
|
14 |
import java.util.List; |
|
15 |
import java.util.UUID; |
|
16 |
|
|
17 |
import org.apache.log4j.Logger; |
|
18 |
import org.springframework.beans.factory.annotation.Autowired; |
|
19 |
import org.springframework.stereotype.Service; |
|
20 |
import org.springframework.transaction.annotation.Transactional; |
|
21 |
|
|
22 |
import eu.etaxonomy.cdm.api.service.pager.Pager; |
|
23 |
import eu.etaxonomy.cdm.api.service.pager.impl.DefaultPagerImpl; |
|
24 |
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor; |
|
25 |
import eu.etaxonomy.cdm.model.agent.Address; |
|
26 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
|
27 |
import eu.etaxonomy.cdm.model.agent.Institution; |
|
28 |
import eu.etaxonomy.cdm.model.agent.InstitutionalMembership; |
|
29 |
import eu.etaxonomy.cdm.model.agent.Person; |
|
30 |
import eu.etaxonomy.cdm.model.agent.Team; |
|
31 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
|
32 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
33 |
import eu.etaxonomy.cdm.persistence.dao.agent.IAgentDao; |
|
34 |
import eu.etaxonomy.cdm.persistence.dao.common.ICdmGenericDao; |
|
35 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
|
36 |
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy; |
|
37 |
import eu.etaxonomy.cdm.strategy.merge.ConvertMergeStrategy; |
|
38 |
import eu.etaxonomy.cdm.strategy.merge.DefaultMergeStrategy; |
|
39 |
import eu.etaxonomy.cdm.strategy.merge.IMergeStrategy; |
|
40 |
import eu.etaxonomy.cdm.strategy.merge.MergeException; |
|
41 |
import eu.etaxonomy.cdm.strategy.merge.MergeMode; |
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
/** |
|
46 |
* @author a.mueller |
|
47 |
* |
|
48 |
*/ |
|
49 |
@Service |
|
50 |
@Transactional(readOnly = true) |
|
51 |
public class AgentServiceImpl extends IdentifiableServiceBase<AgentBase,IAgentDao> implements IAgentService { |
|
52 |
private static final Logger logger = Logger.getLogger(AgentServiceImpl.class); |
|
53 |
|
|
54 |
@Autowired |
|
55 |
ICdmGenericDao genericDao; |
|
56 |
|
|
57 |
@Override |
|
58 |
@Autowired |
|
59 |
protected void setDao(IAgentDao dao) { |
|
60 |
assert dao != null; |
|
61 |
this.dao = dao; |
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* Constructor |
|
66 |
*/ |
|
67 |
public AgentServiceImpl(){ |
|
68 |
if (logger.isDebugEnabled()) { logger.debug("Load AgentService Bean"); } |
|
69 |
} |
|
70 |
|
|
71 |
|
|
72 |
@Override |
|
73 |
@Transactional(readOnly = false) |
|
74 |
public void updateTitleCache(Class<? extends AgentBase> clazz, Integer stepSize, IIdentifiableEntityCacheStrategy<AgentBase> cacheStrategy, IProgressMonitor monitor) { |
|
75 |
if (clazz == null){ |
|
76 |
clazz = AgentBase.class; |
|
77 |
} |
|
78 |
super.updateTitleCacheImpl(clazz, stepSize, cacheStrategy, monitor); |
|
79 |
} |
|
80 |
|
|
81 |
@Override |
|
82 |
public List<Institution> searchInstitutionByCode(String code) { |
|
83 |
return dao.getInstitutionByCode(code); |
|
84 |
} |
|
85 |
|
|
86 |
@Override |
|
87 |
public Pager<InstitutionalMembership> getInstitutionalMemberships(Person person, Integer pageSize, Integer pageNumber) { |
|
88 |
Integer numberOfResults = dao.countInstitutionalMemberships(person); |
|
89 |
|
|
90 |
List<InstitutionalMembership> results = new ArrayList<InstitutionalMembership>(); |
|
91 |
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize) |
|
92 |
results = dao.getInstitutionalMemberships(person, pageSize, pageNumber); |
|
93 |
} |
|
94 |
|
|
95 |
return new DefaultPagerImpl<InstitutionalMembership>(pageNumber, numberOfResults, pageSize, results); |
|
96 |
} |
|
97 |
|
|
98 |
@Override |
|
99 |
public Pager<Person> getMembers(Team team, Integer pageSize, Integer pageNumber) { |
|
100 |
Integer numberOfResults = dao.countMembers(team); |
|
101 |
|
|
102 |
List<Person> results = new ArrayList<Person>(); |
|
103 |
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize) |
|
104 |
results = dao.getMembers(team, pageSize, pageNumber); |
|
105 |
} |
|
106 |
|
|
107 |
return new DefaultPagerImpl<Person>(pageNumber, numberOfResults, pageSize, results); |
|
108 |
} |
|
109 |
|
|
110 |
@Override |
|
111 |
public Pager<Address> getAddresses(AgentBase agent, Integer pageSize, Integer pageNumber) { |
|
112 |
Integer numberOfResults = dao.countAddresses(agent); |
|
113 |
|
|
114 |
List<Address> results = new ArrayList<Address>(); |
|
115 |
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize) |
|
116 |
results = dao.getAddresses(agent, pageSize, pageNumber); |
|
117 |
} |
|
118 |
|
|
119 |
return new DefaultPagerImpl<Address>(pageNumber, numberOfResults, pageSize, results); |
|
120 |
} |
|
121 |
|
|
122 |
@Override |
|
123 |
public List<UuidAndTitleCache<Team>> getTeamUuidAndNomenclaturalTitle() { |
|
124 |
return dao.getTeamUuidAndNomenclaturalTitle(); |
|
125 |
} |
|
126 |
|
|
127 |
@Override |
|
128 |
public List<UuidAndTitleCache<Person>> getPersonUuidAndTitleCache() { |
|
129 |
return dao.getPersonUuidAndTitleCache(); |
|
130 |
} |
|
131 |
|
|
132 |
@Override |
|
133 |
public List<UuidAndTitleCache<Team>> getTeamUuidAndTitleCache() { |
|
134 |
return dao.getTeamUuidAndTitleCache(); |
|
135 |
} |
|
136 |
|
|
137 |
@Override |
|
138 |
public List<UuidAndTitleCache<Institution>> getInstitutionUuidAndTitleCache() { |
|
139 |
return dao.getInstitutionUuidAndTitleCache(); |
|
140 |
} |
|
141 |
|
|
142 |
@Override |
|
143 |
@Transactional(readOnly = false) |
|
144 |
public DeleteResult delete(UUID agentUUID){ |
|
145 |
AgentBase base = dao.load(agentUUID); |
|
146 |
DeleteResult result = this.isDeletable(base, null); |
|
147 |
|
|
148 |
if (result.isOk()){ |
|
149 |
if (base instanceof Team){ |
|
150 |
Team baseTeam = (Team) base; |
|
151 |
List<Person> members = baseTeam.getTeamMembers(); |
|
152 |
List<Person> temp = new ArrayList<Person>(); |
|
153 |
for (Person member:members){ |
|
154 |
temp.add(member); |
|
155 |
} |
|
156 |
for (Person member: temp){ |
|
157 |
members.remove(member); |
|
158 |
} |
|
159 |
} |
|
160 |
saveOrUpdate(base); |
|
161 |
|
|
162 |
dao.delete(base); |
|
163 |
|
|
164 |
} |
|
165 |
|
|
166 |
return result; |
|
167 |
} |
|
168 |
|
|
169 |
@Override |
|
170 |
public DeleteResult delete(AgentBase agent){ |
|
171 |
return delete(agent.getUuid()); |
|
172 |
} |
|
173 |
|
|
174 |
@Override |
|
175 |
@Transactional(readOnly = false) |
|
176 |
public UpdateResult convertTeam2Person(UUID teamUuid) throws MergeException { |
|
177 |
Team team = CdmBase.deproxy(dao.load(teamUuid), Team.class); |
|
178 |
return convertTeam2Person(team); |
|
179 |
} |
|
180 |
|
|
181 |
@Override |
|
182 |
public UpdateResult convertTeam2Person(Team team) throws MergeException { |
|
183 |
UpdateResult result = new UpdateResult(); |
|
184 |
Person newPerson = null; |
|
185 |
team = CdmBase.deproxy(team, Team.class); |
|
186 |
if (team.getTeamMembers().size() > 1){ |
|
187 |
throw new IllegalArgumentException("Team must not have more than 1 member to be convertable into a person"); |
|
188 |
}else if (team.getTeamMembers().size() == 1){ |
|
189 |
newPerson = team.getTeamMembers().get(0); |
|
190 |
IMergeStrategy strategy = DefaultMergeStrategy.NewInstance(TeamOrPersonBase.class); |
|
191 |
strategy.setDefaultCollectionMergeMode(MergeMode.FIRST); |
|
192 |
genericDao.merge(newPerson, team, strategy); |
|
193 |
}else if (team.getTeamMembers().isEmpty()){ |
|
194 |
newPerson = Person.NewInstance(); |
|
195 |
genericDao.save(newPerson); |
|
196 |
IMergeStrategy strategy = DefaultMergeStrategy.NewInstance(TeamOrPersonBase.class); |
|
197 |
strategy.setDefaultMergeMode(MergeMode.SECOND); |
|
198 |
strategy.setDefaultCollectionMergeMode(MergeMode.SECOND); |
|
199 |
genericDao.merge(newPerson, team, strategy); |
|
200 |
}else{ |
|
201 |
throw new IllegalStateException("Unhandled state of team members collection"); |
|
202 |
} |
|
203 |
result.setCdmEntity(newPerson); |
|
204 |
return result; |
|
205 |
} |
|
206 |
|
|
207 |
@Override |
|
208 |
@Transactional(readOnly = false) |
|
209 |
public UpdateResult convertPerson2Team(UUID personUuid) throws MergeException, IllegalArgumentException { |
|
210 |
Person person = CdmBase.deproxy(dao.load(personUuid), Person.class); |
|
211 |
return convertPerson2Team(person); |
|
212 |
} |
|
213 |
|
|
214 |
@Override |
|
215 |
public UpdateResult convertPerson2Team(Person person) throws MergeException, IllegalArgumentException { |
|
216 |
UpdateResult result = new UpdateResult(); |
|
217 |
Team team = Team.NewInstance(); |
|
218 |
ConvertMergeStrategy strategy = ConvertMergeStrategy.NewInstance(TeamOrPersonBase.class); |
|
219 |
strategy.setDefaultMergeMode(MergeMode.SECOND); |
|
220 |
strategy.setDefaultCollectionMergeMode(MergeMode.SECOND); |
|
221 |
strategy.setDeleteSecondObject(true); |
|
222 |
|
|
223 |
|
|
224 |
if (! genericDao.isMergeable(team, person, strategy)){ |
|
225 |
throw new MergeException("Person can not be transformed into team."); |
|
226 |
} |
|
227 |
try { |
|
228 |
this.save(team); |
|
229 |
team.setProtectedNomenclaturalTitleCache(false); |
|
230 |
team.setProtectedTitleCache(true); |
|
231 |
team.setTitleCache(person.getTitleCache(), true); |
|
232 |
genericDao.merge(team, person, strategy); |
|
233 |
//team.addTeamMember(person); |
|
234 |
|
|
235 |
//this.save(team); |
|
236 |
// team.setNomenclaturalTitle(person.getNomenclaturalTitle(), true); |
|
237 |
} catch (Exception e) { |
|
238 |
throw new MergeException("Unhandled merge exception", e); |
|
239 |
} |
|
240 |
result.setCdmEntity(team); |
|
241 |
return result; |
|
242 |
} |
|
243 |
|
|
244 |
} |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IAgentService.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2007 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
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. |
|
9 |
*/ |
|
10 |
|
|
11 |
package eu.etaxonomy.cdm.api.service; |
|
12 |
|
|
13 |
import java.util.List; |
|
14 |
import java.util.UUID; |
|
15 |
|
|
16 |
import eu.etaxonomy.cdm.api.service.pager.Pager; |
|
17 |
import eu.etaxonomy.cdm.model.agent.Address; |
|
18 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
|
19 |
import eu.etaxonomy.cdm.model.agent.Institution; |
|
20 |
import eu.etaxonomy.cdm.model.agent.InstitutionalMembership; |
|
21 |
import eu.etaxonomy.cdm.model.agent.Person; |
|
22 |
import eu.etaxonomy.cdm.model.agent.Team; |
|
23 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
|
24 |
import eu.etaxonomy.cdm.persistence.query.OrderHint; |
|
25 |
import eu.etaxonomy.cdm.strategy.merge.MergeException; |
|
26 |
|
|
27 |
public interface IAgentService extends IIdentifiableEntityService<AgentBase> { |
|
28 |
|
|
29 |
public List<Institution> searchInstitutionByCode(String code); |
|
30 |
|
|
31 |
/** |
|
32 |
* Return a paged list of the institutional memberships held by a person |
|
33 |
* |
|
34 |
* @param person the person |
|
35 |
* @param pageSize The maximum number of memberships returned (can be null for all memberships) |
|
36 |
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based) |
|
37 |
* @return a Pager containing InstitutionalMembership instances |
|
38 |
*/ |
|
39 |
public Pager<InstitutionalMembership> getInstitutionalMemberships(Person person, Integer pageSize, Integer pageNumber); |
|
40 |
|
|
41 |
/** |
|
42 |
* Return a paged list of the members of a team |
|
43 |
* |
|
44 |
* @param team the team |
|
45 |
* @param pageSize The maximum number of members returned (can be null for all members) |
|
46 |
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based) |
|
47 |
* @return a Pager containing Person instances |
|
48 |
*/ |
|
49 |
public Pager<Person> getMembers(Team team, Integer pageSize, Integer pageNumber); |
|
50 |
|
|
51 |
/** |
|
52 |
* Return a paged list of the addresses of an agent |
|
53 |
* |
|
54 |
* @param agent the agent |
|
55 |
* @param pageSize The maximum number of addresses returned (can be null for all members) |
|
56 |
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based) |
|
57 |
* @return a Pager containing Address instances |
|
58 |
*/ |
|
59 |
public Pager<Address> getAddresses(AgentBase agent, Integer pageSize, Integer pageNumber); |
|
60 |
|
|
61 |
/** |
|
62 |
* Returns a Paged List of AgentBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser) |
|
63 |
* |
|
64 |
* @param clazz filter the results by class (or pass null to return all AgentBase instances) |
|
65 |
* @param queryString |
|
66 |
* @param pageSize The maximum number of agents returned (can be null for all matching agents) |
|
67 |
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based) |
|
68 |
* @param orderHints |
|
69 |
* Supports path like <code>orderHints.propertyNames</code> which |
|
70 |
* include *-to-one properties like createdBy.username or |
|
71 |
* authorTeam.persistentTitleCache |
|
72 |
* @param propertyPaths properties to be initialized |
|
73 |
* @return a Pager Agent instances |
|
74 |
* @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a> |
|
75 |
*/ |
|
76 |
@Override |
|
77 |
public Pager<AgentBase> search(Class<? extends AgentBase> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths); |
|
78 |
|
|
79 |
/** |
|
80 |
* Returns a list of <code>UuidAndTitleCache</code> containing all <code>Person</code>s |
|
81 |
* |
|
82 |
* @return a list of <code>UuidAndTitleCache</code> instances |
|
83 |
*/ |
|
84 |
public List<UuidAndTitleCache<Person>> getPersonUuidAndTitleCache(); |
|
85 |
|
|
86 |
/** |
|
87 |
* Returns a list of <code>UuidAndTitleCache</code> containing all <code>TeamOrPersonBase</code> objects |
|
88 |
* with their respective titleCache |
|
89 |
* |
|
90 |
* @return a list of <code>UuidAndTitleCache</code> instances |
|
91 |
*/ |
|
92 |
public List<UuidAndTitleCache<Team>> getTeamUuidAndTitleCache(); |
|
93 |
|
|
94 |
/** |
|
95 |
* Returns a list of <code>UuidAndTitleCache</code> containing all <code>TeamOrPersonBase</code> objects |
|
96 |
* with their respective nomenclaturalTitle instead of regular titleCache |
|
97 |
* |
|
98 |
* @return a list of <code>UuidAndTitleCache</code> instances |
|
99 |
*/ |
|
100 |
public List<UuidAndTitleCache<Team>> getTeamUuidAndNomenclaturalTitle(); |
|
101 |
|
|
102 |
/** |
|
103 |
* Returns a list of <code>UuidAndTitleCache</code> containing all {@link Institution} objects |
|
104 |
* with their respective titleCache |
|
105 |
* |
|
106 |
* @return a list of <code>UuidAndTitleCache</code> instances |
|
107 |
*/ |
|
108 |
public List<UuidAndTitleCache<Institution>> getInstitutionUuidAndTitleCache(); |
|
109 |
|
|
110 |
|
|
111 |
/** |
|
112 |
* @param teamUuid |
|
113 |
* @return |
|
114 |
* @throws MergeException |
|
115 |
*/ |
|
116 |
public UpdateResult convertTeam2Person(UUID teamUuid) throws MergeException; |
|
117 |
|
|
118 |
/** |
|
119 |
* If the given {@link Team} is a single member team all links to the team are redirected to the |
|
120 |
* single member and the team itself is deleted. |
|
121 |
* <BR> |
|
122 |
* If the given {@link Team} has no members (protected caches) a new {@link Person} is created |
|
123 |
* and all links to the team are redirected to the new person and the team itself is deleted. |
|
124 |
* <BR> |
|
125 |
* Otherwise, an {@link IllegalArgumentException} is thrown. |
|
126 |
* |
|
127 |
* @param team the team to be converted |
|
128 |
* @return the existing or new person that replaces the given team |
|
129 |
* @throws IllegalArgumentException if team has > 1 members |
|
130 |
* @throws MergeException if anything else goes wrong during merge |
|
131 |
*/ |
|
132 |
public UpdateResult convertTeam2Person(Team team) throws MergeException, IllegalArgumentException; |
|
133 |
|
|
134 |
|
|
135 |
/** |
|
136 |
* @param personUuid |
|
137 |
* @return |
|
138 |
* @throws MergeException |
|
139 |
* @throws IllegalArgumentException |
|
140 |
*/ |
|
141 |
public UpdateResult convertPerson2Team(UUID personUuid) throws MergeException, IllegalArgumentException; |
|
142 |
|
|
143 |
/** |
|
144 |
* If possible replaces the given person by a new {@link Team}. |
|
145 |
* <BR>This is only possible if the person is at no place used in person only mode, which |
|
146 |
* is the case e.g. at User.person or FieldUnit.primaryCollector. |
|
147 |
* <BR> |
|
148 |
* If the person can not be replaced a {@link MergeException} is thrown. |
|
149 |
* |
|
150 |
* @param person the {@link Person} to be converted |
|
151 |
* @return the new team that replaces the given person |
|
152 |
* @throws MergeException if anything else goes wrong during merge |
|
153 |
*/ |
|
154 |
public UpdateResult convertPerson2Team(Person person) throws MergeException, IllegalArgumentException; |
|
155 |
|
|
156 |
/** |
|
157 |
* @return |
|
158 |
*/ |
|
159 |
List<Person> getAllAgentsUsedAsUser(); |
|
160 |
|
|
161 |
|
|
162 |
|
|
163 |
} |
|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2007 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
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. |
|
9 |
*/ |
|
10 |
|
|
11 |
package eu.etaxonomy.cdm.api.service; |
|
12 |
|
|
13 |
import java.util.List; |
|
14 |
import java.util.UUID; |
|
15 |
|
|
16 |
import eu.etaxonomy.cdm.api.service.pager.Pager; |
|
17 |
import eu.etaxonomy.cdm.model.agent.Address; |
|
18 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
|
19 |
import eu.etaxonomy.cdm.model.agent.Institution; |
|
20 |
import eu.etaxonomy.cdm.model.agent.InstitutionalMembership; |
|
21 |
import eu.etaxonomy.cdm.model.agent.Person; |
|
22 |
import eu.etaxonomy.cdm.model.agent.Team; |
|
23 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
|
24 |
import eu.etaxonomy.cdm.persistence.query.OrderHint; |
|
25 |
import eu.etaxonomy.cdm.strategy.merge.MergeException; |
|
26 |
|
|
27 |
public interface IAgentService extends IIdentifiableEntityService<AgentBase> { |
|
28 |
|
|
29 |
public List<Institution> searchInstitutionByCode(String code); |
|
30 |
|
|
31 |
/** |
|
32 |
* Return a paged list of the institutional memberships held by a person |
|
33 |
* |
|
34 |
* @param person the person |
|
35 |
* @param pageSize The maximum number of memberships returned (can be null for all memberships) |
|
36 |
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based) |
|
37 |
* @return a Pager containing InstitutionalMembership instances |
|
38 |
*/ |
|
39 |
public Pager<InstitutionalMembership> getInstitutionalMemberships(Person person, Integer pageSize, Integer pageNumber); |
|
40 |
|
|
41 |
/** |
|
42 |
* Return a paged list of the members of a team |
|
43 |
* |
|
44 |
* @param team the team |
|
45 |
* @param pageSize The maximum number of members returned (can be null for all members) |
|
46 |
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based) |
|
47 |
* @return a Pager containing Person instances |
|
48 |
*/ |
|
49 |
public Pager<Person> getMembers(Team team, Integer pageSize, Integer pageNumber); |
|
50 |
|
|
51 |
/** |
|
52 |
* Return a paged list of the addresses of an agent |
|
53 |
* |
|
54 |
* @param agent the agent |
|
55 |
* @param pageSize The maximum number of addresses returned (can be null for all members) |
|
56 |
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based) |
|
57 |
* @return a Pager containing Address instances |
|
58 |
*/ |
|
59 |
public Pager<Address> getAddresses(AgentBase agent, Integer pageSize, Integer pageNumber); |
|
60 |
|
|
61 |
/** |
|
62 |
* Returns a Paged List of AgentBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser) |
|
63 |
* |
|
64 |
* @param clazz filter the results by class (or pass null to return all AgentBase instances) |
|
65 |
* @param queryString |
|
66 |
* @param pageSize The maximum number of agents returned (can be null for all matching agents) |
|
67 |
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based) |
|
68 |
* @param orderHints |
|
69 |
* Supports path like <code>orderHints.propertyNames</code> which |
|
70 |
* include *-to-one properties like createdBy.username or |
|
71 |
* authorTeam.persistentTitleCache |
|
72 |
* @param propertyPaths properties to be initialized |
|
73 |
* @return a Pager Agent instances |
|
74 |
* @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a> |
|
75 |
*/ |
|
76 |
@Override |
|
77 |
public Pager<AgentBase> search(Class<? extends AgentBase> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths); |
|
78 |
|
|
79 |
/** |
|
80 |
* Returns a list of <code>UuidAndTitleCache</code> containing all <code>Person</code>s |
|
81 |
* |
|
82 |
* @return a list of <code>UuidAndTitleCache</code> instances |
|
83 |
*/ |
|
84 |
public List<UuidAndTitleCache<Person>> getPersonUuidAndTitleCache(); |
|
85 |
|
|
86 |
/** |
|
87 |
* Returns a list of <code>UuidAndTitleCache</code> containing all <code>TeamOrPersonBase</code> objects |
|
88 |
* with their respective titleCache |
|
89 |
* |
|
90 |
* @return a list of <code>UuidAndTitleCache</code> instances |
|
91 |
*/ |
|
92 |
public List<UuidAndTitleCache<Team>> getTeamUuidAndTitleCache(); |
|
93 |
|
|
94 |
/** |
|
95 |
* Returns a list of <code>UuidAndTitleCache</code> containing all <code>TeamOrPersonBase</code> objects |
|
96 |
* with their respective nomenclaturalTitle instead of regular titleCache |
|
97 |
* |
|
98 |
* @return a list of <code>UuidAndTitleCache</code> instances |
|
99 |
*/ |
|
100 |
public List<UuidAndTitleCache<Team>> getTeamUuidAndNomenclaturalTitle(); |
|
101 |
|
|
102 |
/** |
|
103 |
* Returns a list of <code>UuidAndTitleCache</code> containing all {@link Institution} objects |
|
104 |
* with their respective titleCache |
|
105 |
* |
|
106 |
* @return a list of <code>UuidAndTitleCache</code> instances |
|
107 |
*/ |
|
108 |
public List<UuidAndTitleCache<Institution>> getInstitutionUuidAndTitleCache(); |
|
109 |
|
|
110 |
|
|
111 |
/** |
|
112 |
* @param teamUuid |
|
113 |
* @return |
|
114 |
* @throws MergeException |
|
115 |
*/ |
|
116 |
public UpdateResult convertTeam2Person(UUID teamUuid) throws MergeException; |
|
117 |
|
|
118 |
/** |
|
119 |
* If the given {@link Team} is a single member team all links to the team are redirected to the |
|
120 |
* single member and the team itself is deleted. |
|
121 |
* <BR> |
|
122 |
* If the given {@link Team} has no members (protected caches) a new {@link Person} is created |
|
123 |
* and all links to the team are redirected to the new person and the team itself is deleted. |
|
124 |
* <BR> |
|
125 |
* Otherwise, an {@link IllegalArgumentException} is thrown. |
|
126 |
* |
|
127 |
* @param team the team to be converted |
|
128 |
* @return the existing or new person that replaces the given team |
|
129 |
* @throws IllegalArgumentException if team has > 1 members |
|
130 |
* @throws MergeException if anything else goes wrong during merge |
|
131 |
*/ |
|
132 |
public UpdateResult convertTeam2Person(Team team) throws MergeException, IllegalArgumentException; |
|
133 |
|
|
134 |
|
|
135 |
/** |
|
136 |
* @param personUuid |
|
137 |
* @return |
|
138 |
* @throws MergeException |
|
139 |
* @throws IllegalArgumentException |
|
140 |
*/ |
|
141 |
public UpdateResult convertPerson2Team(UUID personUuid) throws MergeException, IllegalArgumentException; |
|
142 |
|
|
143 |
/** |
|
144 |
* If possible replaces the given person by a new {@link Team}. |
|
145 |
* <BR>This is only possible if the person is at no place used in person only mode, which |
|
146 |
* is the case e.g. at User.person or FieldUnit.primaryCollector. |
|
147 |
* <BR> |
|
148 |
* If the person can not be replaced a {@link MergeException} is thrown. |
|
149 |
* |
|
150 |
* @param person the {@link Person} to be converted |
|
151 |
* @return the new team that replaces the given person |
|
152 |
* @throws MergeException if anything else goes wrong during merge |
|
153 |
*/ |
|
154 |
public UpdateResult convertPerson2Team(Person person) throws MergeException, IllegalArgumentException; |
|
155 |
|
|
156 |
} |
Also available in: Unified diff
Remove method agentsUsedAsUsers related to #5743