1 /* 2 * Copyright 2015 Data Archiving and Networked Services (an institute of 3 * Koninklijke Nederlandse Akademie van Wetenschappen), King's College London, 4 * Georg-August-Universitaet Goettingen Stiftung Oeffentlichen Rechts 5 * 6 * Licensed under the EUPL, Version 1.1 or – as soon they will be approved by 7 * the European Commission - subsequent versions of the EUPL (the "Licence"); 8 * You may not use this work except in compliance with the Licence. 9 * You may obtain a copy of the Licence at: 10 * 11 * https://joinup.ec.europa.eu/software/page/eupl 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the Licence is distributed on an "AS IS" basis, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the Licence for the specific language governing 17 * permissions and limitations under the Licence. 18 */ 19 20 package eu.ehri.project.models.idgen; 21 22 import com.google.common.collect.ListMultimap; 23 import eu.ehri.project.persistence.Bundle; 24 25 import java.util.Collection; 26 27 /** 28 * Generate an ID given an entity type, a set of scopes, and some data. 29 */ 30 public interface IdGenerator { 31 32 /** 33 * @param scopeIds The entity's parent scope identifiers 34 * @param bundle The entity's bundle data 35 * @return A set of errors 36 */ 37 ListMultimap<String, String> handleIdCollision(Collection<String> scopeIds, Bundle bundle); 38 39 /** 40 * Generate an ID given an array of scope IDs. This can be used 41 * where the scope might not yet exist. 42 * 43 * @param scopeIds An array of scope ids, ordered parent-to-child. 44 * @param bundle The entity's bundle data 45 * @return A generated ID string 46 */ 47 String generateId(Collection<String> scopeIds, Bundle bundle); 48 49 /** 50 * Return the base data for the id, sans scoping. 51 * @param bundle The entity's bundle. 52 * @return The base id string. 53 */ 54 String getIdBase(Bundle bundle); 55 }