[MOBY-guts] biomoby commit
Paul Gordon
gordonp at dev.open-bio.org
Sat Apr 10 00:40:17 UTC 2010
gordonp
Fri Apr 9 20:40:17 EDT 2010
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources
In directory dev.open-bio.org:/tmp/cvs-serv14854/src/main/ca/ucalgary/seahawk/resources
Modified Files:
RegexFilterBeanShell
Log Message:
Added support for filter inversion (boolean negation)
moby-live/Java/src/main/ca/ucalgary/seahawk/resources RegexFilterBeanShell,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/RegexFilterBeanShell,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/RegexFilterBeanShell 2010/04/09 15:49:18 1.2
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/RegexFilterBeanShell 2010/04/10 00:40:17 1.3
@@ -11,9 +11,12 @@
List nodelist = document.selectNodes(xpath);
ArrayList outputXmlList = new ArrayList();
+ArrayList outputXmlList_false = new ArrayList();
int i = 1;
Map collections = new LinkedHashMap();
Map collectionsEnd = new HashMap();
+Map collections_false = new LinkedHashMap();
+Map collectionsEnd_false = new HashMap();
Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE | Pattern.DOTALL | (Boolean.parseBoolean(case_sensitive) ? 0 : Pattern.CASE_INSENSITIVE));
for (Iterator iter = nodelist.iterator(); iter.hasNext();) {
Node node = (Node) iter.next();
@@ -31,10 +34,17 @@
break;
default: break;
}
- if(!match){
- continue;
- }
+ Map cs = null;
+ Map csEnd = null;
+ if(match){
+ cs = collections;
+ csEnd = collectionsEnd;
+ }
+ else{
+ cs = collections_false;
+ csEnd = collectionsEnd_false;
+ }
//go up the tree until we hit a mobyData...this is the unit we can forward
StringBuilder collection = null;
StringBuilder collectionEnd = null;
@@ -43,11 +53,11 @@
node.getParent().getName().equals("Collection")){
collection = new StringBuilder(); //start tracking parents
collectionEnd = new StringBuilder();
- if(!collections.containsKey(collection)){
- collections.put(collection, new Vector());
- collectionsEnd.put(collection, collectionEnd);
+ if(!cs.containsKey(collection)){
+ cs.put(collection, new Vector());
+ csEnd.put(collection, collectionEnd);
}
- ((Vector)collections.get(collection)).add(node.asXML());
+ ((Vector)cs.get(collection)).add(node.asXML());
}
node = node.getParent();
if(node != null && collection != null){
@@ -61,14 +71,17 @@
collectionEnd.append("</"+((Element) node).getQualifiedName()+">");
}
}
- if(node == null){
+ if(node == null){ // wasn't part of a mobyData block
continue;
}
- // At mobyData level if we got here
+ // At mobyData level if we got here, add if job not already present
if(collection == null){
- outputXmlList.add(
- "<moby:MOBY xmlns:moby='http://www.biomoby.org/moby' xmlns='http://www.biomoby.org/moby'>"+
- "<moby:mobyContent>"+node.asXML()+"</moby:mobyContent></moby:MOBY>");
+ String jobData = "<moby:MOBY xmlns:moby='http://www.biomoby.org/moby' xmlns='http://www.biomoby.org/moby'>"+
+ "<moby:mobyContent>"+node.asXML()+"</moby:mobyContent></moby:MOBY>";
+ List list = (match ? outputXmlList : outputXmlList_false);
+ if(!list.contains(jobData)){
+ list.add(jobData);
+ }
}
}
@@ -83,6 +96,16 @@
}
((List) uniqueCollections.get(keyString)).addAll((List) collection.getValue());
}
+Map uniqueCollections_false = new LinkedHashMap();
+Map uniqueCollectionsEnd_false = new LinkedHashMap();
+for(Map.Entry collection: collections_false.entrySet()){
+ String keyString = collection.getKey().toString();
+ if(!uniqueCollections_false.containsKey(keyString)){
+ uniqueCollections_false.put(keyString, new Vector());
+ uniqueCollectionsEnd_false.put(keyString, collectionsEnd_false.get(collection.getKey()));
+ }
+ ((List) uniqueCollections_false.get(keyString)).addAll((List) collection.getValue());
+}
//Now concat the collection members that pass the filter
for(Map.Entry collection: uniqueCollections.entrySet()){
@@ -99,6 +122,21 @@
outputXmlList.add(block.toString());
}
+for(Map.Entry collection: uniqueCollections_false.entrySet()){
+ StringBuilder block = new StringBuilder();
+ block.append("<moby:MOBY xmlns:moby='http://www.biomoby.org/moby' xmlns='http://www.biomoby.org/moby'>\n");
+ block.append("<moby:mobyContent>\n");
+ block.append(collection.getKey().toString());
+ for(String val: (List) collection.getValue()){
+ block.append(val);
+ }
+ block.append(uniqueCollectionsEnd_false.get(collection.getKey().toString())); // closing tags
+ block.append("</moby:mobyContent>\n");
+ block.append("</moby:MOBY>\n");
+
+ outputXmlList_false.add(block.toString());
+}
-List nodelistAsXML=outputXmlList;
+List TRUE_nodelistAsXML=outputXmlList;
+List FALSE_nodelistAsXML=outputXmlList_false;
More information about the MOBY-guts
mailing list