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.service.collections; 015 016import org.gbif.api.model.collections.CollectionEntity; 017import org.gbif.api.model.collections.Contact; 018 019import java.util.List; 020import java.util.UUID; 021 022import javax.validation.Valid; 023import javax.validation.constraints.NotNull; 024 025import org.gbif.api.model.collections.suggestions.ChangeSuggestion; 026 027/** API Service for the contacts in the collections service. */ 028public interface ContactService { 029 030 /** 031 * Lists all the contacts of an entity. 032 * 033 * @param entityKey of the entity 034 * @return list of {@link org.gbif.api.model.collections.Contact} 035 */ 036 List<Contact> listContactPersons(@NotNull UUID entityKey); 037 038 /** 039 * Adds a {@link Contact} contact to an entity. 040 * 041 * @param entityKey key of the entity where the contact will be added to. 042 * @param contact key of the contact to add. 043 */ 044 int addContactPerson(@NotNull UUID entityKey, @NotNull @Valid Contact contact); 045 046 /** 047 * Updates a {@link Contact} contact in an entity. 048 * 049 * @param entityKey key of the entity where the contact will be updated. 050 * @param contact updated contact. 051 */ 052 void updateContactPerson(@NotNull UUID entityKey, @NotNull @Valid Contact contact); 053 054 /** 055 * Removes a {@link Contact} contact from an entity. 056 * 057 * @param entityKey key of the entity where the contact will be removed from. 058 * @param contactKey key of the contact to remove. 059 */ 060 void removeContactPerson(@NotNull UUID entityKey, @NotNull int contactKey); 061 062 /** 063 * Removes all the contacts from an entity. 064 * 065 * @param entityKey key of the entity where the contact will be removed from. 066 * @param newContactPersons contact persons that will replace the existing ones. 067 */ 068 void replaceContactPersons(@NotNull UUID entityKey, List<@Valid Contact> newContactPersons); 069 070 /** 071 * Adds a {@link Contact} IH contact to an entity. 072 * 073 * @param entityKey key of the entity where the contact will be added to. 074 * @param changeSuggestion suggestion to get contacts from 075 */ 076 <T extends CollectionEntity> void addSuggestionContacts(@NotNull UUID entityKey, @NotNull ChangeSuggestion<T> changeSuggestion); 077}