Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
ledsoft committed Nov 8, 2022
2 parents 6ca7057 + f76a45c commit c0a5b1d
Show file tree
Hide file tree
Showing 23 changed files with 72 additions and 41 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# JOPA - Release Notes

## 0.19.1 - 2022-11-08
- Fix issues in working with `BigInteger` and `BigDecimal` values.
- Fix a warning about illegal reflective operations on newer JDKs.

## 0.19.0 - 2022-10-26
- Add support for disabling inference via query hints (Enhancement #101).
- Allow registering custom attribute converters (Enhancement #118).
Expand All @@ -10,7 +14,7 @@
- Fix support for custom datatypes in Jena driver (Bug #113).
- Fix mapping enums to simple literals (Bug #111).
- Fix an issue with double-wrapped indirect collections when cloning singleton Maps (Bug #114).
- Dependency updates: RDF4J 3.7.7
- Dependency updates: RDF4J 3.7.7.

## 0.18.6 - 2022-05-09
- Automatically resolve inferred statements contexts for GraphDB (Enhancement #106).
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>0.19.0</version>
<version>0.19.1</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>0.19.0</version>
<version>0.19.1</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>0.19.0</version>
<version>0.19.1</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>0.19.0</version>
<version>0.19.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.slf4j.LoggerFactory;

import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.URI;
import java.net.URL;
import java.time.*;
Expand Down Expand Up @@ -284,6 +286,8 @@ private static Set<Class<?>> getImmutableTypes() {
Long.class,
Float.class,
Double.class,
BigInteger.class,
BigDecimal.class,
Void.class,
String.class,
URI.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,13 @@ void mergeChanges(Field field, Object target, Object originalValue, Object clone
if (clone instanceof IndirectCollection) {
clone = ((IndirectCollection<Collection<Object>>) clone).unwrap();
}
final Optional<Collection<?>> origOpt = createNewInstance(clone.getClass(), clone.size());
Collection<Object> orig = (Collection<Object>) origOpt.orElse(createDefaultCollection(clone.getClass()));
Collection<Object> orig;
if (clone == Collections.emptyList() || clone == Collections.emptySet()) {
orig = createDefaultCollection(clone.getClass());
} else {
final Optional<Collection<?>> origOpt = createNewInstance(clone.getClass(), clone.size());
orig = (Collection<Object>) origOpt.orElse(createDefaultCollection(clone.getClass()));
}
EntityPropertiesUtils.setFieldValue(field, target, orig);

if (clone.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
/**
* Copyright (C) 2022 Czech Technical University in Prague
*
* 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.
*
* 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
* details. You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* <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
* details. You should have received a copy of the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package cz.cvut.kbss.jopa.sessions;

Expand All @@ -19,10 +17,13 @@
import cz.cvut.kbss.jopa.environment.OWLClassA;
import cz.cvut.kbss.jopa.environment.OWLClassC;
import cz.cvut.kbss.jopa.environment.OWLClassJ;
import cz.cvut.kbss.jopa.environment.OWLClassM;
import cz.cvut.kbss.jopa.environment.utils.Generators;
import cz.cvut.kbss.jopa.exceptions.OWLPersistenceException;
import cz.cvut.kbss.jopa.model.descriptors.Descriptor;
import cz.cvut.kbss.jopa.model.descriptors.EntityDescriptor;
import cz.cvut.kbss.jopa.model.metamodel.CollectionType;
import cz.cvut.kbss.jopa.utils.CollectionFactory;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -33,7 +34,7 @@
import java.util.*;
import java.util.stream.IntStream;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
Expand Down Expand Up @@ -106,7 +107,7 @@ public void buildCloneThrowsUnsupportedCollectionTypeExceptionWhenCollectionIsNe
final OWLPersistenceException ex = assertThrows(OWLPersistenceException.class, () -> builder
.buildClone(owner, CollectionOwner.queueField(), owner.queue, new CloneConfiguration(descriptor)));
assertThat(ex.getMessage(),
containsString("Cannot clone unsupported collection instance of type " + owner.queue.getClass()));
containsString("Cannot clone unsupported collection instance of type " + owner.queue.getClass()));
}

private static class CollectionOwner {
Expand Down Expand Up @@ -170,7 +171,7 @@ public void buildingSingletonSetCloneRegistersElementCloneInUoW() throws Excepti
when(uowMock.registerExistingObject(aOrig, descriptor, Collections.emptyList())).thenReturn(aClone);
when(uowMock.isEntityType(OWLClassA.class)).thenReturn(true);
final Set<?> clone = (Set<?>) builder.buildClone(owner, OWLClassJ.getOwlClassAField(), owner.getOwlClassA(),
new CloneConfiguration(descriptor));
new CloneConfiguration(descriptor));
assertEquals(owner.getOwlClassA().size(), clone.size());
assertSame(aClone, clone.iterator().next());
verify(uowMock).registerExistingObject(aOrig, descriptor, Collections.emptyList());
Expand All @@ -187,7 +188,7 @@ public void buildCloneClonesSingletonListWithContent() throws Exception {
when(uowMock.isEntityType(OWLClassA.class)).thenReturn(true);

final List<?> clone = (List<?>) builder.buildClone(owner, OWLClassC.getSimpleListField(), owner.getSimpleList(),
new CloneConfiguration(descriptor));
new CloneConfiguration(descriptor));
assertEquals(1, clone.size());
assertSame(aClone, clone.get(0));
verify(uowMock).registerExistingObject(aOrig, descriptor, Collections.emptyList());
Expand All @@ -207,11 +208,20 @@ public void buildCloneClonesArrayAsListWithContent() throws Exception {
when(uowMock.isEntityType(OWLClassA.class)).thenReturn(true);

final List<?> clone = (List<?>) builder.buildClone(owner, OWLClassC.getSimpleListField(), owner.getSimpleList(),
new CloneConfiguration(descriptor));
new CloneConfiguration(descriptor));
assertEquals(2, clone.size());
assertSame(aOneClone, clone.get(0));
assertSame(aTwoClone, clone.get(1));
verify(uowMock).registerExistingObject(aOneOrig, descriptor, Collections.emptyList());
verify(uowMock).registerExistingObject(aTwoOrig, descriptor, Collections.emptyList());
}

@Test
void mergeChangesReplacesEmptySetWithDefaultSet() throws Exception {
final OWLClassM target = new OWLClassM();
target.initializeTestValues(true);
builder.mergeChanges(OWLClassM.getIntegerSetField(), target, new HashSet<>(), Collections.emptySet());
assertThat(target.getIntegerSet(),
instanceOf(CollectionFactory.createDefaultCollection(CollectionType.SET).getClass()));
}
}
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>0.19.0</version>
<version>0.19.1</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>0.19.0</version>
<version>0.19.1</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>0.19.0</version>
<version>0.19.1</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>0.19.0</version>
<version>0.19.1</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 @@ -16,6 +16,8 @@

import cz.cvut.kbss.jopa.test.OWLClassA;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
Expand Down Expand Up @@ -130,7 +132,7 @@ public static Map<URI, Set<Object>> createTypedProperties(int size) {
}

private static Object generateRandomPropertyValue(int valueIndex, int propertyIndex) {
final int random = randomInt(6);
final int random = randomInt(8);
switch (random) {
case 0: // boolean
return valueIndex % 2 == 0;
Expand All @@ -145,6 +147,10 @@ private static Object generateRandomPropertyValue(int valueIndex, int propertyIn
return OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS);
case 5: // String
return "TypedProperty_" + propertyIndex + "Value_" + valueIndex;
case 6:
return BigInteger.valueOf(valueIndex);
case 7:
return BigDecimal.valueOf(Math.PI);
default:
throw new IllegalArgumentException();
}
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>0.19.0</version>
<version>0.19.1</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>0.19.0</version>
<version>0.19.1</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>0.19.0</version>
<version>0.19.1</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>0.19.0</version>
<version>0.19.1</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>0.19.0</version>
<version>0.19.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
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>0.19.0</version>
<version>0.19.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

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>0.19.0</version>
<version>0.19.1</version>
</parent>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import java.util.List;
import java.util.Objects;

class StorageConnector extends AbstractConnector {
public class StorageConnector extends AbstractConnector {

private static final Logger LOG = LoggerFactory.getLogger(StorageConnector.class);

Expand Down Expand Up @@ -310,8 +310,10 @@ private static boolean isInMemoryRepository(Repository repo) {
if (!(repo instanceof SailRepository)) {
return false;
}
final Sail sail = ((SailRepository) repo).getSail();
return sail instanceof SailWrapper ? ((SailWrapper) sail).getBaseSail() instanceof MemoryStore :
sail instanceof MemoryStore;
Sail sail = ((SailRepository) repo).getSail();
while (sail instanceof SailWrapper) {
sail = ((SailWrapper) sail).getBaseSail();
}
return sail instanceof MemoryStore;
}
}
2 changes: 1 addition & 1 deletion ontodriver-sesame/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>0.19.0</version>
<version>0.19.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

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>0.19.0</version>
<version>0.19.1</version>
<artifactId>jopa-all</artifactId>
<packaging>pom</packaging>
<name>JOPA</name>
Expand Down

0 comments on commit c0a5b1d

Please sign in to comment.