Project

General

Profile

Download (3.07 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.io.dwca.in;
10

    
11
import java.util.Map;
12
import java.util.Set;
13

    
14
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
15

    
16
/**
17
 * @author a.mueller
18
 *
19
 */
20
public interface IImportMapping {
21
	
22
	
23
	public enum MappingType{
24
		InMemoryMapping(0),
25
		DatabaseMapping(1);
26
		
27
		private int index; 
28
		
29
		private MappingType(int index){
30
			this.index = index; 
31
		}
32
		
33
		public IImportMapping getMappingInstance(String mappingId){
34
			if (this.equals(MappingType.InMemoryMapping)){
35
				return new InMemoryMapping();
36
			}else if (this.equals(MappingType.DatabaseMapping)){
37
				return new DatabaseMapping(mappingId);
38
			}else{
39
				throw new RuntimeException("Unknown MappingType: " + this.toString());
40
			}
41
		}
42
		
43
	}
44
	
45
	/**
46
	 * Put the destination object with for the given namespaced identifier into the mapping.
47
	 * @param namespace
48
	 * @param sourceKey
49
	 * @param destinationObject
50
	 */
51
	public void putMapping(String namespace, String sourceKey, IdentifiableEntity destinationObject);
52

    
53
	/**
54
	 * Put the destination object with for the given namespaced identifier into the mapping.
55
	 * @param namespace
56
	 * @param sourceKey
57
	 * @param destinationObject
58
	 * @see #putMapping(String, String, IdentifiableEntity)
59
	 */
60
	public void putMapping(String namespace, Integer sourceKey, IdentifiableEntity destinationObject);
61

    
62
	
63
	/**
64
	 * Retrieve the CdmKey set for the given namespaced identifier.
65
	 * @param namespace
66
	 * @param sourceKey
67
	 * @return
68
	 */
69
	public Set<CdmKey> get(String namespace, String sourceKey);
70

    
71
	/**
72
	 * Checks if a mapping exists for a given namespaced identifier.
73
	 * If destinationClass is not <code>null</code> the mapping is limited to 
74
	 * result objects of the given class or a subclass of the given class.
75
	 * @param namespace
76
	 * @param sourceKey
77
	 * @param destinationClass
78
	 * @return
79
	 */
80
	public boolean exists(String namespace, String sourceKey,Class<?> destinationClass);
81

    
82
	/**
83
	 * Returns the mapping for only those obejcts addressed by the namespacedSourceKeys parameter
84
	 * @param namespacedKeys
85
	 * @return
86
	 */
87
	public InMemoryMapping getPartialMapping(Map<String, Set<String>> namespacedSourceKeys);
88

    
89
//	/**
90
//	 * Returns a list for all mapping entries.
91
//	 * @return
92
//	 */
93
//	//ONLY for InMemoryMapping, remove here
94
//	public List<MappingEntry<String, String, Class, Integer>> getEntryList();
95
//	
96
	
97
	public class CdmKey<CLASS extends IdentifiableEntity>{
98
		Class<CLASS> clazz;
99
		int id;
100
		
101
		public CdmKey(Class clazz, int id){
102
			this.clazz = clazz;
103
			this.id = id;
104
		}
105
			
106
		public CdmKey(IdentifiableEntity<?> object){
107
			this.clazz = (Class)object.getClass();
108
			this.id = object.getId();
109
		}
110
		
111
		@Override
112
		public String toString(){
113
			return id + "@" + clazz.getSimpleName();
114
		}
115
	}
116

    
117
	public void finish();
118
	
119
}
(17-17/28)