Project

General

Profile

Download (4.2 KB) Statistics
| Branch: | 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.app.pesi;
10

    
11
import org.apache.log4j.Logger;
12

    
13
import eu.etaxonomy.cdm.app.common.CdmDestinations;
14
import eu.etaxonomy.cdm.database.ICdmDataSource;
15
import eu.etaxonomy.cdm.io.common.CdmDefaultExport;
16
import eu.etaxonomy.cdm.io.common.DbExportConfiguratorBase.IdType;
17
import eu.etaxonomy.cdm.io.common.IExportConfigurator.CHECK;
18
import eu.etaxonomy.cdm.io.common.IExportConfigurator.DO_REFERENCES;
19
import eu.etaxonomy.cdm.io.common.Source;
20
import eu.etaxonomy.cdm.io.pesi.out.PesiExportConfigurator;
21
import eu.etaxonomy.cdm.io.pesi.out.PesiTransformer;
22

    
23
/**
24
 * @author a.mueller
25
 * @author e.-m.lee
26
 * @since 16.02.2010
27
 */
28
public class PesiExportActivatorIF {
29

    
30
	@SuppressWarnings("unused")
31
	private static final Logger logger = Logger.getLogger(PesiExportActivatorIF.class);
32

    
33
	static final ICdmDataSource cdmSource = CdmDestinations.cdm_test_local_indexFungorum2();
34
	static final Source pesiDestination = PesiDestinations.pesi_test_local_CDM_IF2PESI();
35
//	static final Source pesiDestination = PesiDestinations.pesi_test_local_CDM_IF2PESI_2();
36

    
37

    
38
	static final IdType idType = IdType.CDM_ID;
39
	//check - export
40
	static final CHECK check = CHECK.EXPORT_WITHOUT_CHECK;
41
	static final int partitionSize = 2000;
42

    
43
// ****************** ALL *****************************************
44

    
45
    boolean deleteAll = true;
46
    DO_REFERENCES doReferences =  DO_REFERENCES.ALL;
47
    boolean doTaxa = true;
48
    boolean doRelTaxa = true;
49
    boolean doDescriptions = true;
50

    
51
    boolean doTreeIndex = doTaxa;
52
    boolean doParentAndBiota = doTaxa;
53

    
54
    boolean doPureNames = false;  //!!
55
    boolean doAdditionalTaxonSource = true;  //existing??
56
    boolean doInferredSynonyms = false;   //no inferred synonyms in IF
57
    boolean doEcologyAndLink = false;   //do not exist in IF
58

    
59

    
60
// ************************ NONE **************************************** //
61

    
62
//    boolean deleteAll = false;
63
//    DO_REFERENCES doReferences =  DO_REFERENCES.NONE;
64
//    boolean doTaxa = false;
65
//    boolean doRelTaxa = false;
66
//    boolean doDescriptions = false;
67
//
68
//    boolean doTreeIndex = doTaxa;
69
//    boolean doParentAndBiota = doTaxa;
70
//
71
//    boolean doPureNames = false;  //!!
72
//    boolean doAdditionalTaxonSource = false;  //existing??
73
//    boolean doInferredSynonyms = false;   //no inferred synonyms in IF
74
//    boolean doEcologyAndLink = false;   //do not exist in IF
75

    
76

    
77
	public boolean 	doExport(ICdmDataSource source){
78
		System.out.println("Start export to PESI ("+ pesiDestination.getDatabase() + ") ...");
79

    
80
		//make PESI Source
81
		Source destination = pesiDestination;
82
		PesiTransformer transformer = new PesiTransformer(destination);
83

    
84
		PesiExportConfigurator config = PesiExportConfigurator.NewInstance(destination, source, transformer);
85

    
86
		config.setDoReferences(doReferences);
87
		config.setDoTaxa(doTaxa);
88
		config.setDoRelTaxa(doRelTaxa);
89
		config.setDoParentAndBiota(doParentAndBiota);
90
		config.setDoTreeIndex(doTreeIndex);
91
		config.setDoInferredSynonyms(doInferredSynonyms);
92
		config.setDoPureNames(doPureNames);
93
		config.setDoDescription(doDescriptions);
94
		config.setDoAdditionalTaxonSource(doAdditionalTaxonSource);
95
		config.setDoEcologyAndLink(doEcologyAndLink);
96

    
97
		config.setCheck(check);
98
		config.setLimitSave(partitionSize);
99
		config.setIdType(idType);
100
		if (deleteAll){
101
			destination.update("EXEC sp_deleteAllData");
102
		}
103

    
104
		// invoke export
105
		CdmDefaultExport<PesiExportConfigurator> pesiExport = new CdmDefaultExport<>();
106

    
107
		boolean result = pesiExport.invoke(config).isSuccess();
108

    
109
		System.out.println("End export to PESI ("+ destination.getDatabase() + ")..." + (result? "(successful)":"(with errors)"));
110
		return result;
111
	}
112

    
113
	public static void main(String[] args) {
114
		PesiExportActivatorIF ex = new PesiExportActivatorIF();
115
		ICdmDataSource source = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmSource;
116
		ex.doExport(source);
117
		System.exit(0);
118
	}
119
}
(11-11/12)