001/* 002 * Licensed under the Apache License, Version 2.0 (the "License"); 003 * you may not use this file except in compliance with the License. 004 * You may obtain a copy of the License at 005 * 006 * http://www.apache.org/licenses/LICENSE-2.0 007 * 008 * Unless required by applicable law or agreed to in writing, software 009 * distributed under the License is distributed on an "AS IS" BASIS, 010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 011 * See the License for the specific language governing permissions and 012 * limitations under the License. 013 */ 014package org.gbif.api.model.occurrence.search; 015 016import org.gbif.api.model.common.search.SearchParameter; 017import org.gbif.api.model.common.search.SearchParameterFormat; 018import org.gbif.api.util.IsoDateInterval; 019import org.gbif.api.vocabulary.BasisOfRecord; 020import org.gbif.api.vocabulary.Continent; 021import org.gbif.api.vocabulary.Country; 022import org.gbif.api.vocabulary.EndpointType; 023import org.gbif.api.vocabulary.GbifRegion; 024import org.gbif.api.vocabulary.License; 025import org.gbif.api.vocabulary.MediaType; 026import org.gbif.api.vocabulary.OccurrenceIssue; 027import org.gbif.api.vocabulary.OccurrenceStatus; 028import org.gbif.api.vocabulary.TaxonomicStatus; 029 030import java.io.IOException; 031import java.io.Serializable; 032import java.lang.reflect.Field; 033import java.util.ArrayList; 034import java.util.Date; 035import java.util.List; 036import java.util.Objects; 037import java.util.Optional; 038import java.util.UUID; 039 040import com.fasterxml.jackson.annotation.JsonValue; 041import com.fasterxml.jackson.core.JacksonException; 042import com.fasterxml.jackson.databind.DeserializationContext; 043import com.fasterxml.jackson.databind.JsonDeserializer; 044import com.fasterxml.jackson.databind.KeyDeserializer; 045import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 046import com.fasterxml.jackson.databind.node.ObjectNode; 047 048import static org.gbif.api.model.common.search.SearchParameterFormat.ALPHABETIC; 049import static org.gbif.api.model.common.search.SearchParameterFormat.ALPHABETIC_UNDERSCORE; 050import static org.gbif.api.model.common.search.SearchParameterFormat.ALPHANUMERIC; 051import static org.gbif.api.model.common.search.SearchParameterFormat.ALPHANUMERIC_UNDERSCORE_DOT; 052import static org.gbif.api.model.common.search.SearchParameterFormat.IRI; 053 054/** 055 * Supported query parameters by the occurrence search and download service. 056 * For download predicates only the numerical types support comparisons other than equals. 057 */ 058@JsonDeserialize(as = OccurrenceSearchParameter.class, using = OccurrenceSearchParameter.OccurrenceSearchParameterDeserializer.class) 059public class OccurrenceSearchParameter implements SearchParameter, Serializable { 060 061 /** 062 * The dataset key as a UUID. 063 */ 064 public final static OccurrenceSearchParameter DATASET_KEY = new OccurrenceSearchParameter("DATASET_KEY", UUID.class); 065 066 /** 067 * The checklist key to use for taxonomy matching. 068 */ 069 public final static OccurrenceSearchParameter CHECKLIST_KEY = new OccurrenceSearchParameter("CHECKLIST_KEY", UUID.class); 070 071 /** 072 * The 4 digit year. A year of 98 will be 98 common era, not 1998. 073 * This parameter accepts comma separated range values, e.g.: 074 * <dl> 075 * <dt>*,1810</dt> 076 * <dd>Found before or equal to 1810</dd> 077 * <dt>1848,1933</dt> 078 * <dd>Year between 1848 and 1933</dd> 079 * </dl> 080 */ 081 public final static OccurrenceSearchParameter YEAR = new OccurrenceSearchParameter("YEAR", Integer.class); 082 083 /** 084 * The month of the year, starting with 1 for January. 085 * A month query can be used to retrieve seasonal records when used without a year or a year range. 086 * This parameter accepts comma separated range values, e.g.: 087 * <dl> 088 * <dt>4,8</dt> 089 * <dd>Month between April and August</dd> 090 * </dl> 091 */ 092 public final static OccurrenceSearchParameter MONTH = new OccurrenceSearchParameter("MONTH", Integer.class); 093 094 /** 095 * The day of the month. 096 * This parameter accepts comma separated range values, e.g.: 097 * <dl> 098 * <dt>24,28</dt> 099 * <dd>Day of the month between 24 and 28</dd> 100 * </dl> 101 */ 102 public final static OccurrenceSearchParameter DAY = new OccurrenceSearchParameter("DAY", Integer.class); 103 104 /** 105 * The earliest integer day of the year on which the event occurred (1 for January 1, 365 for December 31, except in a 106 * leap year, in which case it is 366). 107 */ 108 public final static OccurrenceSearchParameter START_DAY_OF_YEAR = new OccurrenceSearchParameter("START_DAY_OF_YEAR", Integer.class); 109 110 /** 111 * The latest integer day of the year on which the event occurred (1 for January 1, 365 for December 31, except in a 112 * leap year, in which case it is 366). 113 */ 114 public final static OccurrenceSearchParameter END_DAY_OF_YEAR = new OccurrenceSearchParameter("END_DAY_OF_YEAR", Integer.class); 115 116 /** 117 * Event date (date the occurrence was recorded) in ISO 8601 formats:yyyy, yyyy-MM, yyyy-MM-dd and MM-dd. 118 * This parameter accepts comma separated range values, examples of valid ranges are: 119 * <dl> 120 * <dt>2001-02-11,2010-01-10</dt> 121 * <dd>Dates between 2001-02-11 and 2010-01-10</dd> 122 * <dt>2001-02,2010-01</dt> 123 * <dd>Dates between first day of 2001-02 and last day of 2010-01</dd> 124 * <dt>2001,2010</dt> 125 * <dd>Dates between first day of 2001 and last day of 2010</dd> 126 * <dt>2001,2010-01</dt> 127 * <dd>Dates between first day of 2001 and last day of 2010-01</dd> 128 * <dt>2001-01-10,2010</dt> 129 * <dd>Dates between 2001-01-10 and last day of 2010</dd> 130 * <dt>2001-01-10,*</dt> 131 * <dd>Dates after 2001-01-10</dd> 132 * <dt>*,2001-01-10</dt> 133 * <dd>Dates before 2001-01-10</dd> 134 * <dt>*</dt> 135 * <dd>all dates</dd> 136 * </dl> 137 */ 138 public final static OccurrenceSearchParameter EVENT_DATE = new OccurrenceSearchParameter("EVENT_DATE", IsoDateInterval.class); 139 140 /** 141 * Lower limit for the range of the event date (date the occurrence was recorded). 142 * 143 * Included for backward compatibility as it mimicks the previous search behaviour: 144 * https://github.com/gbif/occurrence/issues/346 145 */ 146 @Deprecated 147 public final static OccurrenceSearchParameter EVENT_DATE_GTE = new OccurrenceSearchParameter("EVENT_DATE_GTE", Date.class); 148 149 /** 150 * An identifier for the set of information associated with an Event (something that occurs at a place and time). 151 * Maybe a global unique identifier or an identifier specific to the data set. 152 */ 153 public final static OccurrenceSearchParameter EVENT_ID = new OccurrenceSearchParameter("EVENT_ID", String.class); 154 155 /** 156 * An identifier for the broader Event that groups this and potentially other Events. 157 */ 158 public final static OccurrenceSearchParameter PARENT_EVENT_ID = new OccurrenceSearchParameter("PARENT_EVENT_ID", String.class); 159 160 /** 161 * The name of, reference to, or description of the method or protocol used during an Event. 162 */ 163 public final static OccurrenceSearchParameter SAMPLING_PROTOCOL = new OccurrenceSearchParameter("SAMPLING_PROTOCOL", String.class); 164 165 /** 166 * A list (concatenated and separated) of previous assignments of names to the organism. 167 */ 168 public final static OccurrenceSearchParameter PREVIOUS_IDENTIFICATIONS = new OccurrenceSearchParameter("PREVIOUS_IDENTIFICATIONS", String.class); 169 170 /** 171 * Last interpreted date in ISO 8601 formats:yyyy, yyyy-MM, yyyy-MM-dd and MM-dd. 172 * This parameter accepts comma separated range values, examples of valid ranges are: 173 * <dl> 174 * <dt>2001-02-11,2010-01-10</dt> 175 * <dd>Dates between 2001-02-11 and 2010-01-10</dd> 176 * <dt>2001-02,2010-01</dt> 177 * <dd>Dates between first day of 2001-02 and last day of 2010-01</dd> 178 * <dt>2001,2010</dt> 179 * <dd>Dates between first day of 2001 and last day of 2010</dd> 180 * <dt>2001,2010-01</dt> 181 * <dd>Dates between first day of 2001 and last day of 2010-01</dd> 182 * <dt>2001-01-10,2010</dt> 183 * <dd>Dates between 2001-01-10 and last day of 2010</dd> 184 * <dt>2001-01-10,*</dt> 185 * <dd>Dates after 2001-01-10</dd> 186 * <dt>*,2001-01-10</dt> 187 * <dd>Dates before 2001-01-10</dd> 188 * <dt>*</dt> 189 * <dd>all dates</dd> 190 * </dl> 191 */ 192 public final static OccurrenceSearchParameter LAST_INTERPRETED = new OccurrenceSearchParameter("LAST_INTERPRETED", Date.class); 193 194 195 /** 196 * Modified date in ISO 8601 formats:yyyy, yyyy-MM, yyyy-MM-dd and MM-dd. 197 * This parameter accepts comma separated range values, examples of valid ranges are: 198 * <dl> 199 * <dt>2001-02-11,2010-01-10</dt> 200 * <dd>Dates between 2001-02-11 and 2010-01-10</dd> 201 * <dt>2001-02,2010-01</dt> 202 * <dd>Dates between first day of 2001-02 and last day of 2010-01</dd> 203 * <dt>2001,2010</dt> 204 * <dd>Dates between first day of 2001 and last day of 2010</dd> 205 * <dt>2001,2010-01</dt> 206 * <dd>Dates between first day of 2001 and last day of 2010-01</dd> 207 * <dt>2001-01-10,2010</dt> 208 * <dd>Dates between 2001-01-10 and last day of 2010</dd> 209 * <dt>2001-01-10,*</dt> 210 * <dd>Dates after 2001-01-10</dd> 211 * <dt>*,2001-01-10</dt> 212 * <dd>Dates before 2001-01-10</dd> 213 * <dt>*</dt> 214 * <dd>all dates</dd> 215 * </dl> 216 */ 217 public final static OccurrenceSearchParameter MODIFIED = new OccurrenceSearchParameter("MODIFIED", Date.class); 218 219 /** 220 * Latitude in decimals between -90 and 90 based on WGS 84. 221 */ 222 public final static OccurrenceSearchParameter DECIMAL_LATITUDE = new OccurrenceSearchParameter("DECIMAL_LATITUDE", Double.class); 223 224 /** 225 * Longitude in decimals between -180 and 180 based on WGS 84. 226 */ 227 public final static OccurrenceSearchParameter DECIMAL_LONGITUDE = new OccurrenceSearchParameter("DECIMAL_LONGITUDE", Double.class); 228 229 /** 230 * The uncertainty of the coordinate in meters. 231 * This parameter accepts comma separated range values, e.g.: 232 * <dl> 233 * <dt>*,100</dt> 234 * <dd>Uncertainty below or equals 100m</dd> 235 * <dt>10000,*</dt> 236 * <dd>Uncertainty above or equals 10,000m</dd> 237 * <dt>1000,5000</dt> 238 * <dd>Uncertainty between or equals 1000m and 5000m 239 * </dd> 240 * </dl> 241 */ 242 public final static OccurrenceSearchParameter COORDINATE_UNCERTAINTY_IN_METERS = new OccurrenceSearchParameter("COORDINATE_UNCERTAINTY_IN_METERS", Double.class); 243 244 /** 245 * Country the occurrence was recorded in. 246 */ 247 public final static OccurrenceSearchParameter COUNTRY = new OccurrenceSearchParameter("COUNTRY", Country.class); 248 249 /** 250 * GBIF region based on country 251 */ 252 public final static OccurrenceSearchParameter GBIF_REGION = new OccurrenceSearchParameter("GBIF_REGION", GbifRegion.class); 253 254 /** 255 * Continent the occurrence was recorded in. 256 */ 257 public final static OccurrenceSearchParameter CONTINENT = new OccurrenceSearchParameter("CONTINENT", Continent.class); 258 259 /** 260 * The country of the organization that publishes the dataset the occurrence belongs to. 261 */ 262 public final static OccurrenceSearchParameter PUBLISHING_COUNTRY = new OccurrenceSearchParameter("PUBLISHING_COUNTRY", Country.class); 263 264 /** 265 * GBIF region based on publishibg country 266 */ 267 public final static OccurrenceSearchParameter PUBLISHED_BY_GBIF_REGION = new OccurrenceSearchParameter("PUBLISHED_BY_GBIF_REGION", GbifRegion.class); 268 269 /** 270 * Altitude/elevation in meters above sea level. 271 * This parameter accepts comma separated range values, e.g.: 272 * <dl> 273 * <dt>*,100</dt> 274 * <dd>Altitude below or equals 100m</dd> 275 * <dt>100,*</dt> 276 * <dd>Altitude above or equals 100m</dd> 277 * <dt>-2,8.8</dt> 278 * <dd>Altitude between or equals -2m and 8.8m</dd> 279 * </dl> 280 */ 281 public final static OccurrenceSearchParameter ELEVATION = new OccurrenceSearchParameter("ELEVATION", Double.class); 282 283 /** 284 * Depth in meters relative to altitude. For example 10 meters below a lake surface with given altitude. 285 * This parameter accepts comma separated range values, e.g.: 286 * <dl> 287 * <dt>*,10</dt> 288 * <dd>Depth below or equals 10m</dd> 289 * <dt>100,*</dt> 290 * <dd>Depth above or equals 100m</dd> 291 * <dt>12.1,28.8</dt> 292 * <dd>Depth between or equals 12.1m and 28.8m</dd> 293 * </dl> 294 */ 295 public final static OccurrenceSearchParameter DEPTH = new OccurrenceSearchParameter("DEPTH", Double.class); 296 297 /** 298 * An identifier of any form assigned by the source to identify the institution 299 * the record belongs to. Not guaranteed to be unique. 300 */ 301 public final static OccurrenceSearchParameter INSTITUTION_CODE = new OccurrenceSearchParameter("INSTITUTION_CODE", String.class); 302 303 /** 304 * An identifier of any form assigned by the source to identify the physical collection or digital dataset 305 * uniquely within the context of an institution. 306 */ 307 public final static OccurrenceSearchParameter COLLECTION_CODE = new OccurrenceSearchParameter("COLLECTION_CODE", String.class); 308 309 /** 310 * An identifier of any form assigned by the source within a physical collection or digital dataset for the record 311 * which may not be unique, but should be fairly unique in combination with the institution and collection code. 312 */ 313 public final static OccurrenceSearchParameter CATALOG_NUMBER = new OccurrenceSearchParameter("CATALOG_NUMBER", String.class); 314 315 /** 316 * The person who recorded the occurrence. 317 */ 318 public final static OccurrenceSearchParameter RECORDED_BY = new OccurrenceSearchParameter("RECORDED_BY", String.class); 319 320 /** 321 * The person who identified the occurrence. 322 */ 323 public final static OccurrenceSearchParameter IDENTIFIED_BY = new OccurrenceSearchParameter("IDENTIFIED_BY", String.class); 324 325 /** 326 * An identifier given to the Occurrence at the time it was recorded. 327 */ 328 public final static OccurrenceSearchParameter RECORD_NUMBER = new OccurrenceSearchParameter("RECORD_NUMBER", String.class); 329 330 /** 331 * A basis of record enumeration value. 332 */ 333 public final static OccurrenceSearchParameter BASIS_OF_RECORD = new OccurrenceSearchParameter("BASIS_OF_RECORD", BasisOfRecord.class); 334 335 /** 336 * The sex of the biological individual(s) represented in the occurrence. 337 */ 338 public final static OccurrenceSearchParameter SEX = new OccurrenceSearchParameter("SEX", String.class, ALPHABETIC); 339 340 /** 341 * Presents of associated sequences or an extension 342 */ 343 public final static OccurrenceSearchParameter IS_SEQUENCED = new OccurrenceSearchParameter("IS_SEQUENCED", Boolean.class); 344 345 /** 346 * A taxon key from the selected taxonomy (e.g. Catalogue of Life, GBIF Backbone) All included and synonym taxa are included in the search, so a search for 347 * aves with taxonKey=212 will match all birds, no matter which species. 348 */ 349 public final static OccurrenceSearchParameter TAXON_KEY = new OccurrenceSearchParameter("TAXON_KEY", String.class, SearchParameterFormat.TAXON_KEY); 350 351 /** 352 * A taxon key from the selected taxonomy (e.g. Catalogue of Life, GBIF Backbone) for the name usage of the currently valid or accepted taxon. 353 */ 354 public final static OccurrenceSearchParameter ACCEPTED_TAXON_KEY = new OccurrenceSearchParameter("ACCEPTED_TAXON_KEY", String.class, SearchParameterFormat.TAXON_KEY); 355 356 /** 357 * A kingdom key from the selected taxonomy (e.g. Catalogue of Life, GBIF Backbone) 358 */ 359 public final static OccurrenceSearchParameter KINGDOM_KEY = new OccurrenceSearchParameter("KINGDOM_KEY", String.class, SearchParameterFormat.TAXON_KEY); 360 361 /** 362 * A phylum key from the selected taxonomy (e.g. Catalogue of Life, GBIF Backbone) 363 */ 364 public final static OccurrenceSearchParameter PHYLUM_KEY = new OccurrenceSearchParameter("PHYLUM_KEY", String.class, SearchParameterFormat.TAXON_KEY); 365 366 /** 367 * A class key from the selected taxonomy (e.g. Catalogue of Life, GBIF Backbone) 368 */ 369 public final static OccurrenceSearchParameter CLASS_KEY = new OccurrenceSearchParameter("CLASS_KEY", String.class, SearchParameterFormat.TAXON_KEY); 370 371 /** 372 * A order key from the selected taxonomy (e.g. Catalogue of Life, GBIF Backbone) 373 */ 374 public final static OccurrenceSearchParameter ORDER_KEY = new OccurrenceSearchParameter("ORDER_KEY", String.class, SearchParameterFormat.TAXON_KEY); 375 376 /** 377 * A family key from the selected taxonomy (e.g. Catalogue of Life, GBIF Backbone) 378 */ 379 public final static OccurrenceSearchParameter FAMILY_KEY = new OccurrenceSearchParameter("FAMILY_KEY", String.class, SearchParameterFormat.TAXON_KEY); 380 381 /** 382 * A genus key from the selected taxonomy (e.g. Catalogue of Life, GBIF Backbone) 383 */ 384 public final static OccurrenceSearchParameter GENUS_KEY = new OccurrenceSearchParameter("GENUS_KEY", String.class, SearchParameterFormat.TAXON_KEY); 385 386 /** 387 * A subgenus key from the selected taxonomy (e.g. Catalogue of Life, GBIF Backbone) 388 */ 389 public final static OccurrenceSearchParameter SUBGENUS_KEY = new OccurrenceSearchParameter("SUBGENUS_KEY", String.class, SearchParameterFormat.TAXON_KEY); 390 391 /** 392 * A species key from the selected taxonomy (e.g. Catalogue of Life, GBIF Backbone) 393 */ 394 public final static OccurrenceSearchParameter SPECIES_KEY = new OccurrenceSearchParameter("SPECIES_KEY", String.class, SearchParameterFormat.TAXON_KEY); 395 396 /** 397 * Searches the interpreted, full scientific name of the occurrence. 398 */ 399 public final static OccurrenceSearchParameter SCIENTIFIC_NAME = new OccurrenceSearchParameter("SCIENTIFIC_NAME", String.class); 400 401 /** 402 * Scientific name as provided byt the source. 403 */ 404 public final static OccurrenceSearchParameter VERBATIM_SCIENTIFIC_NAME = new OccurrenceSearchParameter("VERBATIM_SCIENTIFIC_NAME", String.class); 405 406 /** 407 * Verbatim identifier for the set of taxon information. Maybe a global unique identifier or an identifier specific to 408 * the data set. 409 */ 410 public final static OccurrenceSearchParameter TAXON_ID = new OccurrenceSearchParameter("TAXON_ID", String.class); 411 412 /** 413 * An identifier for the taxonomic concept to which the record refers - not for the nomenclatural details of a taxon. 414 */ 415 public final static OccurrenceSearchParameter TAXON_CONCEPT_ID = new OccurrenceSearchParameter("TAXON_CONCEPT_ID", String.class); 416 417 /** 418 * The status of the use of the taxon key in the selected taxonomy (e.g. Catalogue of Life, GBIF Backbone). 419 */ 420 public final static OccurrenceSearchParameter TAXONOMIC_STATUS = new OccurrenceSearchParameter("TAXONOMIC_STATUS", TaxonomicStatus.class); 421 422 /** 423 * Searches for occurrence records which contain a value on its coordinate fields (latitude and longitude). 424 * HAS_COORDINATE=true searches for occurrence records with a coordinate value. 425 * HAS_COORDINATE=false searches for occurrence records without a coordinate value. 426 */ 427 public final static OccurrenceSearchParameter HAS_COORDINATE = new OccurrenceSearchParameter("HAS_COORDINATE", Boolean.class); 428 429 /** 430 * Geometry in <a href="https://en.wikipedia.org/wiki/Well-known_text">Well Known Text</a> (WKT) format. 431 * E.g.: POLYGON ((30.0 10.0, 10.12 20.23, 20 40, 40 40, 30 10)). 432 * Multi geometries like MULTIPOLYGON are not supported and multiple parameters should be used instead. 433 * Valid geometries are: 434 * <ul> 435 * <li>POINT</li> 436 * <li>LINESTRING</li> 437 * <li>POLYGON</li> 438 * <li>LINEARRING</li> 439 * </ul> 440 */ 441 public final static OccurrenceSearchParameter GEOMETRY = new OccurrenceSearchParameter("GEOMETRY", String.class); 442 443 /** 444 * Use in combination of LATITUDE and LONGITUDE parameters matches within a given distance. 445 * E.g.: geo_distance=100m,40,90 geo_distance=100km,40,90 geo_distance=100mi,40,90. 446 * See supported units in {@link org.gbif.api.model.occurrence.geo.DistanceUnit}. 447 */ 448 public final static OccurrenceSearchParameter GEO_DISTANCE = new OccurrenceSearchParameter("GEO_DISTANCE", String.class); 449 450 /** 451 * The distance from a known centroid, e.g. a country centroid. 452 */ 453 public final static OccurrenceSearchParameter DISTANCE_FROM_CENTROID_IN_METERS = new OccurrenceSearchParameter("DISTANCE_FROM_CENTROID_IN_METERS", Double.class); 454 455 /** 456 * Includes/excludes occurrence records which contain geospatial issues for their coordinate. 457 * See {@link org.gbif.api.vocabulary.OccurrenceIssue#GEOSPATIAL_RULES} 458 * HAS_GEOSPATIAL_ISSUE=true include records with spatial issues. 459 * HAS_GEOSPATIAL_ISSUE=false exclude records with spatial issues. 460 * The absence of this parameter returns any record with or without spatial issues. 461 */ 462 public final static OccurrenceSearchParameter HAS_GEOSPATIAL_ISSUE = new OccurrenceSearchParameter("HAS_GEOSPATIAL_ISSUE", Boolean.class); 463 464 /** 465 * Searches occurrence for those that have a specific issue. 466 */ 467 public final static OccurrenceSearchParameter ISSUE = new OccurrenceSearchParameter("ISSUE", OccurrenceIssue.class); 468 469 /** 470 * Searches occurrence for those that have a specific taxonomic issue. This is separated out from the general issue 471 * field as taxonomic issues will be tied to a specific checklist. 472 */ 473 public final static OccurrenceSearchParameter TAXONOMIC_ISSUE = new OccurrenceSearchParameter("TAXONOMIC_ISSUE", String.class, ALPHABETIC_UNDERSCORE); 474 475 /** 476 * Nomenclatural type (type status, typified scientific name, publication) applied to the subject. 477 */ 478 public final static OccurrenceSearchParameter TYPE_STATUS = new OccurrenceSearchParameter("TYPE_STATUS", String.class, ALPHABETIC_UNDERSCORE); 479 480 /** 481 * The kind of media object. 482 * Recommended terms from the DCMI Type Vocabulary are StillImage, Sound or MovingImage for GBIF to index and show the 483 * media files. 484 */ 485 public final static OccurrenceSearchParameter MEDIA_TYPE = new OccurrenceSearchParameter("MEDIA_TYPE", MediaType.class); 486 487 /** 488 * An identifier for the Occurrence (as opposed to a particular digital record of the occurrence). 489 * In the absence of a persistent global unique identifier, construct one from a combination of identifiers in the 490 * record that will most closely make the occurrenceID globally unique. 491 */ 492 public final static OccurrenceSearchParameter OCCURRENCE_ID = new OccurrenceSearchParameter("OCCURRENCE_ID", String.class); 493 494 /** 495 * The process by which the biological individual(s) represented in the Occurrence became established at the location. 496 */ 497 public final static OccurrenceSearchParameter ESTABLISHMENT_MEANS = new OccurrenceSearchParameter("ESTABLISHMENT_MEANS", String.class, ALPHABETIC_UNDERSCORE); 498 499 /** 500 * Provides the controlled vocabulary for information about degree to which an Organism survives, reproduces, and expands its range at the given place and time. 501 */ 502 public final static OccurrenceSearchParameter DEGREE_OF_ESTABLISHMENT = new OccurrenceSearchParameter("DEGREE_OF_ESTABLISHMENT", String.class, ALPHABETIC_UNDERSCORE); 503 504 /** 505 * Provides the controlled vocabulary for information about the process by which an Organism came to be in a given place at a given time. 506 * The pathway of an organism or organisms have been introduced to a given place and time. 507 */ 508 public final static OccurrenceSearchParameter PATHWAY = new OccurrenceSearchParameter("PATHWAY", String.class, ALPHABETIC_UNDERSCORE); 509 510 /** 511 * Searches for records whose publishing country is different to the country where the record was recorded in. 512 */ 513 public final static OccurrenceSearchParameter REPATRIATED = new OccurrenceSearchParameter("REPATRIATED", Boolean.class); 514 515 /** 516 * An identifier for the Organism instance (as opposed to a particular digital record of the Organism). 517 * May be a globally unique identifier or an identifier specific to the data set. 518 */ 519 public final static OccurrenceSearchParameter ORGANISM_ID = new OccurrenceSearchParameter("ORGANISM_ID", String.class); 520 521 /** 522 * The name of the next smaller administrative region than country in which the Location occurs. 523 */ 524 public final static OccurrenceSearchParameter STATE_PROVINCE = new OccurrenceSearchParameter("STATE_PROVINCE", String.class); 525 526 /** 527 * The name of the water body in which the Location occurs. 528 */ 529 public final static OccurrenceSearchParameter WATER_BODY = new OccurrenceSearchParameter("WATER_BODY", String.class); 530 531 /** 532 * The specific description of the place. 533 * It may contain information modified from the original to correct perceived errors or standardize the description. 534 */ 535 public final static OccurrenceSearchParameter LOCALITY = new OccurrenceSearchParameter("LOCALITY", String.class); 536 537 /** 538 * Protocol used to provide the occurrence record. 539 */ 540 public final static OccurrenceSearchParameter PROTOCOL = new OccurrenceSearchParameter("PROTOCOL", EndpointType.class); 541 542 /** 543 * The licence applied to the dataset. 544 */ 545 public final static OccurrenceSearchParameter LICENSE = new OccurrenceSearchParameter("LICENSE", License.class); 546 547 /** 548 * The owning organizations uuid key. 549 */ 550 public final static OccurrenceSearchParameter PUBLISHING_ORG = new OccurrenceSearchParameter("PUBLISHING_ORG", UUID.class); 551 552 /** 553 * The GBIF network that the publishing organisation belongs to. 554 */ 555 public final static OccurrenceSearchParameter NETWORK_KEY = new OccurrenceSearchParameter("NETWORK_KEY", UUID.class); 556 557 /** 558 * The category of the dataset this record belongs to.. 559 */ 560 public final static OccurrenceSearchParameter DATASET_CATEGORY = new OccurrenceSearchParameter("DATASET_CATEGORY", String.class, ALPHABETIC_UNDERSCORE); 561 562 /** 563 * The technical installation key that hosts/publishes this record. 564 */ 565 public final static OccurrenceSearchParameter INSTALLATION_KEY = new OccurrenceSearchParameter("INSTALLATION_KEY", UUID.class); 566 567 /** 568 * The organization key of the installation that hosts this record. 569 */ 570 public final static OccurrenceSearchParameter HOSTING_ORGANIZATION_KEY = new OccurrenceSearchParameter("HOSTING_ORGANIZATION_KEY", UUID.class); 571 572 /** 573 * Crawl attempt that harvested this record. 574 */ 575 public final static OccurrenceSearchParameter CRAWL_ID = new OccurrenceSearchParameter("CRAWL_ID", Integer.class); 576 577 /** 578 * GBIF ProjectId. 579 */ 580 public final static OccurrenceSearchParameter PROJECT_ID = new OccurrenceSearchParameter("PROJECT_ID", String.class); 581 582 /** 583 * GBIF Programme Acronym. 584 */ 585 public final static OccurrenceSearchParameter PROGRAMME = new OccurrenceSearchParameter("PROGRAMME", String.class); 586 587 /** 588 * A number or enumeration value for the quantity of organisms. 589 */ 590 public final static OccurrenceSearchParameter ORGANISM_QUANTITY = new OccurrenceSearchParameter("ORGANISM_QUANTITY", Double.class); 591 592 /** 593 * The type of quantification system used for the quantity of organisms. 594 */ 595 public final static OccurrenceSearchParameter ORGANISM_QUANTITY_TYPE = new OccurrenceSearchParameter("ORGANISM_QUANTITY_TYPE", String.class); 596 597 /** 598 * The unit of measurement of the size (time duration, length, area, or volume) of a sample in a sampling event. 599 */ 600 public final static OccurrenceSearchParameter SAMPLE_SIZE_UNIT = new OccurrenceSearchParameter("SAMPLE_SIZE_UNIT", String.class); 601 602 /** 603 * A numeric value for a measurement of the size (time duration, length, area, or volume) of a sample in a sampling event. 604 */ 605 public final static OccurrenceSearchParameter SAMPLE_SIZE_VALUE = new OccurrenceSearchParameter("SAMPLE_SIZE_VALUE", Double.class); 606 607 /** 608 * Calculated organismQuantity relative to the sampleSizeValue i.e. -> organismQuantity / sampleSizeValue. 609 */ 610 public final static OccurrenceSearchParameter RELATIVE_ORGANISM_QUANTITY = new OccurrenceSearchParameter("RELATIVE_ORGANISM_QUANTITY", Double.class); 611 612 /** 613 * Collection key. It links to the collection to which this record belongs. 614 */ 615 public final static OccurrenceSearchParameter COLLECTION_KEY = new OccurrenceSearchParameter("COLLECTION_KEY", UUID.class); 616 617 /** 618 * Institution key. It links to the institution that maintains, recorded or digitized this record. 619 */ 620 public final static OccurrenceSearchParameter INSTITUTION_KEY = new OccurrenceSearchParameter("INSTITUTION_KEY", UUID.class); 621 622 /** 623 * Agent identifiers from GbifTerm.recordedByID 624 */ 625 public final static OccurrenceSearchParameter RECORDED_BY_ID = new OccurrenceSearchParameter("RECORDED_BY_ID", String.class); 626 627 /** 628 * Agent identifiers from GbifTerm.identifiedByID 629 */ 630 public final static OccurrenceSearchParameter IDENTIFIED_BY_ID = new OccurrenceSearchParameter("IDENTIFIED_BY_ID", String.class); 631 632 /** 633 * An occurrence status enumeration value. 634 */ 635 public final static OccurrenceSearchParameter OCCURRENCE_STATUS = new OccurrenceSearchParameter("OCCURRENCE_STATUS", OccurrenceStatus.class); 636 637 /** 638 * A <a href="https://gadm.org">GADM</a> identifier at any level. 639 */ 640 public final static OccurrenceSearchParameter GADM_GID = new OccurrenceSearchParameter("GADM_GID", String.class, ALPHANUMERIC_UNDERSCORE_DOT); 641 642 /** 643 * A <a href="https://gadm.org">GADM</a> country, island or territory (level zero) identifier. 644 */ 645 public final static OccurrenceSearchParameter GADM_LEVEL_0_GID = new OccurrenceSearchParameter("GADM_LEVEL_0_GID", String.class, ALPHANUMERIC_UNDERSCORE_DOT); 646 647 /** 648 * A <a href="https://gadm.org">GADM</a> first-level identifier. 649 */ 650 public final static OccurrenceSearchParameter GADM_LEVEL_1_GID = new OccurrenceSearchParameter("GADM_LEVEL_1_GID", String.class, ALPHANUMERIC_UNDERSCORE_DOT); 651 652 /** 653 * A <a href="https://gadm.org">GADM</a> second-level identifier. 654 */ 655 public final static OccurrenceSearchParameter GADM_LEVEL_2_GID = new OccurrenceSearchParameter("GADM_LEVEL_2_GID", String.class, ALPHANUMERIC_UNDERSCORE_DOT); 656 657 /** 658 * A <a href="https://gadm.org">GADM</a> third-level identifier. 659 */ 660 public final static OccurrenceSearchParameter GADM_LEVEL_3_GID = new OccurrenceSearchParameter("GADM_LEVEL_3_GID", String.class, ALPHANUMERIC_UNDERSCORE_DOT); 661 662 /** 663 * The life stage of an occurrence. 664 */ 665 public final static OccurrenceSearchParameter LIFE_STAGE = new OccurrenceSearchParameter("LIFE_STAGE", String.class, ALPHABETIC); 666 667 /** 668 * Searches for occurrences that are clustered. 669 */ 670 public final static OccurrenceSearchParameter IS_IN_CLUSTER = new OccurrenceSearchParameter("IS_IN_CLUSTER", Boolean.class); 671 672 /** 673 * Searches for occurrences that have a particular DwC-A extension. 674 */ 675 public final static OccurrenceSearchParameter DWCA_EXTENSION = new OccurrenceSearchParameter("DWCA_EXTENSION", String.class, IRI); 676 677 /** 678 * Searches for occurrences that have a IUCN Red List Category. 679 */ 680 public final static OccurrenceSearchParameter IUCN_RED_LIST_CATEGORY = new OccurrenceSearchParameter("IUCN_RED_LIST_CATEGORY", String.class, ALPHABETIC_UNDERSCORE); 681 682 /** 683 * Searches for occurrences whose taxon, according to the checklist, lives in the given environment, 684 * e.g. MARINE, BRACKISH, FRESHWATER or TERRESTRIAL. 685 */ 686 public final static OccurrenceSearchParameter ENVIRONMENTS = new OccurrenceSearchParameter("ENVIRONMENTS", String.class, ALPHABETIC_UNDERSCORE); 687 688 /** 689 * The dwc dataset id. 690 */ 691 public final static OccurrenceSearchParameter DATASET_ID = new OccurrenceSearchParameter("DATASET_ID", String.class); 692 693 /** 694 * The dwc dataset name. 695 */ 696 public final static OccurrenceSearchParameter DATASET_NAME = new OccurrenceSearchParameter("DATASET_NAME", String.class); 697 698 /** 699 * Other catalog numbers associated to an occurrence. 700 */ 701 public final static OccurrenceSearchParameter OTHER_CATALOG_NUMBERS = new OccurrenceSearchParameter("OTHER_CATALOG_NUMBERS", String.class); 702 703 /** 704 * Preparations methods of an occurrence. 705 */ 706 public final static OccurrenceSearchParameter PREPARATIONS = new OccurrenceSearchParameter("PREPARATIONS", String.class); 707 708 /** 709 * The name of the island on or near which the location occurs. 710 */ 711 public final static OccurrenceSearchParameter ISLAND = new OccurrenceSearchParameter("ISLAND", String.class); 712 713 /** 714 * The name of the island group in which the location occurs. 715 */ 716 public final static OccurrenceSearchParameter ISLAND_GROUP = new OccurrenceSearchParameter("ISLAND_GROUP", String.class); 717 718 /** 719 * A list (concatenated and separated) of names of people, groups, or organizations who determined the georeference 720 * (spatial representation) for the location. 721 */ 722 public final static OccurrenceSearchParameter GEOREFERENCED_BY = new OccurrenceSearchParameter("GEOREFERENCED_BY", String.class); 723 724 /** 725 * A list (concatenated and separated) of geographic names less specific than the information captured in the locality 726 * term. 727 */ 728 public final static OccurrenceSearchParameter HIGHER_GEOGRAPHY = new OccurrenceSearchParameter("HIGHER_GEOGRAPHY", String.class); 729 730 /** 731 * An identifier given to the event in the field. Often serves as a link between field notes and the event. 732 */ 733 public final static OccurrenceSearchParameter FIELD_NUMBER = new OccurrenceSearchParameter("FIELD_NUMBER", String.class); 734 735 /** 736 * The full name of the earliest possible geochronologic eon or lowest chrono-stratigraphic eonothem or the informal 737 * name ("Precambrian") attributable to the stratigraphic horizon from which the MaterialEntity was collected. 738 */ 739 public final static OccurrenceSearchParameter EARLIEST_EON_OR_LOWEST_EONOTHEM = new OccurrenceSearchParameter("EARLIEST_EON_OR_LOWEST_EONOTHEM", String.class, ALPHANUMERIC); 740 741 /** 742 * The full name of the latest possible geochronologic eon or highest chrono-stratigraphic eonothem or the informal 743 * name ("Precambrian") attributable to the stratigraphic horizon from which the MaterialEntity was collected. 744 */ 745 public final static OccurrenceSearchParameter LATEST_EON_OR_HIGHEST_EONOTHEM = new OccurrenceSearchParameter("LATEST_EON_OR_HIGHEST_EONOTHEM", String.class, ALPHANUMERIC); 746 747 /** 748 * The full name of the earliest possible geochronologic era or lowest chronostratigraphic erathem attributable to the 749 * stratigraphic horizon from which the MaterialEntity was collected. 750 */ 751 public final static OccurrenceSearchParameter EARLIEST_ERA_OR_LOWEST_ERATHEM = new OccurrenceSearchParameter("EARLIEST_ERA_OR_LOWEST_ERATHEM", String.class, ALPHANUMERIC); 752 753 /** 754 * The full name of the latest possible geochronologic era or highest chronostratigraphic erathem attributable to the 755 * stratigraphic horizon from which the MaterialEntity was collected. 756 */ 757 public final static OccurrenceSearchParameter LATEST_ERA_OR_HIGHEST_ERATHEM = new OccurrenceSearchParameter("LATEST_ERA_OR_HIGHEST_ERATHEM", String.class, ALPHANUMERIC); 758 759 /** 760 * The full name of the earliest possible geochronologic period or lowest chronostratigraphic system attributable to 761 * the stratigraphic horizon from which the MaterialEntity was collected. 762 */ 763 public final static OccurrenceSearchParameter EARLIEST_PERIOD_OR_LOWEST_SYSTEM = new OccurrenceSearchParameter("EARLIEST_PERIOD_OR_LOWEST_SYSTEM", String.class, ALPHANUMERIC); 764 765 /** 766 * The full name of the latest possible geochronologic period or highest chronostratigraphic system attributable to 767 * the stratigraphic horizon from which the MaterialEntity was collected. 768 */ 769 public final static OccurrenceSearchParameter LATEST_PERIOD_OR_HIGHEST_SYSTEM = new OccurrenceSearchParameter("LATEST_PERIOD_OR_HIGHEST_SYSTEM", String.class, ALPHANUMERIC); 770 771 /** 772 * The full name of the earliest possible geochronologic epoch or lowest chronostratigraphic series attributable to 773 * the stratigraphic horizon from which the MaterialEntity was collected. 774 */ 775 public final static OccurrenceSearchParameter EARLIEST_EPOCH_OR_LOWEST_SERIES = new OccurrenceSearchParameter("EARLIEST_EPOCH_OR_LOWEST_SERIES", String.class, ALPHANUMERIC); 776 777 /** 778 * The full name of the latest possible geochronologic epoch or highest chronostratigraphic series attributable to the 779 * stratigraphic horizon from which the MaterialEntity was collected. 780 */ 781 public final static OccurrenceSearchParameter LATEST_EPOCH_OR_HIGHEST_SERIES = new OccurrenceSearchParameter("LATEST_EPOCH_OR_HIGHEST_SERIES", String.class, ALPHANUMERIC); 782 783 /** 784 * The full name of the earliest possible geochronologic age or lowest chronostratigraphic stage attributable to the 785 * stratigraphic horizon from which the MaterialEntity was collected. 786 */ 787 public final static OccurrenceSearchParameter EARLIEST_AGE_OR_LOWEST_STAGE = new OccurrenceSearchParameter("EARLIEST_AGE_OR_LOWEST_STAGE", String.class, ALPHANUMERIC); 788 789 /** 790 * The full name of the latest possible geochronologic age or highest chronostratigraphic stage attributable to the 791 * stratigraphic horizon from which the MaterialEntity was collected. 792 */ 793 public final static OccurrenceSearchParameter LATEST_AGE_OR_HIGHEST_STAGE = new OccurrenceSearchParameter("LATEST_AGE_OR_HIGHEST_STAGE", String.class, ALPHANUMERIC); 794 795 /** 796 * The full name of the lowest possible geological biostratigraphic zone of the stratigraphic horizon from which the 797 * MaterialEntity was collected. 798 */ 799 public final static OccurrenceSearchParameter LOWEST_BIOSTRATIGRAPHIC_ZONE = new OccurrenceSearchParameter("LOWEST_BIOSTRATIGRAPHIC_ZONE", String.class, ALPHANUMERIC); 800 801 /** 802 * The full name of the highest possible geological biostratigraphic zone of the stratigraphic horizon from which the 803 * MaterialEntity was collected. 804 */ 805 public final static OccurrenceSearchParameter HIGHEST_BIOSTRATIGRAPHIC_ZONE = new OccurrenceSearchParameter("HIGHEST_BIOSTRATIGRAPHIC_ZONE", String.class, ALPHANUMERIC); 806 807 /** 808 * The full name of the lithostratigraphic group from which the MaterialEntity was collected. 809 */ 810 public final static OccurrenceSearchParameter GROUP = new OccurrenceSearchParameter("GROUP", String.class); 811 812 /** 813 * The full name of the lithostratigraphic formation from which the MaterialEntity was collected. 814 */ 815 public final static OccurrenceSearchParameter FORMATION = new OccurrenceSearchParameter("FORMATION", String.class); 816 817 /** 818 * The full name of the lithostratigraphic member from which the MaterialEntity was collected. 819 */ 820 public final static OccurrenceSearchParameter MEMBER = new OccurrenceSearchParameter("MEMBER", String.class); 821 822 /** 823 * The full name of the lithostratigraphic bed from which the MaterialEntity was collected. 824 */ 825 public final static OccurrenceSearchParameter BED = new OccurrenceSearchParameter("BED", String.class); 826 827 /** 828 * A list (concatenated and separated) of identifiers (publication, global unique identifier, URI) of 829 * genetic sequence information associated with the material entity. 830 */ 831 public final static OccurrenceSearchParameter ASSOCIATED_SEQUENCES = new OccurrenceSearchParameter("ASSOCIATED_SEQUENCES", String.class); 832 833 /** 834 * Unique GBIF key for the occurrence. 835 */ 836 public final static OccurrenceSearchParameter GBIF_ID = new OccurrenceSearchParameter("GBIF_ID", Long.class); 837 838 /** 839 * Geological time of an occurrence that searches in the chronostratigraphy fields. 840 */ 841 public final static OccurrenceSearchParameter GEOLOGICAL_TIME = new OccurrenceSearchParameter("GEOLOGICAL_TIME", String.class); 842 843 /** 844 * Searches in the lithostratigraphy fields (bed, formation, group, member). 845 */ 846 public final static OccurrenceSearchParameter LITHOSTRATIGRAPHY = new OccurrenceSearchParameter("LITHOSTRATIGRAPHY", String.class); 847 848 /** 849 * Searches in the biostratigraphy fields (lowest and highest biostratigraphy). 850 */ 851 public final static OccurrenceSearchParameter BIOSTRATIGRAPHY = new OccurrenceSearchParameter("BIOSTRATIGRAPHY", String.class); 852 853 /** 854 * Searches in the dna sequence ID. 855 * 856 * @deprecated use {@link #NUCLEOTIDE_SEQUENCE_NUCLEOTIDE_SEQUENCE_ID} or the other nucleotideSequence parameters instead. 857 */ 858 @Deprecated 859 public final static OccurrenceSearchParameter DNA_SEQUENCE_ID = new OccurrenceSearchParameter("DNA_SEQUENCE_ID", String.class); 860 861 /** 862 * MD5 hash of the final cleaned sequence. 863 */ 864 public final static OccurrenceSearchParameter NUCLEOTIDE_SEQUENCE_NUCLEOTIDE_SEQUENCE_ID = new OccurrenceSearchParameter("NUCLEOTIDE_SEQUENCE_NUCLEOTIDE_SEQUENCE_ID", String.class, ALPHANUMERIC); 865 866 /** 867 * Normalized gene name using the target_gene vocabulary. 868 */ 869 public final static OccurrenceSearchParameter NUCLEOTIDE_SEQUENCE_TARGET_GENE = new OccurrenceSearchParameter("NUCLEOTIDE_SEQUENCE_TARGET_GENE", String.class); 870 871 /** 872 * Final cleaned sequence. null if flagged invalid. 873 */ 874 public final static OccurrenceSearchParameter NUCLEOTIDE_SEQUENCE_SEQUENCE = new OccurrenceSearchParameter("NUCLEOTIDE_SEQUENCE_SEQUENCE", String.class); 875 876 /** 877 * Length of cleaned sequence in base pairs. 878 */ 879 public final static OccurrenceSearchParameter NUCLEOTIDE_SEQUENCE_SEQUENCE_LENGTH = new OccurrenceSearchParameter("NUCLEOTIDE_SEQUENCE_SEQUENCE_LENGTH", Integer.class); 880 881 /** 882 * GC content (0-1, based on A/C/G/T only). 883 */ 884 public final static OccurrenceSearchParameter NUCLEOTIDE_SEQUENCE_GC_CONTENT = new OccurrenceSearchParameter("NUCLEOTIDE_SEQUENCE_GC_CONTENT", Double.class); 885 886 /** 887 * Fraction of non-IUPAC characters (0-1). 888 */ 889 public final static OccurrenceSearchParameter NUCLEOTIDE_SEQUENCE_NON_IUPAC_FRACTION = new OccurrenceSearchParameter("NUCLEOTIDE_SEQUENCE_NON_IUPAC_FRACTION", Double.class); 890 891 /** 892 * Fraction of ambiguous IUPAC codes, not A/C/G/T/N (0-1). 893 */ 894 public final static OccurrenceSearchParameter NUCLEOTIDE_SEQUENCE_NON_ACGTN_FRACTION = new OccurrenceSearchParameter("NUCLEOTIDE_SEQUENCE_NON_ACGTN_FRACTION", Double.class); 895 896 /** 897 * Fraction of N characters (0-1). 898 */ 899 public final static OccurrenceSearchParameter NUCLEOTIDE_SEQUENCE_N_FRACTION = new OccurrenceSearchParameter("NUCLEOTIDE_SEQUENCE_N_FRACTION", Double.class); 900 901 /** 902 * Number of N-runs that were capped. 903 */ 904 public final static OccurrenceSearchParameter NUCLEOTIDE_SEQUENCE_N_RUNS_CAPPED = new OccurrenceSearchParameter("NUCLEOTIDE_SEQUENCE_N_RUNS_CAPPED", Integer.class); 905 906 /** 907 * Whether UNMERGED marker was found. 908 */ 909 public final static OccurrenceSearchParameter NUCLEOTIDE_SEQUENCE_NATURAL_LANGUAGE_DETECTED = new OccurrenceSearchParameter("NUCLEOTIDE_SEQUENCE_NATURAL_LANGUAGE_DETECTED", Boolean.class); 910 911 /** 912 * Whether ends were trimmed. 913 */ 914 public final static OccurrenceSearchParameter NUCLEOTIDE_SEQUENCE_ENDS_TRIMMED = new OccurrenceSearchParameter("NUCLEOTIDE_SEQUENCE_ENDS_TRIMMED", Boolean.class); 915 916 /** 917 * Whether gaps and/or whitespace were removed. 918 */ 919 public final static OccurrenceSearchParameter NUCLEOTIDE_SEQUENCE_GAPS_OR_WHITESPACE_REMOVED = new OccurrenceSearchParameter("NUCLEOTIDE_SEQUENCE_GAPS_OR_WHITESPACE_REMOVED", Boolean.class); 920 921 /** 922 * nonIupacFraction > 0 and/or naturalLanguageDetected is true. 923 */ 924 public final static OccurrenceSearchParameter NUCLEOTIDE_SEQUENCE_INVALID = new OccurrenceSearchParameter("NUCLEOTIDE_SEQUENCE_INVALID", Boolean.class); 925 926 /** 927 * Searches the MoF measurementType. 928 */ 929 public final static OccurrenceSearchParameter MEASUREMENT_TYPE = new OccurrenceSearchParameter("MEASUREMENT_TYPE", String.class); 930 931 /** 932 * Searches the eMoF measurementTypeID. 933 */ 934 public final static OccurrenceSearchParameter MEASUREMENT_TYPE_ID = new OccurrenceSearchParameter("MEASUREMENT_TYPE_ID", String.class); 935 936 937 public static OccurrenceSearchParameter[] values(){ 938 939 Field[] values = OccurrenceSearchParameter.class.getFields(); 940 List<OccurrenceSearchParameter> c = new ArrayList<>(); 941 for (Field field: values) { 942 try { 943 c.add((OccurrenceSearchParameter) field.get(OccurrenceSearchParameter.class)); 944 } catch (IllegalAccessException e) { 945 throw new RuntimeException(e); 946 } 947 } 948 return c.toArray(new OccurrenceSearchParameter[0]); 949 } 950 951 private Class<?> type; 952 private String name; 953 private SearchParameterFormat format; 954 955 public OccurrenceSearchParameter() {} 956 957 public OccurrenceSearchParameter(String name, Class<?> type, SearchParameterFormat format) { 958 this.name = name; 959 this.type = type; 960 this.format = format; 961 } 962 963 public OccurrenceSearchParameter(String name, Class<?> type) { 964 this.name = name; 965 this.type = type; 966 } 967 968 @Override 969 public String name() { 970 return this.name; 971 } 972 973 public String getName() { 974 return name; 975 } 976 977 @Override 978 public Class<?> type() { 979 return this.type; 980 } 981 982 public Class<?> getType() { 983 return type; 984 } 985 986 public SearchParameterFormat format() { 987 return this.format; 988 } 989 990 public SearchParameterFormat getFormat() { 991 return format; 992 } 993 994 @Override 995 public String toString() { 996 return name; 997 } 998 999 @Override 1000 public boolean equals(Object o) { 1001 if (this == o) return true; 1002 if (o == null || getClass() != o.getClass()) return false; 1003 OccurrenceSearchParameter that = (OccurrenceSearchParameter) o; 1004 return Objects.equals(type, that.type) && Objects.equals(name, that.name) && Objects.equals(format, that.format); 1005 } 1006 1007 @JsonValue 1008 public String getSerializedValue() { 1009 return name; 1010 } 1011 1012 @Override 1013 public int hashCode() { 1014 return Objects.hash(name, type, format); 1015 } 1016 1017 /** 1018 * Lookup a parameter by its name. 1019 * @param name the name of the parameter 1020 * @return the parameter if found, otherwise empty 1021 */ 1022 public static Optional<OccurrenceSearchParameter> lookup(String name) { 1023 String normedType = name.toUpperCase().replaceAll("[. _-]", ""); 1024 java.lang.reflect.Field[] values = OccurrenceSearchParameter.class.getFields(); 1025 for (Field field: values) { 1026 1027 String fieldName = field.getName(); 1028 String normedVal = fieldName.replaceAll("[. _-]", ""); 1029 if (normedType.equals(normedVal)) { 1030 try { 1031 return Optional.of((OccurrenceSearchParameter) field.get(OccurrenceSearchParameter.class)); 1032 } catch (IllegalAccessException e) { 1033 throw new RuntimeException(e); 1034 } 1035 } 1036 } 1037 return Optional.empty(); 1038 } 1039 1040 public static class OccurrenceSearchParameterKeyDeserializer extends KeyDeserializer { 1041 1042 @Override 1043 public Object deserializeKey(String value, DeserializationContext deserializationContext) throws IOException { 1044 Field[] values = OccurrenceSearchParameter.class.getFields(); 1045 try { 1046 for (Field field: values) { 1047 if (field.getName().equalsIgnoreCase(value)) { 1048 return (OccurrenceSearchParameter) field.get(OccurrenceSearchParameter.class); 1049 } 1050 } 1051 } catch (IllegalAccessException e) { 1052 // DO NOTHING 1053 } 1054 return null; 1055 } 1056 } 1057 1058 public static class OccurrenceSearchParameterDeserializer extends JsonDeserializer<OccurrenceSearchParameter> { 1059 1060 @Override 1061 public OccurrenceSearchParameter deserialize(com.fasterxml.jackson.core.JsonParser jsonParser, com.fasterxml.jackson.databind.DeserializationContext deserializationContext) throws IOException, JacksonException { 1062 1063 Field[] values = OccurrenceSearchParameter.class.getFields(); 1064 try { 1065 String value = jsonParser.getText(); 1066 for (Field field: values) { 1067 if (field.getName().equalsIgnoreCase(value)) { 1068 return (OccurrenceSearchParameter) field.get(OccurrenceSearchParameter.class); 1069 } 1070 } 1071 1072 } catch (IllegalAccessException e) { 1073 // DO NOTHING 1074 } 1075 1076 try { 1077 ObjectNode node = jsonParser.getCodec().readTree(jsonParser); 1078 String value = node.get("name").asText(); 1079 for (Field field: values) { 1080 if (field.getName().equalsIgnoreCase(value)) { 1081 return (OccurrenceSearchParameter) field.get(OccurrenceSearchParameter.class); 1082 } 1083 } 1084 } catch (Exception e) { 1085 // DO NOTHING 1086 } 1087 1088 return null; 1089 } 1090 } 1091}