Project

General

Profile

Download (4.25 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.app.common.PesiDestinations;
15
import eu.etaxonomy.cdm.database.ICdmDataSource;
16
import eu.etaxonomy.cdm.io.common.CdmDefaultExport;
17
import eu.etaxonomy.cdm.io.common.DbExportConfiguratorBase.IdType;
18
import eu.etaxonomy.cdm.io.common.IExportConfigurator.CHECK;
19
import eu.etaxonomy.cdm.io.common.IExportConfigurator.DO_REFERENCES;
20
import eu.etaxonomy.cdm.io.common.Source;
21
import eu.etaxonomy.cdm.io.pesi.out.PesiExportConfigurator;
22
import eu.etaxonomy.cdm.io.pesi.out.PesiTransformer;
23

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

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

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

    
38

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

    
44
// ****************** ALL *****************************************
45

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

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

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

    
60

    
61
// ************************ NONE **************************************** //
62

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

    
77

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

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

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

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

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

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

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

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

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