Revision 4d8fb1a4
Added by Alexander Oppermann about 9 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/common/CdmDestinations.java | ||
---|---|---|
25 | 25 |
public static ICdmDataSource cdm_redlist_localhost(){ |
26 | 26 |
DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL; |
27 | 27 |
String cdmServer = "localhost"; |
28 |
String cdmDB = "cdm_production_rl_lumbricidae";
|
|
28 |
String cdmDB = "cdm_bfn_imports";
|
|
29 | 29 |
String cdmUserName = "root"; |
30 | 30 |
return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null); |
31 | 31 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/app/redlist/BfnXmlTestActivator.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
import java.net.URI; |
13 | 13 |
import java.net.URISyntaxException; |
14 |
import java.util.Arrays; |
|
15 |
import java.util.List; |
|
16 |
import java.util.Scanner; |
|
14 | 17 |
import java.util.UUID; |
15 | 18 |
|
16 | 19 |
import org.apache.log4j.Logger; |
... | ... | |
29 | 32 |
* @version 1.0 |
30 | 33 |
*/ |
31 | 34 |
public class BfnXmlTestActivator { |
35 |
|
|
32 | 36 |
private static final Logger logger = Logger.getLogger(BfnXmlTestActivator.class); |
33 | 37 |
|
34 | 38 |
//database validation status (create, update, validate ...) |
35 |
static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE; |
|
36 |
// static final String tcsSource = TcsSources.tcsXml_cichorium(); |
|
39 |
static DbSchemaValidation schemaValidation = DbSchemaValidation.NONE; |
|
37 | 40 |
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_redlist_localhost(); |
38 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_testDB_localhost(); |
|
39 |
/** |
|
40 |
* If Metadata exists this will be overwritten |
|
41 |
*/ |
|
42 |
private static final String sourceReferenceTitle = "Lumbricidae"; |
|
43 | 41 |
|
44 |
|
|
45 |
static final UUID treeUuid = UUID.fromString("00000000-0c97-48ac-8d33-6099ed68c625"); |
|
46 |
static final String sourceSecId = "BfnXML";
|
|
42 |
private String filename; |
|
43 |
|
|
44 |
private static final String strSource = "/eu/etaxonomy/cdm/io/bfnXml/";
|
|
47 | 45 |
|
48 |
private static final String strSource = "/eu/etaxonomy/cdm/io/bfnXml/rldb_Lumbricidae.xml"; |
|
49 |
// private static final String strSource = "/eu/etaxonomy/cdm/io/bfnXml/rldb_Myxo.xml"; |
|
50 | 46 |
static final boolean includeNormalExplicit = true; |
51 | 47 |
|
52 | 48 |
//check - import |
53 | 49 |
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK; |
54 |
|
|
55 | 50 |
//authors |
56 |
static final boolean doMetaData = false;
|
|
51 |
static final boolean doMetaData = true;
|
|
57 | 52 |
//references |
58 | 53 |
static final DO_REFERENCES doReferences = DO_REFERENCES.ALL; |
59 | 54 |
//names |
60 | 55 |
static final boolean doTaxonNames = true; |
61 | 56 |
static final boolean doRelNames = false; |
62 |
|
|
63 | 57 |
//taxa |
64 | 58 |
static final boolean doTaxa = true; |
65 | 59 |
static final boolean doRelTaxa = false; |
66 |
|
|
67 |
|
|
60 |
|
|
61 |
public BfnXmlTestActivator(String fileName){ |
|
62 |
filename = fileName; |
|
63 |
} |
|
68 | 64 |
|
69 | 65 |
private void doImport(){ |
70 | 66 |
System.out.println("Start import from BfnXML to "+ cdmDestination.getDatabase() + " ..."); |
... | ... | |
72 | 68 |
//make Source |
73 | 69 |
URI source; |
74 | 70 |
try { |
75 |
source = this.getClass().getResource(strSource).toURI(); |
|
71 |
source = this.getClass().getResource(strSource+filename).toURI();
|
|
76 | 72 |
ICdmDataSource destination = cdmDestination; |
77 | 73 |
|
78 | 74 |
BfnXmlImportConfigurator bfnImportConfigurator = BfnXmlImportConfigurator.NewInstance(source, destination); |
79 | 75 |
|
80 |
bfnImportConfigurator.setSourceReferenceTitle(sourceReferenceTitle); |
|
81 |
|
|
82 |
bfnImportConfigurator.setClassificationName("Lumbricidae"); |
|
83 |
bfnImportConfigurator.setClassificationUuid(treeUuid); |
|
84 |
bfnImportConfigurator.setSourceSecId(sourceSecId); |
|
85 |
|
|
86 | 76 |
//if xmllist has two lists |
87 | 77 |
bfnImportConfigurator.setHasSecondList(false); |
88 | 78 |
|
... | ... | |
95 | 85 |
bfnImportConfigurator.setDoRelTaxa(doRelTaxa); |
96 | 86 |
|
97 | 87 |
bfnImportConfigurator.setCheck(check); |
98 |
bfnImportConfigurator.setDbSchemaValidation(hbm2dll);
|
|
88 |
bfnImportConfigurator.setDbSchemaValidation(schemaValidation);
|
|
99 | 89 |
|
100 | 90 |
// invoke import |
101 | 91 |
CdmDefaultImport<BfnXmlImportConfigurator> bfnImport = new CdmDefaultImport<BfnXmlImportConfigurator>(); |
102 |
//new Test().invoke(tcsImportConfigurator); |
|
103 | 92 |
bfnImport.invoke(bfnImportConfigurator); |
104 | 93 |
|
105 |
|
|
106 |
// IReferenceService refService = tcsImport.getCdmAppController().getReferenceService(); |
|
107 |
// IBook book = ReferenceFactory.newBook(); |
|
108 |
// book.setDatePublished(TimePeriod.NewInstance(1945).setEndDay(12).setEndMonth(4)); |
|
109 |
// refService.saveOrUpdate((Reference)book); |
|
110 |
// tcsImport.getCdmAppController().close(); |
|
111 |
|
|
112 |
// NormalExplicitTestActivator normExActivator = new NormalExplicitTestActivator(); |
|
113 |
// normExActivator.doImport(destination, DbSchemaValidation.VALIDATE); |
|
114 |
// |
|
115 |
logger.info("End"); |
|
94 |
logger.warn("End"); |
|
116 | 95 |
System.out.println("End import from BfnXML ("+ source.toString() + ")..."); |
117 | 96 |
} catch (URISyntaxException e) { |
118 | 97 |
e.printStackTrace(); |
... | ... | |
120 | 99 |
|
121 | 100 |
} |
122 | 101 |
|
102 |
|
|
123 | 103 |
/** |
124 | 104 |
* @param args |
125 | 105 |
*/ |
126 | 106 |
public static void main(String[] args) { |
127 |
BfnXmlTestActivator bfnXmlTestActivator = new BfnXmlTestActivator(); |
|
128 |
bfnXmlTestActivator.doImport(); |
|
107 |
|
|
108 |
List<String> fileNames = Arrays.asList( |
|
109 |
// "rldb_print_v4_0_1_0_artenarmeWeichtiergruppen_121127_verantw_syn.xml", |
|
110 |
// "rldb_print_v4_0_1_0_Asilidae_GMH_Wolff_110314_HGxls_120413_DF_korrV_Verantw_syn.xml", |
|
111 |
// "rldb_print_v4_0_1_0_Asseln_121128_verantw_syn.xml", |
|
112 |
// "rldb_print_v4_0_1_0_Asselspinnen_120907_verantw_syn.xml", |
|
113 |
// "rldb_print_v4_0_1_0_Bienen_PWKorr_HG_120413_DF_120612_syn.xml", |
|
114 |
// "rldb_print_v4_0_1_0_Binnenmollusken_0alle_120413_DF_syn.xml", |
|
115 |
// "rldb_print_v4_0_1_0_Blattoptera_140413_DF_syn.xml", |
|
116 |
// "rldb_print_v4_0_1_0_Empidoidea_120413_DF.xml", |
|
117 |
// "rldb_print_v4_0_1_0_Eulen_Korruebern_23-05-2012_KorrV_syn.xml", |
|
118 |
// "rldb_print_v4_0_1_0_Eulenspinner_Spanner_13-06-2012_KorrV_syn.xml" |
|
119 |
// |
|
120 |
// "rldb_print_v4_0_1_0_Flechten_korr_verantw_syn.xml", |
|
121 |
// "rldb_print_v4_0_1_0_Flohkrebse_121128_verantw_syn.xml", |
|
122 |
// "rldb_print_v4_0_1_0_Heuschrecken_syn.xml", |
|
123 |
// "rldb_print_v4_0_1_0_Igelwuermer_120907_verantw.xml", |
|
124 |
// "rldb_print_v4_0_1_0_Kumazeen_120709_verantw_syn.xml", |
|
125 |
// "rldb_print_v4_0_1_0_Lichenicole_verantw_syn.xml", |
|
126 |
// "rldb_print_v4_0_1_0_Makroalgen_150121_syn.xml", |
|
127 |
// "rldb_print_v4_0_1_0_Meeresfische_syn.xml", |
|
128 |
// "rldb_print_v4_0_1_0_Moostierchen_121128_verantw_syn.xml", |
|
129 |
// "rldb_print_v4_0_1_0_Muscheln_121128_verantw_syn.xml", |
|
130 |
// "rldb_print_v4_0_1_0_Myxo_110708_korr_syn_neu.xml", |
|
131 |
// "rldb_print_v4_0_1_0_Nesseltiere_130104_verantw_syn.xml", |
|
132 |
// "rldb_print_v4_0_1_0_Ohrwuermer_DF_syn.xml", |
|
133 |
// "rldb_print_v4_0_1_0_Pflanzenwespen_280711_Autor_110815_HG2_120413_DF_syn.xml", |
|
134 |
// "rldb_print_v4_0_1_0_Pyraloidea_Februar_ 2012_Korruebern_MB_24-04-2012_syn.xml", |
|
135 |
// "rldb_print_v4_0_1_0_Saprophyten_verantw.xml" |
|
136 |
// |
|
137 |
"rldb_print_v4_0_1_0_Schaedellose_120907_verantw_syn.xml", |
|
138 |
"rldb_print_v4_0_1_0_Schnecken_130206_verantw_syn.xml", |
|
139 |
"rldb_print_v4_0_1_0_Schwaemme_121127_verantw_syn.xml", |
|
140 |
"rldb_print_v4_0_1_0_Schwebfliegen_111103_KorrAS_120413_DF_syn.xml", |
|
141 |
"rldb_print_v4_0_1_0_Seepocken_121128_verantw_syn.xml", |
|
142 |
"rldb_print_v4_0_1_0_Seescheiden_121128_verantw_syn.xml", |
|
143 |
"rldb_print_v4_0_1_0_Spinner_Oktober2011_eingearbKorr_120124_Korruebern_MB_02-05-2012_KorrV_syn.xml", |
|
144 |
"rldb_print_v4_0_1_0_Stachelhaeuter_121128_verantw_syn.xml", |
|
145 |
"rldb_print_v4_0_1_0_Tagfalter_06-06-2012_KorrV_syn.xml", |
|
146 |
"rldb_print_v4_0_1_0_Thysanoptera_120413_DF_korrV_Verantw.xml", |
|
147 |
"rldb_print_v4_0_1_0_Vielborster_130206_verantw_syn.xml", |
|
148 |
"rldb_print_v4_0_1_0_Wenigborster_121128_verantw_syn.xml", |
|
149 |
"rldb_print_v4_0_1_0_Zehnfusskrebse_130104_verantw_syn.xml" |
|
150 |
); |
|
151 |
for(String fileName:fileNames){ |
|
152 |
BfnXmlTestActivator bfnXmlTestActivator = new BfnXmlTestActivator(fileName); |
|
153 |
bfnXmlTestActivator.doImport(); |
|
154 |
// pauseProg(); |
|
155 |
} |
|
156 |
|
|
157 |
//first run |
|
158 |
//create DB,Metadata |
|
159 |
// String fileName = "rldb_print_v4_0_1_0_Ameisen_110609_rev120113_syn.xml"; |
|
160 |
// BfnXmlTestActivator bfnXmlTestActivator = new BfnXmlTestActivator(fileName); |
|
161 |
// bfnXmlTestActivator.doImport(); |
|
129 | 162 |
} |
130 | 163 |
|
164 |
public static void pauseProg(){ |
|
165 |
System.out.println("Press enter to continue..."); |
|
166 |
Scanner keyboard = new Scanner(System.in); |
|
167 |
keyboard.nextLine(); |
|
168 |
} |
|
131 | 169 |
} |
170 |
|
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/BfnXmlImportConfigurator.java | ||
---|---|---|
78 | 78 |
|
79 | 79 |
protected static Namespace nsTcsXml = Namespace.getNamespace("http://www.tdwg.org/schemas/tcs/1.01"); |
80 | 80 |
|
81 |
// @Autowired |
|
82 |
// TcsXmlMetaDataImport tcsXmlMetaDataImport; |
|
83 |
// @Autowired |
|
84 |
// TcsXmlSpecimensImport tcsXmlSpecimensIO; |
|
85 |
// @Autowired |
|
86 |
// TcsXmlPublicationsImport tcsXmlPublicationsIO; |
|
87 |
// @Autowired |
|
88 |
// BfnXmlTaxonNameImport tcsXmlTaxonNameIO; |
|
89 |
// @Autowired |
|
90 |
// TcsXmlTaxonNameRelationsImport tcsXmlTaxonNameRelationsIO; |
|
91 |
// @Autowired |
|
92 |
// BfnXmlTaxonImport tcsXmlTaxonIO; |
|
93 |
// @Autowired |
|
94 |
// TcsXmlTaxonRelationsImport tcsXmlTaxonRelationsIO; |
|
95 |
|
|
96 | 81 |
@SuppressWarnings("unchecked") |
97 | 82 |
protected void makeIoClassList(){ |
98 |
// ioBeans = new String[]{ |
|
99 |
// "tcsXmlMetaDataImport" |
|
100 |
// , "tcsXmlSpecimensIO" |
|
101 |
// , "tcsXmlPublicationsIO" |
|
102 |
// , "tcsXmlTaxonNameIO" |
|
103 |
// , "tcsXmlTaxonNameRelationsIO" |
|
104 |
// , "tcsXmlTaxonIO" |
|
105 |
// , "tcsXmlTaxonRelationsIO" |
|
106 |
// }; |
|
107 |
|
|
108 | 83 |
ioClassList = new Class[]{ |
109 | 84 |
BfnXmlImportMetaData.class, |
110 | 85 |
BfnXmlImportFeature.class, |
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/BfnXmlImportFeature.java | ||
---|---|---|
72 | 72 |
public class BfnXmlImportFeature extends BfnXmlImportBase implements ICdmIO<BfnXmlImportState> { |
73 | 73 |
private static final Logger logger = Logger.getLogger(BfnXmlImportFeature.class); |
74 | 74 |
|
75 |
private static final String strNomenclaturalCode = "Botanical"; |
|
76 |
private static int i = 0; |
|
77 |
|
|
78 | 75 |
public BfnXmlImportFeature(){ |
79 | 76 |
super(); |
80 | 77 |
} |
... | ... | |
90 | 87 |
@SuppressWarnings({ "unchecked", "rawtypes" }) |
91 | 88 |
public void doInvoke(BfnXmlImportState state){ |
92 | 89 |
|
93 |
ITermService termService = getTermService(); |
|
94 | 90 |
IVocabularyService vocabularyService = getVocabularyService(); |
95 | 91 |
|
96 | 92 |
|
97 |
logger.info("start create Features in CDM..."); |
|
98 |
MapWrapper<DefinedTermBase> featureMap = (MapWrapper<DefinedTermBase>)state.getStore(ICdmIO.TAXON_STORE); |
|
99 |
MapWrapper<StateData> stateMap = (MapWrapper<StateData>)state.getStore(ICdmIO.FEATURE_STORE); |
|
100 |
|
|
101 |
|
|
93 |
logger.warn("start create Features in CDM..."); |
|
102 | 94 |
ResultWrapper<Boolean> success = ResultWrapper.NewInstance(true); |
103 | 95 |
String childName; |
104 | 96 |
boolean obligatory; |
105 |
String idNamespace = "Features"; |
|
106 |
|
|
107 | 97 |
BfnXmlImportConfigurator config = state.getConfig(); |
108 | 98 |
Element elDataSet = getDataSetElement(config); |
109 | 99 |
Namespace bfnNamespace = config.getBfnXmlNamespace(); |
... | ... | |
130 | 120 |
for (Element elFeature : elFeatureList){ |
131 | 121 |
|
132 | 122 |
if(elFeature.getAttributeValue("standardname", bfnNamespace).equalsIgnoreCase("RL Kat.")){ |
133 |
makeFeature(termService, vocabularyService, featureList,success, obligatory, idNamespace, config, bfnNamespace,elFeature, state);
|
|
123 |
makeFeature(vocabularyService, featureList,success, obligatory, bfnNamespace,elFeature, state);
|
|
134 | 124 |
} |
135 | 125 |
String featureLabel = "Kat. +/-"; |
136 | 126 |
if(elFeature.getAttributeValue("standardname").equalsIgnoreCase(featureLabel)){ |
137 |
//getFeature(state, null, featureLabel, featureLabel, null, null); |
|
138 |
|
|
139 |
makeFeature(termService, vocabularyService, featureList,success, obligatory, idNamespace, config, bfnNamespace,elFeature, state); |
|
127 |
makeFeature(vocabularyService, featureList,success, obligatory, bfnNamespace,elFeature, state); |
|
140 | 128 |
} |
141 | 129 |
if(elFeature.getAttributeValue("standardname").equalsIgnoreCase("aktuelle Bestandsstituation")){ |
142 |
makeFeature(termService, vocabularyService, featureList,success, obligatory, idNamespace, config, bfnNamespace,elFeature, state);
|
|
130 |
makeFeature(vocabularyService, featureList,success, obligatory, bfnNamespace,elFeature, state);
|
|
143 | 131 |
} |
144 | 132 |
if(elFeature.getAttributeValue("standardname").equalsIgnoreCase("langfristiger Bestandstrend")){ |
145 |
makeFeature(termService, vocabularyService, featureList,success, obligatory, idNamespace, config, bfnNamespace,elFeature, state);
|
|
133 |
makeFeature(vocabularyService, featureList,success, obligatory, bfnNamespace,elFeature, state);
|
|
146 | 134 |
} |
147 | 135 |
if(elFeature.getAttributeValue("standardname").equalsIgnoreCase("kurzfristiger Bestandstrend")){ |
148 |
makeFeature(termService, vocabularyService, featureList,success, obligatory, idNamespace, config, bfnNamespace,elFeature, state);
|
|
136 |
makeFeature(vocabularyService, featureList,success, obligatory, bfnNamespace,elFeature, state);
|
|
149 | 137 |
} |
150 | 138 |
if(elFeature.getAttributeValue("standardname").equalsIgnoreCase("Risikofaktoren")){ |
151 |
makeFeature(termService, vocabularyService, featureList,success, obligatory, idNamespace, config, bfnNamespace,elFeature, state);
|
|
139 |
makeFeature(vocabularyService, featureList,success, obligatory, bfnNamespace,elFeature, state);
|
|
152 | 140 |
} |
153 | 141 |
if(elFeature.getAttributeValue("standardname").equalsIgnoreCase("Verantwortlichkeit")){ |
154 |
makeFeature(termService, vocabularyService, featureList,success, obligatory, idNamespace, config, bfnNamespace,elFeature, state);
|
|
142 |
makeFeature(vocabularyService, featureList,success, obligatory, bfnNamespace,elFeature, state);
|
|
155 | 143 |
} |
156 | 144 |
if(elFeature.getAttributeValue("standardname").equalsIgnoreCase("alte RL- Kat.")){ |
157 |
makeFeature(termService, vocabularyService, featureList,success, obligatory, idNamespace, config, bfnNamespace,elFeature, state);
|
|
145 |
makeFeature(vocabularyService, featureList,success, obligatory, bfnNamespace,elFeature, state);
|
|
158 | 146 |
} |
159 | 147 |
if(elFeature.getAttributeValue("standardname").equalsIgnoreCase("Neobiota")){ |
160 |
makeFeature(termService, vocabularyService, featureList,success, obligatory, idNamespace, config, bfnNamespace,elFeature, state);
|
|
148 |
makeFeature(vocabularyService, featureList,success, obligatory, bfnNamespace,elFeature, state);
|
|
161 | 149 |
} |
162 | 150 |
if(elFeature.getAttributeValue("standardname").equalsIgnoreCase("Eindeutiger Code")){ |
163 |
makeFeature(termService, vocabularyService, featureList,success, obligatory, idNamespace, config, bfnNamespace,elFeature, state);
|
|
151 |
makeFeature(vocabularyService, featureList,success, obligatory, bfnNamespace,elFeature, state);
|
|
164 | 152 |
} |
165 | 153 |
if(elFeature.getAttributeValue("standardname").equalsIgnoreCase("Kommentar zur Taxonomie")){ |
166 |
makeFeature(termService, vocabularyService, featureList,success, obligatory, idNamespace, config, bfnNamespace,elFeature, state);
|
|
154 |
makeFeature(vocabularyService, featureList,success, obligatory, bfnNamespace,elFeature, state);
|
|
167 | 155 |
} |
168 | 156 |
if(elFeature.getAttributeValue("standardname").equalsIgnoreCase("Kommentar zur Gefährdung")){ |
169 |
makeFeature(termService, vocabularyService, featureList,success, obligatory, idNamespace, config, bfnNamespace,elFeature, state); |
|
157 |
makeFeature(vocabularyService, featureList,success, obligatory, bfnNamespace,elFeature, state); |
|
158 |
} |
|
159 |
if(elFeature.getAttributeValue("standardname").equalsIgnoreCase("Sonderfälle")){ |
|
160 |
makeFeature(vocabularyService, featureList,success, obligatory, bfnNamespace,elFeature, state); |
|
161 |
} |
|
162 |
if(elFeature.getAttributeValue("standardname").equalsIgnoreCase("Letzter Nachweis")){ |
|
163 |
makeFeature(vocabularyService, featureList,success, obligatory, bfnNamespace,elFeature, state); |
|
164 |
} |
|
165 |
if(elFeature.getAttributeValue("standardname").equalsIgnoreCase("Weitere Kommentare")){ |
|
166 |
makeFeature(vocabularyService, featureList,success, obligatory, bfnNamespace,elFeature, state); |
|
170 | 167 |
} |
171 | 168 |
} |
172 | 169 |
createFeatureTree(featureList); |
173 |
// termService.save(featureMap.objects()); |
|
174 |
|
|
175 | 170 |
commitTransaction(tx); |
176 | 171 |
|
177 | 172 |
logger.info("end create features ..."); |
178 | 173 |
|
179 |
|
|
180 |
|
|
181 | 174 |
if (!success.getValue()){ |
182 | 175 |
state.setUnsuccessfull(); |
183 | 176 |
} |
184 |
//FIXME: Only take the first RoteListeData Features |
|
185 |
|
|
186 |
|
|
187 | 177 |
return; |
188 | 178 |
} |
189 | 179 |
} |
... | ... | |
198 | 188 |
private void createFeatureTree(List<Feature> featureList) { |
199 | 189 |
FeatureTree featureTree = FeatureTree.NewInstance(featureList); |
200 | 190 |
String featureTreeName = "RedListFeatureTree"; |
201 |
featureTree.setTitleCache(featureTreeName); |
|
191 |
featureTree.setTitleCache(featureTreeName, true);
|
|
202 | 192 |
getFeatureTreeService().save(featureTree); |
203 | 193 |
} |
204 | 194 |
|
205 | 195 |
/** |
206 |
* @param termService
|
|
196 |
* |
|
207 | 197 |
* @param vocabularyService |
208 |
* @param featureMap
|
|
198 |
* @param featureList
|
|
209 | 199 |
* @param success |
210 | 200 |
* @param obligatory |
211 |
* @param idNamespace |
|
212 |
* @param config |
|
213 | 201 |
* @param bfnNamespace |
214 | 202 |
* @param elFeature |
203 |
* @param state |
|
215 | 204 |
*/ |
216 |
private void makeFeature(ITermService termService, |
|
217 |
IVocabularyService vocabularyService, |
|
205 |
private void makeFeature(IVocabularyService vocabularyService, |
|
218 | 206 |
List<Feature> featureList, |
219 | 207 |
ResultWrapper<Boolean> success, boolean obligatory, |
220 |
String idNamespace, BfnXmlImportConfigurator config, |
|
221 | 208 |
Namespace bfnNamespace, Element elFeature, BfnXmlImportState state) { |
222 | 209 |
String childName; |
223 | 210 |
String strRlKat = elFeature.getAttributeValue("standardname"); |
... | ... | |
225 | 212 |
try { |
226 | 213 |
featureUUID = BfnXmlTransformer.getRedlistFeatureUUID(strRlKat); |
227 | 214 |
} catch (UnknownCdmTypeException e) { |
228 |
// TODO Auto-generated catch block |
|
229 | 215 |
e.printStackTrace(); |
230 | 216 |
} |
231 | 217 |
Feature redListCat = getFeature(state, featureUUID, strRlKat, strRlKat, strRlKat, null); |
232 | 218 |
featureList.add(redListCat); |
233 |
// Feature redListCat = Feature.NewInstance(strRlKat, strRlKat, strRlKat); |
|
234 |
//TODO save |
|
235 |
// termService.saveOrUpdate(redListCat); |
|
236 | 219 |
childName = "LISTENWERTE"; |
237 | 220 |
Element elListValues = XmlHelp.getSingleChildElement(success, elFeature, childName, bfnNamespace, obligatory); |
238 | 221 |
if(elListValues != null && !elListValues.getContent().isEmpty()){ |
239 | 222 |
String childElementName = "LWERT"; |
240 |
createOrUpdateStates(success, idNamespace, config, bfnNamespace, elListValues, childElementName, redListCat, state);
|
|
223 |
createOrUpdateStates(bfnNamespace, elListValues, childElementName, redListCat, state); |
|
241 | 224 |
} |
242 | 225 |
createOrUpdateTermVocabulary(TermType.Feature, vocabularyService, redListCat, "RedList Feature"); |
243 | 226 |
} |
... | ... | |
267 | 250 |
|
268 | 251 |
/** |
269 | 252 |
* @param success |
270 |
* @param idNamespace |
|
271 |
* @param config |
|
272 | 253 |
* @param bfnNamespace |
273 | 254 |
* @param elListValues |
274 | 255 |
* @param childElementName |
... | ... | |
276 | 257 |
*/ |
277 | 258 |
|
278 | 259 |
@SuppressWarnings({ "unchecked", "rawtypes"}) |
279 |
private void createOrUpdateStates(ResultWrapper<Boolean> success, String idNamespace, |
|
280 |
BfnXmlImportConfigurator config, Namespace bfnNamespace, |
|
281 |
Element elListValues, String childElementName, Feature redListCat, BfnXmlImportState state) { |
|
260 |
private void createOrUpdateStates(Namespace bfnNamespace, Element elListValues, String childElementName, |
|
261 |
Feature redListCat, BfnXmlImportState state) { |
|
282 | 262 |
|
283 | 263 |
List<Element> elListValueList = (List<Element>)elListValues.getChildren(childElementName, bfnNamespace); |
284 | 264 |
// List<StateData> stateList = new ArrayList<StateData>(); |
... | ... | |
293 | 273 |
vocabularyStateUuid = BfnXmlTransformer.getRedlistVocabularyUUID(redListCat.toString()); |
294 | 274 |
} catch (UnknownCdmTypeException e1) { |
295 | 275 |
vocabularyStateUuid = UUID.randomUUID(); |
276 |
logger.info("Element: " + listValue); |
|
296 | 277 |
e1.printStackTrace(); |
297 | 278 |
} |
298 | 279 |
try { |
... | ... | |
311 | 292 |
String vocName = redListCat.toString()+" States"; |
312 | 293 |
termVocabulary = (OrderedTermVocabulary) getVocabulary(TermType.State, vocabularyStateUuid, vocName, vocName, vocName, null, true, null); |
313 | 294 |
State stateTerm = getStateTerm(state, stateTermUuid, matchedListValue, matchedListValue, matchedListValue, termVocabulary); |
314 |
// State stateTerm = State.NewInstance(matchedListValue,matchedListValue, matchedListValue); |
|
315 |
|
|
316 |
// getTermService().saveOrUpdate(stateTerm); |
|
317 |
// termVocabulary = createOrUpdateTermVocabulary(getVocabularyService(), stateTerm, redListCat.toString()+" States"); |
|
318 |
|
|
319 |
// StateData stateData = StateData.NewInstance(stateTerm); |
|
320 |
// featureMap.put(i++, state); |
|
321 |
// stateList.add(stateData); |
|
322 | 295 |
} |
323 | 296 |
if(termVocabulary != null){ |
324 | 297 |
redListCat.addSupportedCategoricalEnumeration(termVocabulary); |
325 | 298 |
getTermService().saveOrUpdate(redListCat); |
326 | 299 |
} |
327 | 300 |
|
328 |
// CategoricalData catData = CategoricalData.NewInstance(); |
|
329 |
// catData.setFeature(redListCat); |
|
330 |
// for(StateData sd: stateList){ |
|
331 |
// catData.addState(sd); |
|
332 |
// } |
|
333 |
// catData.setStatesOnly(stateList); |
|
334 |
// DescriptionElementBase descriptionElementBase = catData; |
|
335 |
// getDescriptionService().saveDescriptionElement(descriptionElementBase); |
|
336 |
// |
|
337 |
// DescriptionBase<?> descriptionBase = null; |
|
338 |
// descriptionBase.addElement(descriptionElementBase); |
|
339 |
// |
|
340 |
//featureMap.put(i++, descriptionBase); |
|
341 | 301 |
} |
342 | 302 |
|
343 | 303 |
|
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/BfnXmlImportMetaData.java | ||
---|---|---|
35 | 35 |
import eu.etaxonomy.cdm.io.common.ICdmIO; |
36 | 36 |
import eu.etaxonomy.cdm.io.common.ImportHelper; |
37 | 37 |
import eu.etaxonomy.cdm.io.common.MapWrapper; |
38 |
import eu.etaxonomy.cdm.io.common.Source; |
|
38 | 39 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
39 | 40 |
import eu.etaxonomy.cdm.model.common.Language; |
40 | 41 |
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary; |
41 | 42 |
import eu.etaxonomy.cdm.model.common.TermType; |
42 | 43 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
44 |
import eu.etaxonomy.cdm.model.common.TimePeriod; |
|
43 | 45 |
import eu.etaxonomy.cdm.model.common.VocabularyEnum; |
44 | 46 |
import eu.etaxonomy.cdm.model.description.CategoricalData; |
45 | 47 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
... | ... | |
64 | 66 |
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException; |
65 | 67 |
import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl; |
66 | 68 |
import eu.etaxonomy.cdm.strategy.parser.ParserProblem; |
69 |
import eu.etaxonomy.cdm.strategy.parser.TimePeriodParser; |
|
67 | 70 |
/** |
68 | 71 |
* |
69 | 72 |
* @author a.oppermann |
... | ... | |
73 | 76 |
@Component |
74 | 77 |
public class BfnXmlImportMetaData extends BfnXmlImportBase implements ICdmIO<BfnXmlImportState> { |
75 | 78 |
private static final Logger logger = Logger.getLogger(BfnXmlImportMetaData.class); |
79 |
private String sourceFileName; |
|
80 |
private String debVersion; |
|
81 |
private String timeStamp; |
|
76 | 82 |
|
77 | 83 |
public BfnXmlImportMetaData(){ |
78 | 84 |
super(); |
... | ... | |
87 | 93 |
|
88 | 94 |
@Override |
89 | 95 |
public void doInvoke(BfnXmlImportState state){ |
90 |
logger.info("start import MetaData...");
|
|
96 |
logger.warn("start import MetaData...");
|
|
91 | 97 |
|
92 | 98 |
|
93 | 99 |
ResultWrapper<Boolean> success = ResultWrapper.NewInstance(true); |
... | ... | |
95 | 101 |
BfnXmlImportConfigurator config = state.getConfig(); |
96 | 102 |
Element elDataSet = getDataSetElement(config); |
97 | 103 |
Namespace bfnNamespace = config.getBfnXmlNamespace(); |
104 |
//create complete source object |
|
105 |
if(elDataSet.getName().equalsIgnoreCase("DEBExport")){ |
|
106 |
sourceFileName = elDataSet.getAttributeValue("source"); |
|
107 |
debVersion = elDataSet.getAttributeValue("debversion"); |
|
108 |
timeStamp = elDataSet.getAttributeValue("timestamp"); |
|
109 |
|
|
110 |
Reference sourceReference = ReferenceFactory.newGeneric(); |
|
111 |
sourceReference.setTitle(sourceFileName); |
|
112 |
TimePeriod parsedTimePeriod = TimePeriodParser.parseString(timeStamp); |
|
113 |
sourceReference.setDatePublished(parsedTimePeriod); |
|
114 |
state.setCompleteSourceRef(sourceReference); |
|
115 |
} |
|
98 | 116 |
|
99 | 117 |
List contentXML = elDataSet.getContent(); |
100 | 118 |
Element currentElement = null; |
101 | 119 |
for(Object object:contentXML){ |
102 | 120 |
|
121 |
|
|
103 | 122 |
if(object instanceof Element){ |
104 | 123 |
currentElement = (Element)object; |
105 | 124 |
|
... | ... | |
114 | 133 |
if( elMetaData.getAttributeValue("standardname").equalsIgnoreCase("KurzLit_A")){ |
115 | 134 |
List<Element> children = (List<Element>)elMetaData.getChildren(); |
116 | 135 |
String kurzlitA = children.get(0).getTextNormalize(); |
117 |
Reference sourceReference = ReferenceFactory.newDatabase();
|
|
136 |
Reference sourceReference = ReferenceFactory.newGeneric();
|
|
118 | 137 |
sourceReference.setTitle(kurzlitA); |
119 | 138 |
state.setFirstListSecRef(sourceReference); |
120 | 139 |
|
121 | 140 |
} |
141 |
else if( elMetaData.getAttributeValue("standardname").equalsIgnoreCase("Klassifikation_A")){ |
|
142 |
List<Element> children = (List<Element>)elMetaData.getChildren(); |
|
143 |
String klassifikation_A = children.get(0).getTextNormalize(); |
|
144 |
state.setFirstClassificationName(klassifikation_A); |
|
145 |
|
|
146 |
} |
|
122 | 147 |
else if( elMetaData.getAttributeValue("standardname").equalsIgnoreCase("KurzLit_B")){ |
123 | 148 |
List<Element> children = (List<Element>)elMetaData.getChildren(); |
124 | 149 |
String kurzlitB = children.get(0).getTextNormalize(); |
125 |
Reference sourceReference = ReferenceFactory.newDatabase();
|
|
150 |
Reference sourceReference = ReferenceFactory.newGeneric();
|
|
126 | 151 |
sourceReference.setTitle(kurzlitB); |
127 | 152 |
state.setSecondListSecRef(sourceReference); |
128 | 153 |
} |
154 |
else if( elMetaData.getAttributeValue("standardname").equalsIgnoreCase("Klassifikation_B")){ |
|
155 |
List<Element> children = (List<Element>)elMetaData.getChildren(); |
|
156 |
String klassifikation_B = children.get(0).getTextNormalize(); |
|
157 |
state.setSecondClassificationName(klassifikation_B); |
|
158 |
|
|
159 |
} |
|
160 |
|
|
129 | 161 |
} |
130 | 162 |
|
163 |
logger.warn("end import MetaData ..."); |
|
131 | 164 |
commitTransaction(tx); |
132 | 165 |
|
133 |
logger.info("end import MetaData ..."); |
|
134 | 166 |
|
135 | 167 |
|
136 | 168 |
|
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/BfnXmlImportState.java | ||
---|---|---|
26 | 26 |
public class BfnXmlImportState extends ImportStateBase<BfnXmlImportConfigurator, BfnXmlImportBase>{ |
27 | 27 |
private Reference refA; |
28 | 28 |
private Reference refB; |
29 |
private Reference currentRef; |
|
29 |
private Reference currentMicroRef; |
|
30 |
private Reference completeSourceRef; |
|
31 |
private String classificationA; |
|
32 |
private String classificationB; |
|
30 | 33 |
@SuppressWarnings("unused") |
31 | 34 |
private static final Logger logger = Logger.getLogger(BfnXmlImportState.class); |
32 | 35 |
|
... | ... | |
41 | 44 |
return commonNameMap; |
42 | 45 |
} |
43 | 46 |
|
47 |
|
|
48 |
|
|
44 | 49 |
public void setCommonNameMap(Map<String, CommonTaxonName> commonNameMap) { |
45 | 50 |
this.commonNameMap = commonNameMap; |
46 | 51 |
} |
... | ... | |
61 | 66 |
return refB; |
62 | 67 |
} |
63 | 68 |
|
64 |
public void setCurrentRef(Reference currentRef) { |
|
65 |
this.currentRef = currentRef; |
|
69 |
public void setCurrentMicroRef(Reference currentRef) { |
|
70 |
this.currentMicroRef = currentRef; |
|
71 |
} |
|
72 |
public Reference getCompleteSourceRef() { |
|
73 |
return completeSourceRef; |
|
74 |
} |
|
75 |
|
|
76 |
public void setCompleteSourceRef(Reference completeSourceRef) { |
|
77 |
this.completeSourceRef = completeSourceRef; |
|
78 |
} |
|
79 |
|
|
80 |
public Reference getCurrentMicroRef(){ |
|
81 |
return currentMicroRef; |
|
66 | 82 |
} |
67 |
public Reference getCurrentRef(){ |
|
68 |
return currentRef; |
|
83 |
public void setFirstClassificationName(String classificationA) { |
|
84 |
this.classificationA = classificationA; |
|
85 |
} |
|
86 |
|
|
87 |
public void setSecondClassificationName(String classificationB) { |
|
88 |
this.classificationB = classificationB; |
|
89 |
} |
|
90 |
|
|
91 |
public String getFirstClassificationName() { |
|
92 |
return classificationA; |
|
93 |
} |
|
94 |
|
|
95 |
public String getSecondClassificationName() { |
|
96 |
return classificationB; |
|
69 | 97 |
} |
70 | 98 |
|
71 | 99 |
// /* (non-Javadoc) |
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/BfnXmlImportTaxonName.java | ||
---|---|---|
10 | 10 |
package eu.etaxonomy.cdm.io.redlist.bfnXml; |
11 | 11 |
|
12 | 12 |
import java.util.ArrayList; |
13 |
import java.util.Arrays; |
|
14 | 13 |
import java.util.Collection; |
15 |
import java.util.HashMap; |
|
16 | 14 |
import java.util.LinkedHashMap; |
17 | 15 |
import java.util.List; |
18 | 16 |
import java.util.Map; |
19 |
import java.util.Set; |
|
20 | 17 |
import java.util.UUID; |
21 | 18 |
|
22 | 19 |
import org.apache.commons.lang.StringUtils; |
23 | 20 |
import org.apache.log4j.Logger; |
24 |
import org.apache.poi.ss.formula.functions.T; |
|
25 |
import org.hibernate.Session; |
|
26 |
import org.jdom.Attribute; |
|
27 | 21 |
import org.jdom.Element; |
28 | 22 |
import org.jdom.Namespace; |
29 | 23 |
import org.springframework.stereotype.Component; |
30 | 24 |
import org.springframework.transaction.TransactionStatus; |
31 | 25 |
|
32 |
import com.google.common.base.CharMatcher; |
|
33 |
|
|
34 | 26 |
import eu.etaxonomy.cdm.api.service.IClassificationService; |
35 | 27 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
36 |
import eu.etaxonomy.cdm.api.service.config.MatchingTaxonConfigurator; |
|
37 |
import eu.etaxonomy.cdm.api.service.pager.Pager; |
|
38 |
import eu.etaxonomy.cdm.api.service.util.TaxonRelationshipEdge; |
|
39 | 28 |
import eu.etaxonomy.cdm.common.ResultWrapper; |
40 | 29 |
import eu.etaxonomy.cdm.common.XmlHelp; |
41 | 30 |
import eu.etaxonomy.cdm.io.common.ICdmIO; |
42 |
import eu.etaxonomy.cdm.io.common.ImportHelper; |
|
43 |
import eu.etaxonomy.cdm.io.common.MapWrapper; |
|
44 | 31 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
45 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
|
46 | 32 |
import eu.etaxonomy.cdm.model.common.Language; |
47 |
import eu.etaxonomy.cdm.model.common.RelationshipBase; |
|
48 |
import eu.etaxonomy.cdm.model.common.RelationshipBase.Direction; |
|
49 | 33 |
import eu.etaxonomy.cdm.model.description.CategoricalData; |
34 |
import eu.etaxonomy.cdm.model.description.CommonTaxonName; |
|
50 | 35 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
51 | 36 |
import eu.etaxonomy.cdm.model.description.Feature; |
52 | 37 |
import eu.etaxonomy.cdm.model.description.State; |
53 | 38 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
54 | 39 |
import eu.etaxonomy.cdm.model.description.TextData; |
40 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
|
55 | 41 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
56 | 42 |
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus; |
57 | 43 |
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType; |
58 | 44 |
import eu.etaxonomy.cdm.model.name.NonViralName; |
59 | 45 |
import eu.etaxonomy.cdm.model.name.Rank; |
60 | 46 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
61 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
62 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
|
63 | 47 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
64 | 48 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
65 | 49 |
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType; |
... | ... | |
106 | 90 |
|
107 | 91 |
BfnXmlImportConfigurator config = state.getConfig(); |
108 | 92 |
Element elDataSet = getDataSetElement(config); |
93 |
//TODO set Namespace |
|
109 | 94 |
Namespace bfnNamespace = config.getBfnXmlNamespace(); |
110 | 95 |
|
111 | 96 |
List<?> contentXML = elDataSet.getContent(); |
... | ... | |
121 | 106 |
createOrUdateClassification(config, taxonService, savedTaxonMap, currentElement, state); |
122 | 107 |
commitTransaction(tx); |
123 | 108 |
}//import concept relations of taxon lists |
124 |
else if(currentElement.getName().equalsIgnoreCase("KONZEPTBEZIEHUNGEN")){ |
|
125 |
TransactionStatus tx = startTransaction(); |
|
126 |
extractTaxonConceptRelationShips(bfnNamespace,currentElement); |
|
127 |
commitTransaction(tx); |
|
109 |
if(config.isHasSecondList()){ |
|
110 |
if(currentElement.getName().equalsIgnoreCase("KONZEPTBEZIEHUNGEN")){ |
|
111 |
TransactionStatus tx = startTransaction(); |
|
112 |
extractTaxonConceptRelationShips(bfnNamespace,currentElement); |
|
113 |
commitTransaction(tx); |
|
114 |
} |
|
128 | 115 |
} |
129 | 116 |
} |
130 | 117 |
} |
... | ... | |
248 | 235 |
Element elSynonyms = XmlHelp.getSingleChildElement(success, elTaxon, childName, bfnNamespace, obligatory); |
249 | 236 |
if(elSynonyms != null){ |
250 | 237 |
childElementName = "SYNONYM"; |
251 |
createOrUpdateSynonym(taxon, success, obligatory, bfnNamespace, childElementName,elSynonyms, taxonId, config); |
|
238 |
createOrUpdateSynonym(taxon, success, obligatory, bfnNamespace, childElementName,elSynonyms, taxonId, state); |
|
239 |
} |
|
240 |
//for vernacular name |
|
241 |
childName = "DEUTSCHENAMEN"; |
|
242 |
Element elVernacularName = XmlHelp.getSingleChildElement(success, elTaxon, childName, bfnNamespace, obligatory); |
|
243 |
if(elVernacularName != null){ |
|
244 |
childElementName = "DNAME"; |
|
245 |
createOrUpdateVernacularName(taxon, bfnNamespace, childElementName, elVernacularName, state); |
|
252 | 246 |
} |
253 | 247 |
//for each information concerning the taxon element |
254 | 248 |
//TODO Information block |
... | ... | |
278 | 272 |
} |
279 | 273 |
|
280 | 274 |
|
275 |
|
|
276 |
|
|
281 | 277 |
/** |
282 | 278 |
* This will put the prior imported list into a classification |
283 | 279 |
* |
... | ... | |
292 | 288 |
@SuppressWarnings("rawtypes") |
293 | 289 |
private boolean createOrUdateClassification(BfnXmlImportConfigurator config, ITaxonService taxonService, Map<UUID, TaxonBase> savedTaxonMap, Element currentElement, BfnXmlImportState state) { |
294 | 290 |
boolean isNewClassification = true; |
291 |
String classificationName = state.getFirstClassificationName(); |
|
292 |
if(config.isFillSecondList()){ |
|
293 |
classificationName = state.getSecondClassificationName(); |
|
294 |
} |
|
295 |
// if(classificationName == null){ |
|
296 |
// classificationName = config.getClassificationName(); |
|
297 |
// } |
|
295 | 298 |
//TODO make classification name dynamically depending on its value in the XML. |
296 |
Classification classification = Classification.NewInstance(config.getClassificationName()+" "+currentElement.getAttributeValue("inhalt"), state.getCurrentRef()); |
|
299 |
Classification classification = Classification.NewInstance(classificationName+" "+currentElement.getAttributeValue("inhalt"), state.getCompleteSourceRef()); |
|
300 |
classification.addImportSource(Integer.toString(classification.getId()), classification.getTitleCache(), state.getCompleteSourceRef(), state.getCurrentMicroRef().toString()); |
|
297 | 301 |
// List<Classification> classificationList = getClassificationService().list(Classification.class, null, null, null, VOC_CLASSIFICATION_INIT_STRATEGY); |
298 | 302 |
// for(Classification c : classificationList){ |
299 | 303 |
// if(c.getTitleCache().equalsIgnoreCase(classification.getTitleCache())){ |
... | ... | |
348 | 352 |
String strAuthor = null; |
349 | 353 |
String strSupplement = null; |
350 | 354 |
Taxon taxon = null; |
351 |
Integer uniqueID = null; |
|
355 |
String uniqueID = null; |
|
356 |
String uriNameSpace = null; |
|
352 | 357 |
// Long uniqueID = null; |
353 | 358 |
for(Element elWissName:elWissNameList){ |
354 | 359 |
|
355 | 360 |
if(elWissName.getAttributeValue("bereich", bfnNamespace).equalsIgnoreCase("Eindeutiger Code")){ |
361 |
uriNameSpace = elWissName.getAttributeValue("bereich"); |
|
356 | 362 |
String textNormalize = elWissName.getTextNormalize(); |
357 | 363 |
if(StringUtils.isBlank(textNormalize)){ |
358 |
uniqueID = -1;
|
|
364 |
uniqueID = "";
|
|
359 | 365 |
}else{ |
360 |
uniqueID = Integer.valueOf(textNormalize);
|
|
366 |
uniqueID = textNormalize;
|
|
361 | 367 |
} |
362 | 368 |
} |
363 | 369 |
if(elWissName.getAttributeValue("bereich", bfnNamespace).equalsIgnoreCase("Autoren")){ |
... | ... | |
397 | 403 |
// if (nameList.size()>1){ |
398 | 404 |
// logger.warn("More than 1 matching taxon name found for " + nameBase.getTitleCache()); |
399 | 405 |
// } |
400 |
// } |
|
406 |
// }CurrentMicroRef
|
|
401 | 407 |
|
402 | 408 |
// taxon = (Taxon) taxonBase; |
403 |
state.setCurrentRef(state.getFirstListSecRef()); |
|
409 |
state.setCurrentMicroRef(state.getFirstListSecRef());
|
|
404 | 410 |
if(config.isFillSecondList()){ |
405 |
state.setCurrentRef(state.getSecondListSecRef()); |
|
411 |
state.setCurrentMicroRef(state.getSecondListSecRef());
|
|
406 | 412 |
} |
407 |
taxon = Taxon.NewInstance(nameBase, state.getCurrentRef()); |
|
408 |
taxon.addImportSource(uniqueID.toString(), config.getBfnXmlNamespace().toString(), state.getCurrentRef(), null); |
|
413 |
taxon = Taxon.NewInstance(nameBase, state.getCurrentMicroRef()); |
|
414 |
// logger.info("Taxon Reference" + taxon.getSec().getTitle()); |
|
415 |
//set NameSpace |
|
416 |
Element parentElement = elWissName.getParentElement(); |
|
417 |
Element grandParentElement = parentElement.getParentElement(); |
|
418 |
// Element newElement = new Element("prefix", parentElement.getName()+":"+parentElement.getAttribute("taxNr").getName()); |
|
419 |
// Element newElement = new Element("element",grandParentElement.getName()+"-"+parentElement.getName()+"-"+elWissName.getName() , uriNameSpace); |
|
420 |
// config.setBfnXmlNamespace(newElement.getNamespace()); |
|
421 |
|
|
422 |
taxon.addImportSource(uniqueID, grandParentElement.getName()+":"+parentElement.getName()+":"+elWissName.getName()+":"+uriNameSpace, state.getCompleteSourceRef(), state.getCurrentMicroRef().getTitle()); |
|
409 | 423 |
} catch (UnknownCdmTypeException e) { |
410 | 424 |
success.setValue(false); |
411 | 425 |
} |
... | ... | |
427 | 441 |
* @param elSynonyms |
428 | 442 |
* @param taxonId |
429 | 443 |
* @param config |
444 |
* @param state |
|
430 | 445 |
*/ |
431 | 446 |
|
432 | 447 |
@SuppressWarnings({ "unchecked" }) |
433 | 448 |
private void createOrUpdateSynonym(Taxon taxon, ResultWrapper<Boolean> success, boolean obligatory, Namespace bfnNamespace, |
434 |
String childElementName, Element elSynonyms, String taxonId, BfnXmlImportConfigurator config) {
|
|
449 |
String childElementName, Element elSynonyms, String taxonId, BfnXmlImportState state) {
|
|
435 | 450 |
|
436 | 451 |
String childName; |
437 | 452 |
List<Element> elSynonymList = (List<Element>)elSynonyms.getChildren(childElementName, bfnNamespace); |
... | ... | |
462 | 477 |
TaxonNameBase<?, ?> nameBase = parseNonviralNames(rank,strAuthor,strSupplement,elSynDetail); |
463 | 478 |
|
464 | 479 |
//TODO find best matching Taxa |
465 |
Synonym synonym = Synonym.NewInstance(nameBase, config.getSourceReference());
|
|
480 |
Synonym synonym = Synonym.NewInstance(nameBase, state.getCurrentMicroRef());
|
|
466 | 481 |
taxon.addSynonym(synonym, SynonymRelationshipType.SYNONYM_OF()); |
467 | 482 |
|
468 | 483 |
} catch (UnknownCdmTypeException e) { |
... | ... | |
476 | 491 |
} |
477 | 492 |
} |
478 | 493 |
|
494 |
|
|
495 |
/** |
|
496 |
* |
|
497 |
* @param taxon |
|
498 |
* @param bfnNamespace |
|
499 |
* @param childElementName |
|
500 |
* @param elVernacularName |
|
501 |
* @param state |
|
502 |
*/ |
|
503 |
private void createOrUpdateVernacularName(Taxon taxon, |
|
504 |
Namespace bfnNamespace, String childElementName, |
|
505 |
Element elVernacularName, BfnXmlImportState state) { |
|
506 |
|
|
507 |
List<Element> elVernacularNameList = (List<Element>)elVernacularName.getChildren(childElementName, bfnNamespace); |
|
508 |
|
|
509 |
TaxonDescription taxonDescription = getTaxonDescription(taxon, false, true); |
|
510 |
|
|
511 |
for(Element elVernacular : elVernacularNameList){ |
|
512 |
Element child = elVernacular.getChild("TRIVIALNAME"); |
|
513 |
if(child != null){ |
|
514 |
makeCommonName(taxonDescription, child, state); |
|
515 |
} |
|
516 |
} |
|
517 |
|
|
518 |
} |
|
519 |
|
|
479 | 520 |
/** |
480 | 521 |
* |
481 | 522 |
* @param taxon |
... | ... | |
537 | 578 |
if(elInfoDetail.getAttributeValue("standardname").equalsIgnoreCase("Kommentar zur Gefährdung")){ |
538 | 579 |
makeFeatures(taxonDescription, elInfoDetail, state, true); |
539 | 580 |
} |
581 |
if(elInfoDetail.getAttributeValue("standardname").equalsIgnoreCase("Sonderfälle")){ |
|
582 |
makeFeatures(taxonDescription, elInfoDetail, state, false); |
|
583 |
} |
|
584 |
if(elInfoDetail.getAttributeValue("standardname").equalsIgnoreCase("Letzter Nachweis")){ |
|
585 |
makeFeatures(taxonDescription, elInfoDetail, state, true); |
|
586 |
} |
|
587 |
if(elInfoDetail.getAttributeValue("standardname").equalsIgnoreCase("Weitere Kommentare")){ |
|
588 |
makeFeatures(taxonDescription, elInfoDetail, state, true); |
|
589 |
} |
|
540 | 590 |
} |
541 | 591 |
} |
542 | 592 |
} |
543 | 593 |
|
594 |
|
|
595 |
|
|
596 |
private void makeCommonName(TaxonDescription taxonDescription, |
|
597 |
Element child, BfnXmlImportState state) { |
|
598 |
String commonNameValue = child.getValue(); |
|
599 |
NamedArea area = getTermService().getAreaByTdwgAbbreviation("GER"); |
|
600 |
CommonTaxonName commonName = CommonTaxonName.NewInstance(commonNameValue, Language.GERMAN(), area); |
|
601 |
taxonDescription.addElement(commonName); |
|
602 |
} |
|
603 |
|
|
604 |
|
|
544 | 605 |
/** |
545 | 606 |
* |
546 | 607 |
* @param taxonDescription |
... | ... | |
553 | 614 |
Element elInfoDetail, |
554 | 615 |
BfnXmlImportState state, |
555 | 616 |
boolean isTextData) { |
617 |
|
|
556 | 618 |
String transformedRlKatValue = null; |
557 | 619 |
UUID featureUUID = null; |
558 | 620 |
UUID stateTermUUID = null; |
... | ... | |
641 | 703 |
TaxonNameBase<?,?> taxonNameBase = null; |
642 | 704 |
|
643 | 705 |
NomenclaturalCode nomCode = BfnXmlTransformer.nomCodeString2NomCode(strNomenclaturalCode); |
644 |
|
|
706 |
//Todo check author |
|
645 | 707 |
String strScientificName = elWissName.getTextNormalize(); |
646 | 708 |
if(strSupplement != null && !strSupplement.isEmpty()){ |
647 | 709 |
strScientificName = StringUtils.remove(strScientificName, strSupplement); |
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/BfnXmlTransformer.java | ||
---|---|---|
48 | 48 |
public static final UUID vocStateRLKatOld = UUID.fromString("e9be0626-e14e-4556-a8af-9d49e6279669"); |
49 | 49 |
public static final UUID vocStateRLNeo = UUID.fromString("6c55ae1d-046d-4b67-89aa-b24c4888df6a"); |
50 | 50 |
public static final UUID vocStateRLKatId = UUID.fromString("c54481b3-bf07-43ce-b1cb-09759e4d2a70"); |
51 |
public static final UUID vocStateRLSpecialCases = UUID.fromString("ce2f4f8f-4222-429f-938b-77b794ecf704"); |
|
51 | 52 |
|
52 | 53 |
//redlist feature |
53 | 54 |
public static final UUID featureRLKat = UUID.fromString("744f8833-619a-4d83-b330-1997c3b2c2f9"); |
... | ... | |
62 | 63 |
public static final UUID featureRLKatId = UUID.fromString("dc9f5dd2-302c-4a32-bd70-278bbd9abd16"); |
63 | 64 |
public static final UUID featureRLTaxComment = UUID.fromString("b7c05d78-16a4-4b6e-a03b-fa6bb2ed74ae"); |
64 | 65 |
public static final UUID featureRLHazardComment = UUID.fromString("5beb1ebf-8643-4d5f-9849-8087c35455bb"); |
66 |
public static final UUID featureRLSpecialCases = UUID.fromString("fb92068d-667a-448e-8019-ca4551891b3b"); |
|
67 |
public static final UUID featureRLLastOccurrence = UUID.fromString("218a32be-fb87-41c9-8d64-b21b43b47caa"); |
|
68 |
public static final UUID featureRLAdditionalComment = UUID.fromString("c610c98e-f242-4f3b-9edd-7b84a9435867"); |
|
65 | 69 |
|
66 | 70 |
|
67 | 71 |
//rl kat state list |
... | ... | |
140 | 144 |
public static final UUID stateTermRLKatOldNb = UUID.fromString("72faec78-6db9-4471-9a65-c6d2337bd324"); |
141 | 145 |
public static final UUID stateTermRLKatOldKn = UUID.fromString("92276f3e-3c09-4761-ba5b-b49697c6d5ce"); |
142 | 146 |
public static final UUID stateTermEmpty = UUID.fromString("1d357340-5329-4f43-a454-7f99625a1d71"); |
147 |
public static final UUID stateTermRLSpecialS = UUID.fromString("71fda1f6-a7eb-44a0-aeb8-e7f676096916"); |
|
148 |
public static final UUID stateTermRLSpecialE = UUID.fromString("ef335a01-f4f1-4a02-95a2-2254aa457774"); |
|
149 |
public static final UUID stateTermRLSpecialD = UUID.fromString("6b267cc5-49b6-4ebd-87ec-aa574e9cbcc5"); |
|
143 | 150 |
|
144 | 151 |
|
145 | 152 |
public static TaxonRelationshipType concept2TaxonRelation(String conceptStatus) throws UnknownCdmTypeException{ |
... | ... | |
207 | 214 |
}else if (strRank.equals("subsubfm")){return Rank.SUBSUBFORM(); |
208 | 215 |
}else if (strRank.equals("subfm")){return Rank.SUBFORM(); |
209 | 216 |
}else if (strRank.equals("fm")){return Rank.FORM(); |
217 |
}else if (strRank.equals("f.")){return Rank.FORM(); |
|
210 | 218 |
}else if (strRank.equals("subsubvar")){return Rank.SUBSUBVARIETY(); |
211 | 219 |
}else if (strRank.equals("subvar")){return Rank.SUBVARIETY(); |
212 | 220 |
}else if (strRank.equals("var")){return Rank.VARIETY(); |
... | ... | |
233 | 241 |
}else if (strRank.equals("superreg")){return Rank.SUPERKINGDOM(); |
234 | 242 |
}else if (strRank.equals("dom")){return Rank.DOMAIN(); |
235 | 243 |
}else if (strRank.equals("taxsupragen")){return Rank.SUPRAGENERICTAXON(); |
244 |
}else if (strRank.equals("Auswertungsgruppe")){return Rank.EMPIRE(); |
|
236 | 245 |
//family group |
237 | 246 |
}else if (strRank.equals("infrafam")){return Rank.FAMILY(); |
238 | 247 |
}else if (strRank.equals("subfam")){return Rank.FAMILY(); |
... | ... | |
270 | 279 |
}else if (redListCode.equals("-")){return "-"; |
271 | 280 |
}else if (redListCode.equals("=")){return "="; |
272 | 281 |
}else if (redListCode.equals("N")){return "N"; |
282 |
}else if (redListCode.equals("S")){return "S"; |
|
283 |
}else if (redListCode.equals("E")){return "E"; |
|
284 |
}else if (redListCode.equals("D")){return "D"; |
|
273 | 285 |
}else if (redListCode.equals("#dtpl_KurzfBest_RUNTER##dtpl_KurzfBest_RUNTER##dtpl_KurzfBest_RUNTER#")){ |
274 | 286 |
char c = 0x2193; |
275 | 287 |
return String.valueOf(c)+String.valueOf(c)+String.valueOf(c); |
... | ... | |
331 | 343 |
if(redListVocabulary.equalsIgnoreCase("alte RL- Kat.")) return vocStateRLKatOld; |
332 | 344 |
if(redListVocabulary.equalsIgnoreCase("Neobiota")) return vocStateRLNeo; |
333 | 345 |
if(redListVocabulary.equalsIgnoreCase("Eindeutiger Code")) return vocStateRLKatId; |
346 |
if(redListVocabulary.equalsIgnoreCase("Sonderfälle")) return vocStateRLSpecialCases; |
|
334 | 347 |
else{ |
335 |
throw new UnknownCdmTypeException("Unknown feature, could not match: " + redListVocabulary); |
|
348 |
throw new UnknownCdmTypeException("Unknown Vocabulary feature, could not match: " + redListVocabulary);
|
|
336 | 349 |
} |
337 | 350 |
|
338 | 351 |
} |
... | ... | |
352 | 365 |
if(redListFeature.equalsIgnoreCase("Eindeutiger Code")) return featureRLKatId; |
353 | 366 |
if(redListFeature.equalsIgnoreCase("Kommentar zur Taxonomie")) return featureRLTaxComment; |
354 | 367 |
if(redListFeature.equalsIgnoreCase("Kommentar zur Gefährdung")) return featureRLHazardComment; |
368 |
if(redListFeature.equalsIgnoreCase("Sonderfälle")) return featureRLSpecialCases; |
|
369 |
if(redListFeature.equalsIgnoreCase("Letzter Nachweis")) return featureRLLastOccurrence; |
|
370 |
if(redListFeature.equalsIgnoreCase("Weitere Kommentare")) return featureRLAdditionalComment; |
|
371 |
|
|
355 | 372 |
else{ |
356 | 373 |
throw new UnknownCdmTypeException("Unknown feature, could not match: " + redListFeature); |
357 | 374 |
} |
... | ... | |
437 | 454 |
|
438 | 455 |
//RL Neo |
439 | 456 |
if(redListStateTerm.equalsIgnoreCase("N") && redListFeature.equalsIgnoreCase("Neobiota")) return stateTermRLKatNeo; |
457 |
|
|
458 |
//RL Special |
|
459 |
if(redListStateTerm.equalsIgnoreCase("S") && redListFeature.equalsIgnoreCase("Sonderfälle")) return stateTermRLSpecialS; |
|
460 |
if(redListStateTerm.equalsIgnoreCase("E") && redListFeature.equalsIgnoreCase("Sonderfälle")) return stateTermRLSpecialE; |
|
461 |
if(redListStateTerm.equalsIgnoreCase("D") && redListFeature.equalsIgnoreCase("Sonderfälle")) return stateTermRLSpecialD; |
|
462 |
|
|
440 | 463 |
|
441 | 464 |
|
442 | 465 |
//RL Empty |
Also available in: Unified diff
Adapted Redlist Import to new XML Schema...