/
NameUsageService.java
185 lines (168 loc) · 7.32 KB
/
NameUsageService.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/*
* Copyright 2020 Global Biodiversity Information Facility (GBIF)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gbif.api.service.checklistbank;
import org.gbif.api.model.checklistbank.NameUsage;
import org.gbif.api.model.checklistbank.NameUsageMetrics;
import org.gbif.api.model.checklistbank.ParsedName;
import org.gbif.api.model.checklistbank.VerbatimNameUsage;
import org.gbif.api.model.common.paging.Pageable;
import org.gbif.api.model.common.paging.PagingResponse;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
import javax.annotation.Nullable;
/**
* This is the public interface providing methods for retrieving name usages in general, no matter if nub or
* checklist usage.
*
* @see NameUsage
*/
public interface NameUsageService {
/**
* Attempt to find a name usage matching the passed key.
* The given Locale determines the name used for the NameUsage.vernacularName property
* with null ignoring any vernacular name.
*
* @param taxonKey that identifies a name usage
* @param locale the locale's language determines the vernacular name to use for a usage.
* Use null to not load any common name
*
* @return a matching name usage, or null if no name usage found
*/
@Nullable
NameUsage get(int taxonKey, @Nullable Locale locale);
/**
* Gets the parsed name representation of a given name usage.
*
* @param taxonKey that identifies a name usage
*
* @return the parsed name of the name usage or null if none can be found
*/
@Nullable
ParsedName getParsedName(int taxonKey);
/**
* Gets the metrics for a given name usage.
*
* @param taxonKey that identifies a name usage
*
* @return the usage metrics of the name usage or null if none can be found
*/
@Nullable
NameUsageMetrics getMetrics(int taxonKey);
/**
* Returns the verbatim data for the usage or null if its a generated usage having no verbatim data.
* This happens for all nub usages and some other usages which have a non SOURCE origin.
*
* @return verbatim data for the usage or null
*/
@Nullable
VerbatimNameUsage getVerbatim(int taxonKey);
/**
* Page through all usages across all or one checklists.
*
* @param datasetKey the optional checklist key to limit paging to.
* @param sourceId the optional checklist key to limit paging to.
* @param locale the locale's language determines the vernacular name to use for a usage
* Use null to not load any common name
* @param page paging parameters or null for first page with default size
*
* @return Paged list of usages
*/
PagingResponse<NameUsage> list(Locale locale, @Nullable UUID datasetKey, @Nullable String sourceId,
@Nullable Pageable page);
/**
* Page through all usages with a given canonical name across all or some checklists.
*
* @param canonicalName the canonical name of a name usage.
* @param locale the locale's language determines the vernacular name to use for a usage
* Use null to not load any common name
* @param datasetKey the optional list of checklist keys to limit paging to.
* @param page paging parameters or null for first page with default size
*
* @return Paged list of usages matching the exact canonical name
*/
PagingResponse<NameUsage> listByCanonicalName(Locale locale, String canonicalName, @Nullable Pageable page,
@Nullable UUID ... datasetKey);
/**
* Lists all accepted child name usages for a given parent.
*
* @param parentKey that identifies the parent name usage
* @param locale the locale's language determines the vernacular name to use for a usage
* Use null to not load any common name
* @param page paging parameters or null for first page with default size
*
* @return Paged list of child usages.
*/
PagingResponse<NameUsage> listChildren(int parentKey, Locale locale, @Nullable Pageable page);
/**
* Lists the complete parental hierarchy of a name usage regardless of their ranks.
*
* @param taxonKey that identifies the name usage to show parents of
* @param locale the locale's language determines the vernacular name to use for a usage
* Use null to not load any common name
*
* @return List of parent usages with the last usage being the immediate parent
*/
List<NameUsage> listParents(int taxonKey, Locale locale);
/**
* Lists all related checklist usages for a given nub usage.
*
* @param taxonKey that identifies a nub usage
* @param locale the locale's language determines the vernacular name to use for a usage
* Use null to not load any common name
* @param page paging parameters or null for first page with default size
* @param datasetKey Optional list of checklist keys to restrict related usages to
*
* @return Paged list of related name usages.
*/
PagingResponse<NameUsage> listRelated(int taxonKey, Locale locale, @Nullable Pageable page, @Nullable UUID... datasetKey);
/**
* Lists all root usages for a given checklist, i.e. accepted usages without a parent.
* To list the 8 root kingdoms of the nub use the respective datasetKey,
* @see org.gbif.api.model.Constants#NUB_DATASET_KEY
*
* @param datasetKey the registered dataset key for the checklist in question
* @param locale the locale's language determines the vernacular name to use for a usage
* Use null to not load any common name
* @param page paging parameters or null for first page with default size
*
* @return Paged list of root name usages.
*
*/
PagingResponse<NameUsage> listRoot(UUID datasetKey, Locale locale, @Nullable Pageable page);
/**
* Lists all synonym name usages for a given accepted name usage.
*
* @param taxonKey that identifies any name usage
* @param locale the locale's language determines the vernacular name to use for a usage
* Use null to not load any common name
* @param page paging parameters or null for first page with default size
*
* @return Paged list of synonym name usages.
*/
PagingResponse<NameUsage> listSynonyms(int taxonKey, Locale locale, @Nullable Pageable page);
/**
* Lists all combinations or names at different rank that are based on this basionym, i.e. a list of all name usages sharing the same basionym (homotypical group).
* The basionym itself is not included in this list.
*
* @param basionymKey the name usage key of the basionym
* @param locale the locale's language determines the vernacular name to use for a usage
* Use null to not load any common name
*
* @return List of name usages sharing the same basionym.
*/
List<NameUsage> listCombinations(int basionymKey, Locale locale);
}