Mercurial > repos > mikel-egana-aranguren > sadi_generic
comparison src/info/wilkinsonlab/sadi/galaxy/SADIGenericClient.java @ 2:977c838e3442 draft default tip
New dir structure, README improved, tests added and RDF merge tool created
author | mikel-egana-aranguren <mikel.egana.aranguren@gmail.com> |
---|---|
date | Fri, 25 Apr 2014 14:41:12 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1:bb17b69a74c5 | 2:977c838e3442 |
---|---|
1 package info.wilkinsonlab.sadi.galaxy; | |
2 | |
3 import java.io.InputStream; | |
4 import java.util.Collection; | |
5 | |
6 import org.apache.log4j.Logger; | |
7 | |
8 import org.sadiframework.SADIException; | |
9 import org.sadiframework.client.Service; | |
10 import org.sadiframework.client.ServiceFactory; | |
11 | |
12 import com.hp.hpl.jena.rdf.model.Model; | |
13 import com.hp.hpl.jena.rdf.model.ModelFactory; | |
14 import com.hp.hpl.jena.rdf.model.Resource; | |
15 import com.hp.hpl.jena.util.FileManager; | |
16 | |
17 public class SADIGenericClient { | |
18 | |
19 /** | |
20 * @param service_URL | |
21 * @param input_RDF | |
22 * | |
23 * Given an RDF input and a service URL, infers whether the RDF | |
24 * complies with the service and if so executes it | |
25 * | |
26 */ | |
27 | |
28 // private static final Logger log = Logger.getLogger(SADIGenericClient.class); | |
29 public static void main(String[] args) { | |
30 String service_URL = args[0]; | |
31 String input_RDF = args[1]; | |
32 | |
33 Service service; | |
34 try { | |
35 service = ServiceFactory.createService(service_URL.trim()); | |
36 } | |
37 catch (SADIException e) { | |
38 System.out.println("[ERROR] Error creating service object: "); | |
39 System.out.println(e.getMessage()); | |
40 e.printStackTrace(); | |
41 service = null; | |
42 } | |
43 | |
44 if (service != null) { | |
45 | |
46 Model model = ModelFactory.createOntologyModel(); | |
47 InputStream in = FileManager.get().open(input_RDF); | |
48 model.read(in, null); | |
49 | |
50 try { | |
51 Collection<Resource> inputs = service.discoverInputInstances(model); | |
52 Model output = service.invokeService(inputs); | |
53 output.write(System.out, "RDF/XML"); | |
54 output.close(); | |
55 } | |
56 catch (SADIException e) { | |
57 System.out.println("[ERROR] Error invoking service: "); | |
58 System.out.println(e.getMessage()); | |
59 e.printStackTrace(); | |
60 } | |
61 } | |
62 } | |
63 } |