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
	@SuppressWarnings("unused")
30
	private static final Logger logger = Logger.getLogger(PesiExportActivatorIF.class);
31

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

    
36

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

    
42
// ****************** ALL *****************************************
43

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

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

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

    
58

    
59
// ************************ NONE **************************************** //
60

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

    
75

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

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

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

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

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

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

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

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

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