Skip to content

Commit

Permalink
Upgraded SesameDriver from Sesame API 2.8.9 to RDF4J 2.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
ledsoft committed Mar 22, 2017
1 parent 46a7708 commit 0464130
Show file tree
Hide file tree
Showing 52 changed files with 1,120 additions and 1,224 deletions.
5 changes: 0 additions & 5 deletions jopa-integration-tests-jena/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
<name>JOPA Integration Tests for Jena</name>
<description>Integration tests of JOPA and Jena OntoDriver implementation</description>

<properties>
<org.aspectj.version>1.8.5</org.aspectj.version>
<pellet.version>2.3.0</pellet.version>
</properties>

<dependencies>
<dependency>
<groupId>cz.cvut.kbss.jopa</groupId>
Expand Down
1 change: 0 additions & 1 deletion jopa-integration-tests-owlapi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<description>Integration tests of JOPA and OWLAPI OntoDriver implementation</description>

<properties>
<org.aspectj.version>1.8.5</org.aspectj.version>
<pellet.version>2.4.0-SNAPSHOT</pellet.version>
</properties>

Expand Down
4 changes: 0 additions & 4 deletions jopa-integration-tests-sesame/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
<name>JOPA Integration Tests for Sesame</name>
<description>Integration tests of JOPA and Sesame OntoDriver implementation</description>

<properties>
<org.aspectj.version>1.8.5</org.aspectj.version>
</properties>


<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

import cz.cvut.kbss.jopa.model.EntityManager;
import cz.cvut.kbss.ontodriver.sesame.util.SesameUtils;
import org.openrdf.model.ValueFactory;
import org.openrdf.repository.Repository;
import org.openrdf.repository.RepositoryConnection;
import org.eclipse.rdf4j.model.ValueFactory;
import org.eclipse.rdf4j.repository.Repository;
import org.eclipse.rdf4j.repository.RepositoryConnection;

import java.net.URI;
import java.util.Collection;
Expand All @@ -33,10 +33,10 @@ public void persistTestData(Collection<Triple> data, EntityManager em) throws Ex
connection.begin();
for (Triple t : data) {
if (t.getValue() instanceof URI) {
connection.add(vf.createURI(t.getSubject().toString()), vf.createURI(t.getProperty().toString()),
vf.createURI(t.getValue().toString()));
connection.add(vf.createIRI(t.getSubject().toString()), vf.createIRI(t.getProperty().toString()),
vf.createIRI(t.getValue().toString()));
} else {
connection.add(vf.createURI(t.getSubject().toString()), vf.createURI(t.getProperty().toString()),
connection.add(vf.createIRI(t.getSubject().toString()), vf.createIRI(t.getProperty().toString()),
SesameUtils.createDataPropertyLiteral(t.getValue(), "en", vf));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* Copyright (C) 2016 Czech Technical University in Prague
*
* <p>
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* <p>
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
Expand All @@ -16,8 +16,8 @@

import cz.cvut.kbss.jopa.model.EntityManager;
import cz.cvut.kbss.jopa.test.environment.SesamePersistenceFactory;
import org.eclipse.rdf4j.repository.Repository;
import org.junit.Test;
import org.openrdf.repository.Repository;

import java.util.Collections;

Expand Down
1 change: 0 additions & 1 deletion jopa-integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<description>Integration tests of JOPA and its OntoDriver implementations</description>

<properties>
<pellet.version>2.3.0</pellet.version>
<ch.qos.logback.version>1.1.6</ch.qos.logback.version>
</properties>

Expand Down
53 changes: 31 additions & 22 deletions jopa-owl2java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,37 @@
</dependency>
</dependencies>

<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<!-- Inserts application version into constants -->
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<ignoreMissingFile>false</ignoreMissingFile>
<file>${project.basedir}/src/main/java/cz/cvut/kbss/jopa/owl2java/Constants.java</file>
<regex>false</regex>
<token>$VERSION$</token>
<value>${project.parent.version}</value>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
<resources>
<resource>
Expand Down Expand Up @@ -96,28 +127,6 @@
</excludes>
</configuration>
</plugin>

<!-- Inserts application version into constants -->
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<ignoreMissingFile>false</ignoreMissingFile>
<file>${project.basedir}/src/main/java/cz/cvut/kbss/jopa/owl2java/Constants.java</file>
<regex>false</regex>
<token>$VERSION$</token>
<value>${project.parent.version}</value>
</configuration>
</plugin>
</plugins>
</build>
</project>
14 changes: 7 additions & 7 deletions ontodriver-sesame/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</parent>

<properties>
<openrdf.sesame.version>2.8.9</openrdf.sesame.version>
<rdf4j.version>2.2</rdf4j.version>
</properties>

<dependencies>
Expand All @@ -24,14 +24,14 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.openrdf.sesame</groupId>
<artifactId>sesame-runtime</artifactId>
<version>${openrdf.sesame.version}</version>
<groupId>org.eclipse.rdf4j</groupId>
<artifactId>rdf4j-runtime</artifactId>
<version>${rdf4j.version}</version>
</dependency>
<dependency>
<groupId>org.openrdf.sesame</groupId>
<artifactId>sesame-sail-nativerdf</artifactId>
<version>${openrdf.sesame.version}</version>
<groupId>org.eclipse.rdf4j</groupId>
<artifactId>rdf4j-sail-nativerdf</artifactId>
<version>${rdf4j.version}</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,49 +14,43 @@
*/
package cz.cvut.kbss.ontodriver.sesame;

import java.util.Collection;
import java.util.HashSet;

import cz.cvut.kbss.ontodriver.sesame.util.SesameUtils;
import org.openrdf.model.Resource;
import org.openrdf.model.Statement;
import org.openrdf.model.URI;
import org.openrdf.model.ValueFactory;

import cz.cvut.kbss.ontodriver.descriptor.ListDescriptor;
import cz.cvut.kbss.ontodriver.exception.IntegrityConstraintViolatedException;
import cz.cvut.kbss.ontodriver.model.*;
import cz.cvut.kbss.ontodriver.sesame.connector.Connector;
import cz.cvut.kbss.ontodriver.descriptor.ListDescriptor;
import cz.cvut.kbss.ontodriver.model.Assertion;
import cz.cvut.kbss.ontodriver.model.Axiom;
import cz.cvut.kbss.ontodriver.model.AxiomImpl;
import cz.cvut.kbss.ontodriver.model.NamedResource;
import cz.cvut.kbss.ontodriver.model.Value;
import cz.cvut.kbss.ontodriver.sesame.util.SesameUtils;
import org.eclipse.rdf4j.model.IRI;
import org.eclipse.rdf4j.model.Resource;
import org.eclipse.rdf4j.model.Statement;
import org.eclipse.rdf4j.model.ValueFactory;

import java.util.Collection;
import java.util.HashSet;

abstract class AbstractSesameIterator implements SesameIterator {

protected final Resource listOwner;
protected final URI hasListProperty;
protected final URI hasNextProperty;
protected final URI context;
protected final IRI hasListProperty;
protected final IRI hasNextProperty;
protected final IRI context;
protected final boolean includeInferred;

protected final Connector connector;
protected final ValueFactory vf;

public AbstractSesameIterator(ListDescriptor listDescriptor, Connector connector,
ValueFactory vf) {
this.listOwner = SesameUtils.toSesameUri(listDescriptor.getListOwner().getIdentifier(), vf);
this.hasListProperty = SesameUtils.toSesameUri(listDescriptor.getListProperty()
public AbstractSesameIterator(ListDescriptor listDescriptor, Connector connector, ValueFactory vf) {
this.listOwner = SesameUtils.toSesameIri(listDescriptor.getListOwner().getIdentifier(), vf);
this.hasListProperty = SesameUtils.toSesameIri(listDescriptor.getListProperty()
.getIdentifier(), vf);
this.hasNextProperty = SesameUtils.toSesameUri(
this.hasNextProperty = SesameUtils.toSesameIri(
listDescriptor.getNextNode().getIdentifier(), vf);
this.context = SesameUtils.toSesameUri(listDescriptor.getContext(), vf);
this.context = SesameUtils.toSesameIri(listDescriptor.getContext(), vf);
this.includeInferred = listDescriptor.getListProperty().isInferred();
this.connector = connector;
this.vf = vf;
}

protected void checkSuccessorMax(Collection<Statement> stmts, URI property) {
protected void checkSuccessorMax(Collection<Statement> stmts, IRI property) {
// We don't mind the same statement multiple times, it could have been added during transaction
if (new HashSet<>(stmts).size() > 1) {
throw new IntegrityConstraintViolatedException(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* Copyright (C) 2016 Czech Technical University in Prague
*
* <p>
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* <p>
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
Expand All @@ -22,10 +22,10 @@
import cz.cvut.kbss.ontodriver.sesame.exceptions.SesameDriverException;
import cz.cvut.kbss.ontodriver.sesame.util.AxiomBuilder;
import cz.cvut.kbss.ontodriver.sesame.util.SesameUtils;
import org.openrdf.model.Resource;
import org.openrdf.model.Statement;
import org.openrdf.model.URI;
import org.openrdf.model.ValueFactory;
import org.eclipse.rdf4j.model.IRI;
import org.eclipse.rdf4j.model.Resource;
import org.eclipse.rdf4j.model.Statement;
import org.eclipse.rdf4j.model.ValueFactory;

import java.util.*;
import java.util.stream.Collectors;
Expand All @@ -35,9 +35,9 @@ class AxiomLoader {
private final Connector connector;
private final ValueFactory valueFactory;

private Map<URI, Assertion> propertyToAssertion;
private Map<URI, Assertion> explicitAssertions;
private Map<URI, Assertion> inferredAssertions;
private Map<IRI, Assertion> propertyToAssertion;
private Map<IRI, Assertion> explicitAssertions;
private Map<IRI, Assertion> inferredAssertions;

AxiomLoader(Connector connector, ValueFactory valueFactory) {
this.connector = connector;
Expand All @@ -51,7 +51,7 @@ Collection<Axiom<?>> loadAxioms(AxiomDescriptor axiomDescriptor) throws SesameDr

private Collection<Axiom<?>> findStatements(AxiomDescriptor descriptor) throws SesameDriverException {
final Collection<Axiom<?>> result = new HashSet<>();
final Resource subject = SesameUtils.toSesameUri(descriptor.getSubject().getIdentifier(), valueFactory);
final Resource subject = SesameUtils.toSesameIri(descriptor.getSubject().getIdentifier(), valueFactory);
final Assertion unspecified = processAssertions(descriptor);
final AxiomBuilder axiomBuilder = new AxiomBuilder(descriptor.getSubject(), propertyToAssertion, unspecified);
final StatementLoader statementLoader = new StatementLoader(descriptor, connector, subject, axiomBuilder);
Expand All @@ -77,7 +77,7 @@ private Assertion processAssertions(AxiomDescriptor descriptor) {
this.inferredAssertions = new HashMap<>(descriptor.getAssertions().size());
Assertion unspecified = null;
for (Assertion a : descriptor.getAssertions()) {
final URI property = SesameUtils.toSesameUri(a.getIdentifier(), valueFactory);
final IRI property = SesameUtils.toSesameIri(a.getIdentifier(), valueFactory);
propertyToAssertion.put(property, a);
if (a.equals(Assertion.createUnspecifiedPropertyAssertion(a.isInferred()))) {
unspecified = a;
Expand All @@ -91,10 +91,10 @@ private Assertion processAssertions(AxiomDescriptor descriptor) {
return unspecified;
}

public Collection<Axiom<?>> loadAxioms(NamedResource individual, boolean includeInferred, java.net.URI context)
Collection<Axiom<?>> loadAxioms(NamedResource individual, boolean includeInferred, java.net.URI context)
throws SesameDriverException {
final URI sesameContext = SesameUtils.toSesameUri(context, valueFactory);
final URI subject = SesameUtils.toSesameUri(individual.getIdentifier(), valueFactory);
final IRI sesameContext = SesameUtils.toSesameIri(context, valueFactory);
final IRI subject = SesameUtils.toSesameIri(individual.getIdentifier(), valueFactory);
final AxiomBuilder axiomBuilder = new AxiomBuilder(individual, Collections.emptyMap(),
Assertion.createUnspecifiedPropertyAssertion(includeInferred));
final Collection<Statement> statements;
Expand Down
Loading

0 comments on commit 0464130

Please sign in to comment.