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.api.service;
|
11
|
|
12
|
import java.util.List;
|
13
|
import java.util.UUID;
|
14
|
|
15
|
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
|
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.TeamOrPersonUuidAndTitleCache;
|
24
|
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
|
25
|
import eu.etaxonomy.cdm.persistence.query.OrderHint;
|
26
|
import eu.etaxonomy.cdm.strategy.merge.MergeException;
|
27
|
|
28
|
public interface IAgentService extends IIdentifiableEntityService<AgentBase> {
|
29
|
|
30
|
public List<Institution> searchInstitutionByCode(String code);
|
31
|
|
32
|
/**
|
33
|
* Return a paged list of the institutional memberships held by a person
|
34
|
*
|
35
|
* @param person the person
|
36
|
* @param pageSize The maximum number of memberships returned (can be null for all memberships)
|
37
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
38
|
* @return a Pager containing InstitutionalMembership instances
|
39
|
*/
|
40
|
public Pager<InstitutionalMembership> getInstitutionalMemberships(Person person, Integer pageSize, Integer pageNumber);
|
41
|
|
42
|
/**
|
43
|
* Return a paged list of the members of a team
|
44
|
*
|
45
|
* @param team the team
|
46
|
* @param pageSize The maximum number of members returned (can be null for all members)
|
47
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
48
|
* @return a Pager containing Person instances
|
49
|
*/
|
50
|
public Pager<Person> getMembers(Team team, Integer pageSize, Integer pageNumber);
|
51
|
|
52
|
/**
|
53
|
* Return a paged list of the addresses of an agent
|
54
|
*
|
55
|
* @param agent the agent
|
56
|
* @param pageSize The maximum number of addresses returned (can be null for all members)
|
57
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
58
|
* @return a Pager containing Address instances
|
59
|
*/
|
60
|
public Pager<Address> getAddresses(AgentBase agent, Integer pageSize, Integer pageNumber);
|
61
|
|
62
|
/**
|
63
|
* Returns a Paged List of AgentBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
|
64
|
*
|
65
|
* @param clazz filter the results by class (or pass null to return all AgentBase instances)
|
66
|
* @param queryString
|
67
|
* @param pageSize The maximum number of agents returned (can be null for all matching agents)
|
68
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
69
|
* @param orderHints
|
70
|
* Supports path like <code>orderHints.propertyNames</code> which
|
71
|
* include *-to-one properties like createdBy.username or
|
72
|
* authorTeam.persistentTitleCache
|
73
|
* @param propertyPaths properties to be initialized
|
74
|
* @return a Pager Agent instances
|
75
|
* @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
|
76
|
*/
|
77
|
@Override
|
78
|
public Pager<AgentBase> search(Class<? extends AgentBase> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
|
79
|
|
80
|
/**
|
81
|
* Returns a list of <code>UuidAndTitleCache</code> containing all <code>TeamOrPersonBase</code> objects
|
82
|
* with their respective nomenclaturalTitle instead of regular titleCache
|
83
|
*
|
84
|
* @return a list of <code>UuidAndTitleCache</code> instances
|
85
|
*/
|
86
|
public List<UuidAndTitleCache<Team>> getTeamUuidAndNomenclaturalTitle();
|
87
|
|
88
|
/**
|
89
|
* Returns a list of <code>UuidAndTitleCache</code> containing all {@link Institution} objects
|
90
|
* with their respective NomenclaturalTitleCache
|
91
|
*
|
92
|
* @return a list of <code>UuidAndTitleCache</code> instances
|
93
|
*/
|
94
|
public <T extends AgentBase> List<TeamOrPersonUuidAndTitleCache<T>> getUuidAndAbbrevTitleCache(Class<T> clazz, Integer limit, String pattern);
|
95
|
|
96
|
/**
|
97
|
* Returns a list of <code>UuidAndTitleCache</code> containing all {@link Institution} objects
|
98
|
* with their respectiveCollectorTitleCache
|
99
|
*
|
100
|
* @return a list of <code>UuidAndTitleCache</code> instances
|
101
|
*/
|
102
|
public <T extends AgentBase> List<TeamOrPersonUuidAndTitleCache<T>> getUuidAndTitleCacheWithCollectorTitleCache(Class<T> clazz, Integer limit, String pattern);
|
103
|
|
104
|
/**
|
105
|
* Returns a list of <code>UuidAndTitleCache</code> containing all {@link Institution} objects
|
106
|
* with their respectiveCollectorTitleCache
|
107
|
*
|
108
|
* @return a list of <code>UuidAndTitleCache</code> instances
|
109
|
*/
|
110
|
public <T extends AgentBase> List<TeamOrPersonUuidAndTitleCache<T>> getTeamOrPersonUuidAndTitleCache(Class<T> clazz, Integer limit, String pattern);
|
111
|
|
112
|
|
113
|
public UpdateResult convertTeam2Person(UUID teamUuid) throws MergeException;
|
114
|
|
115
|
/**
|
116
|
* If the given {@link Team} is a single member team all links to the team are redirected to the
|
117
|
* single member and the team itself is deleted.
|
118
|
* <BR>
|
119
|
* If the given {@link Team} has no members (protected caches) a new {@link Person} is created
|
120
|
* and all links to the team are redirected to the new person and the team itself is deleted.
|
121
|
* <BR>
|
122
|
* Otherwise, an {@link IllegalArgumentException} is thrown.
|
123
|
*
|
124
|
* @param team the team to be converted
|
125
|
* @return the existing or new person that replaces the given team
|
126
|
* @throws IllegalArgumentException if team has > 1 members
|
127
|
* @throws MergeException if anything else goes wrong during merge
|
128
|
*/
|
129
|
public UpdateResult convertTeam2Person(Team team) throws MergeException, IllegalArgumentException;
|
130
|
|
131
|
|
132
|
/**
|
133
|
* @param personUuid
|
134
|
* @return
|
135
|
* @throws MergeException
|
136
|
* @throws IllegalArgumentException
|
137
|
*/
|
138
|
public UpdateResult convertPerson2Team(UUID personUuid) throws MergeException, IllegalArgumentException;
|
139
|
|
140
|
/**
|
141
|
* If possible replaces the given person by a new {@link Team}.
|
142
|
* <BR>This is only possible if the person is at no place used in person only mode, which
|
143
|
* is the case e.g. at User.person or FieldUnit.primaryCollector.
|
144
|
* <BR>
|
145
|
* If the person can not be replaced a {@link MergeException} is thrown.
|
146
|
*
|
147
|
* The new team is created by setting the titleCache and nomenclaturalTitle to protected
|
148
|
* and copy it. Also supplemental data is copied to the team.
|
149
|
* The old person is fully deleted, not added as member to the new team.
|
150
|
*
|
151
|
* @param person the {@link Person} to be converted
|
152
|
* @return the new team that replaces the given person
|
153
|
* @throws MergeException if anything else goes wrong during merge
|
154
|
*/
|
155
|
public UpdateResult convertPerson2Team(Person person) throws MergeException, IllegalArgumentException;
|
156
|
|
157
|
public <T extends AgentBase<?>> List<T> findByTitleAndAbbrevTitle(IIdentifiableEntityServiceConfigurator<T> config);
|
158
|
|
159
|
}
|