Revision 7115f486
Added by Andreas Müller almost 9 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/redlist/BfnXmlTestActivator.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
14 | 14 |
import java.util.Arrays; |
15 | 15 |
import java.util.List; |
16 | 16 |
import java.util.Scanner; |
17 |
import java.util.UUID; |
|
18 | 17 |
|
19 | 18 |
import org.apache.log4j.Logger; |
20 | 19 |
|
... | ... | |
23 | 22 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
24 | 23 |
import eu.etaxonomy.cdm.io.common.CdmDefaultImport; |
25 | 24 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK; |
26 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.DO_REFERENCES; |
|
27 | 25 |
import eu.etaxonomy.cdm.io.redlist.bfnXml.BfnXmlImportConfigurator; |
28 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
|
29 | 26 |
|
30 | 27 |
/** |
31 | 28 |
* @author a.oppermann |
... | ... | |
35 | 32 |
public class BfnXmlTestActivator { |
36 | 33 |
|
37 | 34 |
private static final Logger logger = Logger.getLogger(BfnXmlTestActivator.class); |
38 |
|
|
35 |
|
|
39 | 36 |
//database validation status (create, update, validate ...) |
40 | 37 |
static DbSchemaValidation schemaValidation = DbSchemaValidation.CREATE; |
41 |
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_redlist_plant_localhost(); |
|
38 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_redlist_plant_localhost(); |
|
39 |
static final ICdmDataSource cdmDestination = CdmDestinations.localH2(); |
|
40 |
|
|
41 |
private final String filename; |
|
42 | 42 |
|
43 |
private String filename; |
|
44 |
|
|
45 | 43 |
private static final String strSource = "/eu/etaxonomy/cdm/io/bfnXml/"; |
46 |
|
|
47 |
static final boolean includeNormalExplicit = true; |
|
48 |
|
|
44 |
|
|
49 | 45 |
//check - import |
50 | 46 |
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK; |
51 | 47 |
//authors |
52 | 48 |
static final boolean doMetaData = true; |
53 |
//references |
|
54 |
static final DO_REFERENCES doReferences = DO_REFERENCES.ALL; |
|
55 | 49 |
//names |
56 | 50 |
static final boolean doTaxonNames = true; |
57 |
static final boolean doRelNames = false; |
|
58 |
//taxa |
|
59 |
static final boolean doTaxa = true; |
|
60 |
static final boolean doRelTaxa = false; |
|
61 |
|
|
51 |
//feature |
|
52 |
static final boolean doFeature = true; |
|
53 |
//feature |
|
54 |
static final boolean doAdditionalTerms = true; |
|
55 |
|
|
56 |
|
|
62 | 57 |
public BfnXmlTestActivator(String fileName){ |
63 | 58 |
filename = fileName; |
64 | 59 |
} |
65 |
|
|
60 |
|
|
66 | 61 |
private void doImport(){ |
67 | 62 |
System.out.println("Start import from BfnXML to "+ cdmDestination.getDatabase() + " ..."); |
68 |
|
|
63 |
|
|
69 | 64 |
//make Source |
70 | 65 |
URI source; |
71 | 66 |
try { |
72 | 67 |
source = this.getClass().getResource(strSource+filename).toURI(); |
73 | 68 |
ICdmDataSource destination = cdmDestination; |
74 |
|
|
69 |
|
|
75 | 70 |
BfnXmlImportConfigurator bfnImportConfigurator = BfnXmlImportConfigurator.NewInstance(source, destination); |
76 |
|
|
71 |
|
|
77 | 72 |
//if xmllist has two lists |
78 | 73 |
bfnImportConfigurator.setHasSecondList(false); |
79 | 74 |
bfnImportConfigurator.setNomenclaturalSig("Botanical");// "Zoological";//"Botanical"ICNAFP |
80 | 75 |
bfnImportConfigurator.setDoMetaData(doMetaData); |
81 |
bfnImportConfigurator.setDoReferences(doReferences); |
|
82 | 76 |
bfnImportConfigurator.setDoTaxonNames(doTaxonNames); |
83 |
bfnImportConfigurator.setDoRelNames(doRelNames); |
|
84 |
|
|
85 |
bfnImportConfigurator.setDoTaxa(doTaxa); |
|
86 |
bfnImportConfigurator.setDoRelTaxa(doRelTaxa); |
|
87 |
|
|
77 |
|
|
88 | 78 |
bfnImportConfigurator.setCheck(check); |
89 | 79 |
bfnImportConfigurator.setDbSchemaValidation(schemaValidation); |
90 |
|
|
80 |
|
|
91 | 81 |
// invoke import |
92 | 82 |
CdmDefaultImport<BfnXmlImportConfigurator> bfnImport = new CdmDefaultImport<BfnXmlImportConfigurator>(); |
93 | 83 |
bfnImport.invoke(bfnImportConfigurator); |
94 |
|
|
84 |
|
|
95 | 85 |
logger.warn("End"); |
96 | 86 |
System.out.println("End import from BfnXML ("+ source.toString() + ")..."); |
97 | 87 |
} catch (URISyntaxException e) { |
98 | 88 |
e.printStackTrace(); |
99 | 89 |
} |
100 |
|
|
90 |
|
|
101 | 91 |
} |
102 | 92 |
|
103 |
|
|
93 |
|
|
104 | 94 |
/** |
105 | 95 |
* @param args |
106 | 96 |
*/ |
107 | 97 |
public static void main(String[] args) { |
108 |
|
|
98 |
|
|
109 | 99 |
List<String> fileNames = Arrays.asList( |
110 | 100 |
// Plants |
111 | 101 |
"rldb_print_v4_0_1_0_Flechten_korr_verantw_syn.xml" |
... | ... | |
116 | 106 |
// |
117 | 107 |
// Animals |
118 | 108 |
// "rldb_print_v4_0_1_0_Ameisen_110609_rev120113_syn.xml" |
119 |
|
|
109 |
|
|
120 | 110 |
// "rldb_print_v4_0_1_0_artenarmeWeichtiergruppen_121127_verantw_syn.xml", |
121 | 111 |
// "rldb_print_v4_0_1_0_Asilidae_GMH_Wolff_110314_HGxls_120413_DF_korrV_Verantw_syn.xml", |
122 | 112 |
// "rldb_print_v4_0_1_0_Asseln_121128_verantw_syn.xml", |
... | ... | |
126 | 116 |
// "rldb_print_v4_0_1_0_Blattoptera_140413_DF_syn.xml", |
127 | 117 |
// "rldb_print_v4_0_1_0_Empidoidea_120413_DF.xml", |
128 | 118 |
// "rldb_print_v4_0_1_0_Eulen_Korruebern_23-05-2012_KorrV_syn.xml", |
129 |
//
|
|
119 |
// |
|
130 | 120 |
//// "rldb_print_v4_0_1_0_Eulenspinner_Spanner_13-06-2012_KorrV_syn.xml", |
131 |
//
|
|
121 |
// |
|
132 | 122 |
// "rldb_print_v4_0_1_0_Flohkrebse_121128_verantw_syn.xml", |
133 | 123 |
// "rldb_print_v4_0_1_0_Heuschrecken_syn.xml", |
134 | 124 |
// "rldb_print_v4_0_1_0_Igelwuermer_120907_verantw.xml", |
... | ... | |
153 | 143 |
// "rldb_print_v4_0_1_0_Vielborster_130206_verantw_syn.xml", |
154 | 144 |
// "rldb_print_v4_0_1_0_Wenigborster_121128_verantw_syn.xml", |
155 | 145 |
// "rldb_print_v4_0_1_0_Zehnfusskrebse_130104_verantw_syn.xml" |
156 |
//
|
|
157 |
|
|
146 |
// |
|
147 |
|
|
158 | 148 |
//old list |
159 | 149 |
// "rldb_print_v4_0_1_0_Amphibien.xml", |
160 | 150 |
// "rldb_print_v4_0_1_0_Brutvoegel.xml", |
161 | 151 |
// "rldb_print_v4_0_1_0_Fische.xml", |
162 | 152 |
// "rldb_print_v4_0_1_0_Reptilien_1.xml" |
163 |
|
|
153 |
|
|
164 | 154 |
//two lists in one |
165 | 155 |
// "RoteListe_v4_0_6_0_BFN_Saeuger_korr.xml" |
166 | 156 |
); |
... | ... | |
169 | 159 |
bfnXmlTestActivator.doImport(); |
170 | 160 |
// pauseProg(); |
171 | 161 |
} |
172 |
|
|
162 |
|
|
173 | 163 |
//first run |
174 | 164 |
//create DB,Metadata |
175 | 165 |
// String fileName = "rldb_print_v4_0_1_0_Ameisen_110609_rev120113_syn.xml"; |
176 | 166 |
// BfnXmlTestActivator bfnXmlTestActivator = new BfnXmlTestActivator(fileName); |
177 | 167 |
// bfnXmlTestActivator.doImport(); |
178 | 168 |
} |
179 |
|
|
169 |
|
|
180 | 170 |
public static void pauseProg(){ |
181 | 171 |
System.out.println("Press enter to continue..."); |
182 | 172 |
Scanner keyboard = new Scanner(System.in); |
app-import/src/main/java/eu/etaxonomy/cdm/app/redlist/RoteListeDbChecklistActivator.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
18 | 18 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
19 | 19 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
20 | 20 |
import eu.etaxonomy.cdm.io.common.CdmDefaultImport; |
21 |
import eu.etaxonomy.cdm.io.common.Source; |
|
22 | 21 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK; |
22 |
import eu.etaxonomy.cdm.io.common.Source; |
|
23 | 23 |
import eu.etaxonomy.cdm.io.redlist.RoteListeDbImportConfigurator; |
24 | 24 |
import eu.etaxonomy.cdm.model.reference.Reference; |
25 | 25 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
... | ... | |
32 | 32 |
public class RoteListeDbChecklistActivator { |
33 | 33 |
@SuppressWarnings("unused") |
34 | 34 |
private static final Logger logger = Logger.getLogger(RoteListeDbChecklistActivator.class); |
35 |
|
|
35 |
|
|
36 | 36 |
//database validation status (create, update, validate ...) |
37 | 37 |
static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE; |
38 | 38 |
static final Source mySource = CdmImportSources.ROTE_LISTE_DB(); |
39 |
|
|
39 |
|
|
40 | 40 |
static final ICdmDataSource cdmDestination = CdmDestinations.localH2(); |
41 | 41 |
|
42 | 42 |
int recordsPerTransaction = 1000; |
43 |
|
|
43 |
|
|
44 | 44 |
//feature tree uuid |
45 | 45 |
public static final UUID featureTreeUuid = UUID.fromString("ebe558b5-d04d-41d5-83d9-b61c56e6e34a"); |
46 |
|
|
46 |
|
|
47 | 47 |
public static final String sourceReference = "Flora of Central Africa - Checklist"; |
48 |
|
|
49 |
private UUID uuidGenevaReference = UUID.fromString("cf3fd13d-6cad-430c-ab70-7ea841b7159f"); |
|
50 |
|
|
51 |
private String genevaReferenceTitle = "Geneva Database"; |
|
52 |
|
|
48 |
|
|
49 |
|
|
53 | 50 |
//classification |
54 | 51 |
public static final UUID classificationUuid = UUID.fromString("ce1d035a-79a9-4a3a-95bf-26641ecb4fbe"); |
55 |
|
|
52 |
|
|
56 | 53 |
//check - import |
57 | 54 |
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK; |
58 |
|
|
55 |
|
|
59 | 56 |
//taxa |
60 | 57 |
static final boolean doTaxa = true; |
61 | 58 |
|
62 | 59 |
private void doImport(ICdmDataSource cdmDestination){ |
63 |
|
|
60 |
|
|
64 | 61 |
//make Source |
65 | 62 |
Source source = mySource; |
66 |
|
|
63 |
|
|
67 | 64 |
RoteListeDbImportConfigurator config= RoteListeDbImportConfigurator.NewInstance(source, cdmDestination); |
68 | 65 |
config.setClassificationUuid(classificationUuid); |
69 | 66 |
config.setDoTaxa(doTaxa); |
70 | 67 |
config.setCheck(check); |
71 | 68 |
config.setDbSchemaValidation(hbm2dll); |
72 | 69 |
config.setRecordsPerTransaction(recordsPerTransaction); |
73 |
|
|
70 |
|
|
74 | 71 |
CdmDefaultImport<RoteListeDbImportConfigurator> myImport = new CdmDefaultImport<RoteListeDbImportConfigurator>(); |
75 | 72 |
|
76 | 73 |
System.out.println("Start import from ("+ source.toString() + ") ..."); |
77 | 74 |
config.setSourceReference(getSourceReference(sourceReference)); |
78 | 75 |
myImport.invoke(config); |
79 | 76 |
System.out.println("End import from ("+ source.toString() + ")..."); |
80 |
|
|
81 | 77 |
|
82 |
|
|
78 |
|
|
79 |
|
|
83 | 80 |
// FeatureTree tree = makeFeatureNode(myImport.getCdmAppController().getTermService()); |
84 | 81 |
// myImport.getCdmAppController().getFeatureTreeService().saveOrUpdate(tree); |
85 |
|
|
82 |
|
|
86 | 83 |
} |
87 |
|
|
84 |
|
|
88 | 85 |
private Reference getSourceReference(String string) { |
89 | 86 |
Reference result = ReferenceFactory.newGeneric(); |
90 | 87 |
result.setTitleCache(string); |
91 | 88 |
return result; |
92 | 89 |
} |
93 | 90 |
|
94 |
// private FeatureTree makeFeatureNode(ITermService service){ |
|
95 |
// FloraMalesianaTransformer transformer = new FloraMalesianaTransformer(); |
|
96 |
// |
|
97 |
// FeatureTree result = FeatureTree.NewInstance(featureTreeUuid); |
|
98 |
// result.setTitleCache("Flora Malesiana Presentation Feature Tree"); |
|
99 |
// FeatureNode root = result.getRoot(); |
|
100 |
// FeatureNode newNode; |
|
101 |
// |
|
102 |
// newNode = FeatureNode.NewInstance(Feature.CITATION()); |
|
103 |
// root.addChild(newNode); |
|
104 |
// |
|
105 |
// newNode = FeatureNode.NewInstance(Feature.DESCRIPTION()); |
|
106 |
// root.addChild(newNode); |
|
107 |
// |
|
108 |
// return result; |
|
109 |
// } |
|
110 |
|
|
111 |
|
|
112 | 91 |
|
113 | 92 |
/** |
114 | 93 |
* @param args |
... | ... | |
117 | 96 |
RoteListeDbChecklistActivator me = new RoteListeDbChecklistActivator(); |
118 | 97 |
me.doImport(cdmDestination); |
119 | 98 |
} |
120 |
|
|
99 |
|
|
121 | 100 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/BfnXmlImportAddtionalTerms.java | ||
---|---|---|
20 | 20 |
|
21 | 21 |
import eu.etaxonomy.cdm.api.service.ITermService; |
22 | 22 |
import eu.etaxonomy.cdm.api.service.IVocabularyService; |
23 |
import eu.etaxonomy.cdm.io.common.ICdmIO; |
|
24 | 23 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
25 | 24 |
import eu.etaxonomy.cdm.model.common.OrderedTermBase; |
26 | 25 |
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary; |
... | ... | |
38 | 37 |
* |
39 | 38 |
*/ |
40 | 39 |
@Component |
41 |
public class BfnXmlImportAddtionalTerms extends BfnXmlImportBase implements ICdmIO<BfnXmlImportState> {
|
|
40 |
public class BfnXmlImportAddtionalTerms extends BfnXmlImportBase { |
|
42 | 41 |
|
43 | 42 |
private static final Logger logger = Logger.getLogger(BfnXmlImportAddtionalTerms.class); |
44 | 43 |
|
45 |
public BfnXmlImportAddtionalTerms(){ |
|
46 |
super(); |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
public boolean doCheck(BfnXmlImportState state){ |
|
51 |
boolean result = true; |
|
52 |
//TODO needs to be implemented |
|
53 |
return result; |
|
54 |
} |
|
55 |
|
|
56 | 44 |
public enum Vocabulary{ |
57 | 45 |
GERMAN_FEDERAL_STATES("Bundesländer"), |
58 | 46 |
GERMAN_PRESENCE_TERMS("Vorkommensstatus"), |
... | ... | |
70 | 58 |
} |
71 | 59 |
} |
72 | 60 |
|
61 |
|
|
62 |
private static final List<String> GERMAN_PRESENCE_ABSENCE_TERMS = Arrays.asList(new String[] { |
|
63 |
"a:abwesend", |
|
64 |
"aa:abwesend - ausgestorben", |
|
65 |
"af:abwesend - frühere Fehleingabe", |
|
66 |
"v:vorkommend", |
|
67 |
"v+:vorkommend - in Einbürgerung befindlich", |
|
68 |
"ve:vorkommend - etabliert", |
|
69 |
"vk:vorkommend - kultiviert, domestiziert", |
|
70 |
"vu:vorkommend - unbeständig", |
|
71 |
"vs:vorkommend - Vorkommen unsicher", |
|
72 |
"s:vorkommend - unsicher" |
|
73 |
|
|
74 |
}); |
|
75 |
|
|
76 |
private static final List<String> GERMAN_ESTABLISHMENT_STATUS_TERMS = Arrays.asList(new String[] { |
|
77 |
"A:Archaeophyt", |
|
78 |
"I:Indigen", |
|
79 |
"K:Kulturpflanze / domestiziertes Tier", |
|
80 |
"N:Neophyt", |
|
81 |
"KF:Kultuflüchtling" |
|
82 |
}); |
|
83 |
|
|
84 |
private static final List<String> GERMAN_FEDERAL_STATES = Arrays.asList(new String[] { |
|
85 |
"DE:Deutschland", |
|
86 |
"BW:Baden-Württemberg", |
|
87 |
"BY:Bayern", |
|
88 |
"BE:Berlin", |
|
89 |
"BB:Brandenburg", |
|
90 |
"HB:Bremen", |
|
91 |
"HH:Hamburg", |
|
92 |
"HE:Hessen", |
|
93 |
"MV:Mecklenburg-Vorpommern", |
|
94 |
"NI:Niedersachsen", |
|
95 |
"NW:Nordrhein-Westfalen", |
|
96 |
"RP:Rheinland-Pfalz", |
|
97 |
"SL:Saarland", |
|
98 |
"SN:Sachsen", |
|
99 |
"ST:Sachsen-Anhalt", |
|
100 |
"SH:Schleswig-Holstein", |
|
101 |
"TH:Thüringen" |
|
102 |
}); |
|
103 |
|
|
104 |
|
|
105 |
/** Hibernate classification vocabulary initialisation strategy */ |
|
106 |
private static final List<String> VOC_CLASSIFICATION_INIT_STRATEGY = Arrays.asList(new String[] { |
|
107 |
"classification.$", |
|
108 |
"classification.rootNodes", |
|
109 |
"childNodes", |
|
110 |
"childNodes.taxon", |
|
111 |
"childNodes.taxon.name", |
|
112 |
"taxonNodes", |
|
113 |
"taxonNodes.taxon", |
|
114 |
"synonymRelations", |
|
115 |
"taxon.*", |
|
116 |
"taxon.sec", |
|
117 |
"taxon.name.*", |
|
118 |
"taxon.synonymRelations", |
|
119 |
"termVocabulary.*", |
|
120 |
"terms", |
|
121 |
"namedArea" |
|
122 |
|
|
123 |
}); |
|
124 |
|
|
125 |
|
|
126 |
public BfnXmlImportAddtionalTerms(){ |
|
127 |
super(); |
|
128 |
} |
|
129 |
|
|
130 |
|
|
73 | 131 |
@Override |
74 |
@SuppressWarnings({ "unchecked", "rawtypes" }) |
|
75 | 132 |
public void doInvoke(BfnXmlImportState state){ |
76 | 133 |
logger.info("create german terms ..."); |
77 | 134 |
IVocabularyService vocabularyService = getVocabularyService(); |
... | ... | |
227 | 284 |
return termVocabulary; |
228 | 285 |
} |
229 | 286 |
|
230 |
|
|
231 |
/* (non-Javadoc) |
|
232 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
|
233 |
*/ |
|
234 | 287 |
@Override |
235 | 288 |
protected boolean isIgnore(BfnXmlImportState state){ |
236 |
return ! state.getConfig().isDoTaxonNames();
|
|
289 |
return ! state.getConfig().isDoAdditionalTerms();
|
|
237 | 290 |
} |
238 | 291 |
|
239 | 292 |
|
240 | 293 |
|
241 |
private static final List<String> GERMAN_PRESENCE_ABSENCE_TERMS = Arrays.asList(new String[] { |
|
242 |
"a:abwesend", |
|
243 |
"aa:abwesend - ausgestorben", |
|
244 |
"af:abwesend - frühere Fehleingabe", |
|
245 |
"v:vorkommend", |
|
246 |
"v+:vorkommend - in Einbürgerung befindlich", |
|
247 |
"ve:vorkommend - etabliert", |
|
248 |
"vk:vorkommend - kultiviert, domestiziert", |
|
249 |
"vu:vorkommend - unbeständig", |
|
250 |
"vs:vorkommend - Vorkommen unsicher", |
|
251 |
"s:vorkommend - unsicher" |
|
252 |
|
|
253 |
}); |
|
254 | 294 |
|
255 |
private static final List<String> GERMAN_ESTABLISHMENT_STATUS_TERMS = Arrays.asList(new String[] { |
|
256 |
"A:Archaeophyt", |
|
257 |
"I:Indigen", |
|
258 |
"K:Kulturpflanze / domestiziertes Tier", |
|
259 |
"N:Neophyt", |
|
260 |
"KF:Kultuflüchtling" |
|
261 |
}); |
|
262 |
|
|
263 |
private static final List<String> GERMAN_FEDERAL_STATES = Arrays.asList(new String[] { |
|
264 |
"DE:Deutschland", |
|
265 |
"BW:Baden-Württemberg", |
|
266 |
"BY:Bayern", |
|
267 |
"BE:Berlin", |
|
268 |
"BB:Brandenburg", |
|
269 |
"HB:Bremen", |
|
270 |
"HH:Hamburg", |
|
271 |
"HE:Hessen", |
|
272 |
"MV:Mecklenburg-Vorpommern", |
|
273 |
"NI:Niedersachsen", |
|
274 |
"NW:Nordrhein-Westfalen", |
|
275 |
"RP:Rheinland-Pfalz", |
|
276 |
"SL:Saarland", |
|
277 |
"SN:Sachsen", |
|
278 |
"ST:Sachsen-Anhalt", |
|
279 |
"SH:Schleswig-Holstein", |
|
280 |
"TH:Thüringen" |
|
281 |
}); |
|
282 |
|
|
283 |
|
|
284 |
/** Hibernate classification vocabulary initialisation strategy */ |
|
285 |
private static final List<String> VOC_CLASSIFICATION_INIT_STRATEGY = Arrays.asList(new String[] { |
|
286 |
"classification.$", |
|
287 |
"classification.rootNodes", |
|
288 |
"childNodes", |
|
289 |
"childNodes.taxon", |
|
290 |
"childNodes.taxon.name", |
|
291 |
"taxonNodes", |
|
292 |
"taxonNodes.taxon", |
|
293 |
"synonymRelations", |
|
294 |
"taxon.*", |
|
295 |
"taxon.sec", |
|
296 |
"taxon.name.*", |
|
297 |
"taxon.synonymRelations", |
|
298 |
"termVocabulary.*", |
|
299 |
"terms", |
|
300 |
"namedArea" |
|
301 |
|
|
302 |
}); |
|
295 |
@Override |
|
296 |
public boolean doCheck(BfnXmlImportState state){ |
|
297 |
boolean result = true; |
|
298 |
//TODO needs to be implemented |
|
299 |
return result; |
|
300 |
} |
|
303 | 301 |
|
304 | 302 |
|
305 | 303 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/BfnXmlImportConfigurator.java | ||
---|---|---|
5 | 5 |
* |
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 |
*/
|
|
8 |
*/ |
|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.cdm.io.redlist.bfnXml; |
11 | 11 |
|
... | ... | |
15 | 15 |
* |
16 | 16 |
*/ |
17 | 17 |
import java.io.InputStream; |
18 |
import java.lang.reflect.Method; |
|
19 | 18 |
import java.net.MalformedURLException; |
20 | 19 |
import java.net.URI; |
21 | 20 |
import java.net.URL; |
... | ... | |
27 | 26 |
|
28 | 27 |
import eu.etaxonomy.cdm.common.XmlHelp; |
29 | 28 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
30 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator; |
|
31 | 29 |
import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase; |
32 | 30 |
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer; |
33 |
import eu.etaxonomy.cdm.io.tcsxml.DefaultTcsXmlPlaceholders; |
|
34 |
import eu.etaxonomy.cdm.io.tcsxml.ITcsXmlPlaceholderClass; |
|
35 | 31 |
import eu.etaxonomy.cdm.model.reference.Reference; |
36 | 32 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
37 | 33 |
|
38 | 34 |
@Component |
39 |
public class BfnXmlImportConfigurator extends ImportConfiguratorBase<BfnXmlImportState, URI> implements IImportConfigurator {
|
|
35 |
public class BfnXmlImportConfigurator extends ImportConfiguratorBase<BfnXmlImportState, URI> { |
|
40 | 36 |
private static final Logger logger = Logger.getLogger(BfnXmlImportConfigurator.class); |
41 |
|
|
37 |
|
|
42 | 38 |
//TODO |
43 | 39 |
private static IInputTransformer defaultTransformer = null; |
44 | 40 |
|
45 |
|
|
41 |
|
|
46 | 42 |
private boolean doMetaData = true; |
47 |
private boolean doSpecimen = true; |
|
48 |
private boolean doInformationImport = true; |
|
49 |
private boolean fillSecondList = false; |
|
50 |
private boolean hasSecondList = false; |
|
43 |
private boolean doTaxonNames = true; |
|
44 |
private boolean doFeature = true; |
|
45 |
private boolean doAdditionalTerms = true; |
|
46 |
|
|
47 |
private boolean doInformationImport = true; |
|
48 |
private boolean fillSecondList = false; |
|
49 |
private boolean hasSecondList = false; |
|
51 | 50 |
|
52 | 51 |
|
53 |
|
|
54 |
public boolean isFillSecondList() {
|
|
52 |
|
|
53 |
public boolean isFillSecondList() {
|
|
55 | 54 |
return fillSecondList; |
56 | 55 |
} |
57 | 56 |
|
... | ... | |
59 | 58 |
this.fillSecondList = fillSecondList; |
60 | 59 |
} |
61 | 60 |
|
62 |
// //references |
|
63 |
private DO_REFERENCES doReferences = DO_REFERENCES.ALL; |
|
64 |
// //names |
|
65 |
private boolean doTaxonNames = true; |
|
66 |
private boolean doRelNames = true; |
|
67 |
// //taxa |
|
68 |
private boolean doTaxa = true; |
|
69 |
private boolean doRelTaxa = true; |
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
private Method functionMetaDataDetailed = null; |
|
74 |
private ITcsXmlPlaceholderClass placeholderClass; |
|
75 |
|
|
61 |
|
|
76 | 62 |
// rdfNamespace |
77 | 63 |
Namespace bfnXmlNamespace; |
78 | 64 |
|
79 | 65 |
private String nomenclaturalCode = null; |
80 | 66 |
|
81 |
protected static Namespace nsTcsXml = Namespace.getNamespace("http://www.tdwg.org/schemas/tcs/1.01"); |
|
82 |
|
|
83 | 67 |
@SuppressWarnings("unchecked") |
68 |
@Override |
|
84 | 69 |
protected void makeIoClassList(){ |
85 | 70 |
ioClassList = new Class[]{ |
86 | 71 |
BfnXmlImportAddtionalTerms.class, |
... | ... | |
89 | 74 |
BfnXmlImportTaxonName.class |
90 | 75 |
}; |
91 | 76 |
}; |
92 |
|
|
77 |
|
|
93 | 78 |
public static BfnXmlImportConfigurator NewInstance(URI uri, |
94 | 79 |
ICdmDataSource destination){ |
95 | 80 |
return new BfnXmlImportConfigurator(uri, destination); |
96 | 81 |
} |
97 |
|
|
82 |
|
|
98 | 83 |
/** |
99 | 84 |
* @param berlinModelSource |
100 | 85 |
* @param sourceReference |
... | ... | |
102 | 87 |
*/ |
103 | 88 |
private BfnXmlImportConfigurator() { |
104 | 89 |
super(defaultTransformer); |
105 |
// setSource(url); |
|
106 |
// setDestination(destination); |
|
107 | 90 |
} |
108 |
|
|
91 |
|
|
109 | 92 |
/** |
110 | 93 |
* @param berlinModelSource |
111 | 94 |
* @param sourceReference |
... | ... | |
116 | 99 |
setSource(uri); |
117 | 100 |
setDestination(destination); |
118 | 101 |
} |
119 |
|
|
120 |
|
|
121 | 102 |
|
122 |
/* (non-Javadoc) |
|
123 |
* @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState() |
|
124 |
*/ |
|
103 |
|
|
104 |
@Override |
|
125 | 105 |
public BfnXmlImportState getNewState() { |
126 | 106 |
return new BfnXmlImportState(this); |
127 | 107 |
} |
128 | 108 |
|
129 |
/* (non-Javadoc) |
|
130 |
* @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSource() |
|
131 |
*/ |
|
132 |
public URI getSource() { |
|
133 |
return (URI)super.getSource(); |
|
134 |
} |
|
135 |
|
|
136 |
/** |
|
137 |
* @param file |
|
138 |
*/ |
|
139 |
public void setSource(URI uri) { |
|
140 |
super.setSource(uri); |
|
141 |
} |
|
142 |
|
|
143 | 109 |
/** |
144 | 110 |
* @return |
145 | 111 |
*/ |
... | ... | |
161 | 127 |
} |
162 | 128 |
return null; |
163 | 129 |
} |
164 |
|
|
130 |
|
|
165 | 131 |
private boolean makeNamespaces(Element root){ |
166 | 132 |
bfnXmlNamespace = root.getNamespace(); |
167 |
if (bfnXmlNamespace == null
|
|
168 |
/**|| tcNamespace == null
|
|
169 |
* || tnNamespace == null
|
|
170 |
* || commonNamespace == null
|
|
171 |
* || geoNamespace == null
|
|
133 |
if (bfnXmlNamespace == null |
|
134 |
/**|| tcNamespace == null |
|
135 |
* || tnNamespace == null |
|
136 |
* || commonNamespace == null |
|
137 |
* || geoNamespace == null |
|
172 | 138 |
* || publicationNamespace == null*/){ |
173 | 139 |
logger.warn("At least one Namespace is NULL"); |
174 | 140 |
} |
175 | 141 |
return true; |
176 | 142 |
} |
177 | 143 |
|
178 |
|
|
179 |
/* (non-Javadoc) |
|
180 |
* @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference() |
|
181 |
*/ |
|
182 | 144 |
@Override |
183 | 145 |
public Reference getSourceReference() { |
184 | 146 |
//TODO |
... | ... | |
190 | 152 |
return sourceReference; |
191 | 153 |
} |
192 | 154 |
|
193 |
|
|
194 |
/* (non-Javadoc) |
|
195 |
* @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString() |
|
196 |
*/ |
|
197 |
public String getSourceNameString() { |
|
155 |
@Override |
|
156 |
public String getSourceNameString() { |
|
198 | 157 |
if (this.getSource() == null){ |
199 | 158 |
return null; |
200 | 159 |
}else{ |
201 | 160 |
return this.getSource().toString(); |
202 | 161 |
} |
203 | 162 |
} |
204 |
|
|
163 |
|
|
205 | 164 |
public Namespace getBfnXmlNamespace() { |
206 | 165 |
return bfnXmlNamespace; |
207 | 166 |
} |
... | ... | |
210 | 169 |
this.bfnXmlNamespace = bfnXmlNamespace; |
211 | 170 |
} |
212 | 171 |
|
213 |
/** |
|
214 |
* @param funMetaDataDetailed the funMetaDataDetailed to set |
|
215 |
*/ |
|
216 |
public void setFunctionMetaDataDetailed(Method functionMetaDataDetailed) { |
|
217 |
this.functionMetaDataDetailed = functionMetaDataDetailed; |
|
218 |
} |
|
219 |
|
|
220 |
public DO_REFERENCES getDoReferences() { |
|
221 |
return doReferences; |
|
222 |
} |
|
223 |
public void setDoReferences(DO_REFERENCES doReferences) { |
|
224 |
this.doReferences = doReferences; |
|
225 |
} |
|
226 |
|
|
227 | 172 |
public boolean isDoTaxonNames() { |
228 | 173 |
return doTaxonNames; |
229 | 174 |
} |
... | ... | |
231 | 176 |
this.doTaxonNames = doTaxonNames; |
232 | 177 |
} |
233 | 178 |
|
234 |
public boolean isDoTaxa() { |
|
235 |
return doTaxa; |
|
236 |
} |
|
237 |
public void setDoTaxa(boolean doTaxa) { |
|
238 |
this.doTaxa = doTaxa; |
|
239 |
} |
|
240 |
|
|
241 |
public boolean isDoRelTaxa() { |
|
242 |
return doRelTaxa; |
|
243 |
} |
|
244 |
public void setDoRelTaxa(boolean doRelTaxa) { |
|
245 |
this.doRelTaxa = doRelTaxa; |
|
246 |
} |
|
247 |
|
|
248 |
/** |
|
249 |
* Import name relationships yes/no?. |
|
250 |
* @return |
|
251 |
*/ |
|
252 |
public boolean isDoRelNames() { |
|
253 |
return doRelNames; |
|
254 |
} |
|
255 |
public void setDoRelNames(boolean doRelNames) { |
|
256 |
this.doRelNames = doRelNames; |
|
257 |
} |
|
258 |
|
|
259 | 179 |
/** |
260 | 180 |
* @return the doMetaData |
261 | 181 |
*/ |
... | ... | |
271 | 191 |
} |
272 | 192 |
|
273 | 193 |
|
274 |
/** |
|
275 |
* @return the doSpecimen |
|
276 |
*/ |
|
277 |
public boolean isDoSpecimen() { |
|
278 |
return doSpecimen; |
|
279 |
} |
|
280 |
|
|
281 |
/** |
|
282 |
* @param doSpecimen the doSpecimen to set |
|
283 |
*/ |
|
284 |
public void setDoSpecimen(boolean doSpecimen) { |
|
285 |
this.doSpecimen = doSpecimen; |
|
286 |
} |
|
287 |
|
|
288 |
/** |
|
289 |
* @return the placeholderClass |
|
290 |
*/ |
|
291 |
public ITcsXmlPlaceholderClass getPlaceholderClass() { |
|
292 |
if (placeholderClass == null){ |
|
293 |
placeholderClass = new DefaultTcsXmlPlaceholders(); |
|
294 |
} |
|
295 |
return placeholderClass; |
|
296 |
} |
|
297 |
|
|
298 |
/** |
|
299 |
* @param placeholderClass the placeholderClass to set |
|
300 |
*/ |
|
301 |
public void setPlaceholderClass(ITcsXmlPlaceholderClass placeholderClass) { |
|
302 |
this.placeholderClass = placeholderClass; |
|
303 |
} |
|
304 |
|
|
305 | 194 |
public boolean isDoInformationImport() { |
306 | 195 |
return doInformationImport; |
307 | 196 |
} |
... | ... | |
325 | 214 |
public String getNomenclaturalSig(){ |
326 | 215 |
return nomenclaturalCode; |
327 | 216 |
} |
217 |
|
|
218 |
/** |
|
219 |
* @return the doFeature |
|
220 |
*/ |
|
221 |
public boolean isDoFeature() { |
|
222 |
return doFeature; |
|
223 |
} |
|
224 |
|
|
225 |
|
|
226 |
/** |
|
227 |
* @param doFeature the doFeature to set |
|
228 |
*/ |
|
229 |
public void setDoFeature(boolean doFeature) { |
|
230 |
this.doFeature = doFeature; |
|
231 |
} |
|
232 |
|
|
233 |
/** |
|
234 |
* @return the doAdditionalTerms |
|
235 |
*/ |
|
236 |
public boolean isDoAdditionalTerms() { |
|
237 |
return doAdditionalTerms; |
|
238 |
} |
|
239 |
|
|
240 |
/** |
|
241 |
* @param doAdditionalTerms the doAdditionalTerms to set |
|
242 |
*/ |
|
243 |
public void setDoAdditionalTerms(boolean doAdditionalTerms) { |
|
244 |
this.doAdditionalTerms = doAdditionalTerms; |
|
245 |
} |
|
328 | 246 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/BfnXmlImportFeature.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
14 | 14 |
import java.util.List; |
15 | 15 |
import java.util.UUID; |
16 | 16 |
|
17 |
import javax.management.ObjectInstance; |
|
18 |
|
|
19 |
import org.apache.commons.lang.StringUtils; |
|
20 | 17 |
import org.apache.log4j.Logger; |
21 |
import org.hibernate.id.UUIDGenerator; |
|
22 | 18 |
import org.jdom.Element; |
23 | 19 |
import org.jdom.Namespace; |
24 | 20 |
import org.springframework.stereotype.Component; |
25 | 21 |
import org.springframework.transaction.TransactionStatus; |
26 | 22 |
|
27 |
import eu.etaxonomy.cdm.api.service.IClassificationService; |
|
28 |
import eu.etaxonomy.cdm.api.service.IDescriptionService; |
|
29 |
import eu.etaxonomy.cdm.api.service.IFeatureNodeService; |
|
30 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
|
31 |
import eu.etaxonomy.cdm.api.service.ITermService; |
|
32 | 23 |
import eu.etaxonomy.cdm.api.service.IVocabularyService; |
33 | 24 |
import eu.etaxonomy.cdm.common.ResultWrapper; |
34 | 25 |
import eu.etaxonomy.cdm.common.XmlHelp; |
35 | 26 |
import eu.etaxonomy.cdm.io.common.ICdmIO; |
36 |
import eu.etaxonomy.cdm.io.common.ImportHelper; |
|
37 |
import eu.etaxonomy.cdm.io.common.MapWrapper; |
|
38 | 27 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
39 |
import eu.etaxonomy.cdm.model.common.Language; |
|
40 | 28 |
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary; |
41 | 29 |
import eu.etaxonomy.cdm.model.common.TermType; |
42 | 30 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
43 |
import eu.etaxonomy.cdm.model.common.VocabularyEnum; |
|
44 |
import eu.etaxonomy.cdm.model.description.CategoricalData; |
|
45 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
|
46 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
|
47 | 31 |
import eu.etaxonomy.cdm.model.description.Feature; |
48 |
import eu.etaxonomy.cdm.model.description.FeatureNode; |
|
49 | 32 |
import eu.etaxonomy.cdm.model.description.FeatureTree; |
50 | 33 |
import eu.etaxonomy.cdm.model.description.State; |
51 |
import eu.etaxonomy.cdm.model.description.StateData; |
|
52 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
|
53 |
import eu.etaxonomy.cdm.model.name.NonViralName; |
|
54 |
import eu.etaxonomy.cdm.model.name.Rank; |
|
55 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
|
56 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
|
57 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
|
58 |
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType; |
|
59 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
60 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
61 |
import eu.etaxonomy.cdm.persistence.dao.description.IFeatureDao; |
|
62 | 34 |
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException; |
63 |
import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl; |
|
64 |
import eu.etaxonomy.cdm.strategy.parser.ParserProblem; |
|
65 | 35 |
/** |
66 |
*
|
|
36 |
* |
|
67 | 37 |
* @author a.oppermann |
68 | 38 |
* @date 04.07.2013 |
69 | 39 |
* |
... | ... | |
76 | 46 |
super(); |
77 | 47 |
} |
78 | 48 |
|
79 |
@Override |
|
80 |
public boolean doCheck(BfnXmlImportState state){ |
|
81 |
boolean result = true; |
|
82 |
//TODO needs to be implemented |
|
83 |
return result; |
|
84 |
} |
|
49 |
|
|
50 |
/** Hibernate classification vocabulary initialisation strategy */ |
|
51 |
private static final List<String> VOC_CLASSIFICATION_INIT_STRATEGY = Arrays.asList(new String[] { |
|
52 |
"classification.$", |
|
53 |
"classification.rootNodes", |
|
54 |
"childNodes", |
|
55 |
"childNodes.taxon", |
|
56 |
"childNodes.taxon.name", |
|
57 |
"taxonNodes", |
|
58 |
"taxonNodes.taxon", |
|
59 |
"synonymRelations", |
|
60 |
"taxon.*", |
|
61 |
"taxon.sec", |
|
62 |
"taxon.name.*", |
|
63 |
"taxon.synonymRelations", |
|
64 |
"termVocabulary.*", |
|
65 |
"terms" |
|
66 |
|
|
67 |
}); |
|
85 | 68 |
|
86 | 69 |
@Override |
87 | 70 |
@SuppressWarnings({ "unchecked", "rawtypes" }) |
88 | 71 |
public void doInvoke(BfnXmlImportState state){ |
89 | 72 |
|
90 | 73 |
IVocabularyService vocabularyService = getVocabularyService(); |
91 |
|
|
92 |
|
|
74 |
|
|
75 |
|
|
93 | 76 |
logger.warn("start create Features in CDM..."); |
94 | 77 |
ResultWrapper<Boolean> success = ResultWrapper.NewInstance(true); |
95 | 78 |
String childName; |
... | ... | |
97 | 80 |
BfnXmlImportConfigurator config = state.getConfig(); |
98 | 81 |
Element elDataSet = getDataSetElement(config); |
99 | 82 |
Namespace bfnNamespace = config.getBfnXmlNamespace(); |
100 |
|
|
83 |
|
|
101 | 84 |
List contentXML = elDataSet.getContent(); |
102 | 85 |
Element currentElement = null; |
103 | 86 |
for(Object object:contentXML){ |
104 |
|
|
87 |
|
|
105 | 88 |
if(object instanceof Element){ |
106 | 89 |
currentElement = (Element)object; |
107 | 90 |
|
108 | 91 |
if(currentElement.getName().equalsIgnoreCase("ROTELISTEDATEN")){ |
109 |
|
|
92 |
|
|
110 | 93 |
TransactionStatus tx = startTransaction(); |
111 | 94 |
|
112 | 95 |
childName = "EIGENSCHAFTEN"; |
... | ... | |
114 | 97 |
Element elFeatureNames = XmlHelp.getSingleChildElement(success, currentElement, childName, bfnNamespace, obligatory); |
115 | 98 |
|
116 | 99 |
String bfnElementName = "EIGENSCHAFT"; |
117 |
List<Element> elFeatureList = (List<Element>)elFeatureNames.getChildren(bfnElementName, bfnNamespace);
|
|
100 |
List<Element> elFeatureList = elFeatureNames.getChildren(bfnElementName, bfnNamespace); |
|
118 | 101 |
List<Feature> featureList = new ArrayList<Feature>(); |
119 | 102 |
//for each taxonName |
120 | 103 |
for (Element elFeature : elFeatureList){ |
... | ... | |
168 | 151 |
} |
169 | 152 |
createFeatureTree(featureList); |
170 | 153 |
commitTransaction(tx); |
171 |
|
|
154 |
|
|
172 | 155 |
logger.info("end create features ..."); |
173 |
|
|
156 |
|
|
174 | 157 |
if (!success.getValue()){ |
175 | 158 |
state.setUnsuccessfull(); |
176 | 159 |
} |
... | ... | |
193 | 176 |
} |
194 | 177 |
|
195 | 178 |
/** |
196 |
*
|
|
179 |
* |
|
197 | 180 |
* @param vocabularyService |
198 | 181 |
* @param featureList |
199 | 182 |
* @param success |
... | ... | |
241 | 224 |
if(termVocabulary == null){ |
242 | 225 |
termVocabulary = TermVocabulary.NewInstance(termType, strTermVocabulary, strTermVocabulary, strTermVocabulary, null); |
243 | 226 |
} |
244 |
termVocabulary.addTerm(term);
|
|
227 |
termVocabulary.addTerm(term); |
|
245 | 228 |
vocabularyService.saveOrUpdate(termVocabulary); |
246 |
|
|
229 |
|
|
247 | 230 |
return termVocabulary; |
248 | 231 |
} |
249 | 232 |
|
... | ... | |
253 | 236 |
* @param bfnNamespace |
254 | 237 |
* @param elListValues |
255 | 238 |
* @param childElementName |
256 |
* @param redListCat
|
|
239 |
* @param redListCat |
|
257 | 240 |
*/ |
258 |
|
|
241 |
|
|
259 | 242 |
@SuppressWarnings({ "unchecked", "rawtypes"}) |
260 |
private void createOrUpdateStates(Namespace bfnNamespace, Element elListValues, String childElementName,
|
|
243 |
private void createOrUpdateStates(Namespace bfnNamespace, Element elListValues, String childElementName, |
|
261 | 244 |
Feature redListCat, BfnXmlImportState state) { |
262 | 245 |
|
263 |
List<Element> elListValueList = (List<Element>)elListValues.getChildren(childElementName, bfnNamespace);
|
|
246 |
List<Element> elListValueList = elListValues.getChildren(childElementName, bfnNamespace); |
|
264 | 247 |
// List<StateData> stateList = new ArrayList<StateData>(); |
265 |
|
|
248 |
|
|
266 | 249 |
OrderedTermVocabulary termVocabulary = null; |
267 | 250 |
for(Element elListValue:elListValueList){ |
268 | 251 |
String listValue = elListValue.getTextNormalize(); |
... | ... | |
280 | 263 |
} catch (UnknownCdmTypeException e) { |
281 | 264 |
matchedListValue = listValue; |
282 | 265 |
logger.warn("no matched red list code nor UUID found. \n" + e); |
283 |
|
|
266 |
|
|
284 | 267 |
} |
285 | 268 |
try { |
286 | 269 |
stateTermUuid = BfnXmlTransformer.getRedlistStateTermUUID(matchedListValue, redListCat.getTitleCache()); |
287 | 270 |
} catch (UnknownCdmTypeException e) { |
288 |
// stateTermUuid = UUID.randomUUID();
|
|
271 |
// stateTermUuid = UUID.randomUUID(); |
|
289 | 272 |
//TODO: needs to be fixed for "eindeutiger Code" |
290 | 273 |
logger.warn("could not finde state term uuid for " + matchedListValue + " and redlist category"+ redListCat.getTitleCache()+"\n"+e); |
291 | 274 |
} |
292 | 275 |
String vocName = redListCat.toString()+" States"; |
293 |
termVocabulary = (OrderedTermVocabulary) getVocabulary(TermType.State, vocabularyStateUuid, vocName, vocName, vocName, null, true, null);
|
|
276 |
termVocabulary = (OrderedTermVocabulary) getVocabulary(TermType.State, vocabularyStateUuid, vocName, vocName, vocName, null, true, null); |
|
294 | 277 |
State stateTerm = getStateTerm(state, stateTermUuid, matchedListValue, matchedListValue, matchedListValue, termVocabulary); |
295 | 278 |
} |
296 | 279 |
if(termVocabulary != null){ |
297 | 280 |
redListCat.addSupportedCategoricalEnumeration(termVocabulary); |
298 | 281 |
getTermService().saveOrUpdate(redListCat); |
299 | 282 |
} |
300 |
|
|
283 |
|
|
301 | 284 |
} |
302 | 285 |
|
303 |
|
|
304 |
|
|
305 |
|
|
306 | 286 |
|
307 |
|
|
308 |
|
|
309 |
|
|
310 |
|
|
311 |
/* (non-Javadoc) |
|
312 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
|
313 |
*/ |
|
287 |
@Override |
|
288 |
public boolean doCheck(BfnXmlImportState state){ |
|
289 |
boolean result = true; |
|
290 |
//TODO needs to be implemented |
|
291 |
return result; |
|
292 |
} |
|
293 |
|
|
294 |
@Override |
|
314 | 295 |
protected boolean isIgnore(BfnXmlImportState state){ |
315 |
return ! state.getConfig().isDoTaxonNames();
|
|
296 |
return ! state.getConfig().isDoFeature();
|
|
316 | 297 |
} |
317 |
|
|
318 |
|
|
319 |
|
|
320 |
/** Hibernate classification vocabulary initialisation strategy */ |
|
321 |
private static final List<String> VOC_CLASSIFICATION_INIT_STRATEGY = Arrays.asList(new String[] { |
|
322 |
"classification.$", |
|
323 |
"classification.rootNodes", |
|
324 |
"childNodes", |
|
325 |
"childNodes.taxon", |
|
326 |
"childNodes.taxon.name", |
|
327 |
"taxonNodes", |
|
328 |
"taxonNodes.taxon", |
|
329 |
"synonymRelations", |
|
330 |
"taxon.*", |
|
331 |
"taxon.sec", |
|
332 |
"taxon.name.*", |
|
333 |
"taxon.synonymRelations", |
|
334 |
"termVocabulary.*", |
|
335 |
"terms" |
|
336 |
|
|
337 |
}); |
|
338 | 298 |
|
339 | 299 |
|
340 | 300 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/BfnXmlImportMetaData.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.cdm.io.redlist.bfnXml; |
11 | 11 |
|
12 |
import java.util.ArrayList; |
|
13 |
import java.util.Arrays; |
|
14 | 12 |
import java.util.List; |
15 |
import java.util.UUID; |
|
16 | 13 |
|
17 |
import javax.management.ObjectInstance; |
|
18 |
|
|
19 |
import org.apache.commons.lang.StringUtils; |
|
20 | 14 |
import org.apache.log4j.Logger; |
21 |
import org.hibernate.id.UUIDGenerator; |
|
22 | 15 |
import org.jdom.Element; |
23 | 16 |
import org.jdom.Namespace; |
24 | 17 |
import org.springframework.stereotype.Component; |
25 | 18 |
import org.springframework.transaction.TransactionStatus; |
26 | 19 |
|
27 |
import eu.etaxonomy.cdm.api.service.IClassificationService; |
|
28 |
import eu.etaxonomy.cdm.api.service.IDescriptionService; |
|
29 |
import eu.etaxonomy.cdm.api.service.IFeatureNodeService; |
|
30 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
|
31 |
import eu.etaxonomy.cdm.api.service.ITermService; |
|
32 |
import eu.etaxonomy.cdm.api.service.IVocabularyService; |
|
33 | 20 |
import eu.etaxonomy.cdm.common.ResultWrapper; |
34 |
import eu.etaxonomy.cdm.common.XmlHelp; |
|
35 | 21 |
import eu.etaxonomy.cdm.io.common.ICdmIO; |
36 |
import eu.etaxonomy.cdm.io.common.ImportHelper; |
|
37 |
import eu.etaxonomy.cdm.io.common.MapWrapper; |
|
38 |
import eu.etaxonomy.cdm.io.common.Source; |
|
39 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
|
40 |
import eu.etaxonomy.cdm.model.common.Language; |
|
41 |
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary; |
|
42 |
import eu.etaxonomy.cdm.model.common.TermType; |
|
43 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
|
44 | 22 |
import eu.etaxonomy.cdm.model.common.TimePeriod; |
45 |
import eu.etaxonomy.cdm.model.common.VocabularyEnum; |
|
46 |
import eu.etaxonomy.cdm.model.description.CategoricalData; |
|
47 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
|
48 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
|
49 |
import eu.etaxonomy.cdm.model.description.Feature; |
|
50 |
import eu.etaxonomy.cdm.model.description.FeatureNode; |
|
51 |
import eu.etaxonomy.cdm.model.description.FeatureTree; |
|
52 |
import eu.etaxonomy.cdm.model.description.State; |
|
53 |
import eu.etaxonomy.cdm.model.description.StateData; |
|
54 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
|
55 |
import eu.etaxonomy.cdm.model.name.NonViralName; |
|
56 |
import eu.etaxonomy.cdm.model.name.Rank; |
|
57 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
|
58 | 23 |
import eu.etaxonomy.cdm.model.reference.Reference; |
59 | 24 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
60 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
|
61 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
|
62 |
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType; |
|
63 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
64 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
65 |
import eu.etaxonomy.cdm.persistence.dao.description.IFeatureDao; |
|
66 |
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException; |
|
67 |
import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl; |
|
68 |
import eu.etaxonomy.cdm.strategy.parser.ParserProblem; |
|
69 | 25 |
import eu.etaxonomy.cdm.strategy.parser.TimePeriodParser; |
70 | 26 |
/** |
71 |
*
|
|
27 |
* |
|
72 | 28 |
* @author a.oppermann |
73 | 29 |
* @date 04.07.2013 |
74 | 30 |
* |
... | ... | |
94 | 50 |
@Override |
95 | 51 |
public void doInvoke(BfnXmlImportState state){ |
96 | 52 |
logger.warn("start import MetaData..."); |
97 |
|
|
98 |
|
|
53 |
|
|
54 |
|
|
99 | 55 |
ResultWrapper<Boolean> success = ResultWrapper.NewInstance(true); |
100 | 56 |
|
101 | 57 |
BfnXmlImportConfigurator config = state.getConfig(); |
... | ... | |
106 | 62 |
sourceFileName = elDataSet.getAttributeValue("source"); |
107 | 63 |
debVersion = elDataSet.getAttributeValue("debversion"); |
108 | 64 |
timeStamp = elDataSet.getAttributeValue("timestamp"); |
109 |
|
|
110 |
Reference sourceReference = ReferenceFactory.newGeneric(); |
|
65 |
|
|
66 |
Reference<?> sourceReference = ReferenceFactory.newGeneric();
|
|
111 | 67 |
sourceReference.setTitle(sourceFileName); |
112 | 68 |
TimePeriod parsedTimePeriod = TimePeriodParser.parseString(timeStamp); |
113 | 69 |
sourceReference.setDatePublished(parsedTimePeriod); |
114 | 70 |
state.setCompleteSourceRef(sourceReference); |
115 | 71 |
} |
116 |
|
|
117 |
List contentXML = elDataSet.getContent(); |
|
72 |
|
|
73 |
List<?> contentXML = elDataSet.getContent();
|
|
118 | 74 |
Element currentElement = null; |
119 | 75 |
for(Object object:contentXML){ |
120 |
|
|
121 |
|
|
76 |
|
|
77 |
|
|
122 | 78 |
if(object instanceof Element){ |
123 | 79 |
currentElement = (Element)object; |
124 | 80 |
|
125 | 81 |
if(currentElement.getName().equalsIgnoreCase("METADATEN")){ |
126 |
|
|
82 |
|
|
127 | 83 |
TransactionStatus tx = startTransaction(); |
128 | 84 |
|
129 | 85 |
String bfnElementName = "METADATEN"; |
130 |
List<Element> elMetaDataList = (List<Element>)currentElement.getChildren(); |
|
86 |
@SuppressWarnings("unchecked") |
|
87 |
List<Element> elMetaDataList = currentElement.getChildren(); |
|
131 | 88 |
//for each taxonName |
132 | 89 |
for (Element elMetaData : elMetaDataList){ |
133 | 90 |
if( elMetaData.getAttributeValue("standardname").equalsIgnoreCase("KurzLit_A")){ |
134 |
List<Element> children = (List<Element>)elMetaData.getChildren(); |
|
91 |
@SuppressWarnings("unchecked") |
|
92 |
List<Element> children = elMetaData.getChildren(); |
|
135 | 93 |
String kurzlitA = children.get(0).getTextNormalize(); |
136 |
Reference sourceReference = ReferenceFactory.newGeneric(); |
|
94 |
Reference<?> sourceReference = ReferenceFactory.newGeneric();
|
|
137 | 95 |
sourceReference.setTitle(kurzlitA); |
138 | 96 |
state.setFirstListSecRef(sourceReference); |
139 | 97 |
|
140 | 98 |
} |
141 | 99 |
else if( elMetaData.getAttributeValue("standardname").equalsIgnoreCase("Klassifikation_A")){ |
142 |
List<Element> children = (List<Element>)elMetaData.getChildren(); |
|
100 |
@SuppressWarnings("unchecked") |
|
101 |
List<Element> children = elMetaData.getChildren(); |
|
143 | 102 |
String klassifikation_A = children.get(0).getTextNormalize(); |
144 | 103 |
state.setFirstClassificationName(klassifikation_A); |
145 | 104 |
|
146 |
}
|
|
105 |
} |
|
147 | 106 |
else if( elMetaData.getAttributeValue("standardname").equalsIgnoreCase("KurzLit_B")){ |
148 |
List<Element> children = (List<Element>)elMetaData.getChildren(); |
|
107 |
@SuppressWarnings("unchecked") |
|
108 |
List<Element> children = elMetaData.getChildren(); |
|
149 | 109 |
String kurzlitB = children.get(0).getTextNormalize(); |
150 |
Reference sourceReference = ReferenceFactory.newGeneric(); |
|
110 |
Reference<?> sourceReference = ReferenceFactory.newGeneric();
|
|
151 | 111 |
sourceReference.setTitle(kurzlitB); |
152 | 112 |
state.setSecondListSecRef(sourceReference); |
153 | 113 |
} |
154 | 114 |
else if( elMetaData.getAttributeValue("standardname").equalsIgnoreCase("Klassifikation_B")){ |
155 |
List<Element> children = (List<Element>)elMetaData.getChildren(); |
|
115 |
@SuppressWarnings("unchecked") |
|
116 |
List<Element> children = elMetaData.getChildren(); |
|
156 | 117 |
String klassifikation_B = children.get(0).getTextNormalize(); |
157 | 118 |
state.setSecondClassificationName(klassifikation_B); |
158 | 119 |
|
159 | 120 |
} |
160 | 121 |
|
161 | 122 |
} |
162 |
|
|
123 |
|
|
163 | 124 |
logger.warn("end import MetaData ..."); |
164 | 125 |
commitTransaction(tx); |
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
|
126 |
|
|
127 |
|
|
169 | 128 |
if (!success.getValue()){ |
170 | 129 |
state.setUnsuccessfull(); |
171 | 130 |
} |
172 | 131 |
//FIXME: Only take the first RoteListeData Features |
173 |
|
|
174 |
|
|
132 |
|
|
133 |
|
|
175 | 134 |
return; |
176 | 135 |
} |
177 | 136 |
} |
... | ... | |
182 | 141 |
|
183 | 142 |
@Override |
184 | 143 |
protected boolean isIgnore(BfnXmlImportState state) { |
185 |
return ! state.getConfig().isDoTaxonNames();
|
|
144 |
return ! state.getConfig().isDoMetaData();
|
|
186 | 145 |
} |
187 | 146 |
|
188 | 147 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/BfnXmlImportState.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
24 | 24 |
* @version 1.0 |
25 | 25 |
*/ |
26 | 26 |
public class BfnXmlImportState extends ImportStateBase<BfnXmlImportConfigurator, BfnXmlImportBase>{ |
27 |
private Reference refA; |
|
28 |
private Reference refB; |
|
29 |
private Reference currentMicroRef; |
|
30 |
private Reference completeSourceRef; |
|
27 |
private Reference<?> refA;
|
|
28 |
private Reference<?> refB;
|
|
29 |
private Reference<?> currentMicroRef;
|
|
30 |
private Reference<?> completeSourceRef;
|
|
31 | 31 |
private String classificationA; |
32 | 32 |
private String classificationB; |
33 | 33 |
@SuppressWarnings("unused") |
... | ... | |
35 | 35 |
|
36 | 36 |
//TODO make it better |
37 | 37 |
private Map<String, CommonTaxonName> commonNameMap = null; |
38 |
|
|
38 |
|
|
39 | 39 |
public BfnXmlImportState(BfnXmlImportConfigurator config) { |
40 | 40 |
super(config); |
41 | 41 |
} |
42 |
|
|
42 |
|
|
43 | 43 |
public Map<String, CommonTaxonName> getCommonNameMap() { |
44 | 44 |
return commonNameMap; |
45 | 45 |
} |
46 | 46 |
|
47 |
|
|
48 |
|
|
47 |
|
|
48 |
|
|
49 | 49 |
public void setCommonNameMap(Map<String, CommonTaxonName> commonNameMap) { |
50 | 50 |
this.commonNameMap = commonNameMap; |
51 | 51 |
} |
52 | 52 |
|
53 |
public void setFirstListSecRef(Reference ref) { |
|
53 |
public void setFirstListSecRef(Reference<?> ref) {
|
|
54 | 54 |
this.refA = ref; |
55 | 55 |
} |
56 |
|
|
57 |
public void setSecondListSecRef(Reference ref) { |
|
56 |
|
|
57 |
public void setSecondListSecRef(Reference<?> ref) {
|
|
58 | 58 |
this.refB = ref; |
59 | 59 |
} |
60 | 60 |
|
61 |
public Reference getFirstListSecRef(){ |
|
61 |
public Reference<?> getFirstListSecRef(){
|
|
62 | 62 |
return refA; |
63 | 63 |
} |
64 |
|
|
65 |
public Reference getSecondListSecRef(){ |
|
64 |
|
|
65 |
public Reference<?> getSecondListSecRef(){
|
|
66 | 66 |
return refB; |
67 | 67 |
} |
68 | 68 |
|
69 |
public void setCurrentMicroRef(Reference currentRef) { |
|
69 |
public void setCurrentMicroRef(Reference<?> currentRef) {
|
|
70 | 70 |
this.currentMicroRef = currentRef; |
71 | 71 |
} |
72 |
public Reference getCompleteSourceRef() { |
|
72 |
public Reference<?> getCompleteSourceRef() {
|
|
73 | 73 |
return completeSourceRef; |
74 | 74 |
} |
75 | 75 |
|
76 |
public void setCompleteSourceRef(Reference completeSourceRef) { |
|
76 |
public void setCompleteSourceRef(Reference<?> completeSourceRef) {
|
|
77 | 77 |
this.completeSourceRef = completeSourceRef; |
78 | 78 |
} |
79 | 79 |
|
80 |
public Reference getCurrentMicroRef(){ |
|
80 |
public Reference<?> getCurrentMicroRef(){
|
|
81 | 81 |
return currentMicroRef; |
82 | 82 |
} |
83 | 83 |
public void setFirstClassificationName(String classificationA) { |
84 | 84 |
this.classificationA = classificationA; |
85 | 85 |
} |
86 |
|
|
86 |
|
|
87 | 87 |
public void setSecondClassificationName(String classificationB) { |
88 | 88 |
this.classificationB = classificationB; |
89 | 89 |
} |
90 |
|
|
90 |
|
|
91 | 91 |
public String getFirstClassificationName() { |
92 | 92 |
return classificationA; |
93 | 93 |
} |
... | ... | |
95 | 95 |
public String getSecondClassificationName() { |
96 | 96 |
return classificationB; |
97 | 97 |
} |
98 |
|
|
98 |
|
|
99 | 99 |
// /* (non-Javadoc) |
100 | 100 |
// * @see eu.etaxonomy.cdm.io.common.IoStateBase#initialize(eu.etaxonomy.cdm.io.common.IoConfiguratorBase) |
101 | 101 |
// */ |
102 | 102 |
// @Override |
103 | 103 |
// public void initialize(TcsXmlImportConfigurator config) { |
104 |
//
|
|
104 |
// |
|
105 | 105 |
// } |
106 | 106 |
|
107 | 107 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/BfnXmlImportTaxonName.java | ||
---|---|---|
27 | 27 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
28 | 28 |
import eu.etaxonomy.cdm.common.ResultWrapper; |
29 | 29 |
import eu.etaxonomy.cdm.common.XmlHelp; |
30 |
import eu.etaxonomy.cdm.io.common.ICdmIO; |
|
31 | 30 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
32 | 31 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
33 | 32 |
import eu.etaxonomy.cdm.model.common.Language; |
... | ... | |
66 | 65 |
*/ |
67 | 66 |
//@Component("bfnXmlTaxonNameIO") |
68 | 67 |
@Component |
69 |
public class BfnXmlImportTaxonName extends BfnXmlImportBase implements ICdmIO<BfnXmlImportState> {
|
|
68 |
public class BfnXmlImportTaxonName extends BfnXmlImportBase { |
|
70 | 69 |
|
71 |
|
|
72 |
private static final Logger logger = Logger.getLogger(BfnXmlImportTaxonName.class); |
|
70 |
private static final Logger logger = Logger.getLogger(BfnXmlImportTaxonName.class); |
|
73 | 71 |
|
74 | 72 |
private static String strNomenclaturalCode = null;// "Zoological";//"Botanical"; |
75 | 73 |
private static int parsingProblemCounter = 0; |
... | ... | |
81 | 79 |
super(); |
82 | 80 |
} |
83 | 81 |
|
84 |
@Override |
|
85 |
public boolean doCheck(BfnXmlImportState state){ |
|
86 |
boolean result = true; |
|
87 |
return result; |
|
88 |
} |
|
89 | 82 |
|
90 | 83 |
@Override |
91 | 84 |
@SuppressWarnings({"rawtypes" }) |
... | ... | |
894 | 887 |
} |
895 | 888 |
|
896 | 889 |
|
890 |
@Override |
|
891 |
public boolean doCheck(BfnXmlImportState state){ |
Also available in: Unified diff
Cleanup BfnXmlImport