public Transaction(ObjectRepository objectRepository, LDPathEvaluatorConfiguration evaluatorConfiguration) throws RepositoryException { this.connection = objectRepository.getConnection(); this.evaluatorConfiguration = evaluatorConfiguration; }
/** * 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()); }
/** * 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(); }
/** * Creates an Anno4j instance that can use the concepts contained in the given JAR file. * @param ontologyJar A JAR file containing concepts. * @param classLoader The class loader to use. * @param persistSchemaAnnotations Whether schema annotations should be scanned. * @return Returns an Anno4j instance. * @throws Exception Thrown on error. */ private static Anno4j getAnno4jWithClassLoader(File ontologyJar, ClassLoader classLoader, boolean persistSchemaAnnotations) throws Exception { Set<URL> clazzes = new HashSet<>(); clazzes.addAll(ClasspathHelper.forManifest(ontologyJar.toURI().toURL())); Anno4j anno4j = new Anno4j(new SailRepository(new MemoryStore()), new IDGeneratorAnno4jURN(), null, persistSchemaAnnotations, clazzes); // Register concepts found in JAR: RoleMapper mapper = anno4j.getObjectRepository().getConnection().getObjectFactory().getResolver().getRoleMapper(); for (final String className : getClassNamesInJar(ontologyJar)) { Class<?> clazz = classLoader.loadClass(className); if(clazz.getAnnotation(Iri.class) != null) { mapper.addConcept(clazz); } } return anno4j; }
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; }
/** * Returns the buildable named resource objects of RDFS classes that were found during * the last call to {@link #build()}. * * @return Returns the RDFS classes in the model built. */ @Override public Collection<BuildableRDFSClazz> getClazzes() throws RepositoryException { try { ObjectConnection connection = anno4j.getObjectRepository().getConnection(); ObjectQuery query = connection.prepareObjectQuery( "SELECT DISTINCT ?c {" + " ?c rdfs:subClassOf+ owl:Thing . " + " FILTER( isIRI(?c) )" + "}" ); return query.evaluate(BuildableRDFSClazz.class).asSet(); } catch (MalformedQueryException | QueryEvaluationException e) { throw new RepositoryException(e); } }
annotations = anno4j.getObjectRepository().getConnection().getObjects(Annotation.class).asList(); } catch (QueryEvaluationException | RepositoryException e) { e.printStackTrace();
/** * Returns buildable named resource objects of RDFS classes that were found during * the last call to {@link #build()} which are pairwise distinct, * i.e. that are not declared equivalent. * @return All pairwise distinct named classes in the repository. * @throws RepositoryException Thrown if an error occurs while querying the repository. */ private Collection<BuildableRDFSClazz> getDistinctClasses() throws RepositoryException { try { ObjectConnection connection = anno4j.getObjectRepository().getConnection(); ObjectQuery query = connection.prepareObjectQuery( "SELECT DISTINCT ?c {\n" + " ?c rdfs:subClassOf+ owl:Thing . \n" + " MINUS {\n" + " ?e owl:equivalentClass ?c . \n" + " FILTER(str(?e) < str(?c))\n" + // Impose order on equivalence. Pick only first lexicographical " }\n" + " FILTER( isIRI(?c) )\n" + "}" ); return query.evaluate(BuildableRDFSClazz.class).asSet(); } catch (MalformedQueryException | QueryEvaluationException e) { throw new RepositoryException(e); } }
ObjectConnection connection = anno4j.getObjectRepository().getConnection();
Statement jenaStatement = statementIter.nextStatement(); anno4j.getObjectRepository() .getConnection() .add(JenaSesameUtils.asSesameStatement(jenaStatement)); statementTransferCount++; anno4j.getObjectRepository().getConnection().prepareUpdate( "INSERT {" + " ?c a rdfs:Class . " + "}" ).execute(); anno4j.getObjectRepository().getConnection().prepareUpdate( "INSERT {" + " ?p a rdf:Property . " + anno4j.getObjectRepository().getConnection().prepareUpdate( "INSERT {" + " ?p rdfs:domain ?v . " + "}" ).execute(); anno4j.getObjectRepository().getConnection().prepareUpdate( "INSERT {" + " ?p rdfs:range ?v . " + anno4j.getObjectRepository().getConnection().prepareUpdate( "INSERT {" + " ?p ?t ?v . " +