Code formatting

This commit is contained in:
Maschell 2018-01-02 12:06:59 +01:00
parent 506abd85c0
commit 95353b9505
1 changed files with 38 additions and 19 deletions

View File

@ -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);