diff --git a/inception/inception-kb/NOTICE.txt b/inception/inception-kb/NOTICE.txt deleted file mode 100644 index 84605e6da07..00000000000 --- a/inception/inception-kb/NOTICE.txt +++ /dev/null @@ -1,4 +0,0 @@ -de.tudarmstadt.ukp.inception.kb.querybuilder.backport.Bind: - - Copied from RDF4J 4.0.0 (https://github.com/eclipse/rdf4j) - License: Eclipse Distribution License v1.0 diff --git a/inception/inception-kb/src/main/java/de/tudarmstadt/ukp/inception/kb/querybuilder/SPARQLQueryBuilder.java b/inception/inception-kb/src/main/java/de/tudarmstadt/ukp/inception/kb/querybuilder/SPARQLQueryBuilder.java index 4236c389de0..287d220472d 100644 --- a/inception/inception-kb/src/main/java/de/tudarmstadt/ukp/inception/kb/querybuilder/SPARQLQueryBuilder.java +++ b/inception/inception-kb/src/main/java/de/tudarmstadt/ukp/inception/kb/querybuilder/SPARQLQueryBuilder.java @@ -39,6 +39,7 @@ import static java.util.stream.Stream.concat; import static org.apache.commons.lang3.StringUtils.isBlank; import static org.eclipse.rdf4j.sparqlbuilder.constraint.Expressions.and; +import static org.eclipse.rdf4j.sparqlbuilder.constraint.Expressions.bind; import static org.eclipse.rdf4j.sparqlbuilder.constraint.Expressions.function; import static org.eclipse.rdf4j.sparqlbuilder.constraint.Expressions.notEquals; import static org.eclipse.rdf4j.sparqlbuilder.constraint.Expressions.or; @@ -115,7 +116,6 @@ import de.tudarmstadt.ukp.inception.kb.graph.KBHandle; import de.tudarmstadt.ukp.inception.kb.graph.KBObject; import de.tudarmstadt.ukp.inception.kb.model.KnowledgeBase; -import de.tudarmstadt.ukp.inception.kb.querybuilder.backport.Bind; /** * Build queries against the KB. @@ -1177,7 +1177,7 @@ private GraphPattern withLabelMatchingAnyOf_RDF4J_FTS(String[] aValues) .has(FTS_LUCENE, bNode(LUCENE_QUERY, literalOf(fuzzyQuery)) // .andHas(LUCENE_PROPERTY, VAR_MATCH_TERM_PROPERTY) .andHas(LUCENE_SNIPPET, var("snippet"))) - .and(new Bind( + .and(bind( function(REPLACE, function(REPLACE, var("snippet"), literalOf(""), literalOf("")), @@ -1827,9 +1827,10 @@ private GraphPattern isPropertyPattern() // An item is a property if ... // ... it is explicitly defined as being a property - propertyPatterns.add(VAR_SUBJECT.has( - PropertyPathBuilder.of(typeOfProperty).then(pSubClass).zeroOrMore().build(), + propertyPatterns.add(VAR_SUBJECT.has(typeOfProperty, propertyIri)); + propertyPatterns.add(VAR_SUBJECT.has(PropertyPathBuilder.of(pSubClass).oneOrMore().build(), propertyIri)); + // propertyPatterns.add(VAR_SUBJECT.has(typeOfProperty, propertyIri)); // ... it has any subproperties propertyPatterns.add(bNode().has(subPropertyProperty, VAR_SUBJECT)); // ... it has any superproperties diff --git a/inception/inception-kb/src/main/java/de/tudarmstadt/ukp/inception/kb/querybuilder/backport/Bind.java b/inception/inception-kb/src/main/java/de/tudarmstadt/ukp/inception/kb/querybuilder/backport/Bind.java deleted file mode 100644 index e9854874834..00000000000 --- a/inception/inception-kb/src/main/java/de/tudarmstadt/ukp/inception/kb/querybuilder/backport/Bind.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2021 Eclipse RDF4J contributors. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Distribution License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - */ -package de.tudarmstadt.ukp.inception.kb.querybuilder.backport; - -import org.eclipse.rdf4j.sparqlbuilder.core.Assignable; -import org.eclipse.rdf4j.sparqlbuilder.core.Variable; -import org.eclipse.rdf4j.sparqlbuilder.graphpattern.GraphPattern; -import org.eclipse.rdf4j.sparqlbuilder.util.SparqlBuilderUtils; - -/** - * @since 4.0.0 - * @author Florian Kleedorfer - */ -public class Bind - implements GraphPattern -{ - private static final String AS = " AS "; - private Assignable expression; - private Variable var; - - public Bind(Assignable exp, Variable var) - { - this.expression = exp; - this.var = var; - } - - @Override - public String getQueryString() - { - return "BIND" + SparqlBuilderUtils - .getParenthesizedString(expression.getQueryString() + AS + var.getQueryString()); - } -} diff --git a/inception/inception-kb/src/test/java/de/tudarmstadt/ukp/inception/kb/KnowledgeBaseServiceImplIntegrationTest.java b/inception/inception-kb/src/test/java/de/tudarmstadt/ukp/inception/kb/KnowledgeBaseServiceImplIntegrationTest.java index 6469fb04be0..698a68a8277 100644 --- a/inception/inception-kb/src/test/java/de/tudarmstadt/ukp/inception/kb/KnowledgeBaseServiceImplIntegrationTest.java +++ b/inception/inception-kb/src/test/java/de/tudarmstadt/ukp/inception/kb/KnowledgeBaseServiceImplIntegrationTest.java @@ -406,8 +406,16 @@ public void nonempty_WithEmptyKnowledgeBase_ShouldReturnTrue(Reification reifica String[] expectedProps = { kb.getSubclassIri(), kb.getLabelIri(), kb.getDescriptionIri(), kb.getTypeIri() }; - assertEquals(listProperties.size(), 5); - assertThat(listIdentifier).as("Check that base properties are created") + assertThat(listProperties) // + .extracting(KBProperty::getIdentifier) // + .containsExactly( // + "http://www.w3.org/2000/01/rdf-schema#comment", + "http://www.w3.org/2000/01/rdf-schema#label", + "http://www.w3.org/2000/01/rdf-schema#subClassOf", + "http://www.w3.org/2000/01/rdf-schema#subPropertyOf", + "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"); + assertThat(listIdentifier) // + .as("Check that base properties are created") // .contains(expectedProps); }