public Transaction(ObjectRepository objectRepository, LDPathEvaluatorConfiguration evaluatorConfiguration) throws RepositoryException { this.connection = objectRepository.getConnection(); this.evaluatorConfiguration = evaluatorConfiguration; }
protected ObjectRepository createObjectRepository(RoleMapper mapper, LiteralManager literals, ClassLoader cl) { return new ObjectRepository(mapper, literals, cl); }
/** * Creates a new ObjectConnection that will need to be closed by the caller. */ @Override public ObjectConnection getConnection() throws RepositoryException { ObjectConnection con; RepositoryConnection conn = getDelegate().getConnection(); synchronized (compiled) { ObjectFactory factory = createObjectFactory(mapper, pm, literals, resolver, cl); con = new ObjectConnection(this, conn, factory, createTypeManager(), blobs); } con.setIncludeInferred(isIncludeInferred()); con.setMaxQueryTime(getMaxQueryTime()); // con.setQueryResultLimit(getQueryResultLimit()); con.setQueryLanguage(getQueryLanguage()); con.setReadContexts(getReadContexts()); con.setAddContexts(getAddContexts()); con.setRemoveContexts(getRemoveContexts()); con.setArchiveContexts(getArchiveContexts()); return con; }
public NamedQuery createNamedQuery(URI uri, String queryString) throws RepositoryException { return createNamedQuery(uri, getQueryLanguage(), queryString, uri.stringValue()); }
private void loadSchema(Model schema) throws RepositoryException, AssertionError { RepositoryConnection conn = getDelegate().getConnection(); try { if (schemaGraphs.isEmpty() && schemaGraphTypes.isEmpty()) { result.close(); addLists(conn, schema); } else if (schemaGraphs.isEmpty()) { TupleQuery qry = conn.prepareTupleQuery(SPARQL, SELECT_GRAPH_BY_TYPE);
public File getObjectDataDir() { if (dataDir == null) return getDataDir(); return dataDir; }
public synchronized BlobStore getBlobStore() throws ObjectStoreConfigException { if (blobStoreUrl != null && blobs == null) { try { File dataDir = getDataDir(); if (dataDir == null) { dataDir = new File("."); } java.net.URI base = dataDir.toURI(); String url = base.resolve(blobStoreUrl).toString(); BlobStoreFactory bsf = BlobStoreFactory.newInstance(); blobs = bsf.openBlobStore(url, blobStoreParameters); } catch (IOException e) { throw new ObjectStoreConfigException(e); } catch (IllegalArgumentException e) { throw new ObjectStoreConfigException(e); } } return blobs; }
/** * Creates a new ObjectConnection that will need to be closed by the caller. */ @Override public ObjectConnection getConnection() throws RepositoryException { BlobStore blobs; try { blobs = getBlobStore(); } catch (ObjectStoreConfigException e) { throw new RepositoryException(e); } ObjectFactory factory = service.createObjectFactory(); RepositoryConnection conn = getDelegate().getConnection(); ObjectConnection con = new ObjectConnection(this, conn, factory, createTypeManager(), blobs, idGenerator); con.setIncludeInferred(isIncludeInferred()); con.setMaxQueryTime(getMaxQueryTime()); // con.setQueryResultLimit(getQueryResultLimit()); con.setQueryLanguage(getQueryLanguage()); con.setReadContexts(getReadContexts()); con.setAddContexts(getAddContexts()); con.setRemoveContexts(getRemoveContexts()); con.setArchiveContexts(getArchiveContexts()); return con; }
/** * Returns a builder object that operates on the given repository. * @param repository The repository to use, e.g. for name disambiguation. * @return An instance of the builder. * @throws RepositoryException Thrown if an error occurs while opening a connection to the repository. */ public static IdentifierBuilder forObjectRepository(ObjectRepository repository) throws RepositoryException { return forObjectRepository(repository.getConnection()); }
protected ObjectRepository createObjectRepository(RoleMapper mapper, LiteralManager literals, ClassLoader cl) throws ObjectStoreConfigException { return new ObjectRepository(new ObjectServiceImpl(mapper, literals, cl)); }
/** * Returns a builder object that operates on the given repository. * @param repository The repository to use, e.g. for name disambiguation. * @return An instance of the builder. * @throws RepositoryException Thrown if an error occurs while opening a connection to the repository. */ public static MethodNameBuilder forObjectRepository(ObjectRepository repository) throws RepositoryException { return forObjectRepository(repository.getConnection()); }
/** * Returns a builder object that operates on the given repository. * @param repository The repository to use, e.g. for name disambiguation. * @return An instance of the builder. * @throws RepositoryException Thrown if an error occurs while opening a connection to the repository. */ public static ClassNameBuilder forObjectRepository(ObjectRepository repository) throws RepositoryException { return forObjectRepository(repository.getConnection()); }
@Override public ObjectConnection getConnection() throws RepositoryException { return anno4j.getObjectRepository().getConnection(); }
public void generateSimilarity(Annotation subject, Annotation object, String algorithmName) { SimilarityAlgorithm algorithm = this.algorithms.get(algorithmName); double similarity = algorithm.calculateSimilarity(subject, object); try { Annotation anno = createSimilarityAnnotation(subject, object, similarity); this.anno4j.getObjectRepository().getConnection().addObject(anno); } catch (RepositoryException | InstantiationException | IllegalAccessException e) { e.printStackTrace(); } }
/** * 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; }
ObjectConnection connection = getObjectRepository().getConnection(); try {
/** * Packs the proxies created by the Anno4j instance into a JAR file. * @param commandLine The parsed command line arguments. * @param anno4j The Anno4j instance. * @throws RepositoryException Thrown if an error occurs while querying the repository. * @throws IOException Thrown if an error occurs while writing the JAR file. */ private static void packProxies(CommandLine commandLine, Anno4j anno4j) throws RepositoryException, IOException { ClassFactory factory = anno4j.getObjectRepository().getConnection().getObjectFactory().getResolver().getClassFactory(); JarPacker packer = new JarPacker(new File(getOutputPath(commandLine) + "proxies.jar")); packer.addFile(factory.getOutput()); packer.close(); }
/** * Clears the Anno4j underlying triplestore. * This is required in order to prevent a drop in throughput while parsing. * * @throws RepositoryException Thrown if no connection to the object repository could be made. * @throws UpdateExecutionException Thrown if an error occurred while executing the clearing query. */ private void clear() throws RepositoryException, UpdateExecutionException { String deleteUpdate = "DELETE {?s ?p ?o}\n" + "WHERE {?s ?p ?o}"; ObjectConnection connection = anno4j.getObjectRepository().getConnection(); Update update; try { update = connection.prepareUpdate(deleteUpdate); } catch (MalformedQueryException e) { e.printStackTrace(); return; } update.execute(); }
/** * Shutdown method, closing all repositories and corresponding connection * objects. * Does also call the clear() method, which removes all statements from the local Anno4j instance. * * @throws RepositoryException Thrown if an error occurs while accessing the repository. */ public void shutdown() throws RepositoryException, UpdateExecutionException { // Add anno4j shutdown method here. this.clear(); this.anno4j.getObjectRepository().getConnection().close(); this.anno4j.getRepository().getConnection().close(); }
private ObjectConnection createObjectConnection(URI context) throws RepositoryException { ObjectConnection connection = objectRepository.getConnection(); if(context != null) { connection.setReadContexts(context); connection.setInsertContext(context); connection.setRemoveContexts(context); } else if (defaultContext != null) { connection.setReadContexts(defaultContext); connection.setInsertContext(defaultContext); connection.setRemoveContexts(defaultContext); } return connection; }