From 95353b950568ff073e1c4b61a9d3d9bb8465c487 Mon Sep 17 00:00:00 2001 From: Maschell Date: Tue, 2 Jan 2018 12:06:59 +0100 Subject: [PATCH] Code formatting --- src/main/java/hsh/ins_jena/App.java | 57 +++++++++++++++++++---------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/src/main/java/hsh/ins_jena/App.java b/src/main/java/hsh/ins_jena/App.java index 9d645ba..77220b6 100644 --- a/src/main/java/hsh/ins_jena/App.java +++ b/src/main/java/hsh/ins_jena/App.java @@ -34,20 +34,13 @@ public class App { } private static void readAndHandleFiles(String inputPath) { - // Model owlTboxModel = FileManager.get().loadModel("file:" + "data/owl.ttl"); - // Model tboxModel = FileManager.get().loadModel("file:" + inputPath + "/" + + // Model tboxModel = FileManager.get().loadModel("file:" + inputPath + "/" // Generator.T_BOX_FILENAME_XML); - // Model aboxModel = FileManager.get().loadModel("file:" + inputPath + "/" + + // Model aboxModel = FileManager.get().loadModel("file:" + inputPath + "/" // Generator.A_BOX_FILENAME_XML); Model tboxModel = FileManager.get().loadModel("file:" + "data/tbox.ttl"); Model aboxModel = FileManager.get().loadModel("file:" + "data/abox.ttl"); - // Combine both models to an RDFS model - /* - * Model tBoxComplete = ModelFactory.createDefaultModel(); - * tBoxComplete.add(owlTboxModel); tBoxComplete.add(aboxModel); - */ - // Let's create an owl reasoner Reasoner reasoner = ReasonerRegistry.getOWLReasoner(); reasoner = reasoner.bindSchema(tboxModel); @@ -67,22 +60,48 @@ public class App { } printResource(infModel, "Switch"); + printResource(infModel, "HomeConsole"); printResource(infModel, "PartyConsole"); printResource(infModel, "NintendoConsole"); + //@formatter:off + // Let's define a bunch of queries - Query queryReleaseYear = QueryFactory.create("PREFIX : <" + Generator.OWN_URI + ">" + "SELECT ?console\n" + "WHERE {\n" - + " ?console :madeBy :Nintendo .\n" + " ?console :releaseYear ?releaseYear . \n" + " FILTER(?releaseYear > 2015)\n" + "}"); + Query queryReleaseYear = QueryFactory.create( + "PREFIX : <" + Generator.OWN_URI + ">" + + "SELECT ?console\n" + "WHERE {\n" + + " ?console :madeBy :Nintendo .\n" + + " ?console :releaseYear ?releaseYear . \n" + + " FILTER(?releaseYear > 2015)\n" + + "}"); - Query queryNintendoConsoles = QueryFactory.create("PREFIX : <" + Generator.OWN_URI + ">" + "PREFIX rdf: <" + Generator.RDF_URI + ">" - + "SELECT ?console\n" + "WHERE {\n" + " ?console rdf:type :NintendoConsole .\n" + "}"); + Query queryNintendoConsoles = QueryFactory.create( + "PREFIX : <" + Generator.OWN_URI + ">" + + "PREFIX rdf: <" + Generator.RDF_URI + ">" + + "SELECT ?console\n" + "WHERE {\n" + + " ?console rdf:type :NintendoConsole .\n" + + "}"); - Query queryCEOForConsole = QueryFactory.create("PREFIX : <" + Generator.OWN_URI + ">" + "PREFIX rdf: <" + Generator.RDF_URI + ">" + "PREFIX rdfs: <" - + Generator.RDFS_URI + ">" + "PREFIX foaf: <" + Generator.FOAF_URI + ">" + "CONSTRUCT {\n" + " ?ceo :isRelatedToConsole ?console .\n" + "}\n" - + "WHERE {\n" + " ?console rdf:type :GameConsole .\n" + " ?console :madeBy ?org .\n" + " ?org :ceo ?ceo .\n" - + " ?ceo rdf:type foaf:Person .\n" + "}\n" + ""); + Query queryCEOForConsole = QueryFactory.create( + "PREFIX : <" + Generator.OWN_URI + ">" + + "PREFIX rdf: <" + Generator.RDF_URI + ">" + + "PREFIX rdfs: <" + Generator.RDFS_URI + ">" + + "PREFIX foaf: <" + Generator.FOAF_URI + ">" + + "CONSTRUCT {\n" + + " ?ceo :isRelatedToConsole ?console .\n" + + "}\n" + + "WHERE {\n" + + " ?console rdf:type :GameConsole .\n" + + " ?console :madeBy ?org .\n" + + " ?org :ceo ?ceo .\n" + + " ?ceo rdf:type foaf:Person .\n" + + "}\n" + ""); - Query queryAll = QueryFactory.create("PREFIX : <" + Generator.OWN_URI + ">" + " " + " SELECT ?s ?p ?p WHERE {" + "?s ?p ?o .}"); + Query queryAll = QueryFactory.create( + "PREFIX : <" + Generator.OWN_URI + ">" + + " SELECT ?s ?p ?p WHERE {" + "?s ?p ?o .}"); + + //@formatter:on // Let's execute one query and print its results QueryExecution queryExecLocalConsoles = QueryExecutionFactory.create(queryAll, infModel); @@ -94,7 +113,7 @@ public class App { printQueryResult(queryExecNintendoConsoles); // Let's do more - QueryExecution queryExecLocalReleaseDate = QueryExecutionFactory.create(queryCEOForConsole, infModel); + QueryExecution queryExecLocalReleaseDate = QueryExecutionFactory.create(queryReleaseYear, infModel); QueryExecution queryExecRemoteReleaseDate = QueryExecutionFactory.sparqlService(SPARQL_ENDPOINT, queryReleaseYear); QueryExecution queryExecLocalCEOtoConsole = QueryExecutionFactory.create(queryCEOForConsole, infModel);