Project

General

Profile

Download (3.16 KB) Statistics
| Branch: | Revision:
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.redlist;
11

    
12
import java.util.UUID;
13

    
14
import org.apache.log4j.Logger;
15

    
16
import eu.etaxonomy.cdm.app.common.CdmDestinations;
17
import eu.etaxonomy.cdm.app.common.CdmImportSources;
18
import eu.etaxonomy.cdm.database.DbSchemaValidation;
19
import eu.etaxonomy.cdm.database.ICdmDataSource;
20
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
21
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
22
import eu.etaxonomy.cdm.io.common.Source;
23
import eu.etaxonomy.cdm.io.redlist.RoteListeDbImportConfigurator;
24
import eu.etaxonomy.cdm.model.reference.Reference;
25
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
26

    
27
/**
28
 * @author a.mueller
29
 * @since 20.06.2008
30
 */
31
public class RoteListeDbChecklistActivator {
32
	@SuppressWarnings("unused")
33
	private static final Logger logger = Logger.getLogger(RoteListeDbChecklistActivator.class);
34

    
35
	//database validation status (create, update, validate ...)
36
	static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
37
	static final Source mySource = CdmImportSources.ROTE_LISTE_DB();
38

    
39
	static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
40

    
41
	int recordsPerTransaction = 1000;
42

    
43
	//feature tree uuid
44
	public static final UUID featureTreeUuid = UUID.fromString("ebe558b5-d04d-41d5-83d9-b61c56e6e34a");
45

    
46
	public static final String sourceReference = "Flora of Central Africa - Checklist";
47

    
48

    
49
	//classification
50
	public static final UUID classificationUuid = UUID.fromString("ce1d035a-79a9-4a3a-95bf-26641ecb4fbe");
51

    
52
	//check - import
53
	static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
54

    
55
	//taxa
56
	static final boolean doTaxa = true;
57

    
58
	private void doImport(ICdmDataSource cdmDestination){
59

    
60
		//make Source
61
		Source source = mySource;
62

    
63
		RoteListeDbImportConfigurator config= RoteListeDbImportConfigurator.NewInstance(source, cdmDestination);
64
		config.setClassificationUuid(classificationUuid);
65
		config.setDoTaxa(doTaxa);
66
		config.setCheck(check);
67
		config.setDbSchemaValidation(hbm2dll);
68
		config.setRecordsPerTransaction(recordsPerTransaction);
69

    
70
		CdmDefaultImport<RoteListeDbImportConfigurator> myImport = new CdmDefaultImport<>();
71

    
72
		System.out.println("Start import from ("+ source.toString() + ") ...");
73
		config.setSourceReference(getSourceReference(sourceReference));
74
		myImport.invoke(config);
75
		System.out.println("End import from ("+ source.toString() + ")...");
76

    
77

    
78

    
79
//		FeatureTree tree = makeFeatureNode(myImport.getCdmAppController().getTermService());
80
//		myImport.getCdmAppController().getFeatureTreeService().saveOrUpdate(tree);
81

    
82
	}
83

    
84
	private Reference getSourceReference(String string) {
85
		Reference result = ReferenceFactory.newGeneric();
86
		result.setTitleCache(string, true);
87
		return result;
88
	}
89

    
90

    
91
	/**
92
	 * @param args
93
	 */
94
	public static void main(String[] args) {
95
		RoteListeDbChecklistActivator me = new RoteListeDbChecklistActivator();
96
		me.doImport(cdmDestination);
97
	}
98

    
99
}
(5-5/5)