Revision c385a1b7
Added by Andreas Müller almost 6 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/germanSL/GermanSLTaxonImport.java | ||
---|---|---|
20 | 20 |
|
21 | 21 |
import eu.etaxonomy.cdm.common.CdmUtils; |
22 | 22 |
import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException; |
23 |
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImport; |
|
24 | 23 |
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState; |
25 | 24 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
26 | 25 |
import eu.etaxonomy.cdm.model.common.DefinedTerm; |
... | ... | |
46 | 45 |
* |
47 | 46 |
*/ |
48 | 47 |
@Component |
49 |
public class GermanSLTaxonImport<CONFIG extends GermanSLImportConfigurator>
|
|
50 |
extends SimpleExcelTaxonImport<CONFIG> {
|
|
48 |
public class GermanSLTaxonImport |
|
49 |
extends GermanSLImporBase {
|
|
51 | 50 |
|
52 | 51 |
private static final long serialVersionUID = 236093186271666895L; |
53 | 52 |
|
... | ... | |
99 | 98 |
|
100 | 99 |
|
101 | 100 |
@Override |
102 |
protected void firstPass(SimpleExcelTaxonImportState<CONFIG> state) {
|
|
101 |
protected void firstPass(SimpleExcelTaxonImportState<GermanSLImportConfigurator> state) {
|
|
103 | 102 |
String line = state.getCurrentLine() + ": "; |
104 | 103 |
HashMap<String, String> record = state.getOriginalRecord(); |
105 | 104 |
|
... | ... | |
119 | 118 |
//status |
120 | 119 |
String statusStr = getValue(record, SYNONYM); |
121 | 120 |
TaxonBase<?> taxonBase; |
122 |
if (isAccepted(statusStr)){ |
|
121 |
if (isAccepted(statusStr, nameResult)){
|
|
123 | 122 |
taxonBase = Taxon.NewInstance(taxonName, sec); |
124 |
if (nameResult.proParte){ |
|
125 |
logger.warn(line + "accepted taxon can not be pro parte");
|
|
126 |
} |
|
123 |
// if (nameResult.proParte){
|
|
124 |
// logger.warn(line + "accepted taxon can not be pro parte in GermanSL");
|
|
125 |
// }
|
|
127 | 126 |
}else{ |
128 | 127 |
Synonym syn = Synonym.NewInstance(taxonName, sec); |
129 |
if (nameResult.proParte){ |
|
130 |
syn.setProParte(true); |
|
131 |
} |
|
128 |
// if (nameResult.proParte){
|
|
129 |
// syn.setProParte(true);
|
|
130 |
// }
|
|
132 | 131 |
taxonBase = syn; |
133 | 132 |
} |
134 | 133 |
if (!isBlank(nameResult.sensu)){ |
... | ... | |
217 | 216 |
* @param secRefStr |
218 | 217 |
* @return |
219 | 218 |
*/ |
220 |
private Reference getSecRef(SimpleExcelTaxonImportState<CONFIG> state, String secRefStr, String line) {
|
|
219 |
private Reference getSecRef(SimpleExcelTaxonImportState<GermanSLImportConfigurator> state, String secRefStr, String line) {
|
|
221 | 220 |
Reference result = state.getReference(secRefStr); |
222 | 221 |
if (result == null && secRefStr != null){ |
223 | 222 |
result = ReferenceFactory.newGeneric(); |
... | ... | |
261 | 260 |
} |
262 | 261 |
|
263 | 262 |
|
264 |
private class NameResult{ |
|
265 |
IBotanicalName name; |
|
266 |
boolean proParte = false; |
|
267 |
String sensu = null; |
|
268 |
String auct = null; |
|
269 |
} |
|
270 | 263 |
|
271 | 264 |
/** |
272 | 265 |
* @param record |
273 | 266 |
* @param state |
274 | 267 |
* @return |
275 | 268 |
*/ |
276 |
private NameResult makeName(String line, HashMap<String, String> record, SimpleExcelTaxonImportState<CONFIG> state) {
|
|
269 |
public NameResult makeName(String line, HashMap<String, String> record, SimpleExcelTaxonImportState<GermanSLImportConfigurator> state) {
|
|
277 | 270 |
|
278 | 271 |
String specieNrStr = getValue(record, SPECIES_NR); |
279 | 272 |
String nameStr = getValue(record, ABBREVIAT); |
... | ... | |
335 | 328 |
* @param rankStr |
336 | 329 |
* @return |
337 | 330 |
*/ |
338 |
private Rank makeRank(String line, SimpleExcelTaxonImportState<CONFIG> state, String rankStr) {
|
|
331 |
private Rank makeRank(String line, SimpleExcelTaxonImportState<GermanSLImportConfigurator> state, String rankStr) {
|
|
339 | 332 |
Rank rank = null; |
340 | 333 |
try { |
341 | 334 |
rank = state.getTransformer().getRankByKey(rankStr); |
... | ... | |
386 | 379 |
* @param fullName |
387 | 380 |
* @return |
388 | 381 |
*/ |
389 |
private IBotanicalName getExistingName(SimpleExcelTaxonImportState<CONFIG> state, IBotanicalName fullName) {
|
|
382 |
private IBotanicalName getExistingName(SimpleExcelTaxonImportState<GermanSLImportConfigurator> state, IBotanicalName fullName) {
|
|
390 | 383 |
initExistinNames(state); |
391 | 384 |
return (IBotanicalName)state.getName(fullName.getTitleCache()); |
392 | 385 |
} |
... | ... | |
395 | 388 |
* @param state |
396 | 389 |
*/ |
397 | 390 |
@SuppressWarnings("rawtypes") |
398 |
private void initExistinNames(SimpleExcelTaxonImportState<CONFIG> state) {
|
|
391 |
private void initExistinNames(SimpleExcelTaxonImportState<GermanSLImportConfigurator> state) {
|
|
399 | 392 |
if (!nameMapIsInitialized){ |
400 | 393 |
List<String> propertyPaths = Arrays.asList(""); |
401 | 394 |
List<TaxonName> existingNames = this.getNameService().list(null, null, null, null, propertyPaths); |
... | ... | |
429 | 422 |
} |
430 | 423 |
|
431 | 424 |
|
432 |
|
|
433 |
private boolean isAccepted(String statusStr){ |
|
434 |
if ("FALSE()".equals(statusStr) || "0".equals(statusStr) || "false".equalsIgnoreCase(statusStr)){ |
|
435 |
return true; |
|
436 |
} else if ("TRUE()".equals(statusStr) || "1".equals(statusStr)|| "true".equalsIgnoreCase(statusStr)){ |
|
437 |
return false; |
|
438 |
}else{ |
|
439 |
logger.warn("Unhandled taxon status: " + statusStr); |
|
440 |
return false; |
|
441 |
} |
|
442 |
} |
|
443 |
|
|
444 |
|
|
445 | 425 |
/** |
446 | 426 |
* @param next |
447 | 427 |
* @return |
... | ... | |
457 | 437 |
|
458 | 438 |
|
459 | 439 |
@Override |
460 |
protected boolean isIgnore(SimpleExcelTaxonImportState<CONFIG> state) {
|
|
440 |
protected boolean isIgnore(SimpleExcelTaxonImportState<GermanSLImportConfigurator> state) {
|
|
461 | 441 |
return ! state.getConfig().isDoTaxa(); |
462 | 442 |
} |
463 | 443 |
} |
Also available in: Unified diff
latest changes to BgbmInstancesUpdater, E+M Import, GermanSL Import, etct