Author: clopes
Date: 2012-01-24 12:53:23 -0800 (Tue, 24 Jan 2012)
New Revision: 28091

Modified:
   
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/session/Cy3SessionReaderImpl.java
   
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/write/xgmml/XGMMLWriter.java
Log:
Fixed subnetwork serialization: The base-network must be the first XGMML 
subgraph element; XLINK for network pointers located in another root-network 
had the wrong network file name.
Session reader: Fixed NPE that could happen when merging network tables.

Modified: 
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/session/Cy3SessionReaderImpl.java
===================================================================
--- 
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/session/Cy3SessionReaderImpl.java
        2012-01-24 19:45:11 UTC (rev 28090)
+++ 
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/session/Cy3SessionReaderImpl.java
        2012-01-24 20:53:23 UTC (rev 28091)
@@ -470,12 +470,14 @@
                if (keyName.equals(targetKey.getName())) {
                        for (CyRow sourceRow : source.getAllRows()) {
                                Long key = sourceRow.get(keyName, Long.class);
+                               Long mappedKey = null;
 
-                               if (mappings != null) {
-                                       key = mappings.get(""+key);
-                               }
+                               if (mappings != null)
+                                       mappedKey = mappings.get(""+key);
+                               if (mappedKey == null)
+                                       mappedKey = key;
 
-                               CyRow targetRow = target.getRow(key);
+                               CyRow targetRow = target.getRow(mappedKey);
                                mergeRow(keyName, sourceRow, targetRow);
                        }
                }

Modified: 
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/write/xgmml/XGMMLWriter.java
===================================================================
--- 
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/write/xgmml/XGMMLWriter.java
  2012-01-24 19:45:11 UTC (rev 28090)
+++ 
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/write/xgmml/XGMMLWriter.java
  2012-01-24 20:53:23 UTC (rev 28091)
@@ -38,6 +38,7 @@
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -454,28 +455,21 @@
                                                // Write a nested graph element
                                                writeElement("<att>\n");
                                                depth++;
-                                                                               
-                                               if (sameRoot && 
!networkMap.containsKey(netPointer)) {
-                                                       // New sub-network...
-                                                       
writeSubGraph(netPointer);
-                                               } else {
-                                                       // This sub-network has 
already been written or belongs to another XGMML file...
-                                                       String href = "#" + 
netPointer.getSUID();
                                                        
-                                                       if (!sameRoot) {
-                                                               // This XGMML 
file will be saved as part of a CYS file,
-                                                               // and the 
sub-network does NOT belong to the same root-network
-                                                               CyNetwork 
baseNet = netPointerRoot.getBaseNetwork();
-                                                               // ...So add 
the other base-network's file name to the XLink URI
-                                                               String fileName 
= SessionUtil.getXGMMLFilename(baseNet);
-                                                               href = fileName 
+ href;
-                                                       }
-                                                       
-                                                       writeElement("<graph");
-                                                       
writeAttributePair("xlink:href", href);
-                                                       write("/>\n");
+                                               // This sub-network has already 
been written or belongs to another XGMML file...
+                                               String href = "#" + 
netPointer.getSUID();
+                                               
+                                               if (!sameRoot) {
+                                                       // This XGMML file will 
be saved as part of a CYS file,
+                                                       // and the sub-network 
does NOT belong to the same root-network
+                                                       // ...So add the other 
root-network's file name to the XLink URI
+                                                       String fileName = 
SessionUtil.getXGMMLFilename(netPointerRoot);
+                                                       href = fileName + href;
                                                }
                                                
+                                               writeElement("<graph");
+                                               
writeAttributePair("xlink:href", href);
+                                               write("/>\n");
                                                depth--;
                                                writeElement("</att>\n");
                                        }
@@ -993,8 +987,10 @@
      */
     private Set<CySubNetwork> getRegisteredSubNetworks(CyRootNetwork 
rootNetwork) {
                List<CySubNetwork> subNetList = rootNetwork.getSubNetworkList();
-               Set<CySubNetwork> registeredSubNetSet = new 
HashSet<CySubNetwork>();
+               Set<CySubNetwork> registeredSubNetSet = new 
LinkedHashSet<CySubNetwork>();
                
+               registeredSubNetSet.add(rootNetwork.getBaseNetwork()); // The 
base network must be the first one!
+               
                for (CySubNetwork sn : subNetList) {
                        if (networkManager.networkExists(sn.getSUID()))
                                registeredSubNetSet.add(sn);

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