Skip to content

Commit

Permalink
Merge pull request #224 from kbss-cvut/development
Browse files Browse the repository at this point in the history
[1.2.1] Release
  • Loading branch information
ledsoft authored Jan 22, 2024
2 parents a3ee2f3 + 51f9bf9 commit 5b51de1
Show file tree
Hide file tree
Showing 22 changed files with 80 additions and 31 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

## 1.2.1 - 2024-01-22
- Unwrap `IndirectMultilingualString` instances when owner entity is detached from the persistence context.

## 1.2.0 - 2023-12-20
- Support data properties for referenced list values (Enhancement #209).
- Support using multilingual string as referenced list values (Enhancement #216).
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>1.2.0</version>
<version>1.2.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>1.2.0</version>
<version>1.2.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>1.2.0</version>
<version>1.2.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>1.2.0</version>
<version>1.2.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package cz.cvut.kbss.jopa.sessions;

import cz.cvut.kbss.jopa.adapters.IndirectCollection;
import cz.cvut.kbss.jopa.adapters.IndirectWrapper;
import cz.cvut.kbss.jopa.exceptions.EntityNotFoundException;
import cz.cvut.kbss.jopa.exceptions.OWLEntityExistsException;
Expand Down Expand Up @@ -278,11 +277,11 @@ public void clear() {

private void detachAllManagedInstances() {
cloneMapping.forEach(instance -> {
removeIndirectCollections(instance);
removeIndirectWrappers(instance);
deregisterEntityFromPersistenceContext(instance);
});
newObjectsCloneToOriginal.keySet().forEach(instance -> {
removeIndirectCollections(instance);
removeIndirectWrappers(instance);
deregisterEntityFromPersistenceContext(instance);
});
}
Expand Down Expand Up @@ -893,7 +892,7 @@ public void unregisterObject(Object object) {
if (original != null) {
cloneBuilder.removeVisited(original, repoMap.getEntityDescriptor(object));
}
removeIndirectCollections(object);
removeIndirectWrappers(object);
deregisterEntityFromPersistenceContext(object);
unregisterEntityFromOntologyContext(object);
}
Expand Down Expand Up @@ -1102,18 +1101,18 @@ public Object createIndirectCollection(Object collection, Object owner, Field fi
}

/**
* Remove indirect collection implementations from the specified entity (if present).
* Removes {@link IndirectWrapper} instances from the specified entity (if present).
*
* @param entity The entity to remove indirect collections from
* @param entity The entity to remove indirect wrappers from
*/
private void removeIndirectCollections(Object entity) {
private void removeIndirectWrappers(Object entity) {
assert entity != null;
final EntityType<?> et = entityType(entity.getClass());
for (FieldSpecification<?, ?> fs : et.getFieldSpecifications()) {
final Object value = EntityPropertiesUtils.getFieldValue(fs.getJavaField(), entity);
if (value instanceof IndirectCollection) {
IndirectCollection<?> indCol = (IndirectCollection<?>) value;
EntityPropertiesUtils.setFieldValue(fs.getJavaField(), entity, indCol.unwrap());
if (value instanceof IndirectWrapper) {
IndirectWrapper indirectWrapper = (IndirectWrapper) value;
EntityPropertiesUtils.setFieldValue(fs.getJavaField(), entity, indirectWrapper.unwrap());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,7 @@ static void initOwlClassUMocks(IdentifiableEntityType<OWLClassU> et, SingularAtt
when(singularStringAtt.getJavaType()).thenReturn(OWLClassU.getSingularStringAttField().getType());
when(singularStringAtt.getName()).thenReturn(OWLClassU.getSingularStringAttField().getName());
when(et.getAttribute(OWLClassU.getSingularStringAttField().getName())).thenReturn(singularStringAtt);
when(et.getFieldSpecification(OWLClassU.getSingularStringAttField().getName())).thenReturn(singularStringAtt);
when(singularStringAtt.getPersistentAttributeType()).thenReturn(Attribute.PersistentAttributeType.DATA);
when(singularStringAtt.isCollection()).thenReturn(false);
when(singularStringAtt.getBindableJavaType()).thenReturn(MultilingualString.class);
Expand All @@ -1322,6 +1323,7 @@ static void initOwlClassUMocks(IdentifiableEntityType<OWLClassU> et, SingularAtt
when(pluralStringAtt.getJavaType()).thenReturn(OWLClassU.getPluralStringAttField().getType());
when(pluralStringAtt.getName()).thenReturn(OWLClassU.getPluralStringAttField().getName());
when(et.getAttribute(OWLClassU.getPluralStringAttField().getName())).thenReturn(pluralStringAtt);
when(et.getFieldSpecification(OWLClassU.getPluralStringAttField().getName())).thenReturn(pluralStringAtt);
when(pluralStringAtt.getPersistentAttributeType()).thenReturn(Attribute.PersistentAttributeType.DATA);
when(pluralStringAtt.isCollection()).thenReturn(true);
when(pluralStringAtt.getCollectionType()).thenReturn(CollectionType.SET);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
package cz.cvut.kbss.jopa.sessions;

import cz.cvut.kbss.jopa.adapters.IndirectMap;
import cz.cvut.kbss.jopa.adapters.IndirectMultilingualString;
import cz.cvut.kbss.jopa.adapters.IndirectSet;
import cz.cvut.kbss.jopa.environment.OWLClassA;
import cz.cvut.kbss.jopa.environment.OWLClassB;
import cz.cvut.kbss.jopa.environment.OWLClassD;
import cz.cvut.kbss.jopa.environment.OWLClassF;
import cz.cvut.kbss.jopa.environment.OWLClassL;
import cz.cvut.kbss.jopa.environment.OWLClassR;
import cz.cvut.kbss.jopa.environment.OWLClassU;
import cz.cvut.kbss.jopa.environment.Vocabulary;
import cz.cvut.kbss.jopa.environment.utils.Generators;
import cz.cvut.kbss.jopa.exception.IdentifierNotSetException;
Expand All @@ -35,6 +37,7 @@
import cz.cvut.kbss.jopa.exceptions.OWLPersistenceException;
import cz.cvut.kbss.jopa.model.EntityManagerImpl.State;
import cz.cvut.kbss.jopa.model.LoadState;
import cz.cvut.kbss.jopa.model.MultilingualString;
import cz.cvut.kbss.jopa.model.annotations.ParticipationConstraint;
import cz.cvut.kbss.jopa.model.descriptors.Descriptor;
import cz.cvut.kbss.jopa.model.descriptors.EntityDescriptor;
Expand Down Expand Up @@ -64,10 +67,13 @@
import java.util.stream.Collectors;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
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.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNotSame;
Expand Down Expand Up @@ -1126,4 +1132,15 @@ void isInferredThrowsIllegalArgumentExceptionWhenInstanceIsNotManaged() {
assertThrows(IllegalArgumentException.class, () -> uow.isInferred(entityD, metamodelMocks.forOwlClassD().owlClassAAtt(), entityD.getOwlClassA()));
verify(storageMock, never()).isInferred(any(), any(), any(), any());
}

@Test
void unregisterObjectRemovesIndirectMultilingualStringOfManagedObjectBeingDetached() {
when(transactionMock.isActive()).thenReturn(Boolean.TRUE);
final OWLClassU entityU = new OWLClassU(Generators.createIndividualIdentifier());
entityU.setSingularStringAtt(MultilingualString.create("test", "en"));
final OWLClassU managed = (OWLClassU) uow.registerExistingObject(entityU, descriptor);
assertInstanceOf(IndirectMultilingualString.class, managed.getSingularStringAtt());
uow.unregisterObject(managed);
assertThat(managed.getSingularStringAtt(), not(instanceOf(IndirectMultilingualString.class)));
}
}
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>1.2.0</version>
<version>1.2.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>1.2.0</version>
<version>1.2.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>1.2.0</version>
<version>1.2.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>1.2.0</version>
<version>1.2.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 @@ -18,11 +18,25 @@
package cz.cvut.kbss.jopa.test.runner;

import cz.cvut.kbss.jopa.model.JOPAPersistenceProperties;
import cz.cvut.kbss.jopa.model.SequencesVocabulary;
import cz.cvut.kbss.jopa.model.descriptors.Descriptor;
import cz.cvut.kbss.jopa.model.descriptors.EntityDescriptor;
import cz.cvut.kbss.jopa.model.query.TypedQuery;
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.OWLClassG;
import cz.cvut.kbss.jopa.test.OWLClassI;
import cz.cvut.kbss.jopa.test.OWLClassM;
import cz.cvut.kbss.jopa.test.OWLClassN;
import cz.cvut.kbss.jopa.test.OWLClassP;
import cz.cvut.kbss.jopa.test.OWLClassV;
import cz.cvut.kbss.jopa.test.OWLClassWithQueryAttr;
import cz.cvut.kbss.jopa.test.OWLClassWithQueryAttr2;
import cz.cvut.kbss.jopa.test.OWLClassWithQueryAttr6;
import cz.cvut.kbss.jopa.test.OWLClassWithUrn;
import cz.cvut.kbss.jopa.test.Thing;
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.PersistenceFactory;
Expand All @@ -42,12 +56,26 @@
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.time.LocalDate;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
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.CoreMatchers.hasItems;
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.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;


public abstract class RetrieveOperationsRunner extends BaseRunner {
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>1.2.0</version>
<version>1.2.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>1.2.0</version>
<version>1.2.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>1.2.0</version>
<version>1.2.1</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>1.2.0</version>
<version>1.2.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>1.2.0</version>
<version>1.2.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>1.2.0</version>
<version>1.2.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>1.2.0</version>
<version>1.2.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>1.2.0</version>
<version>1.2.1</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>1.2.0</version>
<version>1.2.1</version>
<artifactId>jopa-all</artifactId>
<packaging>pom</packaging>
<name>JOPA</name>
Expand Down

0 comments on commit 5b51de1

Please sign in to comment.