Commit 7ace7374 authored by Matija Obreza's avatar Matija Obreza
Browse files

Parse speciesRow#specificHybrid properly and use × when printing names of hybrids

parent 34f25ebc
......@@ -116,7 +116,7 @@ public class TaxonomyReader {
speciesRow.setSpeciesId(toLong(row[0]));
speciesRow.setCurrentSpeciesId(toLong(row[1]));
speciesRow.setNomenNumber(toLong(row[2]));
speciesRow.setSpecificHybrid(toBoolean(row[3]));
speciesRow.setSpecificHybrid("x".equals(row[3]));
speciesRow.setSpeciesName(row[4]);
speciesRow.setSpeciesAuthority(row[5]);
speciesRow.setSubspecificHybrid(toBoolean(row[6]));
......
......@@ -459,9 +459,9 @@ public class GenusRow implements Serializable {
public boolean isCurrent() {
return genusId.equals(currentGenusId);
}
@Override
public String toString() {
return getGenusName() + " " + getGenusAuthority() + " " + getSubGenusName() + " " + getSubSectionName() + " current=" + isCurrent();
return (hybrid ? "× " : "") + getGenusName() + " " + getGenusAuthority() + " " + getSubGenusName() + " " + getSubSectionName() + " current=" + isCurrent();
}
}
......@@ -1067,6 +1067,6 @@ public class SpeciesRow implements Serializable {
@Override
public String toString() {
return getSpeciesName() + " " + getSpeciesAuthority() + " " + getSubtaxa() + " " + getSubtaxaAuthority() + " current=" + isCurrent();
return (specificHybrid ? "× " : "") + getSpeciesName() + " " + getSpeciesAuthority() + " " + getSubtaxa() + " " + getSubtaxaAuthority() + " current=" + isCurrent();
}
}
......@@ -42,7 +42,7 @@ import org.junit.Test;
* Testing the TAXONOMY_GENUS.txt
*/
public class GenusTest {
/** The Constant TAXONOMY_GENUS_HEADERS. */
private static final String[] TAXONOMY_GENUS_HEADERS = { "TAXONOMY_GENUS_ID", "CURRENT_TAXONOMY_GENUS_ID", "TAXONOMY_FAMILY_ID", "QUALIFYING_CODE", "IS_HYBRID", "GENUS_NAME",
"GENUS_AUTHORITY", "SUBGENUS_NAME", "SECTION_NAME", "SUBSECTION_NAME", "SERIES_NAME", "SUBSERIES_NAME", "NOTE", "CREATED_DATE", "CREATED_BY", "MODIFIED_DATE",
......@@ -50,7 +50,7 @@ public class GenusTest {
/** The Constant TAXONOMY_GENUS_CSV. */
private static final String TAXONOMY_GENUS_CSV = "TAXONOMY_GENUS.txt";
/** The Constant RESOURCES_PATH. */
private static final String RESOURCES_PATH = "/taxonomy_data_samples/";
......@@ -68,7 +68,7 @@ public class GenusTest {
try {
File file = new File(resource.toURI());
assertThat("File should exist", file.exists(), equalTo(true));
return TaxonomyReader.openCsvReader(new InputStreamReader(new FileInputStream(file), "UTF-8"), startAt);
} catch (FileNotFoundException e) {
......@@ -106,7 +106,7 @@ public class GenusTest {
public void read1stTaxonomyRow() throws FileNotFoundException, IOException, ParseException {
try (CSVReader reader = open(TAXONOMY_GENUS_CSV, 1)) {
GenusRow genusRow = TaxonomyReader.toGenus(reader.readNext());
assertThat("1st data row does not match", genusRow, notNullValue());
assertThat(genusRow.getGenusId(), equalTo(2l));
......@@ -116,7 +116,7 @@ public class GenusTest {
assertThat(genusRow.getHybrid(), equalTo(true));
assertThat(genusRow.getGenusName(), equalTo("Laburnocytisus"));
assertThat(genusRow.getGenusAuthority(), equalTo("C. K. Schneid."));
assertThat(genusRow.getSubGenusName(), nullValue());
assertThat(genusRow.getSectionName(), nullValue());
assertThat(genusRow.getSubSectionName(), nullValue());
......@@ -166,18 +166,29 @@ public class GenusTest {
try (CSVReader reader = TaxonomyReader.openCsvReader(new InputStreamReader(new FileInputStream(file), "UTF-8"), 0)) {
String[] headerRow = reader.readNext();
// Dumb BOM at the start of a UTF8 file!
headerRow[0]=TAXONOMY_GENUS_HEADERS[0];
headerRow[0] = TAXONOMY_GENUS_HEADERS[0];
assertThat("Header row must have more than 1 element", Arrays.asList(headerRow), not(hasSize(1)));
assertThat("Header row does not match", Arrays.asList(headerRow), contains(TAXONOMY_GENUS_HEADERS));
GenusRow genusRow = null;
while ((genusRow = TaxonomyReader.toGenus(reader.readNext())) != null) {
// System.out.println(genusRow.getGenusName() + " " + genusRow.isCurrent());
// System.out.println(genusRow.getGenusName() + " " + genusRow.isCurrent());
assertThat(genusRow, not(nullValue()));
assertThat(genusRow.getGenusId(), not(nullValue()));
if (2l == genusRow.getGenusId()) {
assertThat("Laburnocytisus is a hybrid", genusRow.getHybrid(), equalTo(true));
}
if (4l == genusRow.getGenusId()) {
assertThat("Aa is not a hybrid", genusRow.getHybrid(), equalTo(false));
}
// if (genusRow.getHybrid()) {
// System.err.println(genusRow.getGenusId() + " " + genusRow);
// }
}
}
......
......@@ -147,6 +147,18 @@ public class SpeciesTest {
assertThat(speciesRow.getGenusId(), not(nullValue()));
assertThat("SUBTAXA messed up", speciesRow.getName(), endsWith(StringUtils.defaultIfBlank(speciesRow.getSubtaxa(), "")));
// System.err.println(speciesRow.getName() + " << " + speciesRow.toSubtaxa());
if (2310l == speciesRow.getSpeciesId()) {
assertThat("This is not a specific hybrid!", speciesRow.getSpecificHybrid(), equalTo(false));
}
if (23130l == speciesRow.getSpeciesId()) {
assertThat("proctoriana is a specific hybrid!", speciesRow.getSpecificHybrid(), equalTo(true));
}
// 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