/** * Loads a single Object that is assumed to be of the given concept. */ public <T> T getObject(Class<T> concept, Resource resource) throws RepositoryException, QueryEvaluationException { return getObjects(concept, resource).singleResult(); }
/** * Loads a single Object that is assumed to be of the given concept. */ public <T> T getObject(Class<T> concept, Resource resource) throws RepositoryException, QueryEvaluationException { RDFObject cached = cached(resource); if (concept.isInstance(cached)) return concept.cast(cached); return getObjects(concept, resource).singleResult(); }
/** * {@inheritDoc } */ @Override public <T extends ResourceObject> List<T> findAll(Class<T> type) throws RepositoryException { try { return connection.getObjects(type).asList(); } catch (QueryEvaluationException e) { throw new RepositoryException("Couldn't evaluate query" , e); } }
public <T> Result<T> getObjects(Class<T> concept, String... uris) throws RepositoryException, QueryEvaluationException { ValueFactory vf = getValueFactory(); Resource[] resources = new Resource[uris.length]; for (int i = 0; i < uris.length; i++) { resources[i] = vf.createURI(uris[i]); } return getObjects(concept, resources); }
public <T> Result<T> getObjects(Class<T> concept, String... uris) throws RepositoryException, QueryEvaluationException { ValueFactory vf = getValueFactory(); Resource[] resources = new Resource[uris.length]; for (int i = 0; i < uris.length; i++) { resources[i] = vf.createURI(uris[i]); } return getObjects(concept, resources); }
/** * Returns all instances of the given type (and its subtypes) that are present in this parsers Anno4j instance. * @param type An {@link org.openrdf.annotations.Iri}-annotated type that all returned objects must have. * @param <T> The type of the returned objects. * @return Returns all instances present in the Anno4j connected triplestore having the given {@code type}. * Doesn't contain duplicates. * @throws RepositoryException Thrown if an error occurs accessing the connected triplestore. */ private <T extends ResourceObject> List<T> getInstancesOfType(Class<? extends T> type) throws RepositoryException { List<T> instances = new ArrayList<>(); ObjectConnection connection = anno4j.getObjectRepository().getConnection(); try { instances.addAll(connection.getObjects(type).asSet()); } catch (QueryEvaluationException e) { throw new RepositoryException(e); } return instances; }
annotations = anno4j.getObjectRepository().getConnection().getObjects(Annotation.class).asList(); } catch (QueryEvaluationException | RepositoryException e) { e.printStackTrace();