Project

General

Profile

Download (6.58 KB) Statistics
| Branch: | Tag: | Revision:
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.pager.Pager;
16
import eu.etaxonomy.cdm.model.agent.Address;
17
import eu.etaxonomy.cdm.model.agent.AgentBase;
18
import eu.etaxonomy.cdm.model.agent.Institution;
19
import eu.etaxonomy.cdm.model.agent.InstitutionalMembership;
20
import eu.etaxonomy.cdm.model.agent.Person;
21
import eu.etaxonomy.cdm.model.agent.Team;
22
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
23
import eu.etaxonomy.cdm.persistence.query.OrderHint;
24
import eu.etaxonomy.cdm.strategy.merge.MergeException;
25

    
26
public interface IAgentService extends IIdentifiableEntityService<AgentBase> {
27

    
28
	public List<Institution> searchInstitutionByCode(String code);
29

    
30
	/**
31
	 * Return a paged list of the institutional memberships held by a person
32
	 *
33
	 * @param person the person
34
	 * @param pageSize The maximum number of memberships returned (can be null for all memberships)
35
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
36
	 * @return a Pager containing InstitutionalMembership  instances
37
	 */
38
	public Pager<InstitutionalMembership> getInstitutionalMemberships(Person person, Integer pageSize, Integer pageNumber);
39

    
40
	/**
41
	 * Return a paged list of the members of a team
42
	 *
43
	 * @param team the team
44
	 * @param pageSize The maximum number of members returned (can be null for all members)
45
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
46
	 * @return a Pager containing Person  instances
47
	 */
48
	public Pager<Person> getMembers(Team team, Integer pageSize, Integer pageNumber);
49

    
50
	/**
51
	 * Return a paged list of the addresses of an agent
52
	 *
53
	 * @param agent the agent
54
	 * @param pageSize The maximum number of addresses returned (can be null for all members)
55
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
56
	 * @return a Pager containing Address  instances
57
	 */
58
	public Pager<Address> getAddresses(AgentBase agent, Integer pageSize, Integer pageNumber);
59

    
60
	/**
61
	 * Returns a Paged List of AgentBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
62
	 *
63
	 * @param clazz filter the results by class (or pass null to return all AgentBase instances)
64
	 * @param queryString
65
	 * @param pageSize The maximum number of agents returned (can be null for all matching agents)
66
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
67
	 * @param orderHints
68
	 *            Supports path like <code>orderHints.propertyNames</code> which
69
	 *            include *-to-one properties like createdBy.username or
70
	 *            authorTeam.persistentTitleCache
71
	 * @param propertyPaths properties to be initialized
72
	 * @return a Pager Agent instances
73
	 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
74
	 */
75
	@Override
76
    public Pager<AgentBase> search(Class<? extends AgentBase> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
77

    
78
	/**
79
	 * Returns a list of <code>UuidAndTitleCache</code> containing all <code>Person</code>s
80
	 *
81
	 * @return a list of <code>UuidAndTitleCache</code> instances
82
	 */
83
	public List<UuidAndTitleCache<Person>> getPersonUuidAndTitleCache();
84

    
85
	/**
86
	 * Returns a list of <code>UuidAndTitleCache</code> containing all <code>TeamOrPersonBase</code> objects
87
	 * with their respective titleCache
88
	 *
89
	 * @return a list of <code>UuidAndTitleCache</code> instances
90
	 */
91
	public List<UuidAndTitleCache<Team>> getTeamUuidAndTitleCache();
92

    
93
	/**
94
	 * Returns a list of <code>UuidAndTitleCache</code> containing all <code>TeamOrPersonBase</code> objects
95
	 * with their respective nomenclaturalTitle instead of regular titleCache
96
	 *
97
	 * @return a list of <code>UuidAndTitleCache</code> instances
98
	 */
99
	public List<UuidAndTitleCache<Team>> getTeamUuidAndNomenclaturalTitle();
100

    
101
	/**
102
	 * Returns a list of <code>UuidAndTitleCache</code> containing all {@link Institution} objects
103
	 * with their respective titleCache
104
	 *
105
	 * @return a list of <code>UuidAndTitleCache</code> instances
106
	 */
107
	public List<UuidAndTitleCache<AgentBase>> getInstitutionUuidAndTitleCache(Integer limit, String pattern);
108

    
109

    
110
	/**
111
     * Returns a list of <code>UuidAndTitleCache</code> containing all {@link Institution} objects
112
     * with their respective NomenclaturalTitleCache
113
     *
114
     * @return a list of <code>UuidAndTitleCache</code> instances
115
     */
116
    public List<UuidAndTitleCache<AgentBase>> getUuidAndAbbrevTitleCache(Integer limit, String pattern, Class clazz);
117

    
118
    /**
119
     * @param teamUuid
120
     * @return
121
     * @throws MergeException
122
     */
123
    public UpdateResult convertTeam2Person(UUID teamUuid) throws MergeException;
124

    
125
	/**
126
	 * If the given {@link Team} is a single member team all links to the team are redirected to the
127
	 * single member and the team itself is deleted.
128
	 * <BR>
129
	 * If the given {@link Team} has no members (protected caches) a new {@link Person} is created
130
	 * and all links to the team are redirected to the new person and the team itself is deleted.
131
	 * <BR>
132
	 * Otherwise, an {@link IllegalArgumentException} is thrown.
133
	 *
134
	 * @param team the team to be converted
135
	 * @return the existing or new person that replaces the given team
136
	 * @throws IllegalArgumentException if team has > 1 members
137
	 * @throws MergeException if anything else goes wrong during merge
138
	 */
139
	public UpdateResult convertTeam2Person(Team team) throws MergeException, IllegalArgumentException;
140

    
141

    
142
    /**
143
     * @param personUuid
144
     * @return
145
     * @throws MergeException
146
     * @throws IllegalArgumentException
147
     */
148
    public UpdateResult convertPerson2Team(UUID personUuid) throws MergeException, IllegalArgumentException;
149

    
150
	/**
151
	 * If possible replaces the given person by a new {@link Team}.
152
	 * <BR>This is only possible if the person is at no place used in person only mode, which
153
	 * is the case e.g. at User.person or FieldUnit.primaryCollector.
154
	 * <BR>
155
	 * If the person can not be replaced a {@link MergeException} is thrown.
156
	 *
157
	 * @param person the {@link Person} to be converted
158
	 * @return the new team that replaces the given person
159
	 * @throws MergeException if anything else goes wrong during merge
160
	 */
161
	public UpdateResult convertPerson2Team(Person person) throws MergeException, IllegalArgumentException;
162

    
163
}
(27-27/103)