[MOBY-guts] biomoby commit
Eddie Kawas
kawas at pub.open-bio.org
Fri Oct 21 17:45:01 UTC 2005
kawas
Fri Oct 21 13:45:01 EDT 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended
In directory pub.open-bio.org:/tmp/cvs-serv2292/org/biomoby/shared/extended
Modified Files:
ServiceTypeParser.java
Log Message:
added the parsing logic for the rdf document describing the service type ontology.
moby-live/Java/src/main/org/biomoby/shared/extended ServiceTypeParser.java,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/ServiceTypeParser.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/ServiceTypeParser.java 2005/10/18 18:37:13 1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/ServiceTypeParser.java 2005/10/21 17:45:01 1.2
@@ -14,6 +14,9 @@
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.RDFReader;
+import com.hp.hpl.jena.rdf.model.ResIterator;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.vocabulary.RDFS;
/**
*
@@ -139,7 +142,21 @@
Model model = ModelFactory.createDefaultModel();
RDFReader reader = model.getReader();
reader.read(model, new StringReader(getRdfAsString()), null);
- // TODO start querying the model and creating Service Type objects
+ // start querying the model and creating Service Type objects
+ ResIterator iterator = model.listSubjects();
+ while (iterator.hasNext()) {
+ Resource resource = iterator.nextResource();
+ String name = resource.getLocalName();
+ MobyServiceType servicetype = new MobyServiceType(name);
+ if (!resource.hasProperty(RDFS.subClassOf)) {
+ continue;
+ }
+ String parent = resource.getProperty(RDFS.subClassOf).getObject().toString();
+ servicetype.setParentNames(new String[] {parent});
+ String description = resource.getProperty(RDFS.comment).getLiteral().getString();
+ servicetype.setDescription(description);
+ list.add(servicetype);
+ }
// return the array
return (MobyServiceType[]) list
@@ -153,7 +170,6 @@
private String getRdfAsString() {
String s = null;
StringBuffer sb = new StringBuffer();
- URL url = null;
try {
BufferedReader in = null;
in = new BufferedReader(new InputStreamReader(url.openStream()));
@@ -166,4 +182,12 @@
}
return sb.toString();
}
+
+ public static void main(String[] args) throws MobyException {
+ ServiceTypeParser p = new ServiceTypeParser("http://biomoby.org/RESOURCES/MOBY-S/Services");
+ MobyServiceType[] types = p.getMobyServiceTypesFromRDF();
+ for (int i = 0; i < types.length; i++) {
+ System.out.println(types[i]);
+ }
+ }
}
More information about the MOBY-guts
mailing list