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
;
13 import java
.util
.Collection
;
14 import java
.util
.Enumeration
;
15 import java
.util
.List
;
16 import java
.util
.Locale
;
19 import java
.util
.UUID
;
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
.DefinedTermBase
;
25 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
26 import eu
.etaxonomy
.cdm
.model
.common
.LanguageString
;
27 import eu
.etaxonomy
.cdm
.model
.common
.LanguageStringBase
;
28 import eu
.etaxonomy
.cdm
.model
.common
.OrderedTermBase
;
29 import eu
.etaxonomy
.cdm
.model
.common
.OrderedTermVocabulary
;
30 import eu
.etaxonomy
.cdm
.model
.common
.Representation
;
31 import eu
.etaxonomy
.cdm
.model
.common
.TermType
;
32 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
33 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
34 import eu
.etaxonomy
.cdm
.model
.location
.NamedAreaLevel
;
35 import eu
.etaxonomy
.cdm
.model
.location
.NamedAreaType
;
36 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
37 import eu
.etaxonomy
.cdm
.persistence
.dao
.initializer
.IBeanInitializer
;
38 import eu
.etaxonomy
.cdm
.persistence
.dto
.TermDto
;
39 import eu
.etaxonomy
.cdm
.persistence
.dto
.UuidAndTitleCache
;
40 import eu
.etaxonomy
.cdm
.persistence
.query
.OrderHint
;
42 public interface ITermService
extends IIdentifiableEntityService
<DefinedTermBase
> {
45 * Returns a term according to it's uri
49 public DefinedTermBase
getByUri(URI uri
);
51 public UUID
saveLanguageData(LanguageStringBase languageData
);
53 public List
<LanguageString
> getAllLanguageStrings(int limit
, int start
);
55 public List
<Representation
> getAllRepresentations(int limit
, int start
);
57 public Language
getLanguageByIso(String iso639
);
59 public List
<Language
> getLanguagesByLocale(Enumeration
<Locale
> locales
);
61 public NamedArea
getAreaByTdwgAbbreviation(String tdwgAbbreviation
);
64 * Returns a paged list of Media that represent a given DefinedTerm instance
66 * @param definedTerm the definedTerm represented by these media
67 * @param pageSize The maximum number of media returned (can be null for all related media)
68 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
69 * @return a Pager of media instances
71 public Pager
<Media
> getMedia(DefinedTermBase definedTerm
, Integer pageSize
, Integer pageNumber
);
74 * Returns a paged list of NamedArea instances (optionally filtered by type or level)
76 * @param level restrict the result set to named areas of a certain level (can be null)
77 * @param type restrict the result set to named areas of a certain type (can be null)
78 * @param pageSize The maximum number of namedAreas returned (can be null for all named areas)
79 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
80 * @return a Pager of named areas
82 public Pager
<NamedArea
> list(NamedAreaLevel level
, NamedAreaType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
85 * Return a paged list of terms which are specializations of a given definedTerm
87 * @param definedTerm The term which is a generalization of the terms returned
88 * @param pageSize The maximum number of terms returned (can be null for all specializations)
89 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
90 * @return a Pager of DefinedTerms
92 public <T
extends DefinedTermBase
> Pager
<T
> getGeneralizationOf(T definedTerm
, Integer pageSize
, Integer pageNumber
);
95 * Return a paged list of distinct terms which include the terms supplied
97 * @param definedTerms the set of terms which are part of the terms of interest
98 * @param pageSize The maximum number of terms returned (can be null for all terms)
99 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
100 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
101 * @return a Pager of DefinedTerms
103 public <T
extends DefinedTermBase
> Pager
<T
> getPartOf(Set
<T
> definedTerms
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
106 * Return a paged list of terms which are part of the terms supplied
108 * @param definedTerms the set of terms which include the terms of interest
109 * @param pageSize The maximum number of terms returned (can be null for all terms)
110 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
111 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
112 * @return a Pager of DefinedTerms
114 public <T
extends DefinedTermBase
> Pager
<T
> getIncludes(Collection
<T
> definedTerms
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
117 * Return a paged list of terms which have representations that match the supplied string in the text (description)
119 * @param label a string to match (exactly)
120 * @param pageSize The maximum number of terms returned (can be null for all terms)
121 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
122 * @return a Pager of DefinedTerms
124 public <T
extends DefinedTermBase
> Pager
<T
> findByRepresentationText(String label
, Class
<T
> clazz
, Integer pageSize
, Integer pageNumber
);
127 * Return a paged list of terms which have representations that match the supplied string in the abbreviated label
129 * @param label a string to match (exactly)
130 * @param pageSize The maximum number of terms returned (can be null for all terms)
131 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
132 * @return a Pager of DefinedTerms
134 public <T
extends DefinedTermBase
> Pager
<T
> findByRepresentationAbbreviation(String abbrev
, Class
<T
> clazz
, Integer pageSize
, Integer pageNumber
);
137 * Retrieves all {@link DefinedTermBase}s with the given {@link TermType}
138 * @param termType the term type to filter the terms
142 * @param propertyPaths
143 * @return a list containing the terms
145 public <T
extends DefinedTermBase
> List
<T
> listByTermType(TermType termType
, Integer limit
, Integer start
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
148 * Delete the given term according to the given delete configuration.
149 * In case a problem occurrs while deleting the term the result will reflect this
151 * @param term the term to delete
152 * @param config the configurator
153 * @return DeleteResult which holds the status of the deletion.
155 public DeleteResult
delete(DefinedTermBase term
, TermDeletionConfigurator config
);
158 * Returns the term with the given idInVocabulary for the given vocabulary.
159 * If the same idInVocabulary exists with same vocabulary for multiple terms (though this is against the general
160 * contract of idInVocabulary) always the same term should be returned.
161 * @param id idInVocabulary
162 * @param vocabularyUuid uuid of vocabulary
163 * @param clazz term clazz filter on certain term classes. May be <code>null</code> for no filter.
165 * @throws IllegalArgumentException if id or vocabularyUuid is <code>null</code>
167 public <TERM
extends DefinedTermBase
> TERM
findByIdInVocabulary(String id
, UUID vocabularyUuid
, Class
<TERM
> clazz
)
168 throws IllegalArgumentException
;
175 public DeleteResult
delete(UUID termUuid
, TermDeletionConfigurator config
);
181 public Language
getLanguageByLabel(String label
);
184 * @param representations
187 public Map
<UUID
, Representation
> saveOrUpdateRepresentations(Collection
<Representation
> representations
);
197 List
<UuidAndTitleCache
<NamedArea
>> getUuidAndTitleCache(List
<TermVocabulary
> vocs
, Integer limit
, String pattern
,
201 * Returns all terms that are included in the given parent term resp. a part of the given term.
202 * @param parentTerm the parent term
203 * @return a collection of included terms
205 public Collection
<TermDto
> getIncludesAsDto(TermDto parentTerm
);
208 * Returns all terms that the given term is a generalization of resp. that are a kind of the given term
209 * @param parentTerm the parent term
210 * @return a collection of included terms
212 public Collection
<TermDto
> getKindOfsAsDto(TermDto parentTerm
);
215 * Move the given term to the given parent
216 * @param termDto the {@link TermDto} of the term to move
217 * @param parentUuid the {@link UUID} of the new parent term
218 * @param termMovePosition enum to specify the position for {@link OrderedTermBase}s in an {@link OrderedTermVocabulary}
220 public void moveTerm(TermDto termDto
, UUID parentUuid
, TermMovePosition termMovePosition
);
223 * Move the given term to the given parent
224 * @param termDto the {@link TermDto} of the term to move
225 * @param parentUuid the {@link UUID} of the new parent term
227 public void moveTerm(TermDto termDto
, UUID parentUuid
);
230 * Creates a new term as a child of the given parent.
231 * @param termType the {@link TermType} of the term to create
232 * @param parentUuid the {@link UUID} of the parent term
233 * @param isKindOf if <code>true</code> the term will be added via a
234 * kindOf relation. Otherwise it will added via a partOf relation
235 * @return the new term
237 public TermDto
addNewTerm(TermType termType
, UUID parentUuid
, boolean isKindOf
);