Revision 4fe9a46d
Added by Patrick Plitzner about 8 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportAuthor.java | ||
---|---|---|
63 | 63 |
|
64 | 64 |
@Override |
65 | 65 |
protected void doInvoke(RedListGefaesspflanzenImportState state) { |
66 |
makeAuthors(state, "AUTOR_KOMB");
|
|
67 |
makeAuthors(state, "AUTOR_BASI");
|
|
66 |
makeAuthors(state, RedListUtil.AUTOR_KOMB);
|
|
67 |
makeAuthors(state, RedListUtil.AUTOR_BASI);
|
|
68 | 68 |
} |
69 | 69 |
|
70 | 70 |
|
... | ... | |
100 | 100 |
} |
101 | 101 |
TeamOrPersonBase teamOrPerson; |
102 | 102 |
//check if there are ex authors |
103 |
if(authorName.contains(" ex ")){
|
|
104 |
String[] split = authorName.split(" ex ");
|
|
103 |
if(authorName.contains(RedListUtil.EX)){
|
|
104 |
String[] split = authorName.split(RedListUtil.EX);
|
|
105 | 105 |
for (int i = 0; i < split.length; i++) { |
106 | 106 |
makePerson(state, split[i].trim()); |
107 | 107 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportClassification.java | ||
---|---|---|
93 | 93 |
|
94 | 94 |
private void makeSingleTaxonNode(RedListGefaesspflanzenImportState state, ResultSet rs, Classification classification) |
95 | 95 |
throws SQLException { |
96 |
String id = String.valueOf(rs.getLong("NAMNR"));
|
|
97 |
String parentId = String.valueOf(rs.getLong("LOWER"));
|
|
98 |
String gueltString = rs.getString("GUELT");
|
|
96 |
String id = String.valueOf(rs.getLong(RedListUtil.NAMNR));
|
|
97 |
String parentId = String.valueOf(rs.getLong(RedListUtil.LOWER));
|
|
98 |
String gueltString = rs.getString(RedListUtil.GUELT);
|
|
99 | 99 |
|
100 | 100 |
TaxonBase taxonBase = state.getRelatedObject(RedListUtil.TAXON_NAMESPACE, id, TaxonBase.class); |
101 | 101 |
Taxon parent = (Taxon) state.getRelatedObject(RedListUtil.TAXON_NAMESPACE, parentId, TaxonBase.class); |
... | ... | |
113 | 113 |
} |
114 | 114 |
else if(taxonBase.isInstanceOf(Synonym.class)){ |
115 | 115 |
//basionym |
116 |
if(gueltString.equals("b")){
|
|
116 |
if(gueltString.equals(RedListUtil.GUELT_BASIONYM)){
|
|
117 | 117 |
parent.addHomotypicSynonym((Synonym) taxonBase, null, null); |
118 | 118 |
parent.getName().addBasionym(taxonBase.getName()); |
119 | 119 |
} |
... | ... | |
134 | 134 |
Set<String> idSet = new HashSet<String>(); |
135 | 135 |
try { |
136 | 136 |
while (rs.next()){ |
137 |
idSet.add(String.valueOf(rs.getLong("NAMNR")));
|
|
138 |
idSet.add(String.valueOf(rs.getLong("LOWER")));
|
|
137 |
idSet.add(String.valueOf(rs.getLong(RedListUtil.NAMNR)));
|
|
138 |
idSet.add(String.valueOf(rs.getLong(RedListUtil.LOWER)));
|
|
139 | 139 |
} |
140 | 140 |
} catch (SQLException e) { |
141 | 141 |
e.printStackTrace(); |
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportNames.java | ||
---|---|---|
46 | 46 |
@SuppressWarnings("serial") |
47 | 47 |
public class RedListGefaesspflanzenImportNames extends DbImportBase<RedListGefaesspflanzenImportState, RedListGefaesspflanzenImportConfigurator> { |
48 | 48 |
|
49 |
private static final String EX = " ex "; |
|
50 |
|
|
51 | 49 |
private static final Logger logger = Logger.getLogger(RedListGefaesspflanzenImportNames.class); |
52 | 50 |
|
53 | 51 |
private static final String tableName = "Rote Liste Gefäßpflanzen"; |
... | ... | |
101 | 99 |
|
102 | 100 |
private void makeSingleNameAndTaxon(RedListGefaesspflanzenImportState state, ResultSet rs, Set<TaxonNameBase> namesToSave, Set<TaxonBase> taxaToSave) |
103 | 101 |
throws SQLException { |
104 |
long id = rs.getLong("NAMNR");
|
|
105 |
String taxNameString = rs.getString("TAXNAME");
|
|
106 |
String gueltString = rs.getString("GUELT");
|
|
107 |
String rangString = rs.getString("RANG");
|
|
108 |
String ep1String = rs.getString("EPI1");
|
|
109 |
String ep2String = rs.getString("EPI2");
|
|
110 |
String ep3String = rs.getString("EPI3");
|
|
111 |
String nomZusatzString = rs.getString("NOM_ZUSATZ");
|
|
112 |
String zusatzString = rs.getString("ZUSATZ");
|
|
113 |
String authorKombString = rs.getString("AUTOR_KOMB");
|
|
114 |
String authorBasiString = rs.getString("AUTOR_BASI");
|
|
102 |
long id = rs.getLong(RedListUtil.NAMNR);
|
|
103 |
String taxNameString = rs.getString(RedListUtil.TAXNAME);
|
|
104 |
String gueltString = rs.getString(RedListUtil.GUELT);
|
|
105 |
String rangString = rs.getString(RedListUtil.RANG);
|
|
106 |
String ep1String = rs.getString(RedListUtil.EPI1);
|
|
107 |
String ep2String = rs.getString(RedListUtil.EPI2);
|
|
108 |
String ep3String = rs.getString(RedListUtil.EPI3);
|
|
109 |
String nomZusatzString = rs.getString(RedListUtil.NOM_ZUSATZ);
|
|
110 |
String zusatzString = rs.getString(RedListUtil.ZUSATZ);
|
|
111 |
String authorKombString = rs.getString(RedListUtil.AUTOR_KOMB);
|
|
112 |
String authorBasiString = rs.getString(RedListUtil.AUTOR_BASI);
|
|
115 | 113 |
|
116 | 114 |
if(CdmUtils.isBlank(taxNameString) && CdmUtils.isBlank(ep1String)){ |
117 | 115 |
RedListUtil.logMessage(id, "No name found!", logger); |
... | ... | |
125 | 123 |
|
126 | 124 |
//ep1 should always be present |
127 | 125 |
if(CdmUtils.isBlank(ep1String)){ |
128 |
RedListUtil.logMessage(id, "EPI1 is empty!", logger);
|
|
126 |
RedListUtil.logMessage(id, RedListUtil.EPI1+" is empty!", logger);
|
|
129 | 127 |
} |
130 | 128 |
name.setGenusOrUninomial(ep1String); |
131 | 129 |
if(!CdmUtils.isBlank(ep2String)){ |
... | ... | |
140 | 138 |
|
141 | 139 |
//--- AUTHORS --- |
142 | 140 |
//combination author |
143 |
if(authorKombString.contains(EX)){ |
|
141 |
if(authorKombString.contains(RedListUtil.EX)){
|
|
144 | 142 |
//TODO: what happens with multiple ex authors?? |
145 |
String[] kombSplit = authorKombString.split(EX); |
|
143 |
String[] kombSplit = authorKombString.split(RedListUtil.EX);
|
|
146 | 144 |
if(kombSplit.length!=2){ |
147 | 145 |
RedListUtil.logMessage(id, "Multiple ex combination authors found", logger); |
148 | 146 |
} |
... | ... | |
159 | 157 |
} |
160 | 158 |
} |
161 | 159 |
else if(authorKombString.trim().equals(RedListUtil.AUCT)){ |
162 |
RedListUtil.logMessage(id, "AUCT information in AUTOR_KOMB column", logger);
|
|
160 |
RedListUtil.logMessage(id, "AUCT information in "+RedListUtil.AUTOR_KOMB+" column", logger);
|
|
163 | 161 |
} |
164 | 162 |
else if(!CdmUtils.isBlank(authorKombString)){ |
165 | 163 |
TeamOrPersonBase authorKomb = (TeamOrPersonBase) state.getRelatedObject(RedListUtil.AUTHOR_NAMESPACE, authorKombString); |
166 | 164 |
name.setCombinationAuthorship(authorKomb); |
167 | 165 |
} |
168 | 166 |
//basionym author |
169 |
if(authorBasiString.contains(EX)){ |
|
170 |
String[] basiSplit = authorBasiString.split(EX); |
|
167 |
if(authorBasiString.contains(RedListUtil.EX)){
|
|
168 |
String[] basiSplit = authorBasiString.split(RedListUtil.EX);
|
|
171 | 169 |
for (int i = 0; i < basiSplit.length; i++) { |
172 | 170 |
if(basiSplit.length!=2){ |
173 | 171 |
RedListUtil.logMessage(id, "Multiple ex basionymn authors found", logger); |
... | ... | |
207 | 205 |
} |
208 | 206 |
|
209 | 207 |
//check authorship consistency |
210 |
String authorString = rs.getString("AUTOR");
|
|
208 |
String authorString = rs.getString(RedListUtil.AUTOR);
|
|
211 | 209 |
String authorshipCache = name.getAuthorshipCache(); |
212 | 210 |
|
213 | 211 |
if(!CdmUtils.isBlank(zusatzString)){ |
... | ... | |
220 | 218 |
authorString = ""; |
221 | 219 |
} |
222 | 220 |
if(!authorString.equals(authorshipCache)){ |
223 |
RedListUtil.logMessage(id, "Authorship inconsistent! name.authorhshipCache <-> Column AUTOR: "+authorshipCache+" <-> "+authorString, logger);
|
|
221 |
RedListUtil.logMessage(id, "Authorship inconsistent! name.authorhshipCache <-> Column "+RedListUtil.AUTOR+": "+authorshipCache+" <-> "+authorString, logger);
|
|
224 | 222 |
} |
225 | 223 |
|
226 | 224 |
//id |
... | ... | |
231 | 229 |
|
232 | 230 |
//---TAXON--- |
233 | 231 |
TaxonBase taxonBase = null; |
234 |
if(gueltString.equals("1") || (name.getAppendedPhrase()!=null && name.getAppendedPhrase().equals(RedListUtil.AUCT))){
|
|
232 |
if(gueltString.equals(RedListUtil.GUELT_ACCEPTED_TAXON) || (name.getAppendedPhrase()!=null && name.getAppendedPhrase().equals(RedListUtil.AUCT))){
|
|
235 | 233 |
taxonBase = Taxon.NewInstance(name, null); |
236 | 234 |
} |
237 |
else if(gueltString.equals("x") || gueltString.equals("b")){
|
|
235 |
else if(gueltString.equals(RedListUtil.GUELT_SYNONYM) || gueltString.equals(RedListUtil.GUELT_BASIONYM)){
|
|
238 | 236 |
taxonBase = Synonym.NewInstance(name, null); |
239 | 237 |
} |
240 | 238 |
if(taxonBase==null){ |
... | ... | |
272 | 270 |
|
273 | 271 |
try { |
274 | 272 |
while (rs.next()){ |
275 |
String authorKombString = rs.getString("AUTOR_KOMB");
|
|
273 |
String authorKombString = rs.getString(RedListUtil.AUTOR_KOMB);
|
|
276 | 274 |
|
277 |
if(authorKombString.contains(EX)){ |
|
278 |
String[] kombSplit = authorKombString.split(EX); |
|
275 |
if(authorKombString.contains(RedListUtil.EX)){
|
|
276 |
String[] kombSplit = authorKombString.split(RedListUtil.EX);
|
|
279 | 277 |
for (int i = 0; i < kombSplit.length; i++) { |
280 | 278 |
if(!authorMap.containsKey(kombSplit[i])){ |
281 | 279 |
authorMap.put(kombSplit[i], getAgentService().load(state.getAuthorMap().get(kombSplit[i]))); |
... | ... | |
286 | 284 |
authorMap.put(authorKombString, getAgentService().load(state.getAuthorMap().get(authorKombString))); |
287 | 285 |
} |
288 | 286 |
|
289 |
String authorBasiString = rs.getString("AUTOR_BASI");
|
|
287 |
String authorBasiString = rs.getString(RedListUtil.AUTOR_BASI);
|
|
290 | 288 |
//basionym author |
291 |
if(authorBasiString.contains(EX)){ |
|
292 |
String[] basiSplit = authorBasiString.split(EX); |
|
289 |
if(authorBasiString.contains(RedListUtil.EX)){
|
|
290 |
String[] basiSplit = authorBasiString.split(RedListUtil.EX);
|
|
293 | 291 |
for (int i = 0; i < basiSplit.length; i++) { |
294 | 292 |
if(!authorMap.containsKey(basiSplit[i])){ |
295 | 293 |
authorMap.put(basiSplit[i], getAgentService().load(state.getAuthorMap().get(basiSplit[i]))); |
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListUtil.java | ||
---|---|---|
21 | 21 |
public static final String NAME_NAMESPACE = "name"; |
22 | 22 |
public static final String TAXON_NAMESPACE = "taxon"; |
23 | 23 |
public static final String AUTHOR_NAMESPACE = "author"; |
24 |
|
|
24 | 25 |
public static final String AUCT = "auct."; |
26 |
public static final String EX = " ex "; |
|
27 |
public static final String GUELT_BASIONYM = "b"; |
|
28 |
public static final String GUELT_SYNONYM = "x"; |
|
29 |
public static final String GUELT_ACCEPTED_TAXON = "1"; |
|
30 |
|
|
31 |
|
|
32 |
public static final String GUELT = "GUELT"; |
|
33 |
public static final String LOWER = "LOWER"; |
|
34 |
public static final String NAMNR = "NAMNR"; |
|
35 |
public static final String AUTOR_BASI = "AUTOR_BASI"; |
|
36 |
public static final String AUTOR_KOMB = "AUTOR_KOMB"; |
|
37 |
public static final String ZUSATZ = "ZUSATZ"; |
|
38 |
public static final String NOM_ZUSATZ = "NOM_ZUSATZ"; |
|
39 |
public static final String EPI3 = "EPI3"; |
|
40 |
public static final String EPI2 = "EPI2"; |
|
41 |
public static final String EPI1 = "EPI1"; |
|
42 |
public static final String RANG = "RANG"; |
|
43 |
public static final String TAXNAME = "TAXNAME"; |
|
44 |
public static final String AUTOR = "AUTOR"; |
|
25 | 45 |
|
26 | 46 |
public static void logMessage(long id, String message, Logger logger){ |
27 |
logger.error("NAMNR: "+id+" "+message);
|
|
47 |
logger.error(NAMNR+": "+id+" "+message);
|
|
28 | 48 |
} |
49 |
|
|
29 | 50 |
} |
Also available in: Unified diff
Refactor string constants