Project

General

Profile

« Previous | Next » 

Revision ad6077dc

Added by Andreas Müller over 12 years ago

make mapping type configurable

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/DwcaImportConfigurator.java
18 18
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
19 19
import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
20 20
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
21
import eu.etaxonomy.cdm.io.dwca.in.IImportMapping.MappingType;
21 22
import eu.etaxonomy.cdm.model.reference.Reference;
22 23
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
23 24

  
......
30 31
	private static IInputTransformer defaultTransformer = new DwcaImportTransformer();
31 32
	
32 33
	private boolean usePartitions = true;
33
	private int defaultPartitionSize = 1000;
34
	private int defaultPartitionSize = 2000;
34 35
	
35
//	//new
36
//	private boolean doSpecimen = true;  //reads the specimen worksheet
37
//	private boolean doAreaLevels = true;  //reads the areaLevels worksheet
38
//	private boolean doExtensionTypes = true;  //reads the extensionType worksheet
39
	
40
	
41
//	private boolean useCountry;  //if isocountry and country is available, use country instead of isocountry 
42
//	//tries to match areas by the abbreviated label
43
//	//TODO still needs to be refined as this may hold only for certain vocabularies, levels, ...
44
//	//there also maybe more strategies like first label, then abbreviated label, ....
45
//	private TermMatchMode areaMatchMode = TermMatchMode.UUID_ONLY;
46
//	private PersonParserFormatEnum personParserFormat = PersonParserFormatEnum.POSTFIX;  //
47
//	
48
//	//if true, determinations are imported also as individualAssociations	
49
//	private boolean makeIndividualAssociations = true;
50
//	private boolean useMaterialsExaminedForIndividualsAssociations = true;
51
//	private boolean firstDeterminationIsStoredUnder = false;
52
//	private boolean determinationsAreDeterminationEvent = true;
53
//	
54
//	private boolean preferNameCache = true;
55
//	private boolean createTaxonIfNotExists = false;
56
////	private boolean includeSynonymsForTaxonMatching = false;
57

  
36
	private IImportMapping.MappingType mappingType = MappingType.InMemoryMapping;
58 37
		
59 38

  
60 39

  
......
122 101
	public int getDefaultPartitionSize() {
123 102
		return defaultPartitionSize;
124 103
	}
104

  
105
	public IImportMapping.MappingType getMappingType() {
106
		return mappingType;
107
	}
108

  
109
	public void setMappingType(IImportMapping.MappingType mappingType) {
110
		this.mappingType = mappingType;
111
	}
125 112
	
126 113
	
127 114
}
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/DwcaImportState.java
33 33
public class DwcaImportState extends ImportStateBase<DwcaImportConfigurator, DwcaImport>{
34 34
	private static final Logger logger = Logger.getLogger(DwcaImportState.class);
35 35

  
36
	UUID uuid = UUID.randomUUID();
36
	private UUID uuid = UUID.randomUUID();
37 37
	
38 38
	boolean taxaCreated;
39 39
	private Map<String, Map<String, IdentifiableEntity>> partitionStore;
40 40
	
41
	private IImportMapping mapping = new DatabaseMapping(uuid.toString());
41
	private IImportMapping mapping = getConfig().getMappingType().getMappingInstance(uuid.toString());
42 42
	
43 43
	public DwcaImportState(DwcaImportConfigurator config) {
44 44
		super(config);
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/IImportMapping.java
8 8
*/
9 9
package eu.etaxonomy.cdm.io.dwca.in;
10 10

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

  
......
20 19
 */
21 20
public interface IImportMapping {
22 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
	
23 45
	/**
24 46
	 * Put the destination object with for the given namespaced identifier into the mapping.
25 47
	 * @param namespace

Also available in: Unified diff