Skip to content
Snippets Groups Projects
Commit 31491423 authored by Christopher Schankula's avatar Christopher Schankula :earth_africa:
Browse files

new TrawlExpert object api for getting a certain taxon node from a

scientific name
parent d56106a4
No related branches found
No related tags found
No related merge requests found
......@@ -170,7 +170,7 @@ public class BioTree implements Serializable {
*/
public static Integer processRecord(String scientificName) throws IOException, ParseException {
//reverse lookup based on name, try adding the found taxonId.
Integer taxonId = getTaxonRecord(scientificName);
Integer taxonId = nameToTaxonId(scientificName);
System.out.println(scientificName + ": " + taxonId);
if (taxonId == null) return null;
if (taxonId == -1) return null;
......@@ -237,6 +237,22 @@ public class BioTree implements Serializable {
return idNodes.get(taxonId);
}
/**
* Get the species at a given index (taxonId). This assumes that the
* node already exists or else it will return null. As such, it is best
* to use this function once all the data has been parsed and the BioTree
* has been built.
*
* @param i
* The speciesid (index) of the species.
* @return The Species object.
* @throws ParseException
* @throws IOException
*/
public static TaxonNode getTaxonRecord(String scientificName) throws IOException, ParseException {
return idNodes.get(nameToTaxonId(scientificName));
}
/**
* Get the TaxonNode containing information about the given scientific name.
* This assumes that thenode already exists locally or else it will return null.
......@@ -249,7 +265,7 @@ public class BioTree implements Serializable {
* @throws ParseException
* @throws IOException
*/
public static Integer getTaxonRecord(String scientificName) throws IOException, ParseException {
public static Integer nameToTaxonId(String scientificName) throws IOException, ParseException {
Integer taxonId;
//look up based on string literal, return if found
TaxonNode tx = strNodes.get(scientificName);
......
package model;
import java.io.IOException;
import org.json.simple.parser.ParseException;
import data.BioTree;
import data.DataStore;
import data.FileProcessor;
import data.Record;
import data.TaxonNode;
import search.BasicSearch;
import search.BasicSearchResult;
import sort.KDT;
......@@ -37,4 +40,18 @@ public class TrawlExpert {
public BasicSearchResult rangeSearch(Integer taxonId, Integer yearLo, Integer yearHi) {
return BasicSearch.range(taxonId, yearLo, yearHi);
}
public TaxonNode getTaxonRecord(Integer taxonId) {
return BioTree.getTaxonRecord(taxonId);
}
public TaxonNode getTaxonRecord(String scientificName) {
try {
return BioTree.getTaxonRecord(scientificName);
} catch (IOException | ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment