Skip to content

Commit

Permalink
Merge branch 'master' of /home/keil/eclipse-workspace/abecto
Browse files Browse the repository at this point in the history
  • Loading branch information
jmkeil committed Apr 2, 2020
2 parents 1a42d3a + 2ba924e commit 7e3ee68
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@
import org.apache.jena.query.ResultSet;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.sparql.core.Prologue;
import org.apache.jena.sparql.core.Var;
import org.apache.jena.sparql.lang.sparql_11.ParseException;
import org.apache.jena.sparql.lang.sparql_11.SPARQLParser11;
import org.apache.jena.sparql.syntax.ElementFilter;
import org.apache.jena.sparql.syntax.ElementGroup;
import org.apache.jena.sparql.syntax.PatternVars;
import org.apache.jena.vocabulary.OWL2;
import org.apache.jena.vocabulary.RDF;
import org.apache.jena.vocabulary.RDFS;
import org.apache.jena.vocabulary.SKOS;
import org.apache.jena.vocabulary.XSD;

import com.fasterxml.jackson.annotation.JsonIgnore;

Expand Down Expand Up @@ -66,6 +72,18 @@ public class Category {
@SparqlPattern(subject = "id", predicate = "abecto:ontology")
public UUID ontology;

private final static Prologue DEFAULT_PROLOGUE = new Prologue();

static {
DEFAULT_PROLOGUE.setPrefix("owl", OWL2.getURI());
DEFAULT_PROLOGUE.setPrefix("prov", "http://www.w3.org/ns/prov#");
DEFAULT_PROLOGUE.setPrefix("rdf", RDF.getURI());
DEFAULT_PROLOGUE.setPrefix("rdfs", RDFS.getURI());
DEFAULT_PROLOGUE.setPrefix("schema", "http://schema.org/");
DEFAULT_PROLOGUE.setPrefix("skos", SKOS.getURI());
DEFAULT_PROLOGUE.setPrefix("xsd", XSD.getURI());
}

public Category() {
}

Expand All @@ -83,6 +101,7 @@ public ElementGroup getPatternElementGroup() {
// TODO cache element group (and copy in #contains())
try {
SPARQLParser11 parser = new SPARQLParser11(new ByteArrayInputStream(this.pattern.getBytes()));
parser.setPrologue(DEFAULT_PROLOGUE);
return (ElementGroup) parser.GroupGraphPattern();
} catch (ParseException e) {
throw new IllegalStateException("Failed to parse category pattern.", e);
Expand Down
55 changes: 0 additions & 55 deletions src/main/java/de/uni_jena/cs/fusion/abecto/util/SparqlUtil.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
*/
package de.uni_jena.cs.fusion.abecto.metaentity;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.UUID;

import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -28,8 +29,6 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import de.uni_jena.cs.fusion.abecto.metaentity.Category;

@ExtendWith(SpringExtension.class)
@SpringBootTest
@AutoConfigureMockMvc
Expand All @@ -45,4 +44,15 @@ public void deSerializeation() throws JsonProcessingException {
assertEquals(category, deserialized);
}

@Test
public void defaultPrefixes() throws JsonProcessingException {
new Category("entity", "{?entity owl: ?entity}", UUID.randomUUID());
new Category("entity", "{?entity prov: ?entity}", UUID.randomUUID());
new Category("entity", "{?entity rdf:type ?entity}", UUID.randomUUID());
new Category("entity", "{?entity rdfs:subclassOf ?entity}", UUID.randomUUID());
new Category("entity", "{?entity schema:isPartOf ?entity}", UUID.randomUUID());
new Category("entity", "{?entity skos:broader ?entity}", UUID.randomUUID());
new Category("entity", "{?entity rdfs:label \"String\"^^xsd:string}", UUID.randomUUID());
}

}

0 comments on commit 7e3ee68

Please sign in to comment.