Project

General

Profile

« Previous | Next » 

Revision 10e572d4

Added by Andreas Müller about 10 years ago

add Ferns import activator

View differences:

.gitattributes
1210 1210
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/CentralAfricaChecklistActivator.java -text
1211 1211
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/CentralAfricaEricaceaeActivator.java -text
1212 1212
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/CentralAfricaFernsActivator.java -text
1213
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/CentralAfricaFernsFdacImportActivator.java -text
1213 1214
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/EfloraSources.java -text
1214 1215
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/FloraGuianasActivator.java -text
1215 1216
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/FloraMalesianaActivator.java -text
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/CentralAfricaFernsFdacImportActivator.java
1
/**
2
* Copyright (C) 2007 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

  
10
package eu.etaxonomy.cdm.app.eflora;
11

  
12
import java.net.URI;
13

  
14
import org.apache.log4j.Logger;
15

  
16
import eu.etaxonomy.cdm.database.DbSchemaValidation;
17
import eu.etaxonomy.cdm.database.ICdmDataSource;
18
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
19
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
20
import eu.etaxonomy.cdm.io.common.events.LoggingIoObserver;
21
import eu.etaxonomy.cdm.io.dwca.in.DwcaImportConfigurator;
22
import eu.etaxonomy.cdm.io.dwca.in.DwcaImportConfigurator.DatasetUse;
23
import eu.etaxonomy.cdm.io.dwca.in.IImportMapping.MappingType;
24
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
25
import eu.etaxonomy.cdm.model.reference.Reference;
26
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
27

  
28
/**
29
 * @author a.mueller
30
 * @created 03.04.2012
31
 * @version 1.0
32
 */
33
public class CentralAfricaFernsFdacImportActivator {
34
	@SuppressWarnings("unused")
35
	private static final Logger logger = Logger.getLogger(CentralAfricaFernsFdacImportActivator.class);
36
	
37
	//database validation status (create, update, validate ...)
38
	static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
39
	static final URI source = dwca_ferns();
40
	
41
	
42
//	static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
43
	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_fdac();
44

  
45
	static final String sourceReferenceTitle = "Ferns import(Dwc-A)";
46
	
47
	//default nom code is ICZN as it allows adding publication year 
48
	static final NomenclaturalCode defaultNomCode = NomenclaturalCode.ICBN;
49

  
50
	
51
	//check - import
52
	static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
53
	
54
	//config
55
	static DatasetUse datasetUse = DatasetUse.CLASSIFICATION;
56
	
57
	//validate
58
	static boolean validateRankConsistency = true;
59
	
60
	
61
	//taxa
62
	static final boolean doTaxa = true;
63
	
64
	
65
	
66
	static final MappingType mappingType = MappingType.InMemoryMapping;
67
	
68
	private void doImport(ICdmDataSource cdmDestination){
69
		
70
		//make Source
71
		DwcaImportConfigurator config= DwcaImportConfigurator.NewInstance(source, cdmDestination);
72
		config.addObserver(new LoggingIoObserver());
73
		config.setCheck(check);
74
		config.setDbSchemaValidation(hbm2dll);
75
		config.setMappingType(mappingType);
76
		config.setValidateRankConsistency(validateRankConsistency);
77
		config.setNomenclaturalCode(defaultNomCode);
78
		config.setSourceReferenceTitle(sourceReferenceTitle);
79
		
80
		CdmDefaultImport myImport = new CdmDefaultImport();
81

  
82
		
83
		//...
84
		if (true){
85
			System.out.println("Start import from ("+ source.toString() + ") ...");
86
			config.setSourceReference(getSourceReference(config.getSourceReferenceTitle()));
87
			myImport.invoke(config);
88
			System.out.println("End import from ("+ source.toString() + ")...");
89
		}
90
		
91
		
92
	}
93

  
94
	private Reference<?> getSourceReference(String string) {
95
		Reference<?> result = ReferenceFactory.newGeneric();
96
		result.setTitleCache(string);
97
		return result;
98
	}
99

  
100
	
101
	//Scratchpads test
102
	public static URI dwca_ferns() {
103
		URI sourceUrl = URI.create("file:////PESIIMPORT3/fdac/dwca/ferns.zip");
104
		return sourceUrl;
105
	}
106
	
107

  
108
	/**
109
	 * @param args
110
	 */
111
	public static void main(String[] args) {
112
		CentralAfricaFernsFdacImportActivator me = new CentralAfricaFernsFdacImportActivator();
113
		me.doImport(cdmDestination);
114
	}
115
	
116
}

Also available in: Unified diff