private static final String INCERTAE_SEDIS = "Incertae sedis";
private static UUID rootUuid = UUID.fromString("61187f71-96d1-419d-958b-25ab4c01a93c");
-
+
private static List<String> expectedKeys= Arrays.asList(new String[]{
"SORT","GENUS_X","PHYLUM","SUBPHYLUM","CLASS","SUBCLASS","ORDER","SUBORDER","FAMILY",
"FAM_SYNONYMS","SUBFAMILY","GENUS","SYNONYMS","SPECIES","REFERENCES","MOLECULAR","NOTES"
private Reference sourceReference;
private Reference secReference;
-
+
private NonViralNameParserImpl parser = NonViralNameParserImpl.NewInstance();
// @Override
Taxon genusTaxon = Taxon.NewInstance(genusName, sec);
genusName.addSource(makeOriginalSource(state));
genusTaxon.addSource(makeOriginalSource(state));
-
+
makeSynonyms(state, line, record, genusTaxon, "SYNONYMS");
-
+
//TODO reference => for now we don't use it
-
+
makeNotes(genusTaxon, record, line);
TaxonNode genusNode = parentNode.addChildTaxon(genusTaxon, null, null);
getTaxonNodeService().saveOrUpdate(genusNode);
-
+
return genusTaxon;
}
nameStr = nameStr.replace(", non Tayloriella Kylin (Rhodophyta)".trim(), "");
}
if (nameStr.endsWith("[nom. illeg.]")) {
- result[1] = "nom. illeg.";
+ result[1] = "nom. illeg.";
result[0] = nameStr.replace("[nom. illeg.]".trim(), "");
}else if (nameStr.endsWith("[nom. inval.]")) {
- result[1] = "nom. inval.";
+ result[1] = "nom. inval.";
result[0] = nameStr.replace("[nom. inval.]".trim(), "");
}else if (nameStr.endsWith("[nom. cons. prop.]")) {
- result[1] = "nom. cons. prop.";
+ result[1] = "nom. cons. prop.";
result[0] = nameStr.replace("[nom. cons. prop.]".trim(), "");
}else{
result[0] = nameStr;
String notesStr = getValue(record, "NOTES");
if (isNotBlank(notesStr)) {
if (notesStr.startsWith("Notes.")) {
- notesStr = notesStr.substring(6);
+ notesStr = notesStr.substring(6).trim();
}
//TODO or handle as fact of type "Notes"
genusTaxon.addAnnotation(Annotation.NewInstance(notesStr, AnnotationType.EDITORIAL(), Language.ENGLISH()));
private void checkParsed(TaxonName name, String nameStr, String line) {
if (name.isProtectedTitleCache() || name.isProtectedFullTitleCache() || name.isProtectedNameCache()) {
logger.warn(line + "Name could not be parsed: " + nameStr);
- }
+ }
}
- private void makeSynonyms(SimpleExcelTaxonImportState<CONFIG> state,
+ private void makeSynonyms(SimpleExcelTaxonImportState<CONFIG> state,
String line, Map<String, String> record, Taxon accepted, String fieldName) {
-
+
String synonymsStr = getValue(record, fieldName);
if (isBlank(synonymsStr)) {
return;
for (String singleSynonymStr: splits) {
String[] split2 = parseNomStatus(singleSynonymStr);
singleSynonymStr = split2[0];
-
+
TaxonName synonymName = (TaxonName)parser.parseFullName(singleSynonymStr, state.getConfig().getNomenclaturalCode(), null);
checkParsed(TaxonName.castAndDeproxy(synonymName), singleSynonymStr, line);
makeStatusAndHomonym(state, synonymName, split2);
Synonym synonym = Synonym.NewInstance(synonymName, accepted.getSec());
accepted.addSynonym(synonym, SynonymType.SYNONYM_OF());
synonymName.addSource(makeOriginalSource(state));
- synonym.addSource(makeOriginalSource(state));
+ synonym.addSource(makeOriginalSource(state));
}
}
}
private String lastSubOrder = "";
private String lastFamily = "";
private String lastSubFamily = "";
-
+
private Taxon taxonPhylum = null;
private Taxon taxonSubphylum = null;
private Taxon taxonClass = null;
private Taxon taxonSubOrder = null;
private Taxon taxonFamily = null;
private Taxon taxonSubFamily = null;
-
+
private TaxonNode getParentNode(Map<String, String> record, SimpleExcelTaxonImportState<CONFIG> state, String line) {
Taxon higherTaxon = null;
String suborder = Nz(getValue(record, "SUBORDER"));
String family = Nz(getValue(record, "FAMILY"));
String subfamily = Nz(getValue(record, "SUBFAMILY"));
-
+
if (isNewTaxon(subfamily, lastSubFamily)){
if (isNewTaxon(family, lastFamily)){
if (isNewTaxon(suborder, lastSubOrder)){
taxonSubphylum = makeHigherTaxon(state, subphylum, Rank.SUBPHYLUM());
if (taxonSubphylum != null){ //no null expected
classification.addParentChild(higherTaxon,taxonSubphylum, null, null);
- }
+ }
higherTaxon = isIncertisSedis(subphylum) ? higherTaxon : taxonSubphylum;
lastSubphylum = subphylum;
}else{
}else {
higherTaxon = taxonSubFamily;
}
-
+
getTaxonService().saveOrUpdate(higherTaxon);
return higherTaxon.getTaxonNode(classification);
result |= lastUninomial.equalsIgnoreCase(INCERTAE_SEDIS);
return result;
}
-
+
private Taxon makeHigherTaxon(SimpleExcelTaxonImportState<CONFIG> state, String nameStr, Rank rank) {
if (isBlank(nameStr) || nameStr.equalsIgnoreCase(INCERTAE_SEDIS)){
return null;
}
//name
- INonViralName name = parser.parseFullName(nameStr, NomenclaturalCode.Fungi, rank);
+ INonViralName name = parser.parseFullName(nameStr, NomenclaturalCode.Fungi, rank);
replaceNameAuthorsAndReferences(state, name);
//taxon
Reference secRef = getSecReference(state);
taxon.addSource(makeOriginalSource(state));
return taxon;
}
-
+
private TaxonNode rootNode;
-
+
private TaxonNode getClassification(SimpleExcelTaxonImportState<CONFIG> state) {
if (rootNode == null){
Reference sec = getSecReference(state);
private void replaceNameAuthorsAndReferences(SimpleExcelTaxonImportState<CONFIG> state, INonViralName name) {
dedupHelper().replaceAuthorNamesAndNomRef(state, name);
}
-
+
private ImportDeduplicationHelper<SimpleExcelTaxonImportState<CONFIG>> dedupHelper;
private ImportDeduplicationHelper<SimpleExcelTaxonImportState<CONFIG>> dedupHelper() {
if (dedupHelper == null) {
}
return dedupHelper;
}
-
+
+ @Override
protected IdentifiableSource makeOriginalSource(SimpleExcelTaxonImportState<CONFIG> state) {
String noStr = getValue(state.getOriginalRecord(), "SORT");
return IdentifiableSource.NewDataImportInstance(noStr, "SORT", state.getConfig().getSourceReference());
}
-
+
}