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.net.URI;
|
13
|
import java.util.Arrays;
|
14
|
import java.util.List;
|
15
|
import java.util.Scanner;
|
16
|
|
17
|
import org.apache.log4j.Logger;
|
18
|
|
19
|
import eu.etaxonomy.cdm.app.common.CdmDestinations;
|
20
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
21
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
22
|
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
|
23
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
|
24
|
import eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlImportConfigurator;
|
25
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
26
|
|
27
|
/**
|
28
|
* @author a.oppermann
|
29
|
* @created 16.07.2013
|
30
|
*/
|
31
|
public class BfnXmlTestActivator {
|
32
|
|
33
|
private static final Logger logger = Logger.getLogger(BfnXmlTestActivator.class);
|
34
|
|
35
|
//database validation status (create, update, validate ...)
|
36
|
static DbSchemaValidation schemaValidation = DbSchemaValidation.VALIDATE;
|
37
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_redlist_plant_localhost();
|
38
|
// static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
|
39
|
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_redlist_animalia_localhost();
|
40
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_redlist_animalia_production();
|
41
|
|
42
|
|
43
|
// private static final String strSource = "/eu/etaxonomy/cdm/io/bfnXml/";
|
44
|
private static final String sourceUriBase = "file:////BGBM-PESIHPC/RoteListen/";
|
45
|
|
46
|
//nom Code
|
47
|
private static final NomenclaturalCode nomenclaturalCode = NomenclaturalCode.ICZN;
|
48
|
|
49
|
//check - import
|
50
|
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
51
|
|
52
|
|
53
|
//authors
|
54
|
static final boolean doMetaData = true;
|
55
|
//names
|
56
|
static final boolean doTaxonNames = true;
|
57
|
//feature
|
58
|
static final boolean doFeature = true;
|
59
|
//feature
|
60
|
static final boolean doAdditionalTerms = true;
|
61
|
|
62
|
private final String filename;
|
63
|
|
64
|
public BfnXmlTestActivator(String fileName){
|
65
|
filename = fileName;
|
66
|
}
|
67
|
|
68
|
private void doImport(){
|
69
|
System.out.println("Start import from " + filename + " to "+ cdmDestination.getDatabase() + " ...");
|
70
|
|
71
|
//make Source
|
72
|
URI source;
|
73
|
try {
|
74
|
source = URI.create(sourceUriBase + filename);
|
75
|
// source = this.getClass().getResource(strSource + filename).toURI();
|
76
|
ICdmDataSource destination = cdmDestination;
|
77
|
|
78
|
BfnXmlImportConfigurator bfnImportConfigurator = BfnXmlImportConfigurator.NewInstance(source, destination);
|
79
|
|
80
|
//if xmllist has two lists
|
81
|
bfnImportConfigurator.setHasSecondList(false);
|
82
|
bfnImportConfigurator.setNomenclaturalCode(nomenclaturalCode);
|
83
|
bfnImportConfigurator.setDoMetaData(doMetaData);
|
84
|
bfnImportConfigurator.setDoTaxonNames(doTaxonNames);
|
85
|
|
86
|
bfnImportConfigurator.setCheck(check);
|
87
|
bfnImportConfigurator.setDbSchemaValidation(schemaValidation);
|
88
|
|
89
|
//TODO only quickfix see also MetaData import
|
90
|
String classificationName = filename.replace("rldb_print_v4_0_1_0_", "").split("_")[0];
|
91
|
bfnImportConfigurator.setClassificationName(classificationName);
|
92
|
|
93
|
// invoke import
|
94
|
CdmDefaultImport<BfnXmlImportConfigurator> bfnImport = new CdmDefaultImport<BfnXmlImportConfigurator>();
|
95
|
bfnImport.invoke(bfnImportConfigurator);
|
96
|
|
97
|
logger.warn("End");
|
98
|
System.out.println("End import from BfnXML ("+ source.toString() + ")...");
|
99
|
} catch (Exception e) {
|
100
|
e.printStackTrace();
|
101
|
}
|
102
|
|
103
|
}
|
104
|
|
105
|
/**
|
106
|
* @param args
|
107
|
*/
|
108
|
public static void main(String[] args) {
|
109
|
|
110
|
List<String> fileNames = Arrays.asList(
|
111
|
// Plants
|
112
|
// "rldb_print_v4_0_1_0_Flechten_korr_verantw_syn.xml"
|
113
|
// "rldb_print_v4_0_1_0_Lichenicole_verantw_syn.xml",
|
114
|
// "rldb_print_v4_0_1_0_Makroalgen_150121_syn.xml",
|
115
|
// "rldb_print_v4_0_1_0_Myxo_110708_korr_syn_neu.xml",
|
116
|
// "rldb_print_v4_0_1_0_Saprophyten_verantw.xml"
|
117
|
//
|
118
|
// Animals
|
119
|
// "rldb_print_v4_0_1_0_Ameisen_110609_rev120113_syn.xml"
|
120
|
//
|
121
|
// "rldb_print_v4_0_1_0_artenarmeWeichtiergruppen_121127_verantw_syn.xml",
|
122
|
// "rldb_print_v4_0_1_0_Asilidae_GMH_Wolff_110314_HGxls_120413_DF_korrV_Verantw_syn.xml",
|
123
|
// "rldb_print_v4_0_1_0_Asseln_121128_verantw_syn.xml",
|
124
|
// "rldb_print_v4_0_1_0_Asselspinnen_120907_verantw_syn.xml",
|
125
|
// "rldb_print_v4_0_1_0_Bienen_PWKorr_HG_120413_DF_120612_syn.xml",
|
126
|
// "rldb_print_v4_0_1_0_Binnenmollusken_0alle_120413_DF_syn.xml",
|
127
|
//// "rldb_print_v4_0_1_0_Blattoptera_140413_DF_syn.xml",
|
128
|
// "rldb_print_v4_0_1_0_Empidoidea_120413_DF.xml",
|
129
|
// "rldb_print_v4_0_1_0_Eulen_Korruebern_23-05-2012_KorrV_syn.xml",
|
130
|
//
|
131
|
//// , "rldb_print_v4_0_1_0_Eulenspinner_Spanner_13-06-2012_KorrV_syn.xml",
|
132
|
//
|
133
|
// "rldb_print_v4_0_1_0_Flohkrebse_121128_verantw_syn.xml",
|
134
|
// "rldb_print_v4_0_1_0_Heuschrecken_syn.xml",
|
135
|
// "rldb_print_v4_0_1_0_Igelwuermer_120907_verantw.xml",
|
136
|
// "rldb_print_v4_0_1_0_Kumazeen_120709_verantw_syn.xml",
|
137
|
// "rldb_print_v4_0_1_0_Meeresfische_syn.xml",
|
138
|
// "rldb_print_v4_0_1_0_Moostierchen_121128_verantw_syn.xml",
|
139
|
// "rldb_print_v4_0_1_0_Muscheln_121128_verantw_syn.xml",
|
140
|
// "rldb_print_v4_0_1_0_Nesseltiere_130104_verantw_syn.xml",
|
141
|
// "rldb_print_v4_0_1_0_Ohrwuermer_DF_syn.xml",
|
142
|
// "rldb_print_v4_0_1_0_Pflanzenwespen_280711_Autor_110815_HG2_120413_DF_syn.xml",
|
143
|
// "rldb_print_v4_0_1_0_Pyraloidea_Februar_2012_Korruebern_MB_24-04-2012_syn.xml",
|
144
|
// "rldb_print_v4_0_1_0_Schaedellose_120907_verantw_syn.xml",
|
145
|
// "rldb_print_v4_0_1_0_Schnecken_130206_verantw_syn.xml",
|
146
|
// "rldb_print_v4_0_1_0_Schwaemme_121127_verantw_syn.xml",
|
147
|
// "rldb_print_v4_0_1_0_Schwebfliegen_111103_KorrAS_120413_DF_syn.xml",
|
148
|
// "rldb_print_v4_0_1_0_Seepocken_121128_verantw_syn.xml",
|
149
|
// "rldb_print_v4_0_1_0_Seescheiden_121128_verantw_syn.xml",
|
150
|
// "rldb_print_v4_0_1_0_Spinner_Oktober2011_eingearbKorr_120124_Korruebern_MB_02-05-2012_KorrV_syn.xml",
|
151
|
// "rldb_print_v4_0_1_0_Stachelhaeuter_121128_verantw_syn.xml",
|
152
|
// "rldb_print_v4_0_1_0_Tagfalter_06-06-2012_KorrV_syn.xml",
|
153
|
// "rldb_print_v4_0_1_0_Thysanoptera_120413_DF_korrV_Verantw.xml",
|
154
|
// "rldb_print_v4_0_1_0_Vielborster_130206_verantw_syn.xml",
|
155
|
// "rldb_print_v4_0_1_0_Wenigborster_121128_verantw_syn.xml",
|
156
|
// "rldb_print_v4_0_1_0_Zehnfusskrebse_130104_verantw_syn.xml"
|
157
|
//
|
158
|
|
159
|
//old list
|
160
|
// "rldb_print_v4_0_1_0_Amphibien.xml",
|
161
|
// "rldb_print_v4_0_1_0_Brutvoegel.xml",
|
162
|
// "rldb_print_v4_0_1_0_Fische.xml",
|
163
|
// "rldb_print_v4_0_1_0_Reptilien_1.xml"
|
164
|
|
165
|
//two lists in one
|
166
|
"RoteListe_v4_0_6_0_BFN_Saeuger_korr.xml"
|
167
|
);
|
168
|
for(String fileName : fileNames){
|
169
|
BfnXmlTestActivator bfnXmlTestActivator = new BfnXmlTestActivator(fileName);
|
170
|
bfnXmlTestActivator.doImport();
|
171
|
// pauseProg();
|
172
|
}
|
173
|
|
174
|
//first run
|
175
|
//create DB,Metadata
|
176
|
// String fileName = "rldb_print_v4_0_1_0_Ameisen_110609_rev120113_syn.xml";
|
177
|
// BfnXmlTestActivator bfnXmlTestActivator = new BfnXmlTestActivator(fileName);
|
178
|
// bfnXmlTestActivator.doImport();
|
179
|
}
|
180
|
|
181
|
@SuppressWarnings("resource")
|
182
|
public static void pauseProg(){
|
183
|
System.out.println("Press enter to continue...");
|
184
|
Scanner keyboard = new Scanner(System.in);
|
185
|
keyboard.nextLine();
|
186
|
}
|
187
|
}
|
188
|
|