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
.List
;
14 import java
.util
.UUID
;
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
;
27 public interface IAgentService
extends IIdentifiableEntityService
<AgentBase
> {
29 public List
<Institution
> searchInstitutionByCode(String code
);
32 * Return a paged list of the institutional memberships held by a person
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
39 public Pager
<InstitutionalMembership
> getInstitutionalMemberships(Person person
, Integer pageSize
, Integer pageNumber
);
42 * Return a paged list of the members of a team
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
49 public Pager
<Person
> getMembers(Team team
, Integer pageSize
, Integer pageNumber
);
52 * Return a paged list of the addresses of an agent
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
59 public Pager
<Address
> getAddresses(AgentBase agent
, Integer pageSize
, Integer pageNumber
);
62 * Returns a Paged List of AgentBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
64 * @param clazz filter the results by class (or pass null to return all AgentBase instances)
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)
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>
77 public Pager
<AgentBase
> search(Class
<?
extends AgentBase
> clazz
, String queryString
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
80 * Returns a list of <code>UuidAndTitleCache</code> containing all <code>Person</code>s
82 * @return a list of <code>UuidAndTitleCache</code> instances
84 public List
<UuidAndTitleCache
<Person
>> getPersonUuidAndTitleCache();
87 * Returns a list of <code>UuidAndTitleCache</code> containing all <code>TeamOrPersonBase</code> objects
88 * with their respective titleCache
90 * @return a list of <code>UuidAndTitleCache</code> instances
92 public List
<UuidAndTitleCache
<Team
>> getTeamUuidAndTitleCache();
95 * Returns a list of <code>UuidAndTitleCache</code> containing all <code>TeamOrPersonBase</code> objects
96 * with their respective nomenclaturalTitle instead of regular titleCache
98 * @return a list of <code>UuidAndTitleCache</code> instances
100 public List
<UuidAndTitleCache
<Team
>> getTeamUuidAndNomenclaturalTitle();
103 * Returns a list of <code>UuidAndTitleCache</code> containing all {@link Institution} objects
104 * with their respective titleCache
106 * @return a list of <code>UuidAndTitleCache</code> instances
108 public List
<UuidAndTitleCache
<Institution
>> getInstitutionUuidAndTitleCache();
112 * Returns a list of <code>UuidAndTitleCache</code> containing all {@link Institution} objects
113 * with their respective NomenclaturalTitleCache
115 * @return a list of <code>UuidAndTitleCache</code> instances
117 public List
<UuidAndTitleCache
<AgentBase
>> getUuidAndAbbrevTitleCache();
122 * @throws MergeException
124 public UpdateResult
convertTeam2Person(UUID teamUuid
) throws MergeException
;
127 * If the given {@link Team} is a single member team all links to the team are redirected to the
128 * single member and the team itself is deleted.
130 * If the given {@link Team} has no members (protected caches) a new {@link Person} is created
131 * and all links to the team are redirected to the new person and the team itself is deleted.
133 * Otherwise, an {@link IllegalArgumentException} is thrown.
135 * @param team the team to be converted
136 * @return the existing or new person that replaces the given team
137 * @throws IllegalArgumentException if team has > 1 members
138 * @throws MergeException if anything else goes wrong during merge
140 public UpdateResult
convertTeam2Person(Team team
) throws MergeException
, IllegalArgumentException
;
146 * @throws MergeException
147 * @throws IllegalArgumentException
149 public UpdateResult
convertPerson2Team(UUID personUuid
) throws MergeException
, IllegalArgumentException
;
152 * If possible replaces the given person by a new {@link Team}.
153 * <BR>This is only possible if the person is at no place used in person only mode, which
154 * is the case e.g. at User.person or FieldUnit.primaryCollector.
156 * If the person can not be replaced a {@link MergeException} is thrown.
158 * @param person the {@link Person} to be converted
159 * @return the new team that replaces the given person
160 * @throws MergeException if anything else goes wrong during merge
162 public UpdateResult
convertPerson2Team(Person person
) throws MergeException
, IllegalArgumentException
;