[MOBY-guts] biomoby commit
Paul Gordon
gordonp at dev.open-bio.org
Fri Jun 8 14:04:27 UTC 2007
gordonp
Fri Jun 8 10:04:27 EDT 2007
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services
In directory dev.open-bio.org:/tmp/cvs-serv28675/src/main/ca/ucalgary/seahawk/services
Modified Files:
MobyClient.java MobyComplexBuilder.java TextClient.java
Log Message:
Commit of Seahawk 1.0 updates and associated core updates
moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyClient.java,1.12,1.13 MobyComplexBuilder.java,1.6,1.7 TextClient.java,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/04/26 15:22:27 1.12
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/06/08 14:04:27 1.13
@@ -1,8 +1,10 @@
package ca.ucalgary.seahawk.services;
import ca.ucalgary.seahawk.util.NamespaceContextImpl;
+import ca.ucalgary.seahawk.util.SeahawkOptions;
import org.biomoby.client.*;
+import org.biomoby.registry.meta.Registry;
import org.biomoby.shared.*;
import org.biomoby.shared.data.*;
@@ -15,12 +17,7 @@
import org.apache.xml.utils.PrefixResolver;
import org.apache.xml.utils.PrefixResolverDefault;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import javax.xml.parsers.*;
+import org.w3c.dom.*;
import java.io.*;
import java.net.URL;
@@ -28,6 +25,7 @@
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import javax.xml.parsers.*;
/**
* The engine that finds MOBY data in unstructured text or DOM of other XML languages according
@@ -76,7 +74,17 @@
private int serviceLevel = MobyService.UNCHECKED;
public MobyClient() throws MobyException{
- c = new CentralCachedCallsImpl();
+ Registry reg = SeahawkOptions.getRegistry();
+ if(reg == null){
+ reg = MobyDataType.getDefaultRegistry();
+ }
+
+ if(reg != null && reg.getEndpoint() != null){
+ c = new CentralCachedCallsImpl(reg.getEndpoint());
+ }
+ else{
+ c = new CentralCachedCallsImpl();
+ }
xpathMap = new HashMap();
urlRegexMap = new HashMap();
regexMap = new HashMap<Pattern,MobyComplexBuilder>();
@@ -657,7 +665,7 @@
*/
public MobyDataObject[] getMobyObjects(byte[] rawData, MobyDataType targetDataType){
// Only do the magic check if the target data type inherits from MOBY's base64 class (i.e. might encode binary data)
- if(!targetDataType.inheritsFrom(MobyDataType.getDataType(MobyDataBytes.BASE64_DATATYPE))){
+ if(!targetDataType.inheritsFrom(MobyDataType.getDataType(MobyDataBytes.BASE64_DATATYPE, targetDataType.getRegistry()))){
//System.err.println("Data type does not inerit from Base64, continuing with string-based search...");
return getMobyObjects(new String(rawData), targetDataType);
}
@@ -959,7 +967,8 @@
//}
mService[j].setStatus(MobyService.ALIVE, isServiceAlive(mService[j]));
- mService[j].setServiceType(MobyServiceType.getServiceType(mService[j].getServiceType().getName()));
+ mService[j].setServiceType(MobyServiceType.getServiceType(mService[j].getServiceType().getName(),
+ SeahawkOptions.getRegistry()));
if(serviceLevel != MobyService.UNCHECKED){
int serviceStatus = mService[j].getStatus();
//System.err.println("Service " + mService[j].getName() + " has status " + serviceStatus);
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/04/18 15:58:08 1.6
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyComplexBuilder.java 2007/06/08 14:04:27 1.7
@@ -1,5 +1,7 @@
package ca.ucalgary.seahawk.services;
+import ca.ucalgary.seahawk.util.SeahawkOptions;
+
import org.biomoby.shared.*;
import org.biomoby.shared.data.MobyDataObject;
import org.biomoby.shared.data.MobyDataComposite;
@@ -46,7 +48,7 @@
}
public MobyComplexBuilder(String dataType, Map<String,String[]> members, Map<String,String> nameSpaces, String articleName) throws Exception{
- mobyDataType = MobyDataType.getDataType(dataType);
+ mobyDataType = MobyDataType.getDataType(dataType, SeahawkOptions.getRegistry());
// Not an existing Ontology data type
if(mobyDataType == null){
mobyDataType = new MobyDataType(dataType);
@@ -96,7 +98,7 @@
String ns = (String) iter.next();
// Give the namespace a meaningful description from the MOBY registry
- mobyNS[i] = MobyNamespace.getNamespace(ns);
+ mobyNS[i] = MobyNamespace.getNamespace(ns, SeahawkOptions.getRegistry());
if(mobyNS[i] == null){
System.err.println("Namespace '"+ns+"' is not registered in MOBY Central");
// Not a registered namespace in MOBY Central's ontology
@@ -114,7 +116,7 @@
MobyDataObject mobyObj = null;
if(mobyDataType.getName().equals("Object")){
- mobyObj = new MobyDataObject("");
+ mobyObj = new MobyDataObject("", SeahawkOptions.getRegistry());
}
// else ifs for other primitives in the future maybe?
else{
@@ -152,7 +154,7 @@
}
else{
// ... the subsequent ones are saved as cross-references
- mobyObj.addCrossReference(new MobyDataObject(mobyNS[i].getName(), result));
+ mobyObj.addCrossReference(new MobyDataObject(mobyNS[i].getName(), result, SeahawkOptions.getRegistry()));
}
}
}
@@ -182,6 +184,7 @@
}
}
}
+ System.err.println("Namespace of object being returned is " + mobyObj.getPrimaryNamespace().getName());
return mobyObj;
}
@@ -190,6 +193,7 @@
throws MobyException{
byte[] resultBytes = result.getBytes();
boolean nonBasic = result.length() != 2 || result.indexOf("$") != 0;
+ boolean isBinary = encodingMode != null && encodingMode.equals(MobyClient.ENCODING_ATTR_BASE64_VAL);
MobyPrefixResolver.MobyNodeList nodeList = new MobyPrefixResolver.MobyNodeList();
@@ -205,7 +209,7 @@
// "$250 per metre". Not sure of a good way around this yet (i.e. when varValue had $k in it where k > j)...
for(int j = 0; j <= matcher.groupCount(); j++){
// A replaceAll() for binary data
- if(data != null){
+ if(data != null && isBinary){
int srcPos = 0;
for(int varIndex = result.indexOf("$"+j, srcPos);
varIndex != -1;
@@ -251,7 +255,7 @@
}
}
- if(encodingMode != null && encodingMode.equals(MobyClient.ENCODING_ATTR_BASE64_VAL)){
+ if(isBinary){
//(new Exception("Base 64 encoding")).printStackTrace();
result = org.apache.axis.encoding.Base64.encode(data == null ? result.getBytes() : resultBytes);
}
@@ -281,7 +285,7 @@
MobyDataObject mobyObj = null;
if(mobyDataType.getName().equals("Object")){
- mobyObj = new MobyDataObject("");
+ mobyObj = new MobyDataObject("", SeahawkOptions.getRegistry());
}
// else ifs for other primitives in the future maybe?
else{
@@ -306,7 +310,7 @@
}
else{
// ... the subsequent ones are saved as cross-references
- mobyObj.addCrossReference(new MobyDataObject(mobyNS[i].getName(), value));
+ mobyObj.addCrossReference(new MobyDataObject(mobyNS[i].getName(), value, SeahawkOptions.getRegistry()));
}
}
}
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/TextClient.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/TextClient.java 2007/04/18 16:07:41 1.3
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/TextClient.java 2007/06/08 14:04:27 1.4
@@ -1,5 +1,7 @@
package ca.ucalgary.seahawk.services;
+import ca.ucalgary.seahawk.util.SeahawkOptions;
+
import org.biomoby.shared.*;
import org.biomoby.shared.data.MobyDataInstance;
@@ -92,7 +94,7 @@
}
// See if the type exists in the ontology
- MobyDataType type = MobyDataType.getDataType(templateNameParts[0]);
+ MobyDataType type = MobyDataType.getDataType(templateNameParts[0], SeahawkOptions.getRegistry());
if(type == null){
System.err.println("Ignoring template whose name attribute (" + templateName +
") uses a non-existent datatype (" + templateNameParts[0] + ")");
More information about the MOBY-guts
mailing list