Mercurial > repos > mikel-egana-aranguren > sparql_galaxy
annotate src/es/cbgp/galaxy/sparql/main/Main.java @ 2:b8bf1af83841 draft
Paste query added, query engine improved, examples added
author | Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu> |
---|---|
date | Wed, 04 Dec 2013 08:17:00 +0100 |
parents | 137f9a4a6337 |
children |
rev | line source |
---|---|
0
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
1 package es.cbgp.galaxy.sparql.main; |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
2 |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
3 import java.io.File; |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
4 |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
5 import es.cbgp.galaxy.sparql.jena.OntologyManager; |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
6 |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
7 public class Main { |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
8 |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
9 public Main(String args[]) { |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
10 Result r = check(args); |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
11 if (r.getBoolValue()) { |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
12 String ontFile = args[0]; |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
13 String sparqlFile = args[1]; |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
14 run(ontFile, sparqlFile); |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
15 } else { |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
16 System.err.println("Error: " + r.getMessage()); |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
17 } |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
18 } |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
19 |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
20 private void run(String ontFile, String sparqlFile) { |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
21 try { |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
22 OntologyManager om = new OntologyManager(ontFile, sparqlFile); |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
23 om.executeQuery(); |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
24 } catch (Exception e) { |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
25 e.printStackTrace(); |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
26 } |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
27 } |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
28 |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
29 private Result check(String[] args) { |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
30 if (args.length == 2) { |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
31 String fo = args[0]; |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
32 String fs = args[1]; |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
33 if (new File(fo).exists()) { |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
34 if (new File(fs).exists()) { |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
35 return new Result(true); |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
36 } else { |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
37 return new Result(false, |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
38 "Ontology file exists. SPARQL file not!"); |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
39 } |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
40 } |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
41 return new Result(false, "Ontology file not exists!"); |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
42 } |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
43 return new Result(false, |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
44 "Incorrect number of parameters. Necessary 2: " + args.length); |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
45 } |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
46 |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
47 public static void main(String[] args) { |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
48 /* |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
49 * Input: ontologia "SELECT .... blala" |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
50 */ |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
51 new Main(args); |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
52 } |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
53 |
137f9a4a6337
First version to init the repo, still README etc to add but it works
mikel-egana-aranguren
parents:
diff
changeset
|
54 } |