Author: clopes
Date: 2012-08-03 12:03:39 -0700 (Fri, 03 Aug 2012)
New Revision: 30084

Modified:
   
core3/impl/trunk/group-session-restore-shim/src/main/java/org/cytoscape/group/session/restore/shim/internal/SessionEventsListener.java
   
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/xgmml/handler/ReadDataManager.java
   
core3/impl/trunk/io-impl/impl/src/test/java/org/cytoscape/io/internal/read/xgmml/GenericXGMMLReaderTest.java
Log:
Groups now takes advantage of the ".SUID" column name convention to always get 
the new SUIDs of external edges on session loading. IO impl changed to 
transparently send the new SUIDs when loading Cy2 sessions, as well.

Modified: 
core3/impl/trunk/group-session-restore-shim/src/main/java/org/cytoscape/group/session/restore/shim/internal/SessionEventsListener.java
===================================================================
--- 
core3/impl/trunk/group-session-restore-shim/src/main/java/org/cytoscape/group/session/restore/shim/internal/SessionEventsListener.java
      2012-08-03 18:27:28 UTC (rev 30083)
+++ 
core3/impl/trunk/group-session-restore-shim/src/main/java/org/cytoscape/group/session/restore/shim/internal/SessionEventsListener.java
      2012-08-03 19:03:39 UTC (rev 30084)
@@ -34,7 +34,7 @@
        private final CyGroupManager groupMgr;
        private final CyNetworkManager netMgr;
        private final CyRootNetworkManager rootNetMgr;
-       private final String EXTERNAL_EDGE_ATTRIBUTE="__externalEdges";
+       private final String EXTERNAL_EDGE_ATTRIBUTE="__externalEdges.SUID";
        private final String GROUP_COLLAPSED_ATTRIBUTE="__groupCollapsed";
        // 2.x group attributes
        private final String GROUP_STATE_ATTRIBUTE="__groupState";
@@ -126,17 +126,10 @@
                        // Add in the missing external edges if we're collapsed
                        // CyRow groupNodeRow = net.getRow(n, 
CyNetwork.HIDDEN_ATTRS);
                        if (rnRow.isSet(EXTERNAL_EDGE_ATTRIBUTE)) {
-                               Class<?> listType = 
rnRow.getTable().getColumn(EXTERNAL_EDGE_ATTRIBUTE).getListElementType();
-                               List<?> externalIDs = 
rnRow.getList(EXTERNAL_EDGE_ATTRIBUTE, listType);
+                               List<Long> externalIDs = 
rnRow.getList(EXTERNAL_EDGE_ATTRIBUTE, Long.class);
                                List<CyEdge> externalEdges = new 
ArrayList<CyEdge>();
-                               for (Object oldId: externalIDs) {
-                                       CyEdge newEdge = null;
-                                       
-                                       if (oldId instanceof Long) // Cy3 old 
edge IDs are SUIDs
-                                               newEdge = 
sess.getObject((Long)oldId, CyEdge.class);
-                                       else // Cy2 uses edge labels as IDs
-                                               newEdge = 
sess.getObject(oldId.toString(), CyEdge.class);
-                                               
+                               for (Long suid: externalIDs) {
+                                       CyEdge newEdge = rootNet.getEdge(suid);
                                        if (newEdge != null)
                                                externalEdges.add(newEdge);
                                }

Modified: 
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/xgmml/handler/ReadDataManager.java
===================================================================
--- 
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/xgmml/handler/ReadDataManager.java
       2012-08-03 18:27:28 UTC (rev 30083)
+++ 
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/xgmml/handler/ReadDataManager.java
       2012-08-03 19:03:39 UTC (rev 30084)
@@ -61,6 +61,9 @@
 
 public class ReadDataManager {
 
+       public final static String GROUP_STATE_ATTRIBUTE="__groupState";
+       public final static String 
EXTERNAL_EDGE_ATTRIBUTE="__externalEdges.SUID";
+       
        protected final static String XLINK = "http://www.w3.org/1999/xlink";;
        
        /* RDF Data */
@@ -470,7 +473,7 @@
                CyNode actualSrc = net.getNode(source.getSUID());
                CyNode actualTgt = net.getNode(target.getSUID());
                
-               List<String> extEdgeIds = null; // For 2.x groups
+               List<Long> extEdgeIds = null; // For 2.x groups
                
                if ( (getDocumentVersion() < 3.0 || !isSessionFormat()) && 
(actualSrc == null || actualTgt == null) ) {
                        // The nodes might have been added to other 
sub-networks, but not to the current one.
@@ -497,18 +500,18 @@
                                // Check for the group's metadata attribute
                                final CyRow grhRow = grNet.getRow(grNode, 
CyNetwork.HIDDEN_ATTRS);
                                
-                               if (grhRow.isSet("__groupState")) { // It's a 
group!
+                               if (grhRow.isSet(GROUP_STATE_ATTRIBUTE)) { // 
It's a group!
                                        // Add extra metadata for external 
edges, so that the information is not lost
                                        final CyRow rnRow = 
getRootNetwork().getRow(grNode, CyNetwork.HIDDEN_ATTRS);
                                        
-                                       if 
(rnRow.getTable().getColumn("__externalEdges") == null)
-                                               
rnRow.getTable().createListColumn("__externalEdges", String.class, false);
+                                       if 
(rnRow.getTable().getColumn(EXTERNAL_EDGE_ATTRIBUTE) == null)
+                                               
rnRow.getTable().createListColumn(EXTERNAL_EDGE_ATTRIBUTE, Long.class, false);
                                        
-                                       extEdgeIds = 
rnRow.getList("__externalEdges", String.class);
+                                       extEdgeIds = 
rnRow.getList(EXTERNAL_EDGE_ATTRIBUTE, Long.class);
                                                        
                                        if (extEdgeIds == null) {
-                                               extEdgeIds = new 
ArrayList<String>();
-                                               rnRow.set("__externalEdges", 
extEdgeIds);
+                                               extEdgeIds = new 
ArrayList<Long>();
+                                               
rnRow.set(EXTERNAL_EDGE_ATTRIBUTE, extEdgeIds);
                                        }
                                }
                        }
@@ -517,7 +520,7 @@
                edge = net.addEdge(actualSrc, actualTgt, directed);
                
                if (extEdgeIds != null)
-                       extEdgeIds.add(id.toString());
+                       extEdgeIds.add(edge.getSUID());
                
                mapSUIDs(id, edge.getSUID());
         }

Modified: 
core3/impl/trunk/io-impl/impl/src/test/java/org/cytoscape/io/internal/read/xgmml/GenericXGMMLReaderTest.java
===================================================================
--- 
core3/impl/trunk/io-impl/impl/src/test/java/org/cytoscape/io/internal/read/xgmml/GenericXGMMLReaderTest.java
        2012-08-03 18:27:28 UTC (rev 30083)
+++ 
core3/impl/trunk/io-impl/impl/src/test/java/org/cytoscape/io/internal/read/xgmml/GenericXGMMLReaderTest.java
        2012-08-03 19:03:39 UTC (rev 30084)
@@ -310,7 +310,7 @@
                int npCount = 0;
                
                for (CyNode n : net.getNodeList()) {
-                       if (net.getRow(n, 
CyNetwork.HIDDEN_ATTRS).isSet("__groupState")) {
+                       if (net.getRow(n, 
CyNetwork.HIDDEN_ATTRS).isSet(ReadDataManager.GROUP_STATE_ATTRIBUTE)) {
                                gn = n;
                                if (++npCount > 1) fail("There should be only 
one group node!");
                        } else { // The other nodes have no network pointer!
@@ -331,11 +331,11 @@
                // Check external edges metadata (must be added by the reader!)
                CyRootNetwork rootNet = rootNetworkMgr.getRootNetwork(np);
                CyRow rnRow = rootNet.getRow(gn, HIDDEN_ATTRS);
-               List<String> extEdgeIds = rnRow.getList("__externalEdges", 
String.class);
+               List<Long> extEdgeIds = 
rnRow.getList(ReadDataManager.EXTERNAL_EDGE_ATTRIBUTE, Long.class);
                
                assertNotNull(extEdgeIds);
                assertEquals(1, extEdgeIds.size());
-               assertEquals("node1 (DirectedEdge) node2", extEdgeIds.get(0));
+               assertNotNull(rootNet.getEdge(extEdgeIds.get(0)));
                
                return gn;
        }

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