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.net.URI;
|
13
|
import java.util.Collection;
|
14
|
import java.util.Enumeration;
|
15
|
import java.util.List;
|
16
|
import java.util.Locale;
|
17
|
import java.util.Map;
|
18
|
import java.util.Set;
|
19
|
import java.util.UUID;
|
20
|
|
21
|
import eu.etaxonomy.cdm.api.service.TermServiceImpl.TermMovePosition;
|
22
|
import eu.etaxonomy.cdm.api.service.config.TermDeletionConfigurator;
|
23
|
import eu.etaxonomy.cdm.api.service.pager.Pager;
|
24
|
import eu.etaxonomy.cdm.model.common.Language;
|
25
|
import eu.etaxonomy.cdm.model.common.LanguageString;
|
26
|
import eu.etaxonomy.cdm.model.common.LanguageStringBase;
|
27
|
import eu.etaxonomy.cdm.model.location.Country;
|
28
|
import eu.etaxonomy.cdm.model.location.NamedArea;
|
29
|
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
|
30
|
import eu.etaxonomy.cdm.model.location.NamedAreaType;
|
31
|
import eu.etaxonomy.cdm.model.media.Media;
|
32
|
import eu.etaxonomy.cdm.model.metadata.NamedAreaSearchField;
|
33
|
import eu.etaxonomy.cdm.model.term.DefinedTermBase;
|
34
|
import eu.etaxonomy.cdm.model.term.OrderedTermBase;
|
35
|
import eu.etaxonomy.cdm.model.term.OrderedTermVocabulary;
|
36
|
import eu.etaxonomy.cdm.model.term.Representation;
|
37
|
import eu.etaxonomy.cdm.model.term.TermType;
|
38
|
import eu.etaxonomy.cdm.model.term.TermVocabulary;
|
39
|
import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;
|
40
|
import eu.etaxonomy.cdm.persistence.dto.TermDto;
|
41
|
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
|
42
|
import eu.etaxonomy.cdm.persistence.query.OrderHint;
|
43
|
|
44
|
public interface ITermService extends IIdentifiableEntityService<DefinedTermBase> {
|
45
|
|
46
|
/**
|
47
|
* Returns a term according to it's uri
|
48
|
* @param uri
|
49
|
* @return
|
50
|
*/
|
51
|
public DefinedTermBase getByUri(URI uri);
|
52
|
|
53
|
public UUID saveLanguageData(LanguageStringBase languageData);
|
54
|
|
55
|
public List<LanguageString> getAllLanguageStrings(int limit, int start);
|
56
|
|
57
|
public List<Representation> getAllRepresentations(int limit, int start);
|
58
|
|
59
|
public Language getLanguageByIso(String iso639);
|
60
|
|
61
|
public List<Language> getLanguagesByLocale(Enumeration<Locale> locales);
|
62
|
|
63
|
public NamedArea getAreaByTdwgAbbreviation(String tdwgAbbreviation);
|
64
|
|
65
|
/**
|
66
|
* Returns a paged list of Media that represent a given DefinedTerm instance
|
67
|
*
|
68
|
* @param definedTerm the definedTerm represented by these media
|
69
|
* @param pageSize The maximum number of media returned (can be null for all related media)
|
70
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
71
|
* @return a Pager of media instances
|
72
|
*/
|
73
|
public Pager<Media> getMedia(DefinedTermBase definedTerm, Integer pageSize, Integer pageNumber);
|
74
|
|
75
|
/**
|
76
|
* Returns a paged list of NamedArea instances (optionally filtered by type or level)
|
77
|
*
|
78
|
* @param level restrict the result set to named areas of a certain level (can be null)
|
79
|
* @param type restrict the result set to named areas of a certain type (can be null)
|
80
|
* @param pageSize The maximum number of namedAreas returned (can be null for all named areas)
|
81
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
82
|
* @return a Pager of named areas
|
83
|
*/
|
84
|
public Pager<NamedArea> list(NamedAreaLevel level, NamedAreaType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
|
85
|
|
86
|
/**
|
87
|
* Return a paged list of terms which are specializations of a given definedTerm
|
88
|
*
|
89
|
* @param definedTerm The term which is a generalization of the terms returned
|
90
|
* @param pageSize The maximum number of terms returned (can be null for all specializations)
|
91
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
92
|
* @return a Pager of DefinedTerms
|
93
|
*/
|
94
|
public <T extends DefinedTermBase> Pager<T> getGeneralizationOf(T definedTerm, Integer pageSize, Integer pageNumber);
|
95
|
|
96
|
/**
|
97
|
* Return a paged list of distinct terms which include the terms supplied
|
98
|
*
|
99
|
* @param definedTerms the set of terms which are part of the terms of interest
|
100
|
* @param pageSize The maximum number of terms returned (can be null for all terms)
|
101
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
102
|
* @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
|
103
|
* @return a Pager of DefinedTerms
|
104
|
*/
|
105
|
public <T extends DefinedTermBase> Pager<T> getPartOf(Set<T> definedTerms, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
|
106
|
|
107
|
/**
|
108
|
* Return a paged list of terms which are part of the terms supplied
|
109
|
*
|
110
|
* @param definedTerms the set of terms which include the terms of interest
|
111
|
* @param pageSize The maximum number of terms returned (can be null for all terms)
|
112
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
113
|
* @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
|
114
|
* @return a Pager of DefinedTerms
|
115
|
*/
|
116
|
public <T extends DefinedTermBase> Pager<T> getIncludes(Collection<T> definedTerms, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
|
117
|
|
118
|
/**
|
119
|
* Return a paged list of terms which have representations that match the supplied string in the text (description)
|
120
|
*
|
121
|
* @param label a string to match (exactly)
|
122
|
* @param pageSize The maximum number of terms returned (can be null for all terms)
|
123
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
124
|
* @return a Pager of DefinedTerms
|
125
|
*/
|
126
|
public <T extends DefinedTermBase> Pager<T> findByRepresentationText(String label, Class<T> clazz, Integer pageSize, Integer pageNumber);
|
127
|
|
128
|
/**
|
129
|
* Return a paged list of terms which have representations that match the supplied string in the abbreviated label
|
130
|
*
|
131
|
* @param label a string to match (exactly)
|
132
|
* @param pageSize The maximum number of terms returned (can be null for all terms)
|
133
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
134
|
* @return a Pager of DefinedTerms
|
135
|
*/
|
136
|
public <T extends DefinedTermBase> Pager<T> findByRepresentationAbbreviation(String abbrev, Class<T> clazz, Integer pageSize, Integer pageNumber);
|
137
|
|
138
|
/**
|
139
|
* Retrieves all {@link DefinedTermBase}s with the given {@link TermType}
|
140
|
* @param termType the term type to filter the terms
|
141
|
* @param limit
|
142
|
* @param start
|
143
|
* @param orderHints
|
144
|
* @param propertyPaths
|
145
|
* @return a list containing the terms
|
146
|
*/
|
147
|
public <T extends DefinedTermBase> List<T> listByTermType(TermType termType, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
|
148
|
|
149
|
/**
|
150
|
* Delete the given term according to the given delete configuration.
|
151
|
* In case a problem occurrs while deleting the term the result will reflect this
|
152
|
* via its status.
|
153
|
* @param term the term to delete
|
154
|
* @param config the configurator
|
155
|
* @return DeleteResult which holds the status of the deletion.
|
156
|
*/
|
157
|
public DeleteResult delete(DefinedTermBase term, TermDeletionConfigurator config);
|
158
|
|
159
|
/**
|
160
|
* Returns the term with the given idInVocabulary for the given vocabulary.
|
161
|
* If the same idInVocabulary exists with same vocabulary for multiple terms (though this is against the general
|
162
|
* contract of idInVocabulary) always the same term should be returned.
|
163
|
* @param id idInVocabulary
|
164
|
* @param vocabularyUuid uuid of vocabulary
|
165
|
* @param clazz term clazz filter on certain term classes. May be <code>null</code> for no filter.
|
166
|
* @return the term
|
167
|
* @throws IllegalArgumentException if id or vocabularyUuid is <code>null</code>
|
168
|
*/
|
169
|
public <TERM extends DefinedTermBase> TERM findByIdInVocabulary(String id, UUID vocabularyUuid, Class<TERM> clazz)
|
170
|
throws IllegalArgumentException;
|
171
|
|
172
|
/**
|
173
|
* @param termUuid
|
174
|
* @param config
|
175
|
* @return
|
176
|
*/
|
177
|
public DeleteResult delete(UUID termUuid, TermDeletionConfigurator config);
|
178
|
|
179
|
/**
|
180
|
* @param label
|
181
|
* @return
|
182
|
*/
|
183
|
public Language getLanguageByLabel(String label);
|
184
|
|
185
|
/**
|
186
|
* @param representations
|
187
|
* @return
|
188
|
*/
|
189
|
public Map<UUID, Representation> saveOrUpdateRepresentations(Collection<Representation> representations);
|
190
|
|
191
|
|
192
|
/**
|
193
|
* @param vocs
|
194
|
* @param limit
|
195
|
* @param pattern
|
196
|
* @param lang
|
197
|
* @return
|
198
|
*/
|
199
|
List<UuidAndTitleCache<NamedArea>> getUuidAndTitleCacheNamedArea(List<TermVocabulary> vocs, Integer limit, String pattern,
|
200
|
Language lang);
|
201
|
|
202
|
/**
|
203
|
* Returns all terms that are included in the given parent term resp. a part of the given term.
|
204
|
* @param parentTerm the parent term
|
205
|
* @return a collection of included terms
|
206
|
*/
|
207
|
public Collection<TermDto> getIncludesAsDto(TermDto parentTerm);
|
208
|
|
209
|
/**
|
210
|
* Returns all terms that the given term is a generalization of resp. that are a kind of the given term
|
211
|
* @param parentTerm the parent term
|
212
|
* @return a collection of included terms
|
213
|
*/
|
214
|
public Collection<TermDto> getKindOfsAsDto(TermDto parentTerm);
|
215
|
|
216
|
/**
|
217
|
* Move the given term to the given parent
|
218
|
* @param termDto the {@link TermDto} of the term to move
|
219
|
* @param parentUuid the {@link UUID} of the new parent term
|
220
|
* @param termMovePosition enum to specify the position for {@link OrderedTermBase}s in an {@link OrderedTermVocabulary}
|
221
|
*/
|
222
|
public UpdateResult moveTerm(TermDto termDto, UUID parentUuid, TermMovePosition termMovePosition);
|
223
|
|
224
|
/**
|
225
|
* Move the given term to the given parent
|
226
|
* @param termDto the {@link TermDto} of the term to move
|
227
|
* @param parentUuid the {@link UUID} of the new parent term
|
228
|
*/
|
229
|
public UpdateResult moveTerm(TermDto termDto, UUID parentUuid);
|
230
|
|
231
|
/**
|
232
|
* Creates a new term as a child of the given parent.
|
233
|
* @param termType the {@link TermType} of the term to create
|
234
|
* @param parentUuid the {@link UUID} of the parent term
|
235
|
* @param isKindOf if <code>true</code> the term will be added via a
|
236
|
* kindOf relation. Otherwise it will added via a partOf relation
|
237
|
* @return the new term
|
238
|
*/
|
239
|
public TermDto addNewTerm(TermType termType, UUID parentUuid, boolean isKindOf);
|
240
|
|
241
|
|
242
|
/**
|
243
|
* Returns a collection of {@link TermDto}s that match the given search parameters.
|
244
|
* @param title the term label that the terms have to match
|
245
|
* @param termType the termType that the terms have to match
|
246
|
* @return a collection of matching term DTOs
|
247
|
*/
|
248
|
public Collection<TermDto> findByTitleAsDto(String title, TermType termType);
|
249
|
|
250
|
/**
|
251
|
* Returns a collection of {@link TermDto}s that match the given search parameters.
|
252
|
* @param uri the {@link URI} that the terms have to match
|
253
|
* @param termLabel the term label that the terms have to match
|
254
|
* @param termType the termType that the terms have to match
|
255
|
* @return a collection of matching term DTOs
|
256
|
*/
|
257
|
public Collection<TermDto> findByUriAsDto(URI uri, String termLabel, TermType termType);
|
258
|
|
259
|
/**
|
260
|
* Returns a list of {@link UuidAndTitleCache} of named areas with IdInVocabulary matches search parameter
|
261
|
* @param vocs
|
262
|
* @param limit
|
263
|
* @param pattern
|
264
|
* @param lang
|
265
|
* @return
|
266
|
*/
|
267
|
public List<UuidAndTitleCache<NamedArea>> getUuidAndTitleCacheNamedAreaByAbbrev(List<TermVocabulary> vocs, Integer limit,
|
268
|
String pattern, Language lang, NamedAreaSearchField type);
|
269
|
|
270
|
/**
|
271
|
* Returns a list of {@link TermDto} of terms with uuid matches one of uuids in list
|
272
|
* @param uuidList
|
273
|
* @return
|
274
|
*/
|
275
|
public Collection<TermDto> findByUUIDsAsDto(List<UUID> uuidList);
|
276
|
|
277
|
|
278
|
public Collection<TermDto> findFeatureByUUIDsAsDto(List<UUID> uuidList);
|
279
|
|
280
|
|
281
|
public Collection<TermDto> findFeatureByTitleAsDto(String title);
|
282
|
|
283
|
public Country getCountryByIso(String iso639);
|
284
|
|
285
|
public List<Country> getCountryByName(String name);
|
286
|
|
287
|
}
|