cleanup
[cdmlib.git] / cdmlib-persistence / src / main / java / eu / etaxonomy / cdm / persistence / dao / term / IDefinedTermDao.java
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 package eu.etaxonomy.cdm.persistence.dao.term;
10
11 import java.net.URI;
12 import java.util.Collection;
13 import java.util.Enumeration;
14 import java.util.List;
15 import java.util.Locale;
16 import java.util.Set;
17 import java.util.UUID;
18
19 import eu.etaxonomy.cdm.model.common.Language;
20 import eu.etaxonomy.cdm.model.location.Country;
21 import eu.etaxonomy.cdm.model.location.NamedArea;
22 import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
23 import eu.etaxonomy.cdm.model.location.NamedAreaType;
24 import eu.etaxonomy.cdm.model.media.Media;
25 import eu.etaxonomy.cdm.model.metadata.NamedAreaSearchField;
26 import eu.etaxonomy.cdm.model.term.DefinedTermBase;
27 import eu.etaxonomy.cdm.model.term.TermType;
28 import eu.etaxonomy.cdm.model.term.TermVocabulary;
29 import eu.etaxonomy.cdm.persistence.dao.common.IIdentifiableDao;
30 import eu.etaxonomy.cdm.persistence.dao.common.ITitledDao;
31 import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;
32 import eu.etaxonomy.cdm.persistence.dto.TermDto;
33 import eu.etaxonomy.cdm.persistence.query.MatchMode;
34 import eu.etaxonomy.cdm.persistence.query.OrderHint;
35
36 public interface IDefinedTermDao
37 extends IIdentifiableDao<DefinedTermBase>, ITitledDao<DefinedTermBase>{
38
39 /**
40 * @param iso639 a two or three letter language code according to iso639-1 or iso639-2
41 * @return the Language or null
42 */
43 //TODO refactor typo:
44 public Language getLanguageByIso(String iso639);
45
46 public List<Language> getLanguagesByIso(List<String> iso639List);
47
48 public List<Language> getLanguagesByLocale(Enumeration<Locale> locales);
49
50 /**
51 * Returns the country with the isoCode iso639, works only with string length 2 or 3
52 *
53 * @param iso639 the isoCode of the searched country
54 *
55 * @return country with isoCode iso639
56 */
57 public Country getCountryByIso(String iso639);
58
59 public <TYPE extends DefinedTermBase> List<TYPE> getDefinedTermByRepresentationText(String text, Class<TYPE> clazz );
60
61 public <TYPE extends DefinedTermBase> List<TYPE> getDefinedTermByRepresentationText(String text, Class<TYPE> clazz, Integer pageSize,Integer pageNumber);
62
63 public long countDefinedTermByRepresentationText(String text, Class<? extends DefinedTermBase> clazz);
64
65 public <TYPE extends DefinedTermBase> List<TYPE> getDefinedTermByRepresentationAbbrev(String text, Class<TYPE> clazz, Integer pageSize,Integer pageNumber);
66
67 public long countDefinedTermByRepresentationAbbrev(String text, Class<? extends DefinedTermBase> clazz);
68
69 /**
70 * Returns a List of Media that represent a given DefinedTerm instance
71 *
72 * @param definedTerm the definedTerm represented by these media
73 * @param pageSize The maximum number of media returned (can be null for all related media)
74 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
75 * @return a List of media instances
76 */
77 public List<Media> getMedia(DefinedTermBase definedTerm, Integer pageSize, Integer pageNumber);
78
79 /**
80 * Returns a count of the Media that represent a given
81 * DefinedTermBase instance
82 *
83 * @param definedTerm the definedTerm represented by these media
84 * @return a count of Media entities
85 */
86 public long countMedia(DefinedTermBase definedTerm);
87
88 /**
89 * Returns a List of NamedArea instances (optionally filtered by type or level)
90 *
91 * @param level restrict the result set to named areas of a certain level (can be null)
92 * @param type restrict the result set to named areas of a certain type (can be null)
93 * @param pageSize The maximum number of namedAreas returned (can be null for all named areas)
94 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
95 * @return a List of named areas
96 */
97 public List<NamedArea> list(NamedAreaLevel level, NamedAreaType type, Integer pageSize, Integer pageNumber);
98
99 /**
100 * @param level
101 * @param type
102 * @param pageSize
103 * @param pageNumber
104 * @param orderHints
105 * @param propertyPaths
106 * @return
107 */
108 public List<NamedArea> list(NamedAreaLevel level, NamedAreaType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
109
110 /**
111 * Returns a count of NamedArea instances (optionally filtered by type or level)
112 *
113 * @param level restrict the result set to named areas of a certain level (can be null)
114 * @param type restrict the result set to named areas of a certain type (can be null)
115 * @return a count of named areas
116 */
117 public long count(NamedAreaLevel level, NamedAreaType type);
118
119 /**
120 * Return a list of terms which are specializations of a given definedTerm
121 *
122 * @param definedTerm The term which is a generalization of the terms returned
123 * @param pageSize The maximum number of terms returned (can be null for all specializations)
124 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
125 * @return a List of DefinedTerms
126 */
127 public <T extends DefinedTermBase> List<T> getGeneralizationOf(T definedTerm, Integer pageSize, Integer pageNumber);
128
129 /**
130 * Return a count of terms which are specializations of a given definedTerm
131 *
132 * @param definedTerm The term which is a generalization of the terms returned
133 * @return a count of DefinedTerms
134 */
135 public <T extends DefinedTermBase> long countGeneralizationOf(T definedTerm);
136
137 /**
138 * Return a List of distinct terms which include the terms supplied
139 *
140 * @param definedTerms the set of terms which are part of the terms of interest
141 * @param pageSize The maximum number of terms returned (can be null for all terms)
142 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
143 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
144 * @return a List of DefinedTerms
145 */
146 public <T extends DefinedTermBase> List<T> getPartOf(Set<T> definedTerms, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
147
148 /**
149 * Return a count of distinct terms which include the terms supplied
150 *
151 * @param definedTerms the set of terms which are part of the terms of interest
152 * @return a count of DefinedTerms
153 */
154 public <T extends DefinedTermBase> long countPartOf(Set<T> definedTerms);
155
156 /**
157 * Return a List of terms which are part of the terms supplied
158 *
159 * @param definedTerms the collection of terms which include the terms of interest
160 * @param pageSize The maximum number of terms returned (can be null for all terms)
161 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
162 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
163 * @return a List of DefinedTerms
164 */
165 public <T extends DefinedTermBase> List<T> getIncludes(Collection<T> definedTerms, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
166
167 /**
168 * Return a count of terms which are part of the terms supplied
169 *
170 * @param definedTerms the set of terms which include the terms of interest
171 * @return a count of DefinedTerms
172 */
173 public <T extends DefinedTermBase> long countIncludes(Collection<T> definedTerms);
174
175 public DefinedTermBase findByUri(URI uri);
176
177 /**
178 * Retrieves all {@link DefinedTermBase}s with the given {@link TermType}
179 * @param termType the term type to filter the terms
180 * @param limit
181 * @param start
182 * @param orderHints
183 * @param propertyPaths
184 * @return a list containing the terms
185 */
186 public <T extends DefinedTermBase> List<T> listByTermType(TermType termType, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
187
188 public <TERM extends DefinedTermBase> List<TERM> listByTermClass(Class<TERM> clazz, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
189
190 /**
191 * Returns a term or a list of terms depending of the label/id used in its vocabulary.
192 * @param idInVoc
193 * @param vocUuid
194 * @param clazz
195 * @param pageSize
196 * @param pageNumber
197 * @return
198 */
199 public <TERM extends DefinedTermBase> List<TERM> getDefinedTermByIdInVocabulary(String idInVoc, UUID vocUuid, Class<TERM> clazz, Integer pageSize, Integer pageNumber);
200
201 /**
202 * @param clazz
203 * @param vocs
204 * @param limit
205 * @param pattern
206 * @return
207 */
208 public List<NamedArea> listNamedArea(List<TermVocabulary> vocs, Integer limit,
209 String pattern);
210
211 /**
212 * Returns all terms that are included in the given parent term resp. a part of the given term.
213 * @param parentTerm the parent term
214 * @return a collection of included terms
215 */
216 public Collection<TermDto> getIncludesAsDto(TermDto parentTerm);
217
218 /**
219 * Returns all terms that the given term is a generalization of resp. that are a kind of the given term
220 * @param parentTerm the parent term
221 * @return a collection of included terms
222 */
223 public Collection<TermDto> getKindOfsAsDto(TermDto parentTerm);
224
225
226 /**
227 * Returns a collection of {@link TermDto}s that match the given search parameters.
228 * @param title the term label that the terms have to match
229 * @param termType the termType that the terms have to match
230 * @return a collection of matching term DTOs
231 */
232 public Collection<TermDto> findByTitleAsDto(String title, TermType termType);
233
234 /**
235 * Returns a collection of {@link TermDto}s that match the given search parameters.
236 * @param uri the {@link URI} that the terms have to match
237 * @param termLabel the term label that the terms have to match
238 * @param termType the termType that the terms have to match
239 * @return a collection of matching term DTOs
240 */
241 public Collection<TermDto> findByUriAsDto(URI uri, String termLabel, TermType termType);
242
243 /**
244 * Returns the number of terms in the vocabularies vocs filteres by the given pattern
245 * @param vocs
246 * @param pattern
247 * @return
248 */
249 public long count(List<TermVocabulary> vocs, String pattern);
250
251 /**
252 * @param vocs
253 * @param pageNumber
254 * @param limit
255 * @param pattern
256 * @return
257 */
258 public List<NamedArea> listNamedArea(List<TermVocabulary> vocs, Integer pageNumber, Integer limit, String pattern, MatchMode matchMode);
259
260 /**
261 * @param vocs
262 * @param limit
263 * @param pattern
264 * @return
265 */
266 public List<NamedArea> listNamedAreaByAbbrev(List<TermVocabulary> vocs, Integer pageNumber, Integer limit, String pattern, MatchMode matchmode, NamedAreaSearchField type);
267
268 /**
269 * @param vocs
270 * @param limit
271 * @param pattern
272 * @return
273 */
274 public List<NamedArea> listNamedAreaByAbbrev(List<TermVocabulary> vocs, Integer limit, String pattern, NamedAreaSearchField type);
275
276 /**
277 * Returns all states for all supportedCategoricalEnumeration of this categorical feature
278 * @param featureUuid the feature which has to support categorical data
279 * @return list of all supported states
280 */
281 public List<TermDto> getSupportedStatesForFeature(UUID featureUuid);
282
283 /**
284 * @param uuidList
285 * @return
286 */
287 public Collection<TermDto> findByUUIDsAsDto(List<UUID> uuidList);
288
289
290 /**
291 * @param uuidList
292 * @return
293 */
294 public Collection<TermDto> findByTypeAsDto(TermType termType);
295
296 public Collection<TermDto> findFeatureByUUIDsAsDto(List<UUID> uuidList);
297 public Collection<TermDto> findFeatureByTitleAsDto(String pattern);
298
299 }