diff --git a/data/abox.ttl b/data/abox.ttl index 9edfd17..5f4ba8f 100644 --- a/data/abox.ttl +++ b/data/abox.ttl @@ -5,38 +5,42 @@ @prefix foaf: . @prefix rev: . -:Kimishima rdf:type foaf:Person ; +:Kimishima a foaf:Person ; foaf:familyName "Kimishima"^^xsd:string ; foaf:givenName "Tatsumi"^^xsd:string . -:Wii rdf:type :GameConsole . +:Wii a :GameConsole . +:Wii :releaseYear 2006 . :Wii :madeBy :Nintendo . -:Nintendo rdf:type foaf:Organization ; +:Nintendo a foaf:Organization ; :ceo :Kimishima ; :foundingYear 1889 ; foaf:name "Nintendo Co., Ltd."^^xsd:string . -:Wii_u rdf:type :GameConsole ; +:Wii_u a :GameConsole ; :internetEnabled true ; :consoleName "Wii U"^^xsd:string ; - :numOfSupportedControllers 8 ; + :numOfSupportedControllers 8; :predecessorOfConsole :Wii ; :releaseYear 2012 ; :madeBy :Nintendo ; :successorOfConsole :Switch . -:Switch rdf:type :PortableGameConsole . -:Switch :madeBy :Nintendo . -:Switch rev:hasReview :SwitchReviewByJPT . +:Switch a :PortableGameConsole ; + :madeBy :Nintendo ; + :releaseYear 2017 ; + rev:hasReview :SwitchReviewByJPT . + +:Playstation4 a :GameConsole . :JPT rdf:type foaf:Person ; foaf:name "Jan Philipp Timme"^^xsd:string . -:Maschell rdf:type foaf:Person ; +:Maschell a foaf:Person ; foaf:name "Marcel Felix"^^xsd:string . -:SwitchReview rdf:type rev:Review ; +:SwitchReview a rev:Review ; rev:reviewer :JPT ; rev:text "Yet another gaming console. I lost a tetris game once. Meh."^^xsd:string . diff --git a/data/tbox.ttl b/data/tbox.ttl index 810accc..6682b87 100644 --- a/data/tbox.ttl +++ b/data/tbox.ttl @@ -62,27 +62,28 @@ :successorOfConsole rdfs:subPropertyOf :relatedToConsole . # rdfs:subClassOf -:PortableGameConsole rdf:type rdfs:Class . -:GameConsole rdf:type rdfs:Class . +:PortableGameConsole a rdfs:Class . +:GameConsole a rdfs:Class . :PortableGameConsole rdfs:subClassOf :GameConsole . :HomeConsole owl:equivalentClass [ rdf:type owl:Class ; owl:intersectionOf ( - :GameConsole [owl:complementOf :PortableGameConsole] + :GameConsole [ + owl:complementOf :PortableGameConsole + ] ) ] . :NintendoConsole owl:equivalentClass [ rdf:type owl:Restriction ; owl:onProperty :madeBy ; - owl:someValuesFrom :Nintendo + owl:hasValue :Nintendo ] . -:PartyConsole rdf:equivalentClass [ +:PartyConsole owl:equivalentClass [ rdf:type owl:Restriction ; - owl:minQualifiedCardinality "2"^^xsd:nonNegativeInteger ; + owl:minQualifiedCardinality "1"^^xsd:nonNegativeInteger ; owl:onProperty :numOfSupportedControllers ; - owl:onClass :GameConsole -] . - + owl:onClass :GameConsole +] . \ No newline at end of file diff --git a/src/main/java/hsh/ins_jena/App.java b/src/main/java/hsh/ins_jena/App.java index 4fdb1fe..4d5a920 100644 --- a/src/main/java/hsh/ins_jena/App.java +++ b/src/main/java/hsh/ins_jena/App.java @@ -1,8 +1,11 @@ package hsh.ins_jena; import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.util.Iterator; +import org.apache.jena.ontology.OntModel; import org.apache.jena.ontology.OntModelSpec; import org.apache.jena.query.Query; import org.apache.jena.query.QueryExecution; @@ -28,12 +31,12 @@ public class App { public static String OUTPUT_PATH = "./output"; public static String SPARQL_ENDPOINT = "http://localhost:3030/test/query"; - public static void main(String[] args) { + public static void main(String[] args) throws IOException { generateFiles(OUTPUT_PATH); readAndHandleFiles(OUTPUT_PATH); } - private static void readAndHandleFiles(String inputPath) { + private static void readAndHandleFiles(String inputPath) throws IOException { // Model tboxModel = FileManager.get().loadModel("file:" + inputPath + "/" Generator.T_BOX_FILENAME_XML); // Model aboxModel = FileManager.get().loadModel("file:" + inputPath + "/" Generator.A_BOX_FILENAME_XML); Model tboxModel = FileManager.get().loadModel("file:" + "data/tbox.ttl"); @@ -44,19 +47,12 @@ public class App { reasoner = reasoner.bindSchema(tboxModel); OntModelSpec ontModelSpec = OntModelSpec.OWL_DL_MEM_RULE_INF; ontModelSpec.setReasoner(reasoner); - InfModel infModel = ModelFactory.createOntologyModel(ontModelSpec, aboxModel); + InfModel infModel = ModelFactory.createInfModel(reasoner, aboxModel); - ValidityReport validity = infModel.validate(); - if (validity.isValid()) { - System.out.println("Validation: OK"); - } else { - System.out.println("Conflicts"); - for (Iterator i = validity.getReports(); i.hasNext();) { - ValidityReport.Report report = (ValidityReport.Report) i.next(); - System.out.println(" - " + report); - } - } + validate(infModel); + printResource(infModel, "Wii"); + printResource(infModel, "Wii_u"); printResource(infModel, "Switch"); printResource(infModel, "HomeConsole"); printResource(infModel, "PartyConsole"); @@ -102,8 +98,8 @@ public class App { //@formatter:on // Let's execute one query and print its results - QueryExecution queryExecLocalConsoles = QueryExecutionFactory.create(queryAll, infModel); - System.err.println("Show consoles from local model"); + //QueryExecution queryExecLocalConsoles = QueryExecutionFactory.create(queryAll, infModel); + //System.err.println("Show consoles from local model"); // printQueryResult(queryExecLocalConsoles); QueryExecution queryExecNintendoConsoles = QueryExecutionFactory.create(queryNintendoConsoles, infModel); @@ -128,6 +124,20 @@ public class App { printQueryConstructs(queryExecRemoteCEOtoConsole); } + private static void validate(InfModel model) { + ValidityReport validity = model.validate(); + if (validity.isValid()) { + System.out.println("Validation: OK"); + } else { + System.out.println("Conflicts"); + for (Iterator i = validity.getReports(); i.hasNext();) { + ValidityReport.Report report = (ValidityReport.Report) i.next(); + System.out.println(" - " + report); + } + } + + } + private static void printResource(Model model, String resource) { Resource nForce = model.getResource("http://example.com/ins_uebung/#" + resource); System.out.println(resource + "*:");