001/*
002 * Copyright 2014 Global Biodiversity Information Facility (GBIF)
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.gbif.api.service.occurrence;
017
018import org.gbif.api.exception.ServiceUnavailableException;
019import org.gbif.api.model.occurrence.Occurrence;
020import org.gbif.api.model.occurrence.VerbatimOccurrence;
021
022import javax.annotation.Nullable;
023
024public interface OccurrenceService {
025
026  /**
027   * Attempt to find an occurrence matching the passed key.
028   *
029   * @param key that identifies an occurrence (Integer rather than int for use in methods/classes using generic types)
030   *
031   * @return a matching occurrence, or null if no occurrence can be found
032   *
033   * @throws ServiceUnavailableException if the underlying data connection fails
034   */
035  @Nullable
036  Occurrence get(Integer key);
037
038  /**
039   * Attempt to find the verbatim values for an occurrence matching the passed key.
040   *
041   * @param key that identifies the occurrence
042   *
043   * @return the verbatim occurrence, or null if no occurrence can be found
044   *
045   * @throws ServiceUnavailableException if the underlying data connection fails
046   */
047  @Nullable
048  VerbatimOccurrence getVerbatim(Integer key);
049
050  /**
051   * Returns the "fragment" of raw data (either xml response fragment or json dwca fragment) for the passed in key.
052   * Returns null if no fragment exists.
053   *
054   * @param key that identifies an occurrence
055   *
056   * @return the raw data fragment as a String, or null if no fragment is found
057   *
058   * @throws ServiceUnavailableException if the underlying data connection fails
059   */
060  @Nullable
061  String getFragment(int key);
062}