Author: kono
Date: 2011-07-06 17:06:57 -0700 (Wed, 06 Jul 2011)
New Revision: 26093

Modified:
   
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/read/session/SessionReaderImpl.java
   
core3/session-impl/trunk/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
Log:
fixes #311 URL decorder had been added to session reader to extract correct 
file name String.

Modified: 
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/read/session/SessionReaderImpl.java
===================================================================
--- 
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/read/session/SessionReaderImpl.java
     2011-07-06 23:55:29 UTC (rev 26092)
+++ 
core3/io-impl/trunk/src/main/java/org/cytoscape/io/internal/read/session/SessionReaderImpl.java
     2011-07-07 00:06:57 UTC (rev 26093)
@@ -35,6 +35,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -145,6 +146,7 @@
                this.csvCyReaderFactory = csvCyReaderFactory;
        }
 
+
        /**
         * Read a session file.
         */
@@ -535,13 +537,13 @@
                        logger.warn("The Cysession has no document version!");
                }
 
-               for (Network net : cysession.getNetworkTree().getNetwork()) {
+               for (final Network net : 
cysession.getNetworkTree().getNetwork()) {
                        // We no longer have the concept of a top-level network 
root,
                        // so let's ignore a network with that name, but only 
if the Cysession doc version is old.
                        if (isOldFormat && net.getId().equals(NETWORK_ROOT)) 
continue;
+                       final String fileName = net.getFilename();
+                       final CyNetworkView view = getNetworkView(fileName);
 
-                       CyNetworkView view = getNetworkView(net.getFilename());
-
                        if (view == null) {
                                logger.warn("Failed to find network in session: 
" + net.getFilename());
                        } else {
@@ -566,9 +568,17 @@
                }
        }
 
-       private CyNetworkView getNetworkView(String name) {
-               for (String s : networkViews.keySet()) {
-                       if (s.endsWith("/" + name)) {
+       private CyNetworkView getNetworkView(final String name) {
+               for(String s : networkViews.keySet()) {
+                       String decode = s;
+                       try {
+                               decode = URLDecoder.decode(s, "UTF-8");
+                       } catch (UnsupportedEncodingException e) {
+                               e.printStackTrace();
+                               return null;
+                       }
+                       
+                       if (decode.endsWith("/" + name)) {
                                // this is OK since XGMML only ever reads one 
network
                                return networkViews.get(s)[0];
                        }

Modified: 
core3/session-impl/trunk/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
===================================================================
--- 
core3/session-impl/trunk/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
     2011-07-06 23:55:29 UTC (rev 26092)
+++ 
core3/session-impl/trunk/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
     2011-07-07 00:06:57 UTC (rev 26093)
@@ -171,10 +171,8 @@
                        }
 
                        // Restore visual styles
-                       logger.debug("Restoring visual styles...");
-                       Set<VisualStyle> styles = sess.getVisualStyles();
-                       Map<String, VisualStyle> stylesMap = new 
HashMap<String, VisualStyle>();
-
+                       final Set<VisualStyle> styles = sess.getVisualStyles();
+                       final Map<String, VisualStyle> stylesMap = new 
HashMap<String, VisualStyle>();
                        if (styles != null) {
                                for (VisualStyle vs : styles) {
                                        vmMgr.addVisualStyle(vs);
@@ -184,23 +182,23 @@
                        }
 
                        // Get network frames info
-                       Cysession cysess = sess.getCysession();
+                       final Cysession cysess = sess.getCysession();
 
                        if 
(cysess.getSessionState().getDesktop().getNetworkFrames() != null) {
                                List<NetworkFrame> frames = 
cysess.getSessionState().getDesktop().getNetworkFrames().getNetworkFrame();
                                Map<String, NetworkFrame> framesLookup = new 
Hashtable<String, NetworkFrame>();
 
-                               for (NetworkFrame nf : frames) {
+                               for (NetworkFrame nf : frames)
                                        framesLookup.put(nf.getFrameID(), nf);
-                               }
 
                                // Set visual styles to network views
-                               Map<CyNetworkView, String> netStyleMap = 
sess.getViewVisualStyleMap();
-
+                               
+                               // This is a map from network view to Visual 
Style TITLE (may not be unique.  TODO: use ID?)
+                               final Map<CyNetworkView, String> netStyleMap = 
sess.getViewVisualStyleMap();
                                for (Entry<CyNetworkView, String> entry : 
netStyleMap.entrySet()) {
-                                       CyNetworkView netView = entry.getKey();
-                                       String stName = entry.getValue();
-                                       VisualStyle vs = stylesMap.get(stName);
+                                       final CyNetworkView netView = 
entry.getKey();
+                                       final String stName = entry.getValue();
+                                       final VisualStyle vs = 
stylesMap.get(stName);
 
                                        if (vs != null) {
                                                vmMgr.setVisualStyle(vs, 
netView);

-- 
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