private static SesameManager getSesameManager() { return (SesameManager)ElmoManagerThreadLocal.get(); } }
private static SesameManager getSesameManager() { return (SesameManager)ElmoManagerThreadLocal.get(); } }
@Nonnull private static SesameManager getSesameManager() { return (SesameManager)ElmoManagerThreadLocal.get(); }
@Nonnull private ElmoManager getDelegate() { final ElmoManager em = ElmoManagerThreadLocal.get(); if (em == null) { throw new IllegalStateException("No ElmoManager bound to the current thread."); } return em; }
/******************************************************************************************************************* * * ******************************************************************************************************************/ @Nonnull protected static XMLGregorianCalendar toXMLGregorianCalendar (final @Nonnull Date date) { final Literal literal = ((SesameManager)(ElmoManagerThreadLocal.get())).getLiteralManager().getLiteral(date); assert literal != null : "null literal"; return literal.calendarValue(); }
/******************************************************************************************************************* * * ******************************************************************************************************************/ protected static void merge (final @Nonnull As object) // FIXME: move to an injected capability - Persistence? { Parameters.notNull("object", object); final Entity entity = Wrapper.unwrap(object.as(Entity.class)); ElmoManagerThreadLocal.get().merge(entity); }
/******************************************************************************************************************* * * ******************************************************************************************************************/ public void close() { ElmoManagerThreadLocal.get().close(); ElmoManagerThreadLocal.set(null); smf.close(); }
/******************************************************************************************************************* * * ******************************************************************************************************************/ protected void close() { ElmoManagerThreadLocal.get().close(); ElmoManagerThreadLocal.set(null); smf.close(); } }
final ElmoManager currentEm = ElmoManagerThreadLocal.get();
final ElmoManager em = ElmoManagerThreadLocal.get(); Object as = em.designateEntity(owner, cl);
private void addStatement (final @Nonnull String uri, final @Nonnull String string) { final SesameManager em = (SesameManager)ElmoManagerThreadLocal.get(); final ResourceManager<Resource> rm = em.getResourceManager(); try { em.getConnection().add(rm.createResource(getLookup().lookup(Entity.class).getQName()), new URIImpl(uri), em.getLiteralManager().getLiteral(string)); } catch (RepositoryException e) { throw new RuntimeException(e); } }
@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); } }
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override @Nonnull public Id getScientificNameId() throws NotFoundException { 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(rm.createResource(getLookup().lookup(Entity.class).getQName()), new URIImpl(ElmoTaxonomyVocabulary.URI_SCIENTIFIC_NAME_ID), null); if (!triples.hasNext()) { throw new NotFoundException("scientificNameId"); } final Statement triple = triples.next(); final Literal uri = (Literal)triple.getObject(); return new Id(uri.stringValue()); } catch (RepositoryException e) { throw new RuntimeException(e); } }
final SesameManager em = (SesameManager)ElmoManagerThreadLocal.get(); final ResourceManager<Resource> rm = em.getResourceManager(); final RepositoryResult<Statement> triples = em.getConnection().getStatements(rm.createResource(getLookup().lookup(Entity.class).getQName()),