[MOBY-guts] biomoby commit
Eddie Kawas
kawas at dev.open-bio.org
Wed Feb 27 19:18:23 UTC 2008
kawas
Wed Feb 27 14:18:23 EST 2008
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended
In directory dev.open-bio.org:/tmp/cvs-serv10883/Java/src/main/org/biomoby/shared/extended
Modified Files:
ServiceInstanceParser.java ServiceTypeParser.java
NamespaceParser.java DataTypeParser.java
Log Message:
modified the code to be able to utilize RDF from sources that can send gzip encoded data
moby-live/Java/src/main/org/biomoby/shared/extended ServiceInstanceParser.java,1.21,1.22 ServiceTypeParser.java,1.9,1.10 NamespaceParser.java,1.8,1.9 DataTypeParser.java,1.9,1.10
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/ServiceInstanceParser.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/ServiceInstanceParser.java 2007/11/29 16:59:04 1.21
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/ServiceInstanceParser.java 2008/02/27 19:18:23 1.22
@@ -1,8 +1,6 @@
package org.biomoby.shared.extended;
-import java.io.BufferedReader;
import java.io.IOException;
-import java.io.InputStreamReader;
import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URL;
@@ -155,9 +153,11 @@
Model model = ModelFactory.createDefaultModel();
RDFReader reader = model.getReader();
try {
- reader.read(model, new StringReader(getRdfAsString()), null);
+ reader.read(model, org.biomoby.shared.extended.Utils.getBufferedInputStream(getUrl()), null);
} catch (JenaException e) {
throw new MobyException(e.getLocalizedMessage());
+ } catch (MobyException e) {
+ throw new MobyException(e.getLocalizedMessage());
}
this.parsedOkay = processModel(list, model);
@@ -928,27 +928,6 @@
return url;
}
- /*
- *
- * @return a string form of the RDF so that
- */
- private String getRdfAsString() {
- String s = null;
- StringBuffer sb = new StringBuffer();
- try {
- BufferedReader in = null;
- in = new BufferedReader(new InputStreamReader(url.openStream()));
- while ((s = in.readLine()) != null) {
- sb.append(s + System.getProperty("line.separator"));
- }
- } catch (IOException e) {
- this.parsedOkay = false;
- e.printStackTrace();
- return null;
- }
- return sb.toString();
- }
-
/**
* Method to check whether an RDF document contained only valid services.
*
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/ServiceTypeParser.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/ServiceTypeParser.java 2007/11/29 16:59:04 1.9
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/ServiceTypeParser.java 2008/02/27 19:18:23 1.10
@@ -1,9 +1,5 @@
package org.biomoby.shared.extended;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
@@ -151,7 +147,7 @@
// create the model
Model model = ModelFactory.createDefaultModel();
RDFReader reader = model.getReader();
- reader.read(model, new StringReader(getRdfAsString()), null);
+ reader.read(model, Utils.getBufferedInputStream(getUrl()), null);
// start querying the model and creating Service Type objects
ResIterator iterator = model.listSubjects();
while (iterator.hasNext()) {
@@ -199,25 +195,6 @@
.toArray(new MobyServiceType[list.size()]);
}
- /*
- *
- * @return a string form of the RDF so that
- */
- private String getRdfAsString() {
- String s = null;
- StringBuffer sb = new StringBuffer();
- try {
- BufferedReader in = null;
- in = new BufferedReader(new InputStreamReader(url.openStream()));
- while ((s = in.readLine()) != null) {
- sb.append(s);
- }
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
- return sb.toString();
- }
public static void main(String[] args) throws MobyException {
ServiceTypeParser p = new ServiceTypeParser("http://biomoby.org/RESOURCES/MOBY-S/Services");
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/NamespaceParser.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/NamespaceParser.java 2007/11/29 16:59:04 1.8
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/NamespaceParser.java 2008/02/27 19:18:23 1.9
@@ -1,9 +1,5 @@
package org.biomoby.shared.extended;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
@@ -153,7 +149,7 @@
// create the model
Model model = ModelFactory.createDefaultModel();
RDFReader reader = model.getReader();
- reader.read(model, new StringReader(getRdfAsString()), null);
+ reader.read(model, Utils.getBufferedInputStream(getUrl()), null);
// get all subjects in the document
ResIterator iterator = model.listSubjects();
while (iterator.hasNext()) {
@@ -193,27 +189,6 @@
// return the array
return (MobyNamespace[]) list.toArray(new MobyNamespace[list.size()]);
}
-
- /*
- *
- * @return a string form of the RDF so that
- */
- private String getRdfAsString() {
- String s = null;
- StringBuffer sb = new StringBuffer();
- try {
- BufferedReader in = null;
- in = new BufferedReader(new InputStreamReader(url.openStream()));
- while ((s = in.readLine()) != null) {
- sb.append(s);
- }
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
- return sb.toString();
- }
-
public static void main(String[] args) throws MobyException {
// show how to use this class
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/DataTypeParser.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/DataTypeParser.java 2008/02/27 14:45:49 1.9
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/DataTypeParser.java 2008/02/27 19:18:23 1.10
@@ -1,12 +1,16 @@
package org.biomoby.shared.extended;
+import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.io.PrintWriter;
import java.io.StringReader;
+import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.zip.GZIPInputStream;
import org.biomoby.client.rdf.vocabulary.DC_PROTEGE;
import org.biomoby.client.rdf.vocabulary.Predicates;
@@ -158,7 +162,7 @@
// create the model
Model model = ModelFactory.createDefaultModel();
RDFReader reader = model.getReader();
- reader.read(model, new StringReader(getRdfAsString()), null);
+ reader.read(model, Utils.getBufferedInputStream(getUrl()), null);
ResIterator iterator = model.listSubjects();
while (iterator.hasNext()) {
Resource resource = iterator.nextResource();
@@ -223,25 +227,6 @@
return (MobyDataType[]) list.toArray(new MobyDataType[list.size()]);
}
- /*
- *
- * @return a string form of the RDF so that
- */
- private String getRdfAsString() {
- String s = null;
- StringBuffer sb = new StringBuffer();
- try {
- BufferedReader in = null;
- in = new BufferedReader(new InputStreamReader(url.openStream()));
- while ((s = in.readLine()) != null) {
- sb.append(s);
- }
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
- return sb.toString();
- }
public static void main(String[] args) throws MobyException {
DataTypeParser d = new DataTypeParser("http://biomoby.org/RESOURCES/MOBY-S/Objects");
MobyDataType[] types = d.getMobyDataTypesFromRDF();
More information about the MOBY-guts
mailing list