fixes #499
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / ITermService.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
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.
9 */
10
11 package eu.etaxonomy.cdm.api.service;
12
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.pager.Pager;
22 import eu.etaxonomy.cdm.model.common.DefinedTermBase;
23 import eu.etaxonomy.cdm.model.common.Language;
24 import eu.etaxonomy.cdm.model.common.LanguageString;
25 import eu.etaxonomy.cdm.model.common.LanguageStringBase;
26 import eu.etaxonomy.cdm.model.common.Representation;
27 import eu.etaxonomy.cdm.model.common.TermVocabulary;
28 import eu.etaxonomy.cdm.model.common.VocabularyType;
29 import eu.etaxonomy.cdm.model.location.NamedArea;
30 import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
31 import eu.etaxonomy.cdm.model.location.NamedAreaType;
32 import eu.etaxonomy.cdm.model.media.Media;
33 import eu.etaxonomy.cdm.persistence.dao.BeanInitializer;
34
35 public interface ITermService extends IService<DefinedTermBase> {
36
37 public DefinedTermBase getTermByUri(String uri);
38
39 // FIXME candidate for harmonization?
40 public DefinedTermBase getTermByUuid(UUID uuid);
41
42 /**
43 * FIXME candidate for harmonization?
44 * @param limit
45 * @param start
46 * @return
47 */
48 public List<DefinedTermBase> getAllDefinedTerms(int limit, int start);
49
50 public TermVocabulary getVocabulary(UUID vocabularyUuid);
51
52 public TermVocabulary getVocabulary(VocabularyType vocabularyType);
53
54 public Set<TermVocabulary> listVocabularies(Class termClass);
55
56 /**
57 * Returns Language Vocabulary
58 * @return
59 */
60 public TermVocabulary<Language> getLanguageVocabulary();
61
62 public UUID saveTermVocabulary(TermVocabulary termVocabulary);
63
64 /**
65 * FIXME candidate for harmonization?
66 * @param termBase
67 * @return
68 */
69 public UUID saveTerm(DefinedTermBase termBase);
70
71 /**
72 * FIXME candidate for harmonization?
73 * @param termBaseCollection
74 * @return
75 */
76 public Map<UUID, DefinedTermBase> saveTermsAll(Collection<? extends DefinedTermBase> termBaseCollection);
77
78 public List<TermVocabulary<DefinedTermBase>> getAllTermVocabularies(int limit, int start);
79
80 public Map<UUID, TermVocabulary<DefinedTermBase>>
81 saveTermVocabulariesAll(Collection<TermVocabulary<DefinedTermBase>> termVocabularies);
82
83 public List<Representation> getAllRepresentations(int limit, int start);
84
85 public Map<UUID, LanguageStringBase> saveLanguageDataAll(Collection<LanguageStringBase> languageData);
86
87 public UUID saveLanguageData(LanguageStringBase languageData);
88
89 public List<LanguageString> getAllLanguageStrings(int limit, int start);
90
91 public Map<UUID, LanguageStringBase>
92 saveLanguageStringBasesAll(Collection<LanguageStringBase> languageStringBases);
93
94 public Language getLanguageByIso(String iso639);
95
96 public List<Language> getLanguagesByLocale(Enumeration<Locale> locales);
97
98 public NamedArea getAreaByTdwgAbbreviation(String tdwgAbbreviation);
99
100 /**
101 * Returns a paged list of Media that represent a given DefinedTerm instance
102 *
103 * @param definedTerm the definedTerm represented by these media
104 * @param pageSize The maximum number of media returned (can be null for all related media)
105 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
106 * @return a Pager of media instances
107 */
108 public Pager<Media> getMedia(DefinedTermBase definedTerm, Integer pageSize, Integer pageNumber);
109
110 /**
111 * Returns a paged list 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 * @param pageSize The maximum number of namedAreas returned (can be null for all named areas)
116 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
117 * @return a Pager of named areas
118 */
119 public Pager<NamedArea> list(NamedAreaLevel level, NamedAreaType type, Integer pageSize, Integer pageNumber);
120
121 /**
122 * Return a paged list of terms which are specializations of a given definedTerm
123 *
124 * @param definedTerm The term which is a generalization of the terms returned
125 * @param pageSize The maximum number of terms returned (can be null for all specializations)
126 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
127 * @return a Pager of DefinedTerms
128 */
129 public <T extends DefinedTermBase> Pager<T> getGeneralizationOf(T definedTerm, Integer pageSize, Integer pageNumber);
130
131 /**
132 * Return a paged list of distinct terms which include the terms supplied
133 *
134 * @param definedTerms the set of terms which are part of the terms of interest
135 * @param pageSize The maximum number of terms returned (can be null for all terms)
136 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
137 * @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}
138 * @return a Pager of DefinedTerms
139 */
140 public <T extends DefinedTermBase> Pager<T> getPartOf(Set<T> definedTerms, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
141
142 /**
143 * Return a paged list of terms which are part of the terms supplied
144 *
145 * @param definedTerms the set of terms which include the terms of interest
146 * @param pageSize The maximum number of terms returned (can be null for all terms)
147 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
148 * @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}
149 * @return a Pager of DefinedTerms
150 */
151 public <T extends DefinedTermBase> Pager<T> getIncludes(Set<T> definedTerms, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
152 }