/******************************************************************************************************************* * * ******************************************************************************************************************/ @Override public void readExternal (final @Nonnull ObjectInput oi) throws IOException, ClassNotFoundException { final Id id = (Id)oi.readObject(); try { final Taxonomy taxonomy = Locator.find(TaxonomyPreferences.class).getTaxonomy(); taxon = taxonomy.findTaxa().withId(id).result(); } catch (NotFoundException e) { throw new IOException(e.toString()); // Java 5 / Android compatibility } }
/******************************************************************************************************************* * * Retrieves the {@link Taxon} parameter from an {@link Intent}. * * @return the {@code Taxon} * @throws NotFoundException if no {@code Taxon} has been passed as a parameter * ******************************************************************************************************************/ @Nonnull public static Taxon getTaxon (final @Nonnull Intent intent) throws NotFoundException { NotFoundException.throwWhenNull(intent, "No Intent"); final String id = NotFoundException.throwWhenNull(intent.getExtras(), "No extras").getString(TAXON_ID); NotFoundException.throwWhenNull(id, "No taxonId"); return Locator.find(TaxonomyPreferences.class).getTaxonomy().findTaxa().withId(new Id(id)).result(); }
/******************************************************************************************************************* * * ******************************************************************************************************************/ @Nonnull public List<Taxon> getRecentTaxa() { logger.info("getRecentTaxa()"); final List<Taxon> taxa = new ArrayList<Taxon>(); final Taxonomy taxonomy = Locator.find(TaxonomyPreferences.class).getTaxonomy(); for (final Id taxonId : taxonIdHistory) { try { taxa.add(taxonomy.findTaxa().withId(taxonId).result()); } catch (NotFoundException e) { logger.warning("Can't retrieve taxon for id: %s", taxonId); } } return taxa; }