1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2009 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
package eu.etaxonomy.cdm.app.pesi;
|
11
|
|
12
|
import java.util.UUID;
|
13
|
|
14
|
import org.apache.log4j.Logger;
|
15
|
import org.springframework.transaction.TransactionStatus;
|
16
|
|
17
|
import eu.etaxonomy.cdm.app.common.CdmDestinations;
|
18
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
19
|
import eu.etaxonomy.cdm.io.common.CdmDefaultExport;
|
20
|
import eu.etaxonomy.cdm.io.common.Source;
|
21
|
import eu.etaxonomy.cdm.io.common.IExportConfigurator.CHECK;
|
22
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.DO_REFERENCES;
|
23
|
import eu.etaxonomy.cdm.io.pesi.out.PesiExportConfigurator;
|
24
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
25
|
|
26
|
/**
|
27
|
* @author a.mueller
|
28
|
* @author e.-m.lee
|
29
|
* @date 16.02.2010
|
30
|
*
|
31
|
*/
|
32
|
public class PesiExportActivator {
|
33
|
|
34
|
@SuppressWarnings("unused")
|
35
|
private static final Logger logger = Logger.getLogger(PesiExportActivator.class);
|
36
|
|
37
|
//database validation status (create, update, validate ...)
|
38
|
static final Source pesiDestination = PesiDestinations.pesi_test_local_CDM_DWH_FaEu();
|
39
|
static final ICdmDataSource cdmSource = CdmDestinations.cdm_test_jaxb();
|
40
|
static final UUID secUuid = UUID.fromString("d03ef02a-f226-4cb1-bdb4-f6c154f08a34");
|
41
|
static final int sourceSecId = 7331;
|
42
|
static final int isHomotypicId = 72;
|
43
|
static boolean useTaxonomicTree = true;
|
44
|
|
45
|
//check - export
|
46
|
static final CHECK check = CHECK.EXPORT_WITHOUT_CHECK;
|
47
|
|
48
|
//NomeclaturalCode
|
49
|
static final NomenclaturalCode nomenclaturalCode = NomenclaturalCode.ICBN;
|
50
|
|
51
|
// ****************** ALL *****************************************
|
52
|
|
53
|
//authors
|
54
|
static final boolean doAuthors = true;
|
55
|
//references
|
56
|
static final DO_REFERENCES doReferences = DO_REFERENCES.ALL;
|
57
|
//names
|
58
|
static final boolean doTaxonNames = true;
|
59
|
static final boolean doRelNames = true;
|
60
|
static final boolean doNameStatus = true;
|
61
|
static final boolean doTypes = false;
|
62
|
static final boolean doNameFacts = false;
|
63
|
|
64
|
//taxa
|
65
|
static final boolean doTaxa = true;
|
66
|
static final boolean doRelTaxa = true;
|
67
|
static final boolean doFacts = true;
|
68
|
static final boolean doOccurences = true;
|
69
|
|
70
|
// ************************ NONE **************************************** //
|
71
|
|
72
|
// //authors
|
73
|
// static final boolean doAuthors = false;
|
74
|
// static final boolean doAuthorTeams = false;
|
75
|
// //references
|
76
|
// static final DO_REFERENCES doReferences = DO_REFERENCES.ALL;
|
77
|
// //names
|
78
|
// static final boolean doTaxonNames = true;
|
79
|
// static final boolean doRelNames = true;
|
80
|
// static final boolean doNameStatus = false;
|
81
|
// static final boolean doTypes = false;
|
82
|
// static final boolean doNameFacts = false;
|
83
|
//
|
84
|
// //taxa
|
85
|
// static final boolean doTaxa = false;
|
86
|
// static final boolean doRelTaxa = false;
|
87
|
// static final boolean doFacts = false;
|
88
|
// static final boolean doOccurences = false;
|
89
|
//
|
90
|
|
91
|
public boolean doExport(ICdmDataSource source){
|
92
|
System.out.println("Start export to PESI ("+ pesiDestination.getDatabase() + ") ...");
|
93
|
|
94
|
//make PESI Source
|
95
|
Source destination = pesiDestination;
|
96
|
|
97
|
PesiExportConfigurator pesiExportConfigurator = PesiExportConfigurator.NewInstance(destination, source);
|
98
|
|
99
|
pesiExportConfigurator.setDoAuthors(doAuthors);
|
100
|
pesiExportConfigurator.setDoReferences(doReferences);
|
101
|
pesiExportConfigurator.setDoTaxonNames(doTaxonNames);
|
102
|
pesiExportConfigurator.setDoRelNames(doRelNames);
|
103
|
pesiExportConfigurator.setDoNameStatus(doNameStatus);
|
104
|
pesiExportConfigurator.setDoTypes(doTypes);
|
105
|
pesiExportConfigurator.setDoNameFacts(doNameFacts);
|
106
|
|
107
|
pesiExportConfigurator.setDoTaxa(doTaxa);
|
108
|
pesiExportConfigurator.setDoRelTaxa(doRelTaxa);
|
109
|
pesiExportConfigurator.setDoFacts(doFacts);
|
110
|
pesiExportConfigurator.setDoOccurrence(doOccurences);
|
111
|
// pesiExportConfigurator.setIsHomotypicId(isHomotypicId);
|
112
|
pesiExportConfigurator.setCheck(check);
|
113
|
pesiExportConfigurator.setUseTaxonomicTree(useTaxonomicTree);
|
114
|
|
115
|
// invoke export
|
116
|
CdmDefaultExport<PesiExportConfigurator> pesiExport = new CdmDefaultExport<PesiExportConfigurator>();
|
117
|
boolean result = pesiExport.invoke(pesiExportConfigurator);
|
118
|
|
119
|
System.out.println("End export to PESI ("+ destination.getDatabase() + ")..." + (result? "(successful)":"(with errors)"));
|
120
|
return result;
|
121
|
}
|
122
|
|
123
|
/**
|
124
|
* @param args
|
125
|
*/
|
126
|
public static void main(String[] args) {
|
127
|
PesiExportActivator ex = new PesiExportActivator();
|
128
|
ICdmDataSource source = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmSource;
|
129
|
|
130
|
ex.doExport(source);
|
131
|
}
|
132
|
|
133
|
}
|