[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Sun Apr 11 20:15:28 UTC 2010


gordonp
Sun Apr 11 16:15:28 EDT 2010
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util
In directory dev.open-bio.org:/tmp/cvs-serv17912/src/main/ca/ucalgary/seahawk/util

Modified Files:
	DataUtils.java 
Added Files:
	XPointerResolver.java 
Log Message:
Updates for proper support of data filtering when submitting to forward services
moby-live/Java/src/main/ca/ucalgary/seahawk/util XPointerResolver.java,NONE,1.1 DataUtils.java,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataUtils.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/util/DataUtils.java	2010/04/10 00:40:17	1.3
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataUtils.java	2010/04/11 20:15:28	1.4
@@ -450,7 +450,14 @@
 	}	
     }
 
-    public static MobyDataInstance loadMobyDataFromXPointer(URL targetURL, FilterSearch docFilter){
+    /**
+     * Get the data instance object associated with a given XPointer into a Moby XML doc
+     *
+     * @param targetURL of the form URLpath#/1/1/2/1 where /1/1/2/1 is an XPointer, or an standard xpath, to the part of the Moby XML doc to deserialize
+     * @param filteredXPtrs a map of the xpointers to data that should NOT be deserialized if children of the targetURL XPointer
+     * @param docFilter the current filter applied to the document in targetURL
+     */
+    public static MobyDataInstance loadMobyDataFromXPointer(URL targetURL, Map<String,String> filteredXPtrs, FilterSearch docFilter){
 	// Are we dealing with a simple object or a complex one?
 	MobyDataInstance mobyData = null;
 	
@@ -492,13 +499,35 @@
 	    return null;
 	}
 	
+	// Remove the filtered data from the doc before deserializing to a moby data instance
+	// That way the request actually reflects what is shown on the screen to the user.
+	if(filteredXPtrs != null){
+	    // Mark and sweep (if we just deleted as we found node, the XPointers could be 
+	    // wrong as they refer to ordinality)
+	    Vector<Node> nodesToDelete = new Vector<Node>();
+	    for(String xptr: filteredXPtrs.keySet()){
+		nodesToDelete.add(XPointerResolver.getNodeFromXPointer(domDoc, xptr));
+	    }
+
+	    // Delete
+	    for(Node nodeToDelete: nodesToDelete){
+		Node parent = nodeToDelete.getParentNode();
+		parent.removeChild(nodeToDelete);
+		// Get rid of Simple parents of deleted nodes, because empty Simple
+		// tags are not okay in Moby (causes parsing error)
+		if(MobyTags.SIMPLE.equals(parent.getLocalName())){
+		    parent.getParentNode().removeChild(parent);
+		}
+	    }
+	}
+
 	// Build and run the XPath statement
 	Element mobyObject = null;
 	NodeList idSearchResult = null;
 	Object xobject = null;
 	try{
 	    xobject = XPathFactory.newInstance().newXPath().evaluate(childXPath, 
-								     new InputSource(targetURL.openStream()), 
+								     domDoc, 
 								     XPathConstants.NODESET);
 						
 	    // Check the results




More information about the MOBY-guts mailing list