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.vocabulary;
015
016import org.gbif.api.util.VocabularyUtils;
017
018import java.util.HashMap;
019import java.util.Map;
020
021import javax.annotation.Nullable;
022
023/**
024 * Enumeration for all contact types.
025 * A utility to infer types is provided which has historically been used during data migration activities from legacy
026 * systems such as the previous "GBRDS" which was built on MySQL.
027 *
028 * @see <a href="http://rs.gbif.org/vocabulary/gbif/agent_role.xml">rs.gbif.org vocabulary</a>
029 */
030public enum ContactType {
031  /**
032   * A contact to contact for further technical information related to the dataset.
033   */
034  TECHNICAL_POINT_OF_CONTACT,
035  /**
036   * A contact to contact for further non-technical information related to the dataset.
037   */
038  ADMINISTRATIVE_POINT_OF_CONTACT,
039  /**
040   * A contact to contact for further information about the dataset.
041   */
042  POINT_OF_CONTACT,
043  /**
044   * A contact who originally gathered/prepared the dataset.
045   */
046  ORIGINATOR,
047  /**
048   * A contact responsible for providing the metadata.
049   */
050  METADATA_AUTHOR,
051  /**
052   * A primary scientific contact associated with the dataset.
053   */
054  PRINCIPAL_INVESTIGATOR,
055  /**
056   * A contact who is an author of a publication that used the dataset, or author of a data paper.
057   */
058  AUTHOR,
059  /**
060   * A contact who contributed content to a dataset (the dataset being described may be a composite).
061   */
062  CONTENT_PROVIDER,
063  /**
064   * A contact who is responsible for/takes care of the dataset.
065   */
066  CUSTODIAN_STEWARD,
067  /**
068   * A contact involved in the publishing/distribution chain of a dataset.
069   */
070  DISTRIBUTOR,
071  /**
072   * A contact associated with editing a publication that used the dataset, or a data paper.
073   */
074  EDITOR,
075  /**
076   * A contact who owns the dataset (may or may not be the custodian).
077   */
078  OWNER,
079  /**
080   * A contact responsible for any post-collection processing of the dataset.
081   */
082  PROCESSOR,
083  /**
084   * A contact associated with the publishing of some entity (paper, article, book, etc) based on the dataset, or of a
085   * data paper.
086   */
087  PUBLISHER,
088  /**
089   * The contact that makes use of the dataset.
090   */
091  USER,
092  /**
093   * The contact providing informatics/programming support related to the dataset.
094   */
095  PROGRAMMER,
096  /**
097   * The contact that maintains and documents the specimens in a collection. Some of their duties include preparing and
098   * labeling specimens so they are ready for identification, and protecting the specimens.
099   */
100  CURATOR,
101  /**
102   * A contact who manages the operation of a data system.
103   */
104  DATA_ADMINISTRATOR,
105  /**
106   * A contact who manages the operation of a computer system.
107   */
108  SYSTEM_ADMINISTRATOR,
109  /**
110   * A contact appointed to lead and represent a Participant's delegation at the GBIF Governing Board.
111   */
112  HEAD_OF_DELEGATION,
113  /**
114   * A contact temporarily appointed to lead and represent a Participant's delegation at the GBIF Governing Board.
115   */
116  TEMPORARY_HEAD_OF_DELEGATION,
117  /**
118   * A contact appointed to a Participant's delegation at the GBIF Governing Board.
119   */
120  ADDITIONAL_DELEGATE,
121  /**
122   * A contact temporarily appointed to a Participant's delegation at the GBIF Governing Board.
123   */
124  TEMPORARY_DELEGATE,
125  /**
126   * A contact representing a regional group of Nodes.
127   */
128  REGIONAL_NODE_REPRESENTATIVE,
129  /**
130   * A contact leading the work of the Node and representing the Node in the Nodes Committee.
131   */
132  NODE_MANAGER,
133  /**
134   * A contact who is a member of the Node's staff.
135   */
136  NODE_STAFF,
137  /**
138   * A person assigned to review the dataset and verify its data and/or metadata quality.
139   * This role is analogous to the role played by peer reviewers in the scholarly publication process.
140   */
141  REVIEWER;
142
143  /**
144   * @return the matching ContactType or null
145   */
146  public static ContactType fromString(String contactType) {
147    return (ContactType) VocabularyUtils.lookupEnum(contactType, ContactType.class);
148  }
149
150  // deliberate typos have existed and might be in genuine use
151  private static final Map<String, ContactType> TYPE_LOOKUP = new HashMap<>();
152
153  static {
154    TYPE_LOOKUP.put("administrative", ADMINISTRATIVE_POINT_OF_CONTACT);
155    TYPE_LOOKUP.put("technical", TECHNICAL_POINT_OF_CONTACT);
156    TYPE_LOOKUP.put("pointofcontact", POINT_OF_CONTACT);
157    TYPE_LOOKUP.put("originator", ORIGINATOR);
158    TYPE_LOOKUP.put("metadataprovider", METADATA_AUTHOR);
159    TYPE_LOOKUP.put("principleinvestigator", PRINCIPAL_INVESTIGATOR);
160    TYPE_LOOKUP.put("author", AUTHOR);
161    TYPE_LOOKUP.put("contentprovider", CONTENT_PROVIDER);
162    TYPE_LOOKUP.put("custodiansteward", CUSTODIAN_STEWARD);
163    TYPE_LOOKUP.put("distributor", DISTRIBUTOR);
164    TYPE_LOOKUP.put("editor", EDITOR);
165    TYPE_LOOKUP.put("owner", OWNER);
166    TYPE_LOOKUP.put("processor", PROCESSOR);
167    TYPE_LOOKUP.put("publisher", PUBLISHER);
168    TYPE_LOOKUP.put("user", USER);
169    TYPE_LOOKUP.put("programmer", PROGRAMMER);
170    TYPE_LOOKUP.put("curator", CURATOR);
171    TYPE_LOOKUP.put("data administrator", DATA_ADMINISTRATOR);
172    TYPE_LOOKUP.put("system adminsitrator", SYSTEM_ADMINISTRATOR); // deliberate typo
173    TYPE_LOOKUP.put("system administrator", SYSTEM_ADMINISTRATOR);
174  }
175
176  /**
177   * Tries its best to infer a ContactType from a given string. This can for example be used for the various contact
178   * types from DiGIR, TAPIR and BioCASe.
179   *
180   * @return the inferred ContactType
181   */
182  public static ContactType inferType(@Nullable String type) {
183    if (type != null) {
184      ContactType contactType = TYPE_LOOKUP.get(type.toLowerCase());
185      if (contactType != null) {
186        return contactType;
187      }
188      return fromString(type);
189    }
190    return null;
191  }
192}