@Override @Nonnull public Taxonomy build() { final QName qName = new QName(id.stringValue()); final InternalElmoTaxonomy taxonomy = taxonomyFactory.create(qName); taxonomy.setBindings((Repository)repository); taxonomy.init(this); // taxonomy.getLookup().lookup(DcResource.class).setDcDescription("THE DESCRIPTION"); Taxonomy taxonomy2 = taxonomy; for (final Initializer<Taxonomy> initializer : getInitializers()) { taxonomy2 = initializer.initialize(taxonomy2); } return taxonomy2; } };
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override public Taxonomy findTaxonomyByName (final @Nonnull String name, final @Nonnull Object repository) throws NotFoundException { log.debug("findTaxonomyByName({}, {})", name, repository); // FIXME: handle the repository! final ElmoQuery query = em.createQuery(QUERY_TAXONOMY_BY_NAME).setParameter("name", name); final Entity entity = (Entity)query.getSingleResult(); final InternalElmoTaxonomy taxonomy = taxonomyFactory.find(entity.getQName()); // final ElmoTaxonomy taxonomy = (ElmoTaxonomy)query.getSingleResult(); taxonomy.setBindings((Repository)repository); return Wrapper.wrap(taxonomy); }
@Override @Nonnull public Finder<Taxon> findSynonyms() { try // FIXME: workaround because the @rdf annotation of this.synonym doesn't work { final SesameManager em = (SesameManager)ElmoManagerThreadLocal.get(); final ResourceManager<Resource> rm = em.getResourceManager(); final RepositoryResult<Statement> triples = em.getConnection().getStatements(null, new URIImpl(ElmoTaxonomyVocabulary.URI_SCIENTIFIC_NAME_ID), rm.createResource(getLookup().lookup(Entity.class).getQName())); final List<Taxon> synonyms = new ArrayList<Taxon>(); while (triples.hasNext()) { final URI uri = (URI)triples.next().getSubject(); synonyms.add(((InternalElmoTaxonomy)taxonomy)._findConcept(uri.stringValue())); } return new ElmoFinder<Taxon>(synonyms); } catch (NotFoundException e) { throw new RuntimeException(e); } catch (RepositoryException e) { throw new RuntimeException(e); } }