diff --git a/jopa-impl/src/main/java/cz/cvut/kbss/jopa/oom/converter/ToMultilingualStringConverter.java b/jopa-impl/src/main/java/cz/cvut/kbss/jopa/oom/converter/ToMultilingualStringConverter.java index 3f09e1c18..559a16fed 100644 --- a/jopa-impl/src/main/java/cz/cvut/kbss/jopa/oom/converter/ToMultilingualStringConverter.java +++ b/jopa-impl/src/main/java/cz/cvut/kbss/jopa/oom/converter/ToMultilingualStringConverter.java @@ -19,6 +19,7 @@ import cz.cvut.kbss.jopa.model.MultilingualString; import cz.cvut.kbss.ontodriver.model.LangString; +import cz.cvut.kbss.ontodriver.model.Translations; /** * Supports mapping selected value types to multilingual strings. @@ -30,17 +31,16 @@ public class ToMultilingualStringConverter implements ConverterWrapper type = value.getClass(); assert supportsAxiomValueType(type); - if (value instanceof cz.cvut.kbss.ontodriver.model.MultilingualString) { - return new MultilingualString(((cz.cvut.kbss.ontodriver.model.MultilingualString) value).getValue()); - } else if (value instanceof LangString) { - final LangString ls = (LangString) value; + if (value instanceof Translations translations) { + return new MultilingualString(translations.getValue()); + } else if (value instanceof LangString ls) { return MultilingualString.create(ls.getValue(), ls.getLanguage().orElse(null)); } else { return MultilingualString.create(value.toString(), null); @@ -49,7 +49,7 @@ public MultilingualString convertToAttribute(Object value) { @Override public boolean supportsAxiomValueType(Class type) { - return cz.cvut.kbss.ontodriver.model.MultilingualString.class.isAssignableFrom(type) + return Translations.class.isAssignableFrom(type) || LangString.class.isAssignableFrom(type) || String.class.isAssignableFrom(type); } diff --git a/jopa-impl/src/test/java/cz/cvut/kbss/jopa/oom/converter/ToMultilingualStringConverterTest.java b/jopa-impl/src/test/java/cz/cvut/kbss/jopa/oom/converter/ToMultilingualStringConverterTest.java index bc6ba9851..2a63a4a7c 100644 --- a/jopa-impl/src/test/java/cz/cvut/kbss/jopa/oom/converter/ToMultilingualStringConverterTest.java +++ b/jopa-impl/src/test/java/cz/cvut/kbss/jopa/oom/converter/ToMultilingualStringConverterTest.java @@ -18,7 +18,7 @@ package cz.cvut.kbss.jopa.oom.converter; import cz.cvut.kbss.ontodriver.model.LangString; -import cz.cvut.kbss.ontodriver.model.MultilingualString; +import cz.cvut.kbss.ontodriver.model.Translations; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -45,7 +45,7 @@ void supportsReturnsTrueForSupportedAxiomValueTypes(Class type) { static Stream supportedTypes() { return Stream.of( - Arguments.of(MultilingualString.class), + Arguments.of(Translations.class), Arguments.of(LangString.class), Arguments.of(String.class) ); @@ -61,13 +61,13 @@ void convertToAxiomValueReturnsOntoDriverMultilingualStringWithProvidedValue() { final cz.cvut.kbss.jopa.model.MultilingualString value = cz.cvut.kbss.jopa.model.MultilingualString.create("en", "Test"); final Object result = sut.convertToAxiomValue(value); - assertInstanceOf(MultilingualString.class, result); - assertEquals(value.getValue(), ((MultilingualString) result).getValue()); + assertInstanceOf(Translations.class, result); + assertEquals(value.getValue(), ((Translations) result).getValue()); } @Test void convertToAttributeConvertsOntoDriverMultilingualStringToJopaMultilingualString() { - final MultilingualString value = new MultilingualString(Map.of("en", "Test")); + final Translations value = new Translations(Map.of("en", "Test")); final cz.cvut.kbss.jopa.model.MultilingualString result = sut.convertToAttribute(value); assertEquals(value.getValue(), result.getValue()); diff --git a/ontodriver-api/src/main/java/cz/cvut/kbss/ontodriver/model/MultilingualString.java b/ontodriver-api/src/main/java/cz/cvut/kbss/ontodriver/model/Translations.java similarity index 91% rename from ontodriver-api/src/main/java/cz/cvut/kbss/ontodriver/model/MultilingualString.java rename to ontodriver-api/src/main/java/cz/cvut/kbss/ontodriver/model/Translations.java index d3c440025..83cb44259 100644 --- a/ontodriver-api/src/main/java/cz/cvut/kbss/ontodriver/model/MultilingualString.java +++ b/ontodriver-api/src/main/java/cz/cvut/kbss/ontodriver/model/Translations.java @@ -32,15 +32,15 @@ * string need to be treated as a single value. Its main purpose is to allow support for multilingual strings in * referenced lists (e.g., {@link cz.cvut.kbss.ontodriver.Lists#loadReferencedList(ReferencedListDescriptor)}). */ -public final class MultilingualString implements Serializable { +public final class Translations implements Serializable { private final Map value; - public MultilingualString() { + public Translations() { this.value = new HashMap<>(); } - public MultilingualString(Map value) { + public Translations(Map value) { this.value = new HashMap<>(Objects.requireNonNull(value)); } @@ -79,10 +79,9 @@ public boolean equals(Object o) { if (this == o) { return true; } - if (!(o instanceof MultilingualString)) { + if (!(o instanceof Translations that)) { return false; } - MultilingualString that = (MultilingualString) o; return value.equals(that.value); } diff --git a/ontodriver-jena/src/main/java/cz/cvut/kbss/ontodriver/jena/list/ReferencedListHelper.java b/ontodriver-jena/src/main/java/cz/cvut/kbss/ontodriver/jena/list/ReferencedListHelper.java index 0dc277b42..5a6e9025a 100644 --- a/ontodriver-jena/src/main/java/cz/cvut/kbss/ontodriver/jena/list/ReferencedListHelper.java +++ b/ontodriver-jena/src/main/java/cz/cvut/kbss/ontodriver/jena/list/ReferencedListHelper.java @@ -20,7 +20,7 @@ import cz.cvut.kbss.ontodriver.jena.util.JenaUtils; import cz.cvut.kbss.ontodriver.model.Assertion; import cz.cvut.kbss.ontodriver.model.LangString; -import cz.cvut.kbss.ontodriver.model.MultilingualString; +import cz.cvut.kbss.ontodriver.model.Translations; import cz.cvut.kbss.ontodriver.model.Value; import org.apache.jena.rdf.model.RDFNode; @@ -33,7 +33,7 @@ private ReferencedListHelper() { } static Stream toRdfNodes(Object value, Assertion nodeContentAssertion) { - if (value instanceof MultilingualString mls) { + if (value instanceof Translations mls) { return mls.getValue().entrySet().stream() .map(e -> JenaUtils.valueToRdfNode(nodeContentAssertion, new Value<>(new LangString(e.getValue(), e.getKey())))); } else { diff --git a/ontodriver-jena/src/main/java/cz/cvut/kbss/ontodriver/jena/list/ReferencedListIterator.java b/ontodriver-jena/src/main/java/cz/cvut/kbss/ontodriver/jena/list/ReferencedListIterator.java index ca48b6f0d..646350676 100644 --- a/ontodriver-jena/src/main/java/cz/cvut/kbss/ontodriver/jena/list/ReferencedListIterator.java +++ b/ontodriver-jena/src/main/java/cz/cvut/kbss/ontodriver/jena/list/ReferencedListIterator.java @@ -24,7 +24,7 @@ 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.MultilingualString; +import cz.cvut.kbss.ontodriver.model.Translations; import cz.cvut.kbss.ontodriver.model.NamedResource; import cz.cvut.kbss.ontodriver.model.Value; import org.apache.jena.rdf.model.Literal; @@ -79,7 +79,7 @@ T nextValue() { return (T) (value.isResource() ? NamedResource.create(value.asResource() .getURI()) : JenaUtils.literalToValue(value.asLiteral())); } else { - final MultilingualString mls = new MultilingualString(); + final Translations mls = new Translations(); content.forEach(n -> { assert n.isLiteral(); final Literal lit = n.asLiteral(); diff --git a/ontodriver-jena/src/test/java/cz/cvut/kbss/ontodriver/jena/list/ListTestUtil.java b/ontodriver-jena/src/test/java/cz/cvut/kbss/ontodriver/jena/list/ListTestUtil.java index 5dd60dc34..d93e9b6be 100644 --- a/ontodriver-jena/src/test/java/cz/cvut/kbss/ontodriver/jena/list/ListTestUtil.java +++ b/ontodriver-jena/src/test/java/cz/cvut/kbss/ontodriver/jena/list/ListTestUtil.java @@ -19,7 +19,7 @@ import cz.cvut.kbss.ontodriver.jena.connector.StorageConnector; import cz.cvut.kbss.ontodriver.jena.environment.Generator; -import cz.cvut.kbss.ontodriver.model.MultilingualString; +import cz.cvut.kbss.ontodriver.model.Translations; import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.Statement; @@ -118,10 +118,10 @@ void initReferencedListStatements(List items) { final List contentStatements; if (content instanceof URI) { contentStatements = List.of(createStatement(node, hasContent, createResource(content.toString()))); - } else if (content instanceof MultilingualString) { - contentStatements = ((MultilingualString) content).getValue().entrySet().stream() - .map(e -> createStatement(node, hasContent, createLangLiteral(e.getValue(), e.getKey()))) - .collect(Collectors.toList()); + } else if (content instanceof Translations) { + contentStatements = ((Translations) content).getValue().entrySet().stream() + .map(e -> createStatement(node, hasContent, createLangLiteral(e.getValue(), e.getKey()))) + .collect(Collectors.toList()); } else { contentStatements = List.of(createStatement(node, hasContent, createTypedLiteral(content))); } diff --git a/ontodriver-jena/src/test/java/cz/cvut/kbss/ontodriver/jena/list/ReferencedListHandlerTest.java b/ontodriver-jena/src/test/java/cz/cvut/kbss/ontodriver/jena/list/ReferencedListHandlerTest.java index fa85d87f3..791dd8e36 100644 --- a/ontodriver-jena/src/test/java/cz/cvut/kbss/ontodriver/jena/list/ReferencedListHandlerTest.java +++ b/ontodriver-jena/src/test/java/cz/cvut/kbss/ontodriver/jena/list/ReferencedListHandlerTest.java @@ -25,7 +25,7 @@ import cz.cvut.kbss.ontodriver.model.Assertion; import cz.cvut.kbss.ontodriver.model.Axiom; import cz.cvut.kbss.ontodriver.model.LangString; -import cz.cvut.kbss.ontodriver.model.MultilingualString; +import cz.cvut.kbss.ontodriver.model.Translations; import cz.cvut.kbss.ontodriver.model.NamedResource; import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.RDFNode; @@ -330,12 +330,12 @@ public void loadListRetrievesAllDataPropertyListElements() { @Test void persistListSavesMultilingualStringTranslationsAsContentOfSingleNode() { - final ReferencedListValueDescriptor desc = new ReferencedListValueDescriptor<>(OWNER, - HAS_LIST, - HAS_NEXT, Assertion.createDataPropertyAssertion(HAS_CONTENT.getIdentifier(), false)); - final List refList = List.of( - new MultilingualString(Map.of("en", "one", "cs", "jedna")), - new MultilingualString(Map.of("en", "two", "cs", "dva")) + final ReferencedListValueDescriptor desc = new ReferencedListValueDescriptor<>(OWNER, + HAS_LIST, + HAS_NEXT, Assertion.createDataPropertyAssertion(HAS_CONTENT.getIdentifier(), false)); + final List refList = List.of( + new Translations(Map.of("en", "one", "cs", "jedna")), + new Translations(Map.of("en", "two", "cs", "dva")) ); refList.forEach(desc::addValue); diff --git a/ontodriver-jena/src/test/java/cz/cvut/kbss/ontodriver/jena/list/ReferencedListIteratorTest.java b/ontodriver-jena/src/test/java/cz/cvut/kbss/ontodriver/jena/list/ReferencedListIteratorTest.java index 3e17c3990..351679dd4 100644 --- a/ontodriver-jena/src/test/java/cz/cvut/kbss/ontodriver/jena/list/ReferencedListIteratorTest.java +++ b/ontodriver-jena/src/test/java/cz/cvut/kbss/ontodriver/jena/list/ReferencedListIteratorTest.java @@ -24,7 +24,7 @@ import cz.cvut.kbss.ontodriver.jena.exception.ListProcessingException; import cz.cvut.kbss.ontodriver.model.Assertion; import cz.cvut.kbss.ontodriver.model.Axiom; -import cz.cvut.kbss.ontodriver.model.MultilingualString; +import cz.cvut.kbss.ontodriver.model.Translations; import cz.cvut.kbss.ontodriver.model.NamedResource; import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.Statement; @@ -221,11 +221,11 @@ void nextAxiomReturnsAxiomWithMultilingualStringValueWhenNodeContentIsMultilingu createStatement(node, HAS_CONTENT, createLangLiteral("jedna", "cs")) ); when(connectorMock.find(node, HAS_CONTENT, null, Collections.emptySet())).thenReturn(content); - final ReferencedListIterator sut = new ReferencedListIterator<>(descriptor(Assertion.AssertionType.DATA_PROPERTY, null), connectorMock); + final ReferencedListIterator sut = new ReferencedListIterator<>(descriptor(Assertion.AssertionType.DATA_PROPERTY, null), connectorMock); - final Axiom result = sut.nextAxiom(); + final Axiom result = sut.nextAxiom(); assertNotNull(result); - assertEquals(new MultilingualString(Map.of("en", "one", "cs", "jedna")), result.getValue().getValue()); + assertEquals(new Translations(Map.of("en", "one", "cs", "jedna")), result.getValue().getValue()); } @Test @@ -238,9 +238,9 @@ void replaceReplacesAllTranslationsOfMultilingualStringInCurrentNode() { createStatement(node, HAS_CONTENT, createLangLiteral("jedna", "cs")) ); when(connectorMock.find(node, HAS_CONTENT, null, Collections.emptySet())).thenReturn(content); - final ReferencedListIterator sut = new ReferencedListIterator<>(descriptor(Assertion.AssertionType.DATA_PROPERTY, null), connectorMock); + final ReferencedListIterator sut = new ReferencedListIterator<>(descriptor(Assertion.AssertionType.DATA_PROPERTY, null), connectorMock); - final MultilingualString newContent = new MultilingualString(Map.of( + final Translations newContent = new Translations(Map.of( "en", "New", "cs", "Nový" )); diff --git a/ontodriver-owlapi/src/main/java/cz/cvut/kbss/ontodriver/owlapi/list/ReferencedListIterator.java b/ontodriver-owlapi/src/main/java/cz/cvut/kbss/ontodriver/owlapi/list/ReferencedListIterator.java index f7e1636a3..1050da476 100644 --- a/ontodriver-owlapi/src/main/java/cz/cvut/kbss/ontodriver/owlapi/list/ReferencedListIterator.java +++ b/ontodriver-owlapi/src/main/java/cz/cvut/kbss/ontodriver/owlapi/list/ReferencedListIterator.java @@ -21,7 +21,7 @@ import cz.cvut.kbss.ontodriver.exception.IntegrityConstraintViolatedException; import cz.cvut.kbss.ontodriver.model.Assertion; import cz.cvut.kbss.ontodriver.model.Axiom; -import cz.cvut.kbss.ontodriver.model.MultilingualString; +import cz.cvut.kbss.ontodriver.model.Translations; import cz.cvut.kbss.ontodriver.model.NamedResource; import cz.cvut.kbss.ontodriver.owlapi.AxiomAdapter; import cz.cvut.kbss.ontodriver.owlapi.change.MutableAddAxiom; @@ -158,14 +158,14 @@ protected T extractNodeContent() { return (T) OwlapiUtils.owlLiteralToValue(literal); } } else { - final MultilingualString mls = new MultilingualString(); + final Translations translations = new Translations(); nextItem.forEach(n -> { assert n instanceof OWLLiteral; final OWLLiteral lit = (OWLLiteral) n; assert lit.getLang() != null; - mls.set(lit.getLang(), lit.getLiteral()); + translations.set(lit.getLang(), lit.getLiteral()); }); - return (T) mls; + return (T) translations; } } diff --git a/ontodriver-owlapi/src/main/java/cz/cvut/kbss/ontodriver/owlapi/list/ReferencedListNodeGenerator.java b/ontodriver-owlapi/src/main/java/cz/cvut/kbss/ontodriver/owlapi/list/ReferencedListNodeGenerator.java index aac376e28..b6b8fc5f7 100644 --- a/ontodriver-owlapi/src/main/java/cz/cvut/kbss/ontodriver/owlapi/list/ReferencedListNodeGenerator.java +++ b/ontodriver-owlapi/src/main/java/cz/cvut/kbss/ontodriver/owlapi/list/ReferencedListNodeGenerator.java @@ -22,7 +22,7 @@ import cz.cvut.kbss.ontodriver.model.Assertion; import cz.cvut.kbss.ontodriver.model.AxiomImpl; import cz.cvut.kbss.ontodriver.model.LangString; -import cz.cvut.kbss.ontodriver.model.MultilingualString; +import cz.cvut.kbss.ontodriver.model.Translations; import cz.cvut.kbss.ontodriver.model.NamedResource; import cz.cvut.kbss.ontodriver.model.Value; import cz.cvut.kbss.ontodriver.owlapi.AxiomAdapter; @@ -80,8 +80,8 @@ Collection generateNodeContent(NamedResource node, V va return List.of(new MutableAddAxiom(ontology, valueAxiom)); } else { assert descriptor.getNodeContent().getType() == Assertion.AssertionType.DATA_PROPERTY; - if (value instanceof MultilingualString) { - final MultilingualString mls = (MultilingualString) value; + if (value instanceof Translations) { + final Translations mls = (Translations) value; return mls.getValue().entrySet().stream().map(e -> { final String lang = e.getKey(); final String val = e.getValue(); diff --git a/ontodriver-owlapi/src/test/java/cz/cvut/kbss/ontodriver/owlapi/list/ReferencedListHandlerTest.java b/ontodriver-owlapi/src/test/java/cz/cvut/kbss/ontodriver/owlapi/list/ReferencedListHandlerTest.java index 56e396c2c..cdbb476db 100644 --- a/ontodriver-owlapi/src/test/java/cz/cvut/kbss/ontodriver/owlapi/list/ReferencedListHandlerTest.java +++ b/ontodriver-owlapi/src/test/java/cz/cvut/kbss/ontodriver/owlapi/list/ReferencedListHandlerTest.java @@ -24,7 +24,7 @@ import cz.cvut.kbss.ontodriver.model.Assertion; import cz.cvut.kbss.ontodriver.model.Axiom; import cz.cvut.kbss.ontodriver.model.LangString; -import cz.cvut.kbss.ontodriver.model.MultilingualString; +import cz.cvut.kbss.ontodriver.model.Translations; import cz.cvut.kbss.ontodriver.model.NamedResource; import cz.cvut.kbss.ontodriver.owlapi.OwlapiAdapter; import cz.cvut.kbss.ontodriver.owlapi.connector.OntologySnapshot; @@ -382,11 +382,11 @@ public void loadListLoadsListWithDataPropertyValues() { @Test void persistListSavesMultilingualStringTranslationsAsContentOfSingleNode() { - final List refList = List.of( - new MultilingualString(Map.of("en", "one", "cs", "jedna")), - new MultilingualString(Map.of("en", "two", "cs", "dva")) + final List refList = List.of( + new Translations(Map.of("en", "one", "cs", "jedna")), + new Translations(Map.of("en", "two", "cs", "dva")) ); - final ReferencedListValueDescriptor valueDescriptor = new ReferencedListValueDescriptor<>(ListTestHelper.SUBJECT, ListTestHelper.HAS_LIST, ListTestHelper.HAS_NEXT, Assertion.createDataPropertyAssertion(URI.create(ListTestHelper.HAS_CONTENT_PROPERTY), false)); + final ReferencedListValueDescriptor valueDescriptor = new ReferencedListValueDescriptor<>(ListTestHelper.SUBJECT, ListTestHelper.HAS_LIST, ListTestHelper.HAS_NEXT, Assertion.createDataPropertyAssertion(URI.create(ListTestHelper.HAS_CONTENT_PROPERTY), false)); refList.forEach(valueDescriptor::addValue); sut.persistList(valueDescriptor); diff --git a/ontodriver-owlapi/src/test/java/cz/cvut/kbss/ontodriver/owlapi/list/ReferencedListIteratorTest.java b/ontodriver-owlapi/src/test/java/cz/cvut/kbss/ontodriver/owlapi/list/ReferencedListIteratorTest.java index 9897bc643..116ba95c4 100644 --- a/ontodriver-owlapi/src/test/java/cz/cvut/kbss/ontodriver/owlapi/list/ReferencedListIteratorTest.java +++ b/ontodriver-owlapi/src/test/java/cz/cvut/kbss/ontodriver/owlapi/list/ReferencedListIteratorTest.java @@ -20,7 +20,7 @@ import cz.cvut.kbss.ontodriver.descriptor.ReferencedListDescriptor; import cz.cvut.kbss.ontodriver.descriptor.ReferencedListDescriptorImpl; import cz.cvut.kbss.ontodriver.model.Assertion; -import cz.cvut.kbss.ontodriver.model.MultilingualString; +import cz.cvut.kbss.ontodriver.model.Translations; import cz.cvut.kbss.ontodriver.model.NamedResource; import cz.cvut.kbss.ontodriver.owlapi.change.TransactionalChange; import org.junit.jupiter.api.BeforeEach; @@ -72,17 +72,17 @@ OwlapiListIterator iterator() { @Test void nextValueAllowsMultipleNodeContentStatementsWhenTheyRepresentTranslationsOfString() { - initMultilingualStringList(List.of(new MultilingualString(Map.of( + initMultilingualStringList(List.of(new Translations(Map.of( "en", "One", "cs", "Jedna" )))); final ReferencedListDescriptor descriptor = new ReferencedListDescriptorImpl(ListTestHelper.SUBJECT, ListTestHelper.HAS_LIST, ListTestHelper.HAS_NEXT, Assertion.createDataPropertyAssertion(URI.create(HAS_CONTENT_PROPERTY), false)); - final OwlapiListIterator sut = new ReferencedListIterator<>(descriptor, snapshot, axiomAdapter); + final OwlapiListIterator sut = new ReferencedListIterator<>(descriptor, snapshot, axiomAdapter); assertDoesNotThrow(sut::nextValue); } - private void initMultilingualStringList(List list) { + private void initMultilingualStringList(List list) { final OWLDataFactory dataFactory = snapshot.getDataFactory(); final OWLOntology ontology = snapshot.getOntology(); final OWLObjectProperty hasList = dataFactory.getOWLObjectProperty(IRI.create(HAS_LIST_PROPERTY)); @@ -93,7 +93,7 @@ private void initMultilingualStringList(List list) { final String sequenceNodeBase = ListTestHelper.SUBJECT.getIdentifier() + SEQUENCE_NODE_SUFFIX; OWLNamedIndividual previousNode = dataFactory.getOWLNamedIndividual(SUBJECT); OWLNamedIndividual node = dataFactory.getOWLNamedIndividual(IRI.create(sequenceNodeBase + i)); - for (MultilingualString mls : list) { + for (Translations mls : list) { snapshot.getOntologyManager() .addAxiom(ontology, dataFactory.getOWLObjectPropertyAssertionAxiom(next, previousNode, node)); for (Map.Entry e : mls.getValue().entrySet()) { @@ -108,29 +108,29 @@ private void initMultilingualStringList(List list) { @Test void nextValueReturnsMultilingualStringWhenNodeContentAreTranslationsOfString() { - final MultilingualString mls = new MultilingualString(Map.of( + final Translations mls = new Translations(Map.of( "en", "One", "cs", "Jedna" )); initMultilingualStringList(List.of(mls)); final ReferencedListDescriptor descriptor = new ReferencedListDescriptorImpl(ListTestHelper.SUBJECT, ListTestHelper.HAS_LIST, ListTestHelper.HAS_NEXT, Assertion.createDataPropertyAssertion(URI.create(HAS_CONTENT_PROPERTY), false)); - final OwlapiListIterator sut = new ReferencedListIterator<>(descriptor, snapshot, axiomAdapter); + final OwlapiListIterator sut = new ReferencedListIterator<>(descriptor, snapshot, axiomAdapter); assertEquals(mls, sut.nextValue()); } @Test void replaceNodeReplacesAllTranslationAxiomsWhenNodeContainsTranslationsOfString() { - final MultilingualString oldMls = new MultilingualString(Map.of( + final Translations oldMls = new Translations(Map.of( "en", "One", "cs", "Jedna" )); initMultilingualStringList(List.of(oldMls)); final ReferencedListDescriptor descriptor = new ReferencedListDescriptorImpl(ListTestHelper.SUBJECT, ListTestHelper.HAS_LIST, ListTestHelper.HAS_NEXT, Assertion.createDataPropertyAssertion(URI.create(HAS_CONTENT_PROPERTY), false)); - final OwlapiListIterator sut = new ReferencedListIterator<>(descriptor, snapshot, axiomAdapter); - final MultilingualString newMls = new MultilingualString(Map.of( + final OwlapiListIterator sut = new ReferencedListIterator<>(descriptor, snapshot, axiomAdapter); + final Translations newMls = new Translations(Map.of( "en", "New one", "cs", "Nová jedna" )); diff --git a/ontodriver-rdf4j/src/main/java/cz/cvut/kbss/ontodriver/rdf4j/list/ReferencedListHelper.java b/ontodriver-rdf4j/src/main/java/cz/cvut/kbss/ontodriver/rdf4j/list/ReferencedListHelper.java index 8f751a480..ca04a9d48 100644 --- a/ontodriver-rdf4j/src/main/java/cz/cvut/kbss/ontodriver/rdf4j/list/ReferencedListHelper.java +++ b/ontodriver-rdf4j/src/main/java/cz/cvut/kbss/ontodriver/rdf4j/list/ReferencedListHelper.java @@ -19,7 +19,7 @@ import cz.cvut.kbss.ontodriver.model.Assertion; import cz.cvut.kbss.ontodriver.model.LangString; -import cz.cvut.kbss.ontodriver.model.MultilingualString; +import cz.cvut.kbss.ontodriver.model.Translations; import cz.cvut.kbss.ontodriver.rdf4j.exception.Rdf4jDriverException; import cz.cvut.kbss.ontodriver.rdf4j.util.ValueConverter; import org.eclipse.rdf4j.model.Value; @@ -36,8 +36,8 @@ class ReferencedListHelper { ReferencedListHelper(ValueConverter valueConverter) {this.valueConverter = valueConverter;} Collection toRdf4jValue(Assertion a, Object value) throws Rdf4jDriverException { - if (value instanceof MultilingualString) { - final MultilingualString mls = (MultilingualString) value; + if (value instanceof Translations) { + final Translations mls = (Translations) value; final List values = new ArrayList<>(mls.getValue().size()); for (Map.Entry e : mls.getValue().entrySet()) { values.add(valueConverter.toRdf4jValue(a, new cz.cvut.kbss.ontodriver.model.Value<>(new LangString(e.getValue(), e.getKey())))); diff --git a/ontodriver-rdf4j/src/main/java/cz/cvut/kbss/ontodriver/rdf4j/list/ReferencedListIterator.java b/ontodriver-rdf4j/src/main/java/cz/cvut/kbss/ontodriver/rdf4j/list/ReferencedListIterator.java index 25cacdb7d..2773562e5 100644 --- a/ontodriver-rdf4j/src/main/java/cz/cvut/kbss/ontodriver/rdf4j/list/ReferencedListIterator.java +++ b/ontodriver-rdf4j/src/main/java/cz/cvut/kbss/ontodriver/rdf4j/list/ReferencedListIterator.java @@ -21,7 +21,7 @@ import cz.cvut.kbss.ontodriver.exception.IntegrityConstraintViolatedException; import cz.cvut.kbss.ontodriver.model.Axiom; import cz.cvut.kbss.ontodriver.model.AxiomImpl; -import cz.cvut.kbss.ontodriver.model.MultilingualString; +import cz.cvut.kbss.ontodriver.model.Translations; import cz.cvut.kbss.ontodriver.model.NamedResource; import cz.cvut.kbss.ontodriver.model.Value; import cz.cvut.kbss.ontodriver.rdf4j.connector.RepoConnection; @@ -131,7 +131,7 @@ public T currentContent() { if (currentContent.size() == 1) { return (T) fromRdf4jValue(currentContent.iterator().next().getObject()); } else { - final MultilingualString mls = currentContentToMultilingualString(); + final Translations mls = currentContentToMultilingualString(); return (T) mls; } } @@ -150,13 +150,13 @@ public Axiom nextAxiom() throws Rdf4jDriverException { listDescriptor.getNodeContent(), new Value<>(fromRdf4jValue(obj))); } - final MultilingualString mls = currentContentToMultilingualString(); + final Translations mls = currentContentToMultilingualString(); return new AxiomImpl(NamedResource.create(currentContent.iterator().next().getSubject().stringValue()), listDescriptor.getNodeContent(), new Value<>(mls)); } - private MultilingualString currentContentToMultilingualString() { - final MultilingualString mls = new MultilingualString(); + private Translations currentContentToMultilingualString() { + final Translations mls = new Translations(); currentContent.forEach(s -> { assert s.getObject().isLiteral(); final Literal literal = (Literal) s.getObject(); diff --git a/ontodriver-rdf4j/src/test/java/cz/cvut/kbss/ontodriver/rdf4j/list/ReferencedListHandlerTest.java b/ontodriver-rdf4j/src/test/java/cz/cvut/kbss/ontodriver/rdf4j/list/ReferencedListHandlerTest.java index 6a9dad7d9..f95e565fa 100644 --- a/ontodriver-rdf4j/src/test/java/cz/cvut/kbss/ontodriver/rdf4j/list/ReferencedListHandlerTest.java +++ b/ontodriver-rdf4j/src/test/java/cz/cvut/kbss/ontodriver/rdf4j/list/ReferencedListHandlerTest.java @@ -24,7 +24,7 @@ import cz.cvut.kbss.ontodriver.model.Assertion; import cz.cvut.kbss.ontodriver.model.Axiom; import cz.cvut.kbss.ontodriver.model.LangString; -import cz.cvut.kbss.ontodriver.model.MultilingualString; +import cz.cvut.kbss.ontodriver.model.Translations; import cz.cvut.kbss.ontodriver.model.NamedResource; import cz.cvut.kbss.ontodriver.rdf4j.connector.RepoConnection; import cz.cvut.kbss.ontodriver.rdf4j.environment.Generator; @@ -390,11 +390,11 @@ public void loadsReferencedListConsistingOfLiterals() throws Exception { @Test void persistListSavesMultilingualStringTranslationsAsContentOfSingleNode() throws Exception { - final List refList = List.of( - new MultilingualString(Map.of("en", "one", "cs", "jedna")), - new MultilingualString(Map.of("en", "two", "cs", "dva")) + final List refList = List.of( + new Translations(Map.of("en", "one", "cs", "jedna")), + new Translations(Map.of("en", "two", "cs", "dva")) ); - final ReferencedListValueDescriptor desc = createValueDescriptor(Assertion.AssertionType.DATA_PROPERTY, false); + final ReferencedListValueDescriptor desc = createValueDescriptor(Assertion.AssertionType.DATA_PROPERTY, false); refList.forEach(desc::addValue); sut.persistList(desc); diff --git a/ontodriver-rdf4j/src/test/java/cz/cvut/kbss/ontodriver/rdf4j/list/ReferencedListIteratorTest.java b/ontodriver-rdf4j/src/test/java/cz/cvut/kbss/ontodriver/rdf4j/list/ReferencedListIteratorTest.java index 1808274b7..a41e79624 100644 --- a/ontodriver-rdf4j/src/test/java/cz/cvut/kbss/ontodriver/rdf4j/list/ReferencedListIteratorTest.java +++ b/ontodriver-rdf4j/src/test/java/cz/cvut/kbss/ontodriver/rdf4j/list/ReferencedListIteratorTest.java @@ -22,7 +22,7 @@ import cz.cvut.kbss.ontodriver.exception.IntegrityConstraintViolatedException; import cz.cvut.kbss.ontodriver.model.Assertion; import cz.cvut.kbss.ontodriver.model.Axiom; -import cz.cvut.kbss.ontodriver.model.MultilingualString; +import cz.cvut.kbss.ontodriver.model.Translations; import cz.cvut.kbss.ontodriver.model.NamedResource; import cz.cvut.kbss.ontodriver.rdf4j.connector.RepoConnection; import cz.cvut.kbss.ontodriver.rdf4j.environment.Generator; @@ -86,7 +86,7 @@ void nextNodeAllowsMultipleTranslationsOfStringAsNodeContentValues() throws Exce List.of(VF.createStatement(node, ReferencedListHandlerTest.nodeContentProperty, VF.createLiteral("One", "en")), VF.createStatement(node, ReferencedListHandlerTest.nodeContentProperty, VF.createLiteral("Jedna", "cs"))) ); - final ReferencedListIterator sut = new ReferencedListIterator<>( + final ReferencedListIterator sut = new ReferencedListIterator<>( descriptor(Assertion.createDataPropertyAssertion(URI.create(ListHandlerTestHelper.NODE_CONTENT_PROPERTY), false)), connector, VF); @@ -102,13 +102,13 @@ void nextAxiomReturnsAxiomWithMultilingualStringWhenNodeContentIsMultilingualStr List.of(VF.createStatement(node, ReferencedListHandlerTest.nodeContentProperty, VF.createLiteral("One", "en")), VF.createStatement(node, ReferencedListHandlerTest.nodeContentProperty, VF.createLiteral("Jedna", "cs"))) ); - final ReferencedListIterator sut = new ReferencedListIterator<>( + final ReferencedListIterator sut = new ReferencedListIterator<>( descriptor(Assertion.createDataPropertyAssertion(URI.create(ListHandlerTestHelper.NODE_CONTENT_PROPERTY), false)), connector, VF); - final Axiom result = sut.nextAxiom(); + final Axiom result = sut.nextAxiom(); assertNotNull(result); - assertEquals(new MultilingualString(Map.of("en", "One", "cs", "Jedna")), result.getValue().getValue()); + assertEquals(new Translations(Map.of("en", "One", "cs", "Jedna")), result.getValue().getValue()); } @Test @@ -120,13 +120,13 @@ void currentContentReturnsMultilingualStringWhenNodeContentIsMultilingualString( List.of(VF.createStatement(node, ReferencedListHandlerTest.nodeContentProperty, VF.createLiteral("One", "en")), VF.createStatement(node, ReferencedListHandlerTest.nodeContentProperty, VF.createLiteral("Jedna", "cs"))) ); - final ReferencedListIterator sut = new ReferencedListIterator<>( + final ReferencedListIterator sut = new ReferencedListIterator<>( descriptor(Assertion.createDataPropertyAssertion(URI.create(ListHandlerTestHelper.NODE_CONTENT_PROPERTY), false)), connector, VF); sut.nextNode(); - final MultilingualString result = sut.currentContent(); - assertEquals(new MultilingualString(Map.of("en", "One", "cs", "Jedna")), result); + final Translations result = sut.currentContent(); + assertEquals(new Translations(Map.of("en", "One", "cs", "Jedna")), result); } @Test @@ -138,11 +138,11 @@ void replaceCurrentWithReplacesMultilingualStringStatementsWithProvidedValues() List.of(VF.createStatement(node, ReferencedListHandlerTest.nodeContentProperty, VF.createLiteral("One", "en")), VF.createStatement(node, ReferencedListHandlerTest.nodeContentProperty, VF.createLiteral("Jedna", "cs"))) ); - final ReferencedListIterator sut = new ReferencedListIterator<>( + final ReferencedListIterator sut = new ReferencedListIterator<>( descriptor(Assertion.createDataPropertyAssertion(URI.create(ListHandlerTestHelper.NODE_CONTENT_PROPERTY), false)), connector, VF); - final MultilingualString newValue = new MultilingualString(Map.of("en", "new one", "cs", "nová jedna")); + final Translations newValue = new Translations(Map.of("en", "new one", "cs", "nová jedna")); sut.nextNode(); sut.replaceCurrentWith(newValue); verify(connector).removeStatements(List.of(