Commit 11265e63 authored by Matija Obreza's avatar Matija Obreza
Browse files

Fixed wrong SUBTAUTHOR logic

parent 48701b7b
......@@ -18,23 +18,28 @@ package org.genesys2.gringlobal.taxonomy.model;
import java.io.Serializable;
import java.util.Date;
import org.apache.commons.lang3.StringUtils;
import com.opencsv.bean.CsvBind;
// TODO: Auto-generated Javadoc
/**
* "TAXONOMY_SPECIES_ID", "CURRENT_TAXONOMY_SPECIES_ID", "NOMEN_NUMBER", "IS_SPECIFIC_HYBRID", "SPECIES_NAME",
* "SPECIES_AUTHORITY", "IS_SUBSPECIFIC_HYBRID", "SUBSPECIES_NAME", "SUBSPECIES_AUTHORITY", "IS_VARIETAL_HYBRID",
* "VARIETY_NAME", "VARIETY_AUTHORITY", "IS_SUBVARIETAL_HYBRID", "SUBVARIETY_NAME", "SUBVARIETY_AUTHORITY",
* "IS_FORMA_HYBRID", "FORMA_RANK_TYPE", "FORMA_NAME", "FORMA_AUTHORITY", "TAXONOMY_GENUS_ID", "PRIORITY1_SITE_ID",
* "PRIORITY2_SITE_ID", "CURATOR1_COOPERATOR_ID", "CURATOR2_COOPERATOR_ID", "RESTRICTION_CODE", "LIFE_FORM_CODE",
* "COMMON_FERTILIZATION_CODE", "IS_NAME_PENDING", "SYNONYM_CODE", "VERIFIER_COOPERATOR_ID", "NAME_VERIFIED_DATE",
* "NAME", "NAME_AUTHORITY", "PROTOLOGUE", "NOTE", "SITE_NOTE", "ALTERNATE_NAME", "CREATED_DATE", "CREATED_BY",
* "MODIFIED_DATE", "MODIFIED_BY", "OWNED_DATE", "OWNED_BY"
* "TAXONOMY_SPECIES_ID", "CURRENT_TAXONOMY_SPECIES_ID", "NOMEN_NUMBER", "IS_SPECIFIC_HYBRID", "SPECIES_NAME", "SPECIES_AUTHORITY", "IS_SUBSPECIFIC_HYBRID", "SUBSPECIES_NAME",
* "SUBSPECIES_AUTHORITY", "IS_VARIETAL_HYBRID", "VARIETY_NAME", "VARIETY_AUTHORITY", "IS_SUBVARIETAL_HYBRID", "SUBVARIETY_NAME", "SUBVARIETY_AUTHORITY", "IS_FORMA_HYBRID",
* "FORMA_RANK_TYPE", "FORMA_NAME", "FORMA_AUTHORITY", "TAXONOMY_GENUS_ID", "PRIORITY1_SITE_ID", "PRIORITY2_SITE_ID", "CURATOR1_COOPERATOR_ID", "CURATOR2_COOPERATOR_ID",
* "RESTRICTION_CODE", "LIFE_FORM_CODE", "COMMON_FERTILIZATION_CODE", "IS_NAME_PENDING", "SYNONYM_CODE", "VERIFIER_COOPERATOR_ID", "NAME_VERIFIED_DATE", "NAME", "NAME_AUTHORITY",
* "PROTOLOGUE", "NOTE", "SITE_NOTE", "ALTERNATE_NAME", "CREATED_DATE", "CREATED_BY", "MODIFIED_DATE", "MODIFIED_BY", "OWNED_DATE", "OWNED_BY"
*
* TODO Upgrade to opencsv 3.8 with @CsvDate annotation when available
*/
public class SpeciesRow implements Serializable {
private static final String PREFIX_SUBSPECIES = "subsp. ";
private static final String PREFIX_VARIETY = "var. ";
private static final String PREFIX_SUBVARIETY = "subvar. ";
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 5963864285661022518L;
......@@ -1015,23 +1020,22 @@ public class SpeciesRow implements Serializable {
}
/**
* Generates and returns the subspecies, variety information as the MCPD SUBTAXA. This should be like taking the
* {@link #name} field and removing Genus and species.
* Generates and returns the subspecies, variety information as the MCPD SUBTAXA. This should be like taking the {@link #name} field and removing Genus and species.
*
* @return the subtaxa
*/
public String toSubtaxa() {
if (formaName != null) {
return formaName;
return StringUtils.defaultIfBlank(formaRankType, "") + formaName;
}
if (subvarietyName != null) {
return "subvar. " + subvarietyName;
return PREFIX_SUBVARIETY + subvarietyName;
}
if (varietyName != null) {
return "var. " + varietyName;
return PREFIX_VARIETY + varietyName;
}
if (subspeciesName != null) {
return "subsp. " + subspeciesName;
return PREFIX_SUBSPECIES + subspeciesName;
}
return null;
// StringBuilder sb = new StringBuilder();
......@@ -1057,12 +1061,24 @@ public class SpeciesRow implements Serializable {
}
/**
* Get MCPD SUBTAUTHOR, a synonym for {@link #getNameAuthority()}.
* Get MCPD SUBTAUTHOR: subtaxon authority at the most detailed taxonomic level.
*
* @return {@link #getNameAuthority()}
* @return subtaxon authority at the most detailed taxonomic level.
*/
public String getSubtaxaAuthority() {
return getNameAuthority();
if (formaName != null) {
return formaAuthority;
}
if (subvarietyName != null) {
return subvarietyAuthority;
}
if (varietyName != null) {
return varietyAuthority;
}
if (subspeciesName != null) {
return subspeciesAuthority;
}
return null;
}
@Override
......
......@@ -42,12 +42,11 @@ import org.junit.Test;
public class SpeciesTest {
/** The Constant TAXONOMY_SPECIES_HEADERS. */
private static final String[] TAXONOMY_SPECIES_HEADERS = { "TAXONOMY_SPECIES_ID", "CURRENT_TAXONOMY_SPECIES_ID", "NOMEN_NUMBER", "IS_SPECIFIC_HYBRID", "SPECIES_NAME",
"SPECIES_AUTHORITY", "IS_SUBSPECIFIC_HYBRID", "SUBSPECIES_NAME", "SUBSPECIES_AUTHORITY", "IS_VARIETAL_HYBRID", "VARIETY_NAME", "VARIETY_AUTHORITY",
"IS_SUBVARIETAL_HYBRID", "SUBVARIETY_NAME", "SUBVARIETY_AUTHORITY", "IS_FORMA_HYBRID", "FORMA_RANK_TYPE", "FORMA_NAME", "FORMA_AUTHORITY", "TAXONOMY_GENUS_ID",
"PRIORITY1_SITE_ID", "PRIORITY2_SITE_ID", "CURATOR1_COOPERATOR_ID", "CURATOR2_COOPERATOR_ID", "RESTRICTION_CODE", "LIFE_FORM_CODE", "COMMON_FERTILIZATION_CODE",
"IS_NAME_PENDING", "SYNONYM_CODE", "VERIFIER_COOPERATOR_ID", "NAME_VERIFIED_DATE", "NAME", "NAME_AUTHORITY", "PROTOLOGUE", "NOTE", "SITE_NOTE", "ALTERNATE_NAME",
"CREATED_DATE", "CREATED_BY", "MODIFIED_DATE", "MODIFIED_BY", "OWNED_DATE", "OWNED_BY" };
private static final String[] TAXONOMY_SPECIES_HEADERS = { "TAXONOMY_SPECIES_ID", "CURRENT_TAXONOMY_SPECIES_ID", "NOMEN_NUMBER", "IS_SPECIFIC_HYBRID", "SPECIES_NAME", "SPECIES_AUTHORITY",
"IS_SUBSPECIFIC_HYBRID", "SUBSPECIES_NAME", "SUBSPECIES_AUTHORITY", "IS_VARIETAL_HYBRID", "VARIETY_NAME", "VARIETY_AUTHORITY", "IS_SUBVARIETAL_HYBRID", "SUBVARIETY_NAME",
"SUBVARIETY_AUTHORITY", "IS_FORMA_HYBRID", "FORMA_RANK_TYPE", "FORMA_NAME", "FORMA_AUTHORITY", "TAXONOMY_GENUS_ID", "PRIORITY1_SITE_ID", "PRIORITY2_SITE_ID", "CURATOR1_COOPERATOR_ID",
"CURATOR2_COOPERATOR_ID", "RESTRICTION_CODE", "LIFE_FORM_CODE", "COMMON_FERTILIZATION_CODE", "IS_NAME_PENDING", "SYNONYM_CODE", "VERIFIER_COOPERATOR_ID", "NAME_VERIFIED_DATE", "NAME",
"NAME_AUTHORITY", "PROTOLOGUE", "NOTE", "SITE_NOTE", "ALTERNATE_NAME", "CREATED_DATE", "CREATED_BY", "MODIFIED_DATE", "MODIFIED_BY", "OWNED_DATE", "OWNED_BY" };
/** The Constant TAXONOMY_SPECIES_CSV. */
private static final String TAXONOMY_SPECIES_CSV = "TAXONOMY_SPECIES.txt";
......@@ -145,7 +144,7 @@ public class SpeciesTest {
assertThat(speciesRow, not(nullValue()));
assertThat(speciesRow.getSpeciesId(), not(nullValue()));
assertThat(speciesRow.getGenusId(), not(nullValue()));
assertThat("SUBTAXA messed up", speciesRow.getName(), endsWith(StringUtils.defaultIfBlank(speciesRow.getSubtaxa(), "")));
assertThat("SUBTAXA messed up for speciesId=" + speciesRow.getSpeciesId(), speciesRow.getName(), endsWith(StringUtils.defaultIfBlank(speciesRow.getSubtaxa(), "")));
// System.err.println(speciesRow.getName() + " << " + speciesRow.toSubtaxa());
if (2310l == speciesRow.getSpeciesId()) {
......@@ -156,6 +155,10 @@ public class SpeciesTest {
assertThat("proctoriana is a specific hybrid!", speciesRow.getSpecificHybrid(), equalTo(true));
}
if (316933l == speciesRow.getSpeciesId()) {
assertThat("Abies shastensis has no SUBTAUTHOR", speciesRow.getSubtaxaAuthority(), nullValue());
}
// if (speciesRow.getSpecificHybrid() || speciesRow.getFormaHybrid() || speciesRow.getSubspecificHybrid() || speciesRow.getSubvarietalHybrid()) {
// System.err.println(speciesRow);
// }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment