2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.api
.service
;
12 import java
.util
.List
;
13 import java
.util
.UUID
;
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
;
26 public interface IAgentService
extends IIdentifiableEntityService
<AgentBase
> {
28 public List
<Institution
> searchInstitutionByCode(String code
);
31 * Return a paged list of the institutional memberships held by a person
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
38 public Pager
<InstitutionalMembership
> getInstitutionalMemberships(Person person
, Integer pageSize
, Integer pageNumber
);
41 * Return a paged list of the members of a team
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
48 public Pager
<Person
> getMembers(Team team
, Integer pageSize
, Integer pageNumber
);
51 * Return a paged list of the addresses of an agent
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
58 public Pager
<Address
> getAddresses(AgentBase agent
, Integer pageSize
, Integer pageNumber
);
61 * Returns a Paged List of AgentBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
63 * @param clazz filter the results by class (or pass null to return all AgentBase instances)
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)
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>
76 public Pager
<AgentBase
> search(Class
<?
extends AgentBase
> clazz
, String queryString
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
79 * Returns a list of <code>UuidAndTitleCache</code> containing all <code>Person</code>s
81 * @return a list of <code>UuidAndTitleCache</code> instances
83 public List
<UuidAndTitleCache
<Person
>> getPersonUuidAndTitleCache();
86 * Returns a list of <code>UuidAndTitleCache</code> containing all <code>TeamOrPersonBase</code> objects
87 * with their respective titleCache
89 * @return a list of <code>UuidAndTitleCache</code> instances
91 public List
<UuidAndTitleCache
<Team
>> getTeamUuidAndTitleCache();
94 * Returns a list of <code>UuidAndTitleCache</code> containing all <code>TeamOrPersonBase</code> objects
95 * with their respective nomenclaturalTitle instead of regular titleCache
97 * @return a list of <code>UuidAndTitleCache</code> instances
99 public List
<UuidAndTitleCache
<Team
>> getTeamUuidAndNomenclaturalTitle();
102 * Returns a list of <code>UuidAndTitleCache</code> containing all {@link Institution} objects
103 * with their respective titleCache
105 * @return a list of <code>UuidAndTitleCache</code> instances
107 public List
<UuidAndTitleCache
<Institution
>> getInstitutionUuidAndTitleCache();
111 * Returns a list of <code>UuidAndTitleCache</code> containing all {@link Institution} objects
112 * with their respective NomenclaturalTitleCache
114 * @return a list of <code>UuidAndTitleCache</code> instances
116 public List
<UuidAndTitleCache
<AgentBase
>> getUuidAndAbbrevTitleCache(Integer limit
, String pattern
, Class clazz
);
121 * @throws MergeException
123 public UpdateResult
convertTeam2Person(UUID teamUuid
) throws MergeException
;
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.
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.
132 * Otherwise, an {@link IllegalArgumentException} is thrown.
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
139 public UpdateResult
convertTeam2Person(Team team
) throws MergeException
, IllegalArgumentException
;
145 * @throws MergeException
146 * @throws IllegalArgumentException
148 public UpdateResult
convertPerson2Team(UUID personUuid
) throws MergeException
, IllegalArgumentException
;
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.
155 * If the person can not be replaced a {@link MergeException} is thrown.
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
161 public UpdateResult
convertPerson2Team(Person person
) throws MergeException
, IllegalArgumentException
;