Skip to content

Commit

Permalink
Merge pull request #262 from kbss-cvut/development
Browse files Browse the repository at this point in the history
[2.0.3] Release
  • Loading branch information
ledsoft authored Jul 22, 2024
2 parents 9e024c7 + 5170f45 commit cfe7441
Show file tree
Hide file tree
Showing 47 changed files with 387 additions and 246 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# JOPA - Change Log

## 2.0.3 - 2024-07-22
- Fix an issue with generating static metamodel under JDK 21 (Bug #257).
- Support using URI/URL as data property values (as RDF simple literal) (Enhancement #256).
- Support target ontology query hint (Enhancement #245).
- Dependency updates: Jena 5.1.0, RDF4J 5.0.1.

## 2.0.2 - 2024-06-24
- Fix a NPX when calling `EntityManager.isInferred` with lazy loading proxy (Bug #252).
- Allow using multiple values for a query parameter that is written into SPARQL `VALUES` clause (Bug #246).
Expand All @@ -20,7 +26,7 @@
- Modify name resolution in OWL2Java, support prefixes so that terms are better disambiguated without appending the useless `_A` suffix if possible (Enhancement #85).
- Remove dependency on AspectJ by rewriting object change tracking and lazy loading (Enhancement #145, #231). See the [wiki](https://github.com/kbss-cvut/jopa/wiki/Change-Tracking-and-Lazy-Loading) for details.
- Add support for RDF collections (Enhancement #51).
- Update dependencies (Jena 5.0.0, RDF4J 4.3.11).
- Dependency updates: Jena 5.0.0, RDF4J 4.3.11.
- Require Java 17.

## 1.2.2 - 2024-01-30
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.2</version>
<version>2.0.3</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.2</version>
<version>2.0.3</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package cz.cvut.kbss.jopa.model;

import cz.cvut.kbss.jopa.NonJPA;
import cz.cvut.kbss.jopa.exceptions.EntityNotFoundException;
import cz.cvut.kbss.jopa.exceptions.OWLEntityExistsException;
import cz.cvut.kbss.jopa.exceptions.OWLPersistenceException;
import cz.cvut.kbss.jopa.exceptions.TransactionRequiredException;
Expand Down Expand Up @@ -136,16 +137,18 @@ public interface EntityManager extends AutoCloseable {
* @return the found entity instance or {@code null} if the entity does not exist in the given ontology context
* @throws IllegalArgumentException if the first argument does not denote an entity type or the second argument is
* not a valid type for that entity’s identifier
* @throws NullPointerException If {@code entityClass}, {@code identifier} or {@code contextUri} is {@code
* null}
* @throws NullPointerException If {@code entityClass}, {@code identifier} or {@code contextUri} is
* {@code null}
* @see #getContexts()
*/
<T> T find(final Class<T> entityClass, final Object identifier, final Descriptor descriptor);

/**
* Get an instance, whose state may be lazily fetched.
* <p>
* If the requested instance does not exist in the database, {@code null} is returned.
* If the requested instance does not exist in the database, the {@link EntityNotFoundException} is thrown when the
* instance state is first accessed. (The persistence provider runtime is permitted to throw the
* {@code EntityNotFoundException} when getReference is called.)
* <p>
* The application should not expect that the instance state will be available upon detachment, unless it was
* accessed by the application while the entity manager was open.
Expand All @@ -161,7 +164,9 @@ public interface EntityManager extends AutoCloseable {
/**
* Get an instance, whose state may be lazily fetched.
* <p>
* If the requested instance does not exist in the database, {@code null} is returned.
* If the requested instance does not exist in the database, the {@link EntityNotFoundException} is thrown when the
* instance state is first accessed. (The persistence provider runtime is permitted to throw the
* {@code EntityNotFoundException} when getReference is called.)
* <p>
* The application should not expect that the instance state will be available upon detachment, unless it was
* accessed by the application while the entity manager was open.
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.2</version>
<version>2.0.3</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.2</version>
<version>2.0.3</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,35 @@
package cz.cvut.kbss.jopa.model.metamodel;

import cz.cvut.kbss.jopa.model.JOPAPersistenceProperties;
import cz.cvut.kbss.jopa.oom.converter.*;
import cz.cvut.kbss.jopa.oom.converter.datetime.*;
import cz.cvut.kbss.jopa.oom.converter.ConverterWrapper;
import cz.cvut.kbss.jopa.oom.converter.ObjectConverter;
import cz.cvut.kbss.jopa.oom.converter.ToDoubleConverter;
import cz.cvut.kbss.jopa.oom.converter.ToFloatConverter;
import cz.cvut.kbss.jopa.oom.converter.ToIntegerConverter;
import cz.cvut.kbss.jopa.oom.converter.ToLangStringConverter;
import cz.cvut.kbss.jopa.oom.converter.ToLongConverter;
import cz.cvut.kbss.jopa.oom.converter.ToShortConverter;
import cz.cvut.kbss.jopa.oom.converter.ToStringConverter;
import cz.cvut.kbss.jopa.oom.converter.ToURIConverter;
import cz.cvut.kbss.jopa.oom.converter.ToURLConverter;
import cz.cvut.kbss.jopa.oom.converter.datetime.DateConverter;
import cz.cvut.kbss.jopa.oom.converter.datetime.InstantConverter;
import cz.cvut.kbss.jopa.oom.converter.datetime.LocalDateTimeConverter;
import cz.cvut.kbss.jopa.oom.converter.datetime.LocalTimeConverter;
import cz.cvut.kbss.jopa.oom.converter.datetime.ZonedDateTimeConverter;
import cz.cvut.kbss.jopa.utils.Configuration;
import cz.cvut.kbss.ontodriver.model.LangString;

import java.net.URI;
import java.net.URL;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZonedDateTime;
import java.util.*;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

/**
* Manages attribute converters.
Expand Down Expand Up @@ -70,7 +89,9 @@ void registerConverter(Class<?> attributeType, ConverterWrapper<?, ?> converter)
Map.entry(Float.class, new ToFloatConverter()),
Map.entry(Double.class, new ToDoubleConverter()),
Map.entry(String.class, new ToStringConverter()),
Map.entry(LangString.class, new ToLangStringConverter()));
Map.entry(LangString.class, new ToLangStringConverter()),
Map.entry(URI.class, new ToURIConverter()),
Map.entry(URL.class, new ToURLConverter()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ private <T> void addAssertions(T entity, EntityType<T> et,
fs.buildAxiomValuesFromInstance(entity, valueBuilder);
}

<T> AxiomValueGatherer mapFieldToAxioms(URI primaryKey, T entity, FieldSpecification<? super T, ?> fieldSpec,
<T> AxiomValueGatherer mapFieldToAxioms(URI identifier, T entity, FieldSpecification<? super T, ?> fieldSpec,
EntityType<T> et, Descriptor descriptor) {
final AxiomValueGatherer valueBuilder = createAxiomValueBuilder(primaryKey, descriptor);
final AxiomValueGatherer valueBuilder = createAxiomValueBuilder(identifier, descriptor);
addAssertions(entity, et, fieldSpec, descriptor, valueBuilder);
return valueBuilder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public <T> void loadFieldValue(T entity, FieldSpecification<? super T, ?> fieldS
LOG.trace("Lazily loading value of field {} of entity {}.", fieldSpec, uow.stringify(entity));

final EntityType<T> et = (EntityType<T>) getEntityType(entity.getClass());
final URI primaryKey = EntityPropertiesUtils.getIdentifier(entity, et);
final URI identifier = EntityPropertiesUtils.getIdentifier(entity, et);

if (et.hasQueryAttribute(fieldSpec.getName())) {
QueryAttribute<? super T, ?> queryAttribute = (QueryAttribute<? super T, ?>) fieldSpec;
Expand All @@ -183,7 +183,7 @@ public <T> void loadFieldValue(T entity, FieldSpecification<? super T, ?> fieldS
}

final AxiomDescriptor axiomDescriptor =
descriptorFactory.createForFieldLoading(primaryKey, fieldSpec, descriptor, et);
descriptorFactory.createForFieldLoading(identifier, fieldSpec, descriptor, et);
try {
final Collection<Axiom<?>> axioms = storageConnection.find(axiomDescriptor);
entityBuilder.setFieldValue(entity, fieldSpec, axioms, et, descriptor);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package cz.cvut.kbss.jopa.oom.converter;

import cz.cvut.kbss.jopa.exception.UnsupportedTypeTransformationException;

import java.net.URI;

/**
* Converter to {@link java.net.URI}.
* <p>
* Only {@code String} values are supported.
*/
public class ToURIConverter implements ConverterWrapper<URI, Object> {
@Override
public boolean supportsAxiomValueType(Class<?> type) {
return String.class.equals(type);
}

@Override
public Object convertToAxiomValue(URI value) {
return value.toString();
}

@Override
public URI convertToAttribute(Object value) {
try {
return URI.create(value.toString());
} catch (IllegalArgumentException e) {
throw new UnsupportedTypeTransformationException("Unable to convert value " + value + " to URI.", e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package cz.cvut.kbss.jopa.oom.converter;

import cz.cvut.kbss.jopa.exception.UnsupportedTypeTransformationException;

import java.net.MalformedURLException;
import java.net.URL;

/**
* Converter to {@link java.net.URL}.
* <p>
* Only {@code String} values are supported.
*/
public class ToURLConverter implements ConverterWrapper<URL, Object> {

@Override
public boolean supportsAxiomValueType(Class<?> type) {
return String.class.equals(type);
}

@Override
public Object convertToAxiomValue(URL value) {
return value.toString();
}

@Override
public URL convertToAttribute(Object value) {
try {
return new URL(value.toString());
} catch (MalformedURLException e) {
throw new UnsupportedTypeTransformationException("Unable to convert value " + value + " to URL.", e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ void containsThrowsIllegalArgumentForNonEntity() {
@Test
void findThrowsIllegalArgumentForNonEntity() {
final IllegalArgumentException ex = assertThrows(IllegalArgumentException.class,
() -> em.find(UnknownEntity.class, "primaryKey", new EntityDescriptor()));
() -> em.find(UnknownEntity.class, "identifier", new EntityDescriptor()));
assertEquals(NON_ENTITY_CLASS_EXCEPTION_MESSAGE, ex.getMessage());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public void evictInferredClassesRemovesInstancesOfInferredClasses() {
}

@Test
public void testEvictByContextClassAndPrimaryKey() throws Exception {
public void testEvictByContextClassAndIdentifier() throws Exception {
final Descriptor descriptorOne = descriptor(CONTEXT_ONE);
final Descriptor descriptorTwo = descriptor(CONTEXT_TWO);
manager.add(testA.getUri(), testA, descriptors(descriptorTwo));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void testEvictByContext() throws Exception {
}

@Test
public void testEvictByContextClassAndPrimaryKey() throws Exception {
public void testEvictByContextClassAndIdentifier() throws Exception {
final LruCache lruCache = getLruCache();
final Descriptor descriptorOne = descriptor(CONTEXT_ONE);
final Descriptor descriptorTwo = descriptor(CONTEXT_TWO);
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.2</version>
<version>2.0.3</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 @@ -47,6 +47,7 @@ void setUp() {
final Map<String, String> properties = new HashMap<>();
properties.put(JenaOntoDriverProperties.JENA_STORAGE_TYPE, JenaOntoDriverProperties.IN_MEMORY);
properties.put(JenaOntoDriverProperties.JENA_TREAT_DEFAULT_GRAPH_AS_UNION, Boolean.toString(true));
properties.put(JenaOntoDriverProperties.JENA_ISOLATION_STRATEGY, JenaOntoDriverProperties.SNAPSHOT);
em = persistenceFactory.getEntityManager("SPARQLTypedQueryTests", false, properties);
QueryTestEnvironment.generateTestData(em);
em.clear();
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.2</version>
<version>2.0.3</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.2</version>
<version>2.0.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>jopa-integration-tests-rdf4j</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ protected EntityManager getEntityManager() {
@Test
@Override
public void askQueryAgainstTransactionalOntologyContainsUncommittedChangesAsWell() {
// This is not solved in RDF4J driver, yet
// RDF4J does not support queries against transactional snapshot because it does not use it
}
}
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.2</version>
<version>2.0.3</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,6 +23,7 @@
import cz.cvut.kbss.jopa.test.environment.TestEnvironment;
import cz.cvut.kbss.ontodriver.model.LangString;

import java.net.URI;
import java.time.LocalDate;
import java.time.ZoneOffset;
import java.util.*;
Expand Down Expand Up @@ -73,6 +74,9 @@ public class OWLClassM {
@OWLDataProperty(iri = Vocabulary.p_m_simpleLiteral, simpleLiteral = true)
private String simpleLiteral;

@OWLDataProperty(iri = Vocabulary.p_m_simpleLiteralUri, simpleLiteral = true)
private URI simpleLiteralUri;

@OWLDataProperty(iri = Vocabulary.p_m_StringCollection)
private Collection<String> stringCollection;

Expand Down Expand Up @@ -232,6 +236,14 @@ public void setEnumSimpleLiteral(Severity enumSimpleLiteral) {
this.enumSimpleLiteral = enumSimpleLiteral;
}

public URI getSimpleLiteralUri() {
return simpleLiteralUri;
}

public void setSimpleLiteralUri(URI simpleLiteralUri) {
this.simpleLiteralUri = simpleLiteralUri;
}

public ZoneOffset getWithConverter() {
return withConverter;
}
Expand Down Expand Up @@ -279,6 +291,7 @@ public String toString() {
", integerSet=" + integerSet +
", lexicalForm=" + lexicalForm +
", simpleLiteral=" + simpleLiteral +
", simpleLiteralUri=" + simpleLiteralUri +
", stringCollection=" + stringCollection +
", explicitDatatype=" + explicitDatatype +
", langString=" + langString +
Expand All @@ -305,6 +318,7 @@ public void initializeTestValues(boolean includingKey) {
this.integerSet = IntStream.generate(Generators::randomInt).limit(10).boxed().collect(Collectors.toSet());
this.stringCollection = new HashSet<>(Arrays.asList("test-one", "test-two", "test-three"));
this.enumSimpleLiteral = Severity.HIGH;
this.simpleLiteralUri = Generators.generateUri();
this.withConverter = ZoneOffset.UTC;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public class Vocabulary {
public static final String p_m_IntegerSet = ATTRIBUTE_IRI_BASE + "m-pluralIntAttribute";
public static final String p_m_lexicalForm = ATTRIBUTE_IRI_BASE + "m-lexicalForm";
public static final String p_m_simpleLiteral = ATTRIBUTE_IRI_BASE + "m-simpleLiteral";
public static final String p_m_simpleLiteralUri = ATTRIBUTE_IRI_BASE + "m-simpleLiteralUri";
public static final String p_m_StringCollection = ATTRIBUTE_IRI_BASE + "m-collectionStringAttribute";
public static final String p_m_explicitDatatype = ATTRIBUTE_IRI_BASE + "m-explicitDatatype";
public static final String p_m_langString = ATTRIBUTE_IRI_BASE + "m-langString";
Expand Down
Loading

0 comments on commit cfe7441

Please sign in to comment.