Skip to content

Commit 74178d7

Browse files
author
John Waller
committed
adding support for institution_search
1 parent 40e3dfe commit 74178d7

File tree

7 files changed

+634
-3
lines changed

7 files changed

+634
-3
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export(gbif_oai_list_sets)
7171
export(gbif_photos)
7272
export(gbif_wkt2bbox)
7373
export(installations)
74+
export(institution_search)
7475
export(lit_count)
7576
export(lit_export)
7677
export(lit_search)

R/collection_search.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ collection_search <- function(
124124
assert(gbifRegion,"character")
125125
assert(machineTagNamespace,"character")
126126
assert(machineTagName,"character")
127-
assert(machineTagValue,"character")
128127
assert(identifierType,"character")
129128
assert(active,"logical")
130129
assert(displayOnNHCPortal,"logical")

R/institution_search.R

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
#' Search GRSciColl institutions
2+
#'
3+
#' @param query (character) Simple full text search parameter. The value for
4+
#' this parameter can be a simple word or a phrase. Wildcards are not supported
5+
#' @param type (character) Type of a GrSciColl institution
6+
#' Available values : BIOMEDICAL_RESEARCH_INSTITUTE, BOTANICAL_GARDEN,
7+
#' HERBARIUM, LIVING_ORGANISM_COLLECTION, MEDICAL_RESEARCH_INSTITUTE, MUSEUM,
8+
#' MUSEUM_HERBARIUM_PRIVATE_NON_PROFIT, OTHER_INSTITUTIONAL_TYPE,
9+
#' OTHER_TYPE_RESEARCH_INSTITUTION_BIOREPOSITORY, UNIVERSITY_COLLEGE,
10+
#' ZOO_AQUARIUM
11+
#' @param institutionalGovernance (character) Instutional governance of a
12+
#' GrSciColl institution Available values : ACADEMIC_FEDERAL,
13+
#' ACADEMIC_FOR_PROFIT, ACADEMIC_LOCAL, ACADEMIC_NON_PROFIT, ACADEMIC_STATE,
14+
#' FEDERAL, FOR_PROFIT, LOCAL, NON_PROFIT, OTHER, STATE.
15+
#' @param disciplines (character) Discipline of a GrSciColl institution.
16+
#' Check available values :
17+
#' https://techdocs.gbif.org/en/openapi/v1/registry#/Institutions/listInstitutions
18+
#' @param name (character) Name of a GrSciColl institution or collection
19+
#' @param fuzzyName (character) It searches by name fuzzily so the parameter
20+
#' doesn't have to be the exact name.
21+
#' @param numberSpecimens (character) Number of specimens. It supports ranges
22+
#' and a `*` can be used as a wildcard.
23+
#' @param occurrenceCount (character) Count of occurrences linked. It supports
24+
#' ranges and a `*` can be used as a wildcard.
25+
#' @param typeSpecimenCount (character) Count of type specimens linked. It
26+
#' supports ranges and a `*` can be used as a wildcard.
27+
#' @param sourceId (character) sourceId of MasterSourceMetadata
28+
#' @param source (character) Source attribute of MasterSourceMetadata
29+
#' Available values : DATASET, ORGANIZATION, IH_IRN
30+
#' @param code (character) Code of a GrSciColl institution or collection.
31+
#' @param alternativeCode (character) Alternative code of a GrSciColl institution.
32+
#' @param contact (character) Filters collections and institutions whose
33+
#' contacts contain the person key specified.
34+
#' @param institutionKey (character) Keys of institutions to filter by.
35+
#' @param country (character) Filters by country given as a ISO 639-1 (2 letter)
36+
#' country code.
37+
#' @param city (character) Filters by the city of the address. It searches in both the
38+
#' physical and the mailing address.
39+
#' @param gbifRegion (character) Filters by a gbif region. Available values : AFRICA, ASIA,
40+
#' EUROPE, NORTH_AMERICA, OCEANIA, LATIN_AMERICA, ANTARCTICA.
41+
#' @param machineTagNamespace (character) Filters for entities with a machine
42+
#' tag in the specified namespace.
43+
#' @param machineTagName (character) Filters for entities with a machine tag
44+
#' with the specified name (use in combination with the machineTagNamespace
45+
#' parameter).
46+
#' @param machineTagValue (character) Filters for entities with a machine tag
47+
#' with the specified value (use in combination with the machineTagNamespace and
48+
#' machineTagName parameters).
49+
#' @param identifier (character) An identifier of the type given by the
50+
#' `identifierType` parameter, for example a DOI or UUID.
51+
#' @param identifierType (character) An identifier type for the
52+
#' identifier parameter.
53+
#' Available values : URL, LSID, HANDLER, DOI, UUID, FTP, URI, UNKNOWN,
54+
#' GBIF_PORTAL, GBIF_NODE, GBIF_PARTICIPANT, GRSCICOLL_ID, GRSCICOLL_URI,
55+
#' IH_IRN, ROR, GRID, CITES, SYMBIOTA_UUID, WIKIDATA, NCBI_BIOCOLLECTION, ISIL,
56+
#' CLB_DATASET_KEY.
57+
#' @param active (logical) Active status of a GrSciColl institution or collection.
58+
#' @param displayOnNHCPortal (logical) Flag to show this record in the NHC
59+
#' portal.
60+
#' @param masterSourceType (character) The master source type of a GRSciColl
61+
#' institution or collection. Available values : GRSCICOLL, GBIF_REGISTRY, IH.
62+
#' @param replacedBy (character) Key of the entity that replaced another entity.
63+
#' @param sortBy (character) Field to sort the results by. It only supports the
64+
#' fields contained in the enum. Available values : NUMBER_SPECIMENS.
65+
#' @param sortOrder (character) Sort order to use with the sortBy parameter.
66+
#' Available values : ASC, DESC.
67+
#' @param offset (numeric) Determines the offset for the search results.
68+
#' @param limit (numeric) Controls the number of results in the page.
69+
#' Default 20.
70+
#' @param curlopts (list) curlopts options passed on to [crul::HttpClient].
71+
#'
72+
#' @return A `list`
73+
#' @export
74+
#'
75+
#' @examples \dontrun{
76+
#' institution_search(query="Kansas",limit=1)
77+
#' institution_search(numberSpecimens = "1000,*",limit=2)
78+
#' institution_search(source = "IH_IRN")
79+
#' institution_search(country = "US;GB")
80+
#' institution_search(typeSpecimenCount = "10,100")
81+
#'
82+
#' }
83+
institution_search <- function(
84+
query = NULL,
85+
type = NULL,
86+
institutionalGovernance = NULL,
87+
disciplines = NULL,
88+
name = NULL,
89+
fuzzyName = NULL,
90+
numberSpecimens = NULL,
91+
occurrenceCount = NULL,
92+
typeSpecimenCount = NULL,
93+
sourceId = NULL,
94+
source = NULL,
95+
code = NULL,
96+
alternativeCode = NULL,
97+
contact = NULL,
98+
institutionKey = NULL,
99+
country = NULL,
100+
city = NULL,
101+
gbifRegion = NULL,
102+
machineTagNamespace = NULL,
103+
machineTagName = NULL,
104+
machineTagValue = NULL,
105+
identifier = NULL,
106+
identifierType = NULL,
107+
active = NULL,
108+
displayOnNHCPortal = NULL,
109+
masterSourceType = NULL,
110+
replacedBy = NULL,
111+
sortBy = NULL,
112+
sortOrder = NULL,
113+
offset = NULL,
114+
limit = NULL,
115+
curlopts = list()
116+
) {
117+
assert(query, "character")
118+
assert(type, "character")
119+
assert(institutionalGovernance, "character")
120+
assert(disciplines, "character")
121+
assert(name, "character")
122+
assert(fuzzyName, "character")
123+
assert(source, "character")
124+
assert(sourceId, "character")
125+
assert(code, "character")
126+
assert(alternativeCode, "character")
127+
assert(contact, "character")
128+
assert(institutionKey, "character")
129+
assert(country, "character")
130+
assert(city, "character")
131+
assert(gbifRegion, "character")
132+
assert(machineTagNamespace, "character")
133+
assert(machineTagName, "character")
134+
assert(identifierType, "character")
135+
assert(active, "logical")
136+
assert(displayOnNHCPortal, "logical")
137+
assert(masterSourceType, "character")
138+
assert(replacedBy, "character")
139+
assert(sortBy, "character")
140+
assert(sortOrder, "character")
141+
assert(offset, "numeric")
142+
assert(limit, "numeric")
143+
144+
# check for valid values
145+
if(!is.null(sortBy)) {
146+
match.arg(sortBy, c("NUMBER_SPECIMENS"))
147+
}
148+
if(!is.null(sortOrder)) {
149+
match.arg(sortOrder, c("ASC", "DESC"))
150+
}
151+
152+
args <- as.list(
153+
rgbif_compact(c(
154+
q = query,
155+
numberSpecimens = numberSpecimens,
156+
occurrenceCount = occurrenceCount,
157+
typeSpecimenCount = typeSpecimenCount,
158+
active = active,
159+
displayOnNHCPortal = displayOnNHCPortal,
160+
replacedBy = replacedBy,
161+
sortBy = sortBy,
162+
sortOrder = sortOrder,
163+
offset = offset,
164+
limit = limit
165+
)))
166+
167+
args <- rgbif_compact(
168+
c(
169+
args,
170+
convmany(type),
171+
convmany(institutionalGovernance),
172+
convmany(disciplines),
173+
convmany(name),
174+
convmany(fuzzyName),
175+
convmany(sourceId),
176+
convmany(source),
177+
convmany(code),
178+
convmany(alternativeCode),
179+
convmany(contact),
180+
convmany(institutionKey),
181+
convmany(country),
182+
convmany(city),
183+
convmany(gbifRegion),
184+
convmany(machineTagNamespace),
185+
convmany(machineTagName),
186+
convmany(machineTagValue),
187+
convmany(identifier),
188+
convmany(identifierType)
189+
))
190+
191+
url <- paste0(gbif_base(), "/grscicoll/institution")
192+
tt <- gbif_GET(url, args, TRUE, curlopts)
193+
194+
meta <- tt[c('offset','limit','endOfRecords','count')]
195+
data <- tibble::as_tibble(tt$results)
196+
197+
list(meta = as.data.frame(meta), data = data)
198+
}

man/collection_search.Rd

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/institution_search.Rd

Lines changed: 158 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)