[MOBY-guts] biomoby commit
Eddie Kawas
kawas at pub.open-bio.org
Wed Mar 15 17:28:15 UTC 2006
kawas
Wed Mar 15 12:28:15 EST 2006
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended
In directory pub.open-bio.org:/tmp/cvs-serv32436/org/biomoby/shared/extended
Modified Files:
NamespaceParser.java DataTypeParser.java
ServiceInstanceParser.java ServiceTypeParser.java
Log Message:
Added support for LSIDs with versioning information.
moby-live/Java/src/main/org/biomoby/shared/extended NamespaceParser.java,1.4,1.5 DataTypeParser.java,1.3,1.4 ServiceInstanceParser.java,1.10,1.11 ServiceTypeParser.java,1.4,1.5
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/NamespaceParser.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/NamespaceParser.java 2006/02/16 18:28:15 1.4
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/NamespaceParser.java 2006/03/15 17:28:15 1.5
@@ -17,6 +17,8 @@
import com.hp.hpl.jena.rdf.model.ResIterator;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.vocabulary.RDFS;
+import com.ibm.lsid.LSID;
+import com.ibm.lsid.MalformedLSIDException;
/**
*
@@ -156,8 +158,15 @@
while (iterator.hasNext()) {
Resource resource = iterator.nextResource();
// extract the name of the namespace
- String name = resource.getLocalName();
+ LSID lsid = null;
+ try {
+ lsid = new LSID(resource.getURI());
+ } catch (MalformedLSIDException e) {
+ throw new MobyException("Expected an LSID as a URI, instead got " + resource.getURI()+ " " + e.getLocalizedMessage());
+ }
+ String name = lsid.getObject();
MobyNamespace namespace = new MobyNamespace(name);
+ namespace.setLSID(lsid.getLsid());
// extract the comment (a literal in the document)
String description = resource.getProperty(RDFS.comment).getLiteral().getString();
namespace.setDescription(description);
@@ -191,7 +200,7 @@
public static void main(String[] args) throws MobyException {
// show how to use this class
- NamespaceParser p = new NamespaceParser("http://biomoby.org/RESOURCES/MOBY-S/Namespaces");
+ NamespaceParser p = new NamespaceParser("http://bioinfo.icapture.ubc.ca:8090/RESOURCES/MOBY-S/Namespaces");
MobyNamespace[] namespaces = p.getMobyNamespacesFromRDF();
for (int i = 0; i < namespaces.length; i++) {
System.out.println(namespaces[i]);
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/DataTypeParser.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/DataTypeParser.java 2006/02/16 18:28:15 1.3
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/DataTypeParser.java 2006/03/15 17:28:15 1.4
@@ -22,6 +22,8 @@
import com.hp.hpl.jena.rdf.model.StmtIterator;
import com.hp.hpl.jena.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.RDFS;
+import com.ibm.lsid.LSID;
+import com.ibm.lsid.MalformedLSIDException;
/**
*
@@ -157,20 +159,28 @@
Model model = ModelFactory.createDefaultModel();
RDFReader reader = model.getReader();
reader.read(model, new StringReader(getRdfAsString()), null);
- // TODO start querying the model and creating Data Type objects
ResIterator iterator = model.listSubjects();
while (iterator.hasNext()) {
Resource resource = iterator.nextResource();
- String name = resource.getLocalName();
- if (name == null)
+
+ if (resource.getLocalName() == null)
continue;
+
+ LSID lsid = null;
+ try {
+ lsid = new LSID(resource.getURI());
+ } catch (MalformedLSIDException e) {
+ throw new MobyException("Expected an LSID as a URI, instead got " + resource.getURI()+ " " + e.getLocalizedMessage());
+ }
+ String name = lsid.getObject();
String parent = null;
if (resource.hasProperty(RDFS.subClassOf)) {
- parent = ((Resource)resource.getProperty(RDFS.subClassOf).getObject()).getLocalName();
+ parent = ((Resource)resource.getProperty(RDFS.subClassOf).getObject()).getURI();
}
String description = resource.getProperty(RDFS.comment).getLiteral().getString();
// create the base datatype without container relationships
MobyDataType datatype = new MobyDataType(name);
+ datatype.setLSID(lsid.getLsid());
datatype.setComment(description);
datatype.setParentNames((parent == null ? new String[0] : new String[]{parent}));
// now add the container relationships
@@ -216,7 +226,7 @@
return sb.toString();
}
public static void main(String[] args) throws MobyException {
- DataTypeParser d = new DataTypeParser("http://biomoby.org/RESOURCES/MOBY-S/Objects");
+ DataTypeParser d = new DataTypeParser("http://bioinfo.icapture.ubc.ca:8090/RESOURCES/MOBY-S/Objects");
MobyDataType[] types = d.getMobyDataTypesFromRDF();
for (int i = 0; i < types.length; i++) {
System.out.println(types[i]);
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/ServiceInstanceParser.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/ServiceInstanceParser.java 2006/02/27 22:46:45 1.10
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/ServiceInstanceParser.java 2006/03/15 17:28:15 1.11
@@ -42,25 +42,25 @@
* An example of how to use this class is below:
*
* <pre><code>
- * import org.biomoby.shared.MobyService;
- * import org.biomoby.shared.Utils;
- * import org.biomoby.shared.extended.ServiceInstanceParser;
- *
- * ...
- *
- * ServiceInstanceParser p = new ServiceInstanceParser(
- * "http://biomoby.org/RESOURCES/MOBY-S/ServiceInstances");
- * MobyService[] services = p.getMobyServicesFromRDF();
- * if (!p.isRDFValid()) {
- * System.out.println("One or more services in the RDF were invalid");
- * System.out.println("The errors are the following:");
- * System.out.println(Utils.format(p.getErrors(),2));
- *
- * }
- * System.out.println("The valid services are:");
- * for (int i = 0; i < services.length; i++) {
- * System.out.println((services[i]));
- * }
+ * import org.biomoby.shared.MobyService;
+ * import org.biomoby.shared.Utils;
+ * import org.biomoby.shared.extended.ServiceInstanceParser;
+ *
+ * ...
+ *
+ * ServiceInstanceParser p = new ServiceInstanceParser(
+ * "http://biomoby.org/RESOURCES/MOBY-S/ServiceInstances");
+ * MobyService[] services = p.getMobyServicesFromRDF();
+ * if (!p.isRDFValid()) {
+ * System.out.println("One or more services in the RDF were invalid");
+ * System.out.println("The errors are the following:");
+ * System.out.println(Utils.format(p.getErrors(),2));
+ *
+ * }
+ * System.out.println("The valid services are:");
+ * for (int i = 0; i < services.length; i++) {
+ * System.out.println((services[i]));
+ * }
* </code></pre>
*
* <p>
@@ -206,7 +206,8 @@
name = resource.getProperty(FetaVocabulary.hasServiceNameText)
.getObject().toString();
MobyService service = new MobyService(name);
-
+ // set the lsid
+ service.setLSID(resource.getURI());
// get the signatureURL
String signatureURL = "";
if (resource
@@ -300,326 +301,357 @@
Map outputCollectionMap = new HashMap();
// is the current service bad?
while (inputs.hasNext()) {
-
+
Resource parameter = (Resource) inputs.nextStatement()
.getObject();
- if (parameter.getProperty(FetaVocabulary.hasParameterType)
- .getResource().getProperty(RDF.type).getObject()
- .toString().endsWith("simpleParameter")) {
- // we have a simple
- // make sure that object type and article name exist
- if (!parameter
- .hasProperty(ServiceDescriptionPredicates.object_type)) {
- success = false;
- currentlyBad = true;
- errors.append(service.getName() + ","
- + service.getAuthority()
- + "{Input for service " + service.getName()
- + " was missing an object type}");
- errors.append(newline);
- continue;
- }
- if (!parameter
- .hasProperty(FetaVocabulary.hasParameterNameText)) {
- currentlyBad = true;
- success = false;
- errors.append(service.getName() + ","
- + service.getAuthority()
- + "{Input for service " + service.getName()
- + " was missing an article name}");
- errors.append(newline);
- continue;
- }
-
- // name
- String datatype = parameter.getProperty(
- ServiceDescriptionPredicates.object_type)
- .getObject().toString();
- if (datatype.indexOf("#") > 0)
- datatype = datatype.substring(datatype
- .lastIndexOf("#") + 1);
- // if (datatype.indexOf(":") > 0)
- // datatype = datatype.substring(datatype
- // .lastIndexOf(":") + 1);
-
- // extract the article name
- String articlename = parameter.getProperty(
- FetaVocabulary.hasParameterNameText)
- .getObject().toString();
- if (articlename.equals("")) {
- success = false;
- currentlyBad = true;
- errors.append(service.getName() + ","
- + service.getAuthority()
- + "{Input for service " + service.getName()
- + " was missing a non empty article name}");
- errors.append(newline);
- continue;
- }
- // check for namespaces
- ArrayList namespaces = new ArrayList();
- if (parameter
- .hasProperty(ServiceDescriptionPredicates.inNamespaces)) {
- Resource namespaceResource = (Resource) parameter
- .getProperty(
- ServiceDescriptionPredicates.inNamespaces)
- .getObject();
- StmtIterator namespaceIterator = namespaceResource
- .listProperties(ServiceDescriptionPredicates.namespace_type);
- while (namespaceIterator.hasNext()) {
- String namespace = namespaceIterator
- .nextStatement().getObject().toString();
- if (namespace.indexOf("#") > 0)
- namespace = namespace.substring(namespace
- .lastIndexOf("#") + 1);
- // if (namespace.indexOf(":") > 0)
- // namespace = namespace.substring(namespace
- // .lastIndexOf(":") + 1);
- namespaces.add(namespace);
+ if (!parameter.getProperty(FetaVocabulary.hasParameterType)
+ .getResource().hasProperty(RDF.type)) {
+ success = false;
+ currentlyBad = true;
+ errors.append(service.getName() + ","
+ + service.getAuthority()
+ + "{Input for service "
+ + service.getName()
+ + " did not have a parameter type of type RDF:type}");
+ errors.append(newline);
+ continue;
+ } else {
+ if (parameter.getProperty(
+ FetaVocabulary.hasParameterType).getResource()
+ .getProperty(RDF.type).getObject().toString()
+ .endsWith("simpleParameter")) {
+ // we have a simple
+ // make sure that object type and article name exist
+ if (!parameter
+ .hasProperty(ServiceDescriptionPredicates.object_type)) {
+ success = false;
+ currentlyBad = true;
+ errors.append(service.getName() + ","
+ + service.getAuthority()
+ + "{Input for service "
+ + service.getName()
+ + " was missing an object type}");
+ errors.append(newline);
+ continue;
}
- }
- MobyPrimaryDataSimple primaryInput = new MobyPrimaryDataSimple();
- primaryInput.setDataType(new MobyDataType(datatype));
- primaryInput.setName(articlename);
- if (!namespaces.isEmpty()) {
- for (Iterator nsIterator = namespaces.iterator(); nsIterator
- .hasNext();) {
- primaryInput.addNamespace(new MobyNamespace(
- (String) nsIterator.next()));
+ if (!parameter
+ .hasProperty(FetaVocabulary.hasParameterNameText)) {
+ currentlyBad = true;
+ success = false;
+ errors.append(service.getName() + ","
+ + service.getAuthority()
+ + "{Input for service "
+ + service.getName()
+ + " was missing an article name}");
+ errors.append(newline);
+ continue;
}
- }
- service.addInput(primaryInput);
- } else if (parameter.getProperty(
- FetaVocabulary.hasParameterType).getResource()
- .getProperty(RDF.type).getObject().toString()
- .endsWith("collectionParameter")) {
- // we have a collection
- // make sure that object type and article name exist
- if (!parameter
- .hasProperty(ServiceDescriptionPredicates.object_type)) {
- currentlyBad = true;
- success = false;
- errors.append(service.getName() + ","
- + service.getAuthority()
- + "{Collection input for service "
- + service.getName()
- + " was missing an object type.}");
- errors.append(newline);
- continue;
- }
- if (!parameter
- .hasProperty(FetaVocabulary.hasParameterNameText)) {
- success = false;
- currentlyBad = true;
- errors.append(service.getName() + ","
- + service.getAuthority()
- + "{Collection for service "
- + service.getName()
- + " was missing an article name.}");
- errors.append(newline);
- continue;
- }
- // name
- String datatype = parameter.getProperty(
- ServiceDescriptionPredicates.object_type)
- .getObject().toString();
- if (datatype.indexOf("#") > 0)
- datatype = datatype.substring(datatype
- .lastIndexOf("#") + 1);
- // if (datatype.indexOf(":") > 0)
- // datatype = datatype.substring(datatype
- // .lastIndexOf(":") + 1);
-
- // extract the article name
- String articlename = parameter.getProperty(
- FetaVocabulary.hasParameterNameText)
- .getObject().toString();
- if (articlename.equals("")) {
- success = false;
- currentlyBad = true;
- errors
- .append(service.getName()
- + ","
- + service.getAuthority()
- + "{Collection input for service "
- + service.getName()
- + " was missing a non empty article name.}");
- errors.append(newline);
- continue;
- }
- // check for namespaces
- ArrayList namespaces = new ArrayList();
- if (parameter
- .hasProperty(ServiceDescriptionPredicates.inNamespaces)) {
- Resource namespaceResource = (Resource) parameter
- .getProperty(
- ServiceDescriptionPredicates.inNamespaces)
- .getObject();
- StmtIterator namespaceIterator = namespaceResource
- .listProperties(ServiceDescriptionPredicates.namespace_type);
- while (namespaceIterator.hasNext()) {
- String namespace = namespaceIterator
- .nextStatement().getObject().toString();
- if (namespace.indexOf("#") > 0)
- namespace = namespace.substring(namespace
- .lastIndexOf("#") + 1);
- // if (namespace.indexOf(":") > 0)
- // namespace = namespace.substring(namespace
- // .lastIndexOf(":") + 1);
- namespaces.add(namespace);
+ // name
+ String datatype = parameter.getProperty(
+ ServiceDescriptionPredicates.object_type)
+ .getObject().toString();
+ if (datatype.indexOf("#") > 0)
+ datatype = datatype.substring(datatype
+ .lastIndexOf("#") + 1);
+ // if (datatype.indexOf(":") > 0)
+ // datatype = datatype.substring(datatype
+ // .lastIndexOf(":") + 1);
+
+ // extract the article name
+ String articlename = parameter.getProperty(
+ FetaVocabulary.hasParameterNameText)
+ .getObject().toString();
+ if (articlename.equals("")) {
+ success = false;
+ currentlyBad = true;
+ errors
+ .append(service.getName()
+ + ","
+ + service.getAuthority()
+ + "{Input for service "
+ + service.getName()
+ + " was missing a non empty article name}");
+ errors.append(newline);
+ continue;
}
- }
-
- MobyPrimaryDataSet collection = null;
- if (inputCollectionMap.containsKey(articlename)) {
- collection = (MobyPrimaryDataSet) inputCollectionMap
- .get(articlename);
- } else
- collection = new MobyPrimaryDataSet(articlename);
- MobyPrimaryDataSimple input = new MobyPrimaryDataSimple(
- "");
- input.setDataType(new MobyDataType(datatype));
- if (!namespaces.isEmpty()) {
- for (Iterator nsIterator = namespaces.iterator(); nsIterator
- .hasNext();) {
- input.addNamespace(new MobyNamespace(
- (String) nsIterator.next()));
+ // check for namespaces
+ ArrayList namespaces = new ArrayList();
+ if (parameter
+ .hasProperty(ServiceDescriptionPredicates.inNamespaces)) {
+ Resource namespaceResource = (Resource) parameter
+ .getProperty(
+ ServiceDescriptionPredicates.inNamespaces)
+ .getObject();
+ StmtIterator namespaceIterator = namespaceResource
+ .listProperties(ServiceDescriptionPredicates.namespace_type);
+ while (namespaceIterator.hasNext()) {
+ String namespace = namespaceIterator
+ .nextStatement().getObject()
+ .toString();
+ if (namespace.indexOf("#") > 0)
+ namespace = namespace
+ .substring(namespace
+ .lastIndexOf("#") + 1);
+ // if (namespace.indexOf(":") > 0)
+ // namespace = namespace.substring(namespace
+ // .lastIndexOf(":") + 1);
+ namespaces.add(namespace);
+ }
+ }
+ MobyPrimaryDataSimple primaryInput = new MobyPrimaryDataSimple();
+ primaryInput
+ .setDataType(new MobyDataType(datatype));
+ primaryInput.setName(articlename);
+ if (!namespaces.isEmpty()) {
+ for (Iterator nsIterator = namespaces
+ .iterator(); nsIterator.hasNext();) {
+ primaryInput
+ .addNamespace(new MobyNamespace(
+ (String) nsIterator.next()));
+ }
+ }
+ service.addInput(primaryInput);
+ } else if (parameter.getProperty(
+ FetaVocabulary.hasParameterType).getResource()
+ .getProperty(RDF.type).getObject().toString()
+ .endsWith("collectionParameter")) {
+ // we have a collection
+ // make sure that object type and article name exist
+ if (!parameter
+ .hasProperty(ServiceDescriptionPredicates.object_type)) {
+ currentlyBad = true;
+ success = false;
+ errors.append(service.getName() + ","
+ + service.getAuthority()
+ + "{Collection input for service "
+ + service.getName()
+ + " was missing an object type.}");
+ errors.append(newline);
+ continue;
}
- }
- collection.addElement(input);
- inputCollectionMap.put(articlename, collection);
- } else if (parameter.getProperty(
- FetaVocabulary.hasParameterType).getResource()
- .getProperty(RDF.type).getObject().toString()
- .endsWith("secondaryParameter")) {
- // we have a secondary
- if (!parameter
- .hasProperty(ServiceDescriptionPredicates.datatype)) {
- currentlyBad = true;
- success = false;
- errors
- .append(service.getName()
- + ","
- + service.getAuthority()
- + "{Invalid secondary input found. Missing moby datatype"
- + " (one of String, Float, Integer, DateTime).}");
- errors.append(newline);
- continue;
- }
- if (!parameter
- .hasProperty(FetaVocabulary.hasParameterNameText)) {
- success = false;
- currentlyBad = true;
- errors
- .append(service.getName()
- + ","
- + service.getAuthority()
- + "{Invalid secondary input found. Missing an article name.}");
- errors.append(newline);
- continue;
- }
- String datatype = parameter.getProperty(
- ServiceDescriptionPredicates.datatype)
- .getLiteral().getValue().toString();
- if (datatype.indexOf("#") > 0)
- datatype = datatype
- .substring(datatype.indexOf("#") + 1);
- if (datatype.indexOf(":") > 0)
- datatype = datatype
- .substring(datatype.indexOf(":") + 1);
- // extract the article name
- String articlename = parameter.getProperty(
- FetaVocabulary.hasParameterNameText)
- .getLiteral().getValue().toString();
- if (articlename.equals("")) {
- success = false;
- currentlyBad = true;
- errors
- .append(service.getName()
- + ","
- + service.getAuthority()
- + "{Invalid secondary input found. Missing a non empty article name.}");
- errors.append(newline);
- continue;
- }
-
- // create the datatype
- MobySecondaryData secondary = new MobySecondaryData(
- articlename);
- secondary.setDataType(datatype);
-
- if (parameter
- .hasProperty(FetaVocabulary.hasDefaultValue)) {
- secondary.setDefaultValue(parameter.getProperty(
- FetaVocabulary.hasDefaultValue)
- .getLiteral().getValue().toString());
- }
- // process the description
- if (parameter
- .hasProperty(ServiceDescriptionPredicates.secondary_description)) {
- secondary.setDescription(parameter.getProperty(
- ServiceDescriptionPredicates.secondary_description)
- .getLiteral().getValue().toString());
- }
-
- if (parameter
- .hasProperty(ServiceDescriptionPredicates.max)) {
- try {
- secondary
- .setMaximumValue(Integer
- .parseInt(parameter
- .getProperty(
- ServiceDescriptionPredicates.max)
- .getLiteral()
- .getValue().toString()));
- } catch (NumberFormatException e) {
+ if (!parameter
+ .hasProperty(FetaVocabulary.hasParameterNameText)) {
+ success = false;
+ currentlyBad = true;
+ errors.append(service.getName() + ","
+ + service.getAuthority()
+ + "{Collection for service "
+ + service.getName()
+ + " was missing an article name.}");
+ errors.append(newline);
+ continue;
+ }
+ // name
+ String datatype = parameter.getProperty(
+ ServiceDescriptionPredicates.object_type)
+ .getObject().toString();
+ if (datatype.indexOf("#") > 0)
+ datatype = datatype.substring(datatype
+ .lastIndexOf("#") + 1);
+ // if (datatype.indexOf(":") > 0)
+ // datatype = datatype.substring(datatype
+ // .lastIndexOf(":") + 1);
+
+ // extract the article name
+ String articlename = parameter.getProperty(
+ FetaVocabulary.hasParameterNameText)
+ .getObject().toString();
+ if (articlename.equals("")) {
success = false;
currentlyBad = true;
errors
.append(service.getName()
+ ","
+ service.getAuthority()
- + "{Invalid maximum value for secondary input.}");
+ + "{Collection input for service "
+ + service.getName()
+ + " was missing a non empty article name.}");
errors.append(newline);
continue;
}
- }
- if (parameter
- .hasProperty(ServiceDescriptionPredicates.min)) {
- try {
- secondary
- .setMinimumValue(Integer
- .parseInt(parameter
- .getProperty(
- ServiceDescriptionPredicates.min)
- .getLiteral()
- .getValue().toString()));
- } catch (NumberFormatException e) {
+
+ // check for namespaces
+ ArrayList namespaces = new ArrayList();
+ if (parameter
+ .hasProperty(ServiceDescriptionPredicates.inNamespaces)) {
+ Resource namespaceResource = (Resource) parameter
+ .getProperty(
+ ServiceDescriptionPredicates.inNamespaces)
+ .getObject();
+ StmtIterator namespaceIterator = namespaceResource
+ .listProperties(ServiceDescriptionPredicates.namespace_type);
+ while (namespaceIterator.hasNext()) {
+ String namespace = namespaceIterator
+ .nextStatement().getObject()
+ .toString();
+ if (namespace.indexOf("#") > 0)
+ namespace = namespace
+ .substring(namespace
+ .lastIndexOf("#") + 1);
+ // if (namespace.indexOf(":") > 0)
+ // namespace = namespace.substring(namespace
+ // .lastIndexOf(":") + 1);
+ namespaces.add(namespace);
+ }
+ }
+
+ MobyPrimaryDataSet collection = null;
+ if (inputCollectionMap.containsKey(articlename)) {
+ collection = (MobyPrimaryDataSet) inputCollectionMap
+ .get(articlename);
+ } else
+ collection = new MobyPrimaryDataSet(articlename);
+ MobyPrimaryDataSimple input = new MobyPrimaryDataSimple(
+ "");
+ input.setDataType(new MobyDataType(datatype));
+ if (!namespaces.isEmpty()) {
+ for (Iterator nsIterator = namespaces
+ .iterator(); nsIterator.hasNext();) {
+ input.addNamespace(new MobyNamespace(
+ (String) nsIterator.next()));
+ }
+ }
+ collection.addElement(input);
+ inputCollectionMap.put(articlename, collection);
+ } else if (parameter.getProperty(
+ FetaVocabulary.hasParameterType).getResource()
+ .getProperty(RDF.type).getObject().toString()
+ .endsWith("secondaryParameter")) {
+ // we have a secondary
+ if (!parameter
+ .hasProperty(ServiceDescriptionPredicates.datatype)) {
+ currentlyBad = true;
+ success = false;
+ errors
+ .append(service.getName()
+ + ","
+ + service.getAuthority()
+ + "{Invalid secondary input found. Missing moby datatype"
+ + " (one of String, Float, Integer, DateTime).}");
+ errors.append(newline);
+ continue;
+ }
+ if (!parameter
+ .hasProperty(FetaVocabulary.hasParameterNameText)) {
success = false;
currentlyBad = true;
errors
.append(service.getName()
+ ","
+ service.getAuthority()
- + "{Invalid minimum value for secondary input.}");
+ + "{Invalid secondary input found. Missing an article name.}");
errors.append(newline);
continue;
}
- }
- if (parameter
- .hasProperty(ServiceDescriptionPredicates.enumeration)) {
- StmtIterator enumerations = parameter
- .listProperties(ServiceDescriptionPredicates.enumeration);
- while (enumerations.hasNext()) {
- secondary.addAllowedValue(enumerations
- .nextStatement().getLiteral()
- .getValue().toString());
+ String datatype = parameter.getProperty(
+ ServiceDescriptionPredicates.datatype)
+ .getLiteral().getValue().toString();
+ if (datatype.indexOf("#") > 0)
+ datatype = datatype.substring(datatype
+ .indexOf("#") + 1);
+ if (datatype.indexOf(":") > 0)
+ datatype = datatype.substring(datatype
+ .indexOf(":") + 1);
+ // extract the article name
+ String articlename = parameter.getProperty(
+ FetaVocabulary.hasParameterNameText)
+ .getLiteral().getValue().toString();
+ if (articlename.equals("")) {
+ success = false;
+ currentlyBad = true;
+ errors
+ .append(service.getName()
+ + ","
+ + service.getAuthority()
+ + "{Invalid secondary input found. Missing a non empty article name.}");
+ errors.append(newline);
+ continue;
}
+
+ // create the datatype
+ MobySecondaryData secondary = new MobySecondaryData(
+ articlename);
+ secondary.setDataType(datatype);
+
+ if (parameter
+ .hasProperty(FetaVocabulary.hasDefaultValue)) {
+ secondary.setDefaultValue(parameter
+ .getProperty(
+ FetaVocabulary.hasDefaultValue)
+ .getLiteral().getValue().toString());
+ }
+ // process the description
+ if (parameter
+ .hasProperty(ServiceDescriptionPredicates.secondary_description)) {
+ secondary
+ .setDescription(parameter
+ .getProperty(
+ ServiceDescriptionPredicates.secondary_description)
+ .getLiteral().getValue()
+ .toString());
+ }
+
+ if (parameter
+ .hasProperty(ServiceDescriptionPredicates.max)) {
+ try {
+ secondary
+ .setMaximumValue(Integer
+ .parseInt(parameter
+ .getProperty(
+ ServiceDescriptionPredicates.max)
+ .getLiteral()
+ .getValue()
+ .toString()));
+ } catch (NumberFormatException e) {
+ success = false;
+ currentlyBad = true;
+ errors
+ .append(service.getName()
+ + ","
+ + service.getAuthority()
+ + "{Invalid maximum value for secondary input.}");
+ errors.append(newline);
+ continue;
+ }
+ }
+ if (parameter
+ .hasProperty(ServiceDescriptionPredicates.min)) {
+ try {
+ secondary
+ .setMinimumValue(Integer
+ .parseInt(parameter
+ .getProperty(
+ ServiceDescriptionPredicates.min)
+ .getLiteral()
+ .getValue()
+ .toString()));
+ } catch (NumberFormatException e) {
+ success = false;
+ currentlyBad = true;
+ errors
+ .append(service.getName()
+ + ","
+ + service.getAuthority()
+ + "{Invalid minimum value for secondary input.}");
+ errors.append(newline);
+ continue;
+ }
+ }
+ if (parameter
+ .hasProperty(ServiceDescriptionPredicates.enumeration)) {
+ StmtIterator enumerations = parameter
+ .listProperties(ServiceDescriptionPredicates.enumeration);
+ while (enumerations.hasNext()) {
+ secondary.addAllowedValue(enumerations
+ .nextStatement().getLiteral()
+ .getValue().toString());
+ }
+ }
+ service.addInput(secondary);
+ } else {
+ // everything else is ignored.
}
- service.addInput(secondary);
- } else {
- // everything else is ignored.
}
}
@@ -628,182 +660,211 @@
while (outputs.hasNext()) {
Resource parameter = (Resource) outputs.nextStatement()
.getObject();
- if (parameter.getProperty(FetaVocabulary.hasParameterType)
- .getResource().getProperty(RDF.type).getObject()
- .toString().endsWith("simpleParameter")) {
- // we have a simple
- // make sure that object type and article name exist
- if (!parameter
- .hasProperty(ServiceDescriptionPredicates.object_type)) {
- currentlyBad = true;
- success = false;
- errors.append(service.getName() + ","
- + service.getAuthority()
- + "{Output for service "
- + service.getName()
- + " was missing an object type.}");
- errors.append(newline);
- continue;
- }
- if (!parameter
- .hasProperty(FetaVocabulary.hasParameterNameText)) {
- success = false;
- currentlyBad = true;
- errors.append(service.getName() + ","
- + service.getAuthority()
- + "{Output for service "
- + service.getName()
- + " was missing an article name}");
- errors.append(newline);
- continue;
- }
-
- // name
- String datatype = parameter.getProperty(
- ServiceDescriptionPredicates.object_type)
- .getObject().toString();
- if (datatype.indexOf("#") > 0)
- datatype = datatype.substring(datatype
- .lastIndexOf("#") + 1);
- // if (datatype.indexOf(":") > 0)
- // datatype = datatype.substring(datatype
- // .lastIndexOf(":") + 1);
-
- // extract the article name
- String articlename = parameter.getProperty(
- FetaVocabulary.hasParameterNameText)
- .getObject().toString();
- if (articlename.equals("")) {
- // throw new MobyException("Output for service " +
- // service.getName() + " was missing a non empty
- // article name");
- }
- // check for namespaces
- ArrayList namespaces = new ArrayList();
- if (parameter
- .hasProperty(ServiceDescriptionPredicates.inNamespaces)) {
- Resource namespaceResource = (Resource) parameter
- .getProperty(
- ServiceDescriptionPredicates.inNamespaces)
- .getObject();
- StmtIterator namespaceIterator = namespaceResource
- .listProperties(ServiceDescriptionPredicates.namespace_type);
- while (namespaceIterator.hasNext()) {
- String namespace = namespaceIterator
- .nextStatement().getObject().toString();
- if (namespace.indexOf("#") > 0)
- namespace = namespace.substring(namespace
- .lastIndexOf("#") + 1);
- // if (namespace.indexOf(":") > 0)
- // namespace = namespace.substring(namespace
- // .lastIndexOf(":") + 1);
- namespaces.add(namespace);
+ if (!parameter.getProperty(FetaVocabulary.hasParameterType)
+ .getResource().hasProperty(RDF.type)) {
+ success = false;
+ currentlyBad = true;
+ errors.append(service.getName() + ","
+ + service.getAuthority()
+ + "{Output for service "
+ + service.getName()
+ + " did not have a parameter type of type RDF:type}");
+ errors.append(newline);
+ continue;
+ } else {
+ if (parameter.getProperty(
+ FetaVocabulary.hasParameterType).getResource()
+ .getProperty(RDF.type).getObject().toString()
+ .endsWith("simpleParameter")) {
+ // we have a simple
+ // make sure that object type and article name exist
+ if (!parameter
+ .hasProperty(ServiceDescriptionPredicates.object_type)) {
+ currentlyBad = true;
+ success = false;
+ errors.append(service.getName() + ","
+ + service.getAuthority()
+ + "{Output for service "
+ + service.getName()
+ + " was missing an object type.}");
+ errors.append(newline);
+ continue;
}
- }
- MobyPrimaryDataSimple primaryOutput = new MobyPrimaryDataSimple();
- primaryOutput.setDataType(new MobyDataType(datatype));
- primaryOutput.setName(articlename);
- if (!namespaces.isEmpty()) {
- for (Iterator nsIterator = namespaces.iterator(); nsIterator
- .hasNext();) {
- primaryOutput.addNamespace(new MobyNamespace(
- (String) nsIterator.next()));
+ if (!parameter
+ .hasProperty(FetaVocabulary.hasParameterNameText)) {
+ success = false;
+ currentlyBad = true;
+ errors.append(service.getName() + ","
+ + service.getAuthority()
+ + "{Output for service "
+ + service.getName()
+ + " was missing an article name}");
+ errors.append(newline);
+ continue;
}
- }
- service.addOutput(primaryOutput);
- } else if (parameter.getProperty(
- FetaVocabulary.hasParameterType).getResource()
- .getProperty(RDF.type).getObject().toString()
- .endsWith("collectionParameter")) {
- // we have a collection
- // make sure that object type and article name exist
- if (!parameter
- .hasProperty(ServiceDescriptionPredicates.object_type)) {
- success = false;
- currentlyBad = true;
- errors.append(service.getName() + "," +service.getAuthority()+ "{Collection Output for service "
- + service.getName()
- + " was missing an object type.}");
- errors.append(newline);
- continue;
- }
- if (!parameter
- .hasProperty(FetaVocabulary.hasParameterNameText)) {
- success = false;
- currentlyBad = true;
- errors.append(service.getName() + "," +service.getAuthority()+ "{Collection for service "
- + service.getName()
- + " was missing an article name.}");
- errors.append(newline);
- continue;
- }
- // name
- String datatype = parameter.getProperty(
- ServiceDescriptionPredicates.object_type)
- .getObject().toString();
- if (datatype.indexOf("#") > 0)
- datatype = datatype.substring(datatype
- .lastIndexOf("#") + 1);
- // if (datatype.indexOf(":") > 0)
- // datatype = datatype.substring(datatype
- // .lastIndexOf(":") + 1);
-
- // extract the article name
- String articlename = parameter.getProperty(
- FetaVocabulary.hasParameterNameText)
- .getObject().toString();
- if (articlename.equals("")) {
- success = false;
- currentlyBad = true;
- errors.append(service.getName() + "," +service.getAuthority()+ "{Collection output for service "
- + service.getName()
- + " was missing a non empty article name.}");
- errors.append(newline);
- continue;
- }
+ // name
+ String datatype = parameter.getProperty(
+ ServiceDescriptionPredicates.object_type)
+ .getObject().toString();
+ if (datatype.indexOf("#") > 0)
+ datatype = datatype.substring(datatype
+ .lastIndexOf("#") + 1);
+ // if (datatype.indexOf(":") > 0)
+ // datatype = datatype.substring(datatype
+ // .lastIndexOf(":") + 1);
+
+ // extract the article name
+ String articlename = parameter.getProperty(
+ FetaVocabulary.hasParameterNameText)
+ .getObject().toString();
+ if (articlename.equals("")) {
+ // throw new MobyException("Output for service "
+ // +
+ // service.getName() + " was missing a non empty
+ // article name");
+ }
+ // check for namespaces
+ ArrayList namespaces = new ArrayList();
+ if (parameter
+ .hasProperty(ServiceDescriptionPredicates.inNamespaces)) {
+ Resource namespaceResource = (Resource) parameter
+ .getProperty(
+ ServiceDescriptionPredicates.inNamespaces)
+ .getObject();
+ StmtIterator namespaceIterator = namespaceResource
+ .listProperties(ServiceDescriptionPredicates.namespace_type);
+ while (namespaceIterator.hasNext()) {
+ String namespace = namespaceIterator
+ .nextStatement().getObject()
+ .toString();
+ if (namespace.indexOf("#") > 0)
+ namespace = namespace
+ .substring(namespace
+ .lastIndexOf("#") + 1);
+ // if (namespace.indexOf(":") > 0)
+ // namespace = namespace.substring(namespace
+ // .lastIndexOf(":") + 1);
+ namespaces.add(namespace);
+ }
+ }
+ MobyPrimaryDataSimple primaryOutput = new MobyPrimaryDataSimple();
+ primaryOutput
+ .setDataType(new MobyDataType(datatype));
+ primaryOutput.setName(articlename);
+ if (!namespaces.isEmpty()) {
+ for (Iterator nsIterator = namespaces
+ .iterator(); nsIterator.hasNext();) {
+ primaryOutput
+ .addNamespace(new MobyNamespace(
+ (String) nsIterator.next()));
+ }
+ }
+ service.addOutput(primaryOutput);
+ } else if (parameter.getProperty(
+ FetaVocabulary.hasParameterType).getResource()
+ .getProperty(RDF.type).getObject().toString()
+ .endsWith("collectionParameter")) {
+ // we have a collection
+ // make sure that object type and article name exist
+ if (!parameter
+ .hasProperty(ServiceDescriptionPredicates.object_type)) {
+ success = false;
+ currentlyBad = true;
+ errors.append(service.getName() + ","
+ + service.getAuthority()
+ + "{Collection Output for service "
+ + service.getName()
+ + " was missing an object type.}");
+ errors.append(newline);
+ continue;
+ }
+ if (!parameter
+ .hasProperty(FetaVocabulary.hasParameterNameText)) {
+ success = false;
+ currentlyBad = true;
+ errors.append(service.getName() + ","
+ + service.getAuthority()
+ + "{Collection for service "
+ + service.getName()
+ + " was missing an article name.}");
+ errors.append(newline);
+ continue;
+ }
+ // name
+ String datatype = parameter.getProperty(
+ ServiceDescriptionPredicates.object_type)
+ .getObject().toString();
+ if (datatype.indexOf("#") > 0)
+ datatype = datatype.substring(datatype
+ .lastIndexOf("#") + 1);
+ // if (datatype.indexOf(":") > 0)
+ // datatype = datatype.substring(datatype
+ // .lastIndexOf(":") + 1);
+
+ // extract the article name
+ String articlename = parameter.getProperty(
+ FetaVocabulary.hasParameterNameText)
+ .getObject().toString();
+ if (articlename.equals("")) {
+ success = false;
+ currentlyBad = true;
+ errors
+ .append(service.getName()
+ + ","
+ + service.getAuthority()
+ + "{Collection output for service "
+ + service.getName()
+ + " was missing a non empty article name.}");
+ errors.append(newline);
+ continue;
- // check for namespaces
- ArrayList namespaces = new ArrayList();
- if (parameter
- .hasProperty(ServiceDescriptionPredicates.inNamespaces)) {
- Resource namespaceResource = (Resource) parameter
- .getProperty(
- ServiceDescriptionPredicates.inNamespaces)
- .getObject();
- StmtIterator namespaceIterator = namespaceResource
- .listProperties(ServiceDescriptionPredicates.namespace_type);
- while (namespaceIterator.hasNext()) {
- String namespace = namespaceIterator
- .nextStatement().getObject().toString();
- if (namespace.indexOf("#") > 0)
- namespace = namespace.substring(namespace
- .lastIndexOf("#") + 1);
- // if (namespace.indexOf(":") > 0)
- // namespace = namespace.substring(namespace
- // .lastIndexOf(":") + 1);
- namespaces.add(namespace);
}
- }
- MobyPrimaryDataSet collection = null;
- if (outputCollectionMap.containsKey(articlename)) {
- collection = (MobyPrimaryDataSet) outputCollectionMap
- .get(articlename);
- } else
- collection = new MobyPrimaryDataSet(articlename);
- MobyPrimaryDataSimple output = new MobyPrimaryDataSimple(
- "");
- output.setDataType(new MobyDataType(datatype));
- if (!namespaces.isEmpty()) {
- for (Iterator nsIterator = namespaces.iterator(); nsIterator
- .hasNext();) {
- output.addNamespace(new MobyNamespace(
- (String) nsIterator.next()));
+ // check for namespaces
+ ArrayList namespaces = new ArrayList();
+ if (parameter
+ .hasProperty(ServiceDescriptionPredicates.inNamespaces)) {
+ Resource namespaceResource = (Resource) parameter
+ .getProperty(
+ ServiceDescriptionPredicates.inNamespaces)
+ .getObject();
+ StmtIterator namespaceIterator = namespaceResource
+ .listProperties(ServiceDescriptionPredicates.namespace_type);
+ while (namespaceIterator.hasNext()) {
+ String namespace = namespaceIterator
+ .nextStatement().getObject()
+ .toString();
+ if (namespace.indexOf("#") > 0)
+ namespace = namespace
+ .substring(namespace
+ .lastIndexOf("#") + 1);
+ // if (namespace.indexOf(":") > 0)
+ // namespace = namespace.substring(namespace
+ // .lastIndexOf(":") + 1);
+ namespaces.add(namespace);
+ }
+ }
+
+ MobyPrimaryDataSet collection = null;
+ if (outputCollectionMap.containsKey(articlename)) {
+ collection = (MobyPrimaryDataSet) outputCollectionMap
+ .get(articlename);
+ } else
+ collection = new MobyPrimaryDataSet(articlename);
+ MobyPrimaryDataSimple output = new MobyPrimaryDataSimple(
+ "");
+ output.setDataType(new MobyDataType(datatype));
+ if (!namespaces.isEmpty()) {
+ for (Iterator nsIterator = namespaces
+ .iterator(); nsIterator.hasNext();) {
+ output.addNamespace(new MobyNamespace(
+ (String) nsIterator.next()));
+ }
}
+ collection.addElement(output);
+ outputCollectionMap.put(articlename, collection);
}
- collection.addElement(output);
- outputCollectionMap.put(articlename, collection);
}
}
@@ -940,7 +1001,7 @@
MalformedURLException, IOException {
// show how to use this class
ServiceInstanceParser p = new ServiceInstanceParser(
- "http://biomoby.org/RESOURCES/MOBY-S/ServiceInstances");
+ "http://bioinfo.icapture.ubc.ca:8090/RESOURCES/MOBY-S/ServiceInstances");
MobyService[] services = p.getMobyServicesFromRDF();
if (!p.isRDFValid()) {
System.out.println("One or more services in the RDF were invalid");
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/ServiceTypeParser.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/ServiceTypeParser.java 2006/02/16 18:28:15 1.4
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/extended/ServiceTypeParser.java 2006/03/15 17:28:15 1.5
@@ -17,6 +17,8 @@
import com.hp.hpl.jena.rdf.model.ResIterator;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.vocabulary.RDFS;
+import com.ibm.lsid.LSID;
+import com.ibm.lsid.MalformedLSIDException;
/**
*
@@ -154,8 +156,15 @@
ResIterator iterator = model.listSubjects();
while (iterator.hasNext()) {
Resource resource = iterator.nextResource();
- String name = resource.getLocalName();
+ LSID lsid = null;
+ try {
+ lsid = new LSID(resource.getURI());
+ } catch (MalformedLSIDException e) {
+ throw new MobyException("Expected an LSID as a URI, instead got " + resource.getURI()+ " " + e.getLocalizedMessage());
+ }
+ String name = lsid.getObject();
MobyServiceType servicetype = new MobyServiceType(name);
+ servicetype.setLSID(lsid.getLsid());
if (!resource.hasProperty(RDFS.subClassOf)) {
continue;
}
@@ -192,7 +201,7 @@
}
public static void main(String[] args) throws MobyException {
- ServiceTypeParser p = new ServiceTypeParser("http://biomoby.org/RESOURCES/MOBY-S/Services");
+ ServiceTypeParser p = new ServiceTypeParser("http://bioinfo.icapture.ubc.ca:8090/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