2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.app
.redlist
;
13 import java
.util
.Arrays
;
14 import java
.util
.List
;
15 import java
.util
.Scanner
;
17 import org
.apache
.log4j
.Logger
;
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
;
31 public class BfnXmlTestActivator
{
33 private static final Logger logger
= Logger
.getLogger(BfnXmlTestActivator
.class);
35 //database validation status (create, update, validate ...)
36 static DbSchemaValidation schemaValidation
= DbSchemaValidation
.CREATE
;
37 // static final ICdmDataSource cdmDestination = CdmDestinations.cdm_redlist_plant_localhost();
38 // static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
39 static final ICdmDataSource cdmDestination
= CdmDestinations
.cdm_test_local_mysql();
40 // static final ICdmDataSource cdmDestination = CdmDestinations.cdm_redlist_animalia_production();
43 // private static final String strSource = "/eu/etaxonomy/cdm/io/bfnXml/";
44 private static final String sourceUriBase
= "file:///home/pplitzner/Rote%20Listen%202020/doctronic/";
47 private static final NomenclaturalCode nomenclaturalCode
= NomenclaturalCode
.ICZN
;
50 static final CHECK check
= CHECK
.IMPORT_WITHOUT_CHECK
;
54 static final boolean doMetaData
= true;
56 static final boolean doTaxonNames
= true;
58 static final boolean doFeature
= true;
60 static final boolean doAdditionalTerms
= true;
62 private final String filename
;
64 public BfnXmlTestActivator(String fileName
){
68 private void doImport(){
69 System
.out
.println("Start import from " + filename
+ " to "+ cdmDestination
.getDatabase() + " ...");
74 source
= URI
.create(sourceUriBase
+ filename
);
75 // source = this.getClass().getResource(strSource + filename).toURI();
76 ICdmDataSource destination
= cdmDestination
;
78 BfnXmlImportConfigurator bfnImportConfigurator
= BfnXmlImportConfigurator
.NewInstance(source
, destination
);
80 //if xmllist has two lists
81 bfnImportConfigurator
.setHasSecondList(true);
82 bfnImportConfigurator
.setNomenclaturalCode(nomenclaturalCode
);
83 bfnImportConfigurator
.setDoMetaData(doMetaData
);
84 bfnImportConfigurator
.setDoTaxonNames(doTaxonNames
);
86 bfnImportConfigurator
.setCheck(check
);
87 bfnImportConfigurator
.setDbSchemaValidation(schemaValidation
);
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
);
94 CdmDefaultImport
<BfnXmlImportConfigurator
> bfnImport
= new CdmDefaultImport
<BfnXmlImportConfigurator
>();
95 bfnImport
.invoke(bfnImportConfigurator
);
98 System
.out
.println("End import from BfnXML ("+ source
.toString() + ")...");
99 } catch (Exception e
) {
108 public static void main(String
[] args
) {
110 List
<String
> fileNames
= Arrays
.asList(
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"
119 // "rldb_print_v4_0_1_0_Ameisen_110609_rev120113_syn.xml"
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",
131 //// , "rldb_print_v4_0_1_0_Eulenspinner_Spanner_13-06-2012_KorrV_syn.xml",
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"
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"
166 "RoteListe_v4_0_6_0_BFN_Saeuger_korr.xml"
168 for(String fileName
: fileNames
){
169 BfnXmlTestActivator bfnXmlTestActivator
= new BfnXmlTestActivator(fileName
);
170 bfnXmlTestActivator
.doImport();
176 // String fileName = "rldb_print_v4_0_1_0_Ameisen_110609_rev120113_syn.xml";
177 // BfnXmlTestActivator bfnXmlTestActivator = new BfnXmlTestActivator(fileName);
178 // bfnXmlTestActivator.doImport();
181 @SuppressWarnings("resource")
182 public static void pauseProg(){
183 System
.out
.println("Press enter to continue...");
184 Scanner keyboard
= new Scanner(System
.in
);