Skip to content

Commit

Permalink
Merge pull request #269 from kbss-cvut/development
Browse files Browse the repository at this point in the history
[2.0.5] Release
  • Loading branch information
ledsoft authored Sep 3, 2024
2 parents 515e038 + 88909b4 commit 4c400cd
Show file tree
Hide file tree
Showing 24 changed files with 68 additions and 45 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# JOPA - Change Log

## 2.0.5 - 2024-09-03
- Modify target ontology selection in queries (use only query hints) to prevent RDF4J driver from spanning application log.

## 2.0.4 - 2024-08-15
- Fix an issue with cloning instances of `AbstractImmutableMap` (produced by `Map.of`) (Bug #264).
- Ensure changes done by `@PreUpdate` callback inherited by entity are propagated to repository (Bug #265).
Expand Down
2 changes: 1 addition & 1 deletion datatype/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>jopa-all</artifactId>
<groupId>cz.cvut.kbss.jopa</groupId>
<version>2.0.4</version>
<version>2.0.5</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion jopa-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>cz.cvut.kbss.jopa</groupId>
<artifactId>jopa-all</artifactId>
<version>2.0.4</version>
<version>2.0.5</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion jopa-distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>cz.cvut.kbss.jopa</groupId>
<artifactId>jopa-all</artifactId>
<version>2.0.4</version>
<version>2.0.5</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion jopa-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>cz.cvut.kbss.jopa</groupId>
<artifactId>jopa-all</artifactId>
<version>2.0.4</version>
<version>2.0.5</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ public void executeUpdate() {

private Statement initQueryStatement() {
final Statement stmt = connection.createStatement();
stmt.useOntology(Statement.StatementOntology.TRANSACTIONAL);
applyQueryHints(stmt);
logQuery();
return stmt;
Expand Down
2 changes: 1 addition & 1 deletion jopa-integration-tests-jena/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>cz.cvut.kbss.jopa</groupId>
<artifactId>jopa-all</artifactId>
<version>2.0.4</version>
<version>2.0.5</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion jopa-integration-tests-owlapi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>cz.cvut.kbss.jopa</groupId>
<artifactId>jopa-all</artifactId>
<version>2.0.4</version>
<version>2.0.5</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion jopa-integration-tests-rdf4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>cz.cvut.kbss.jopa</groupId>
<artifactId>jopa-all</artifactId>
<version>2.0.4</version>
<version>2.0.5</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>jopa-integration-tests-rdf4j</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion jopa-integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>cz.cvut.kbss.jopa</groupId>
<artifactId>jopa-all</artifactId>
<version>2.0.4</version>
<version>2.0.5</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
import cz.cvut.kbss.jopa.model.annotations.OWLClass;
import cz.cvut.kbss.jopa.model.query.Query;
import cz.cvut.kbss.jopa.query.QueryHints;
import cz.cvut.kbss.jopa.test.*;
import cz.cvut.kbss.jopa.test.OWLClassA;
import cz.cvut.kbss.jopa.test.OWLClassB;
import cz.cvut.kbss.jopa.test.OWLClassD;
import cz.cvut.kbss.jopa.test.OWLClassE;
import cz.cvut.kbss.jopa.test.OWLClassT;
import cz.cvut.kbss.jopa.test.Vocabulary;
import cz.cvut.kbss.jopa.test.environment.DataAccessor;
import cz.cvut.kbss.jopa.test.environment.Generators;
import cz.cvut.kbss.jopa.test.environment.Quad;
Expand All @@ -36,13 +41,24 @@
import org.slf4j.Logger;

import java.net.URI;
import java.util.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.hasItem;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

public abstract class QueryRunner extends BaseQueryRunner {

Expand Down
2 changes: 1 addition & 1 deletion jopa-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>jopa-all</artifactId>
<groupId>cz.cvut.kbss.jopa</groupId>
<version>2.0.4</version>
<version>2.0.5</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion jopa-owl2java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>cz.cvut.kbss.jopa</groupId>
<artifactId>jopa-all</artifactId>
<version>2.0.4</version>
<version>2.0.5</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion jopa-owlapi-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>cz.cvut.kbss.jopa</groupId>
<artifactId>jopa-all</artifactId>
<version>2.0.4</version>
<version>2.0.5</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion modelgen/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>jopa-all</artifactId>
<groupId>cz.cvut.kbss.jopa</groupId>
<version>2.0.4</version>
<version>2.0.5</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion ontodriver-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>jopa-all</artifactId>
<groupId>cz.cvut.kbss.jopa</groupId>
<version>2.0.4</version>
<version>2.0.5</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion ontodriver-jena/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>cz.cvut.kbss.jopa</groupId>
<artifactId>jopa-all</artifactId>
<version>2.0.4</version>
<version>2.0.5</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class JenaStatement implements Statement {

private final StatementExecutor executor;

private StatementOntology targetOntology = StatementOntology.SHARED;
private StatementOntology targetOntology = StatementOntology.TRANSACTIONAL;
private boolean open = true;

private AbstractResultSet currentResultSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,24 @@
import cz.cvut.kbss.ontodriver.util.StatementHolder;
import cz.cvut.kbss.ontodriver.util.Vocabulary;
import org.apache.jena.query.QueryFactory;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.jupiter.MockitoExtension;

import java.lang.reflect.Field;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith(MockitoExtension.class)
public class JenaPreparedStatementTest {

private static final String QUERY = "SELECT * WHERE { ?x ?y ?z . }";
Expand All @@ -50,13 +53,6 @@ public class JenaPreparedStatementTest {

private JenaPreparedStatement statement;

@BeforeEach
public void setUp() throws Exception {
MockitoAnnotations.openMocks(this);
when(executor.executeSelectQuery(any(), any())).thenReturn(resultSet);
when(executor.executeAskQuery(any(), any())).thenReturn(resultSet);
}

@Test
public void constructorAnalyzesQueryPassedAsParameter() throws Exception {
this.statement = new JenaPreparedStatement(executor, QUERY);
Expand Down Expand Up @@ -99,13 +95,14 @@ public void setParameterThrowsIllegalStateOnClosedStatement() throws Exception {

@Test
public void executeQueryExecutesStatementWithParameter() throws Exception {
when(executor.executeSelectQuery(any(), any())).thenReturn(resultSet);
this.statement = new JenaPreparedStatement(executor, QUERY);
final String value = "<" + Vocabulary.RDF_TYPE + ">";
statement.setObject("y", value);
final String expected = QUERY.replace("?y", value);
statement.executeQuery();
verify(executor)
.executeSelectQuery(eq(QueryFactory.create(expected)), eq(Statement.StatementOntology.SHARED));
.executeSelectQuery(eq(QueryFactory.create(expected)), eq(Statement.StatementOntology.TRANSACTIONAL));
}

@Test
Expand All @@ -124,7 +121,7 @@ public void executeUpdateExecutesUpdateStatement() throws Exception {
statement.setObject("type", value);
final String expected = update.replace("?type", value);
statement.executeUpdate();
verify(executor).executeUpdate(eq(expected), eq(Statement.StatementOntology.SHARED));
verify(executor).executeUpdate(eq(expected), eq(Statement.StatementOntology.TRANSACTIONAL));
}

@Test
Expand All @@ -138,13 +135,14 @@ public void executeUpdateThrowsIllegalStateForClosedStatement() throws Exception

@Test
public void clearParametersClearsAlreadySetParameters() throws Exception {
when(executor.executeSelectQuery(any(), any())).thenReturn(resultSet);
this.statement = new JenaPreparedStatement(executor, QUERY);
final String value = "<" + Vocabulary.RDF_TYPE + ">";
statement.setObject("y", value);
statement.clearParameters();
statement.executeQuery();
verify(executor)
.executeSelectQuery(eq(QueryFactory.create(QUERY)), eq(Statement.StatementOntology.SHARED));
.executeSelectQuery(eq(QueryFactory.create(QUERY)), eq(Statement.StatementOntology.TRANSACTIONAL));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,15 @@

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

public class JenaStatementTest {

Expand All @@ -51,7 +58,7 @@ public void executeQueryExecutesSelect() throws JenaDriverException {
when(executor.executeSelectQuery(any(), any())).thenReturn(rsMock);
final String query = "SELECT * WHERE { ?x ?y ?z .}";
final ResultSet rs = statement.executeQuery(query);
verify(executor).executeSelectQuery(any(Query.class), eq(Statement.StatementOntology.SHARED));
verify(executor).executeSelectQuery(any(Query.class), eq(Statement.StatementOntology.TRANSACTIONAL));
assertSame(rsMock, rs);
}

Expand All @@ -61,7 +68,7 @@ public void executeQueryExecutesAsk() throws JenaDriverException {
when(executor.executeAskQuery(any(), any())).thenReturn(rsMock);
final String query = "ASK { ?x a <http://xmlns.com/foaf/0.1/Person> . }";
final ResultSet rs = statement.executeQuery(query);
verify(executor).executeAskQuery(any(Query.class), eq(Statement.StatementOntology.SHARED));
verify(executor).executeAskQuery(any(Query.class), eq(Statement.StatementOntology.TRANSACTIONAL));
assertSame(rsMock, rs);
}

Expand All @@ -72,7 +79,7 @@ public void executeQueryExecutesAskWhenPrefixesAreDeclared() throws JenaDriverEx
final String query = "PREFIX foaf: <http://xmlns.com/foaf/0.1/> \n" +
"ASK { ?x a foaf:Person . }";
statement.executeQuery(query);
verify(executor).executeAskQuery(any(Query.class), eq(Statement.StatementOntology.SHARED));
verify(executor).executeAskQuery(any(Query.class), eq(Statement.StatementOntology.TRANSACTIONAL));
}

@Test
Expand Down Expand Up @@ -112,7 +119,7 @@ public void executeQueryClosesCurrentResultSet() throws JenaDriverException {
public void executeUpdateExecutesUpdateQuery() throws JenaDriverException {
final String query = "INSERT DATA { _:b1 a <http://xmlns.com/foaf/0.1/Person> . }";
statement.executeUpdate(query);
verify(executor).executeUpdate(query, Statement.StatementOntology.SHARED);
verify(executor).executeUpdate(query, Statement.StatementOntology.TRANSACTIONAL);
}

@Test
Expand Down Expand Up @@ -149,10 +156,10 @@ public void settingTargetOntologyIsReflectedInQueryExecutionParameter() throws E
final SelectResultSet rsMock = mock(SelectResultSet.class);
when(executor.executeSelectQuery(any(), any())).thenReturn(rsMock);
final String query = "SELECT * WHERE { ?x ?y ?z .}";
statement.useOntology(Statement.StatementOntology.TRANSACTIONAL);
assertEquals(Statement.StatementOntology.TRANSACTIONAL, statement.getStatementOntology());
statement.useOntology(Statement.StatementOntology.SHARED);
assertEquals(Statement.StatementOntology.SHARED, statement.getStatementOntology());
final ResultSet rs = statement.executeQuery(query);
verify(executor).executeSelectQuery(any(Query.class), eq(Statement.StatementOntology.TRANSACTIONAL));
verify(executor).executeSelectQuery(any(Query.class), eq(Statement.StatementOntology.SHARED));
assertSame(rsMock, rs);
}
}
2 changes: 1 addition & 1 deletion ontodriver-owlapi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>cz.cvut.kbss.jopa</groupId>
<artifactId>jopa-all</artifactId>
<version>2.0.4</version>
<version>2.0.5</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

public class OwlapiStatement implements Statement {

private StatementOntology targetOntology;
private StatementOntology targetOntology = StatementOntology.TRANSACTIONAL;
private boolean open;
private boolean disableInference;

Expand Down
2 changes: 1 addition & 1 deletion ontodriver-rdf4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<artifactId>jopa-all</artifactId>
<groupId>cz.cvut.kbss.jopa</groupId>
<version>2.0.4</version>
<version>2.0.5</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>

<groupId>cz.cvut.kbss.jopa</groupId>
<version>2.0.4</version>
<version>2.0.5</version>
<artifactId>jopa-all</artifactId>
<packaging>pom</packaging>
<name>JOPA</name>
Expand Down

0 comments on commit 4c400cd

Please sign in to comment.