Author: jm
Date: 2011-04-04 08:37:40 -0700 (Mon, 04 Apr 2011)
New Revision: 24649

Added:
   
core3/cpath2-impl/trunk/src/main/java/org/cytoscape/cpath2/internal/util/StaxHack.java
Modified:
   core3/cpath2-impl/trunk/pom.xml
   
core3/cpath2-impl/trunk/src/main/java/org/cytoscape/cpath2/internal/biopax/util/BioPaxUtil.java
   
core3/cpath2-impl/trunk/src/main/java/org/cytoscape/cpath2/internal/task/ExecuteGetRecordByCPathId.java
Log:
Importing BioPAX format from cPath now works
Pulled StaxHack into a top-level class

Modified: core3/cpath2-impl/trunk/pom.xml
===================================================================
--- core3/cpath2-impl/trunk/pom.xml     2011-04-01 21:57:22 UTC (rev 24648)
+++ core3/cpath2-impl/trunk/pom.xml     2011-04-04 15:37:40 UTC (rev 24649)
@@ -65,6 +65,11 @@
                        <artifactId>commons-codec</artifactId>
                        <version>1.3</version>
                </dependency>
+               <dependency>
+                       <groupId>cytoscape-temp</groupId>
+                       <artifactId>collections-generic</artifactId>
+                       <version>4.01</version>
+               </dependency>
                
                <dependency>
                        <groupId>cytoscape-temp</groupId>

Modified: 
core3/cpath2-impl/trunk/src/main/java/org/cytoscape/cpath2/internal/biopax/util/BioPaxUtil.java
===================================================================
--- 
core3/cpath2-impl/trunk/src/main/java/org/cytoscape/cpath2/internal/biopax/util/BioPaxUtil.java
     2011-04-01 21:57:22 UTC (rev 24648)
+++ 
core3/cpath2-impl/trunk/src/main/java/org/cytoscape/cpath2/internal/biopax/util/BioPaxUtil.java
     2011-04-04 15:37:40 UTC (rev 24649)
@@ -70,6 +70,7 @@
 import org.biopax.paxtools.util.ClassFilterSet;
 import org.cytoscape.cpath2.internal.biopax.ExternalLink;
 import org.cytoscape.cpath2.internal.biopax.MapBioPaxToCytoscape;
+import org.cytoscape.cpath2.internal.util.StaxHack;
 import org.cytoscape.model.CyNetwork;
 import org.cytoscape.model.CyRow;
 import org.slf4j.Logger;
@@ -195,11 +196,15 @@
         * @return BioPaxUtil new instance (containing the imported BioPAX data)
         * @throws FileNotFoundException 
         */
-       public static Model read(InputStream in) throws FileNotFoundException {
+       public static Model read(final InputStream in) throws 
FileNotFoundException {
                Model model = null;
                try {
-                       // TODO: Use StAXHack here
-                       model = (new SimpleReader()).convertFromOWL(in);
+                       model = new StaxHack<Model>() {
+                               @Override
+                               public Model runWithHack() {
+                                       return new 
SimpleReader().convertFromOWL(in);
+                               }
+                       }.runWithHack();
                } catch (Exception e) {
                        log.warn("Import failed: " + e);
                }

Modified: 
core3/cpath2-impl/trunk/src/main/java/org/cytoscape/cpath2/internal/task/ExecuteGetRecordByCPathId.java
===================================================================
--- 
core3/cpath2-impl/trunk/src/main/java/org/cytoscape/cpath2/internal/task/ExecuteGetRecordByCPathId.java
     2011-04-01 21:57:22 UTC (rev 24648)
+++ 
core3/cpath2-impl/trunk/src/main/java/org/cytoscape/cpath2/internal/task/ExecuteGetRecordByCPathId.java
     2011-04-04 15:37:40 UTC (rev 24649)
@@ -28,6 +28,7 @@
 import org.cytoscape.cpath2.internal.cytoscape.BinarySifVisualStyleUtil;
 import org.cytoscape.cpath2.internal.util.AttributeUtil;
 import org.cytoscape.cpath2.internal.util.SelectUtil;
+import org.cytoscape.cpath2.internal.util.StaxHack;
 import org.cytoscape.cpath2.internal.web_service.CPathException;
 import org.cytoscape.cpath2.internal.web_service.CPathProperties;
 import org.cytoscape.cpath2.internal.web_service.CPathResponseFormat;
@@ -39,7 +40,6 @@
 import org.cytoscape.model.CyNode;
 import org.cytoscape.model.CyRow;
 import org.cytoscape.session.CyNetworkNaming;
-import org.cytoscape.view.layout.CyLayoutAlgorithm;
 import org.cytoscape.view.layout.CyLayouts;
 import org.cytoscape.view.model.CyNetworkView;
 import org.cytoscape.work.AbstractTask;
@@ -558,23 +558,3 @@
        public void setTitle(String arg0) {
        }
 }
-
-/**
- * This class executes code using this bundle's ClassLoader as the current
- * thread's context ClassLoader.  This enables the service discovery mechanism
- * used by some StAX implementations to function properly under OSGi.
- */
-abstract class StaxHack<T> {
-       public abstract T runWithHack();
-       
-       public final T run() {
-               Thread thread = Thread.currentThread();
-               ClassLoader oldClassLoader = thread.getContextClassLoader();
-               try {
-                       
thread.setContextClassLoader(getClass().getClassLoader());
-                       return runWithHack();
-               } finally {
-                       thread.setContextClassLoader(oldClassLoader);
-               }
-       }
-}

Added: 
core3/cpath2-impl/trunk/src/main/java/org/cytoscape/cpath2/internal/util/StaxHack.java
===================================================================
--- 
core3/cpath2-impl/trunk/src/main/java/org/cytoscape/cpath2/internal/util/StaxHack.java
                              (rev 0)
+++ 
core3/cpath2-impl/trunk/src/main/java/org/cytoscape/cpath2/internal/util/StaxHack.java
      2011-04-04 15:37:40 UTC (rev 24649)
@@ -0,0 +1,21 @@
+package org.cytoscape.cpath2.internal.util;
+
+/**
+ * This class executes code using this bundle's ClassLoader as the current
+ * thread's context ClassLoader.  This enables the service discovery mechanism
+ * used by some StAX implementations to function properly under OSGi.
+ */
+public abstract class StaxHack<T> {
+       public abstract T runWithHack();
+       
+       public final T run() {
+               Thread thread = Thread.currentThread();
+               ClassLoader oldClassLoader = thread.getContextClassLoader();
+               try {
+                       
thread.setContextClassLoader(getClass().getClassLoader());
+                       return runWithHack();
+               } finally {
+                       thread.setContextClassLoader(oldClassLoader);
+               }
+       }
+}
\ No newline at end of file


Property changes on: 
core3/cpath2-impl/trunk/src/main/java/org/cytoscape/cpath2/internal/util/StaxHack.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to