} catch ( NumberFormatException e ) {
LOGGER.info("NumberFormatException, user supplied taxon variant id was probably null: "+tvId);
}
}
else {
Taxon taxon = null;
taxon = getTaxonHome().findByUBIOTaxId(manualId);
if ( taxon != null ) {
// 2a
Collection<TaxonVariant> variants = getTaxonHome().findVariantsByTaxon(taxon);
variant = variants.iterator().next();
}
else {
// 2b
TaxonLabelService taxonLabelService = getTaxonLabelService();
Integer ncbiId = taxonLabelService.findNcbiTaxIdByUBIOTaxId(manualId);
Taxon newTaxon = null;
TaxonVariant newVariant = null;
if ( null != ncbiId ) {
String ncbiPreferredName = taxonLabelService.getNCBIPreferredName(ncbiId.toString());
newTaxon = new Taxon(ncbiPreferredName,manualId,ncbiId);
newVariant = new TaxonVariant(manualId,taxonLabel.getTaxonLabel(),ncbiPreferredName,"canonical form");
}
else {
newTaxon = new Taxon();
newTaxon.setName(taxonLabel.getTaxonLabel());
newTaxon.setUBioNamebankId(manualId);
newVariant = new TaxonVariant(manualId,taxonLabel.getTaxonLabel(),taxonLabel.getTaxonLabel(),"canonical form");
}
newVariant.setTaxon(newTaxon);
getTaxonHome().store(newTaxon);
getTaxonHome().store(newVariant);