Author: clopes
Date: 2012-04-03 13:24:20 -0700 (Tue, 03 Apr 2012)
New Revision: 28730

Modified:
   
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/CyActivator.java
   
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/datatable/CSVCyReader.java
   
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/datatable/CSVCyReaderFactory.java
   
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/session/Cy3SessionReaderImpl.java
   
core3/impl/trunk/io-impl/impl/src/test/java/org/cytoscape/io/internal/read/datatable/CSVCyReaderTest.java
   
core3/impl/trunk/session-impl/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
   
core3/impl/trunk/table-import-impl/src/main/java/org/cytoscape/tableimport/internal/task/ImportOntologyAndAnnotationTask.java
   
core3/impl/trunk/table-import-impl/src/main/java/org/cytoscape/tableimport/internal/task/MapGeneAssociationTask.java
Log:
Fixes #843 : Global Table Browser registeres non-global tables to the combobox:
- CSV table reader no longer registers the tables it creates
- session manager registers all tables, including network ones

Modified: 
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/CyActivator.java
===================================================================
--- 
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/CyActivator.java
      2012-04-03 19:34:03 UTC (rev 28729)
+++ 
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/CyActivator.java
      2012-04-03 20:24:20 UTC (rev 28730)
@@ -187,7 +187,7 @@
                XGMMLParser xgmmlParser = new 
XGMMLParser(handlerFactory,readDataManager);
                XGMMLNetworkReaderFactory xgmmlNetworkReaderFactory = new 
XGMMLNetworkReaderFactory(xgmmlFilter,cyNetworkViewFactoryServiceRef,cyNetworkFactoryServiceRef,cyRootNetworkManagerServiceRef,renderingEngineManagerServiceRef,readDataManager,xgmmlParser,unrecognizedVisualPropertyManager);
                XGMMLNetworkViewReaderFactory xgmmlNetworkViewReaderFactory = 
new 
XGMMLNetworkViewReaderFactory(xgmmlViewFilter,cyNetworkViewFactoryServiceRef,cyNetworkFactoryServiceRef,renderingEngineManagerServiceRef,readDataManager,xgmmlParser,unrecognizedVisualPropertyManager);
-               CSVCyReaderFactory sessionTableReaderFactory = new 
CSVCyReaderFactory(sessionTableFilter,true,true,cyTableFactoryServiceRef,compilerServiceRef,cyTableManagerServiceRef);
+               CSVCyReaderFactory sessionTableReaderFactory = new 
CSVCyReaderFactory(sessionTableFilter,true,true,cyTableFactoryServiceRef,compilerServiceRef);
                Cy3SessionReaderFactoryImpl cy3SessionReaderFactory = new 
Cy3SessionReaderFactoryImpl(cys3Filter,readCache,cyNetworkReaderManager,cyPropertyReaderManager,vizmapReaderManager,sessionTableReaderFactory,cyNetworkTableManagerServiceRef,cyRootNetworkManagerServiceRef);
                Cy2SessionReaderFactoryImpl cy2SessionReaderFactory = new 
Cy2SessionReaderFactoryImpl(cys2Filter,readCache,cyNetworkReaderManager,cyPropertyReaderManager,vizmapReaderManager,cyRootNetworkManagerServiceRef);
                CysessionReaderFactory cysessionReaderFactory = new 
CysessionReaderFactory(cysessionFilter);

Modified: 
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/datatable/CSVCyReader.java
===================================================================
--- 
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/datatable/CSVCyReader.java
       2012-04-03 19:34:03 UTC (rev 28729)
+++ 
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/datatable/CSVCyReader.java
       2012-04-03 20:24:20 UTC (rev 28730)
@@ -18,7 +18,6 @@
 import org.cytoscape.model.CyRow;
 import org.cytoscape.model.CyTable;
 import org.cytoscape.model.CyTableFactory;
-import org.cytoscape.model.CyTableManager;
 import org.cytoscape.work.TaskMonitor;
 
 import au.com.bytecode.opencsv.CSVReader;
@@ -32,21 +31,19 @@
        private final boolean handleEquations;
        private final CyTableFactory tableFactory;
        private final EquationCompiler compiler;
-       private final CyTableManager tableManager;
 
        private boolean isCanceled;
        private CyTable table;
 
        public CSVCyReader(final InputStream stream, final boolean readSchema,
                           final boolean handleEquations, final CyTableFactory 
tableFactory,
-                          final EquationCompiler compiler, final 
CyTableManager tableManager)
+                          final EquationCompiler compiler)
        {
                this.stream          = stream;
                this.readSchema      = readSchema;
                this.handleEquations = handleEquations;
                this.tableFactory    = tableFactory;
                this.compiler        = compiler;
-               this.tableManager    = tableManager;
        }
 
        @Override
@@ -63,9 +60,6 @@
 
                TableInfo info = readHeader(reader);
                table = createTable(reader, info);
-               taskMonitor.setProgress(0.6);
-
-               tableManager.addTable(table);
                taskMonitor.setProgress(1.0);
        }
 

Modified: 
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/datatable/CSVCyReaderFactory.java
===================================================================
--- 
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/datatable/CSVCyReaderFactory.java
        2012-04-03 19:34:03 UTC (rev 28729)
+++ 
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/datatable/CSVCyReaderFactory.java
        2012-04-03 20:24:20 UTC (rev 28730)
@@ -7,7 +7,6 @@
 import org.cytoscape.io.CyFileFilter;
 import org.cytoscape.io.read.AbstractInputStreamTaskFactory;
 import org.cytoscape.model.CyTableFactory;
-import org.cytoscape.model.CyTableManager;
 import org.cytoscape.work.TaskIterator;
 
 
@@ -16,23 +15,20 @@
        private final boolean handleEquations;
        private final CyTableFactory tableFactory;
        private final EquationCompiler compiler;
-       private final CyTableManager tableManager;
 
        public CSVCyReaderFactory(final CyFileFilter filter, final boolean 
readSchema,
                                  final boolean handleEquations, final 
CyTableFactory tableFactory,
-                                 final EquationCompiler compiler, final 
CyTableManager tableManager)
+                                 final EquationCompiler compiler)
        {
                super(filter);
                this.readSchema      = readSchema;
                this.handleEquations = handleEquations;
                this.tableFactory    = tableFactory;
                this.compiler        = compiler;
-               this.tableManager    = tableManager;
        }
        
        @Override
        public TaskIterator createTaskIterator(InputStream stream, String 
inputName) {
-               return new TaskIterator(new CSVCyReader(stream, readSchema, 
handleEquations,
-                                                       tableFactory, compiler, 
tableManager));
+               return new TaskIterator(new CSVCyReader(stream, readSchema, 
handleEquations, tableFactory, compiler));
        }
 }

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-04-03 19:34:03 UTC (rev 28729)
+++ 
core3/impl/trunk/io-impl/impl/src/main/java/org/cytoscape/io/internal/read/session/Cy3SessionReaderImpl.java
        2012-04-03 20:24:20 UTC (rev 28730)
@@ -451,15 +451,19 @@
        }
 
        private void mergeNetworkTables() throws UnsupportedEncodingException {
-               for (Entry<Long, CyNetwork> entry : networkLookup.entrySet()) {
-                       CyNetwork network = entry.getValue();
-                       Object oldId = cache.getOldId(network.getSUID());
-                       Set<CyTableMetadataBuilder> builders = 
networkTableMap.get(oldId);
+               for (Entry<Long, Set<CyTableMetadataBuilder>> entry : 
networkTableMap.entrySet()) {
+                       final Object oldId = entry.getKey();
+                       final Set<CyTableMetadataBuilder> builders = 
entry.getValue();
+                       final CyNetwork network = cache.getNetwork(oldId);
 
-                       if (builders == null)
-                               continue;
+                       if (network == null)
+                               throw new RuntimeException("Cannot merge 
network tables: Cannot find network " + oldId);
 
                        for (CyTableMetadataBuilder builder : builders) {
+                               if ("VIEW".equals(builder.getNamespace())) {
+                                       continue; // TODO: disabled due to 
timing conflicts with Ding (The VIEW tables are not created yet).
+                               }
+                               
                                builder.setNetwork(network);
                                mergeNetworkTable(network, builder);
                                CyTableMetadata metadata = builder.build();
@@ -476,14 +480,10 @@
        private void mergeNetworkTable(CyNetwork network, 
CyTableMetadataBuilder builder) {
                Class<? extends CyIdentifiable> type = (Class<? extends 
CyIdentifiable>) builder.getType();
                String namespace = builder.getNamespace();
-
-               if ("VIEW".equals(namespace)) {
-                       return; // TODO: disabled due to timing conflicts with 
Ding (The VIEW tables are not created yet).
-               }
-
                Map<String, CyTable> tableMap = 
networkTableMgr.getTables(network, type);
                CyTable targetTable = tableMap.get(namespace);
                CyTable sourceTable = builder.getTable();
+               
                mergeTables(sourceTable, targetTable, type);
                builder.setCyTable(targetTable);
        }

Modified: 
core3/impl/trunk/io-impl/impl/src/test/java/org/cytoscape/io/internal/read/datatable/CSVCyReaderTest.java
===================================================================
--- 
core3/impl/trunk/io-impl/impl/src/test/java/org/cytoscape/io/internal/read/datatable/CSVCyReaderTest.java
   2012-04-03 19:34:03 UTC (rev 28729)
+++ 
core3/impl/trunk/io-impl/impl/src/test/java/org/cytoscape/io/internal/read/datatable/CSVCyReaderTest.java
   2012-04-03 20:24:20 UTC (rev 28730)
@@ -10,10 +10,9 @@
 import java.io.UnsupportedEncodingException;
 import java.util.List;
 
+import org.cytoscape.model.CyIdentifiable;
 import org.cytoscape.model.CyRow;
 import org.cytoscape.model.CyTable;
-import org.cytoscape.model.CyTableManager;
-import org.cytoscape.model.CyIdentifiable;
 import org.cytoscape.model.CyTable.Mutability;
 import org.cytoscape.model.CyTableFactory;
 import org.cytoscape.model.TableTestSupport;
@@ -26,7 +25,6 @@
 
 public class CSVCyReaderTest {
        @Mock TaskMonitor taskMonitor;
-       @Mock CyTableManager tableManager;
 
        private CyTableFactory tableFactory;
 
@@ -45,8 +43,7 @@
        public void testReadSimple() throws Exception {
                String data = "SUID\r\njava.lang.Long\r\ntest 
table,\"public\\,mutable\"\r\n5\r\n6";
                CSVCyReader reader = new CSVCyReader(createStream(data), true,
-                                                    /* handleEquations = */ 
false, tableFactory,
-                                                    null, tableManager);
+                                                    /* handleEquations = */ 
false, tableFactory, null);
                reader.run(taskMonitor);
                CyTable[] tables = reader.getTables();
                assertNotNull(tables);
@@ -67,8 +64,7 @@
        public void testReadString() throws Exception {
                String data = 
"SUID,name\r\njava.lang.Long,java.lang.String\r\ntest 
table,\"public\\,mutable\"\r\n1,Alice\r\n2,Bob\r\n3,Carol";
                CSVCyReader reader = new CSVCyReader(createStream(data), true,
-                                                    /* handleEquations = */ 
false, tableFactory,
-                                                    null, tableManager);
+                                                    /* handleEquations = */ 
false, tableFactory, null);
                reader.run(taskMonitor);
                CyTable[] tables = reader.getTables();
                CyTable table = tables[0];
@@ -80,8 +76,7 @@
        public void testReadDouble() throws Exception {
                String data = 
"SUID,weight\r\njava.lang.Long,java.lang.Double\r\ntest 
table,\"public\\,mutable\"\r\n0,0.56\r\n-5,-1.234";
                CSVCyReader reader = new CSVCyReader(createStream(data), true,
-                                                    /* handleEquations = */ 
false, tableFactory,
-                                                    null, tableManager);
+                                                    /* handleEquations = */ 
false, tableFactory, null);
                reader.run(taskMonitor);
                CyTable[] tables = reader.getTables();
                CyTable table = tables[0];
@@ -93,8 +88,7 @@
        public void testReadBoolean() throws Exception {
                String data = 
"SUID,hidden\r\njava.lang.Long,java.lang.Boolean\r\ntest 
table,\"public\\,mutable\"\r\n30,true\r\n40,false\r\n50,true";
                CSVCyReader reader = new CSVCyReader(createStream(data), true,
-                                                    /* handleEquations = */ 
false, tableFactory,
-                                                    null, tableManager);
+                                                    /* handleEquations = */ 
false, tableFactory, null);
                reader.run(taskMonitor);
                CyTable[] tables = reader.getTables();
                CyTable table = tables[0];
@@ -106,8 +100,7 @@
        public void testReadList() throws Exception {
                String data = 
"SUID,list\r\njava.lang.Long,java.util.List<java.lang.String>\r\ntest 
table,\"public\\,mutable\"\r\n1,\"a\rb\rc\"";
                CSVCyReader reader = new CSVCyReader(createStream(data), true,
-                                                    /* handleEquations = */ 
false, tableFactory,
-                                                    null, tableManager);
+                                                    /* handleEquations = */ 
false, tableFactory, null);
                reader.run(taskMonitor);
                CyTable[] tables = reader.getTables();
                CyTable table = tables[0];

Modified: 
core3/impl/trunk/session-impl/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
===================================================================
--- 
core3/impl/trunk/session-impl/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
        2012-04-03 19:34:03 UTC (rev 28729)
+++ 
core3/impl/trunk/session-impl/src/main/java/org/cytoscape/session/internal/CySessionManagerImpl.java
        2012-04-03 20:24:20 UTC (rev 28730)
@@ -262,12 +262,12 @@
        }
 
        private void restoreTables(CySession sess) {
-               // Register global tables
+               // Register all tables, if not already registered
                for (CyTableMetadata metadata : sess.getTables()) {
-                       CyNetwork network = metadata.getNetwork();
+                       final CyTable tbl = metadata.getTable();
                        
-                       if (network == null) {
-                               tblMgr.addTable(metadata.getTable());
+                       if (tblMgr.getTable(tbl.getSUID()) == null) {
+                               tblMgr.addTable(tbl);
                        }
                }
        }

Modified: 
core3/impl/trunk/table-import-impl/src/main/java/org/cytoscape/tableimport/internal/task/ImportOntologyAndAnnotationTask.java
===================================================================
--- 
core3/impl/trunk/table-import-impl/src/main/java/org/cytoscape/tableimport/internal/task/ImportOntologyAndAnnotationTask.java
       2012-04-03 19:34:03 UTC (rev 28729)
+++ 
core3/impl/trunk/table-import-impl/src/main/java/org/cytoscape/tableimport/internal/task/ImportOntologyAndAnnotationTask.java
       2012-04-03 20:24:20 UTC (rev 28730)
@@ -20,7 +20,7 @@
        private static final Logger logger = 
LoggerFactory.getLogger(ImportOntologyAndAnnotationTask.class);
        
        private final InputStreamTaskFactory factory;
-       private final CyNetworkManager manager;
+       private final CyNetworkManager networkManager;
        private final String ontologyDagName;
        private final CyTableFactory tableFactory;
        private final InputStream gaStream;
@@ -28,7 +28,7 @@
        private final CyTableManager tableManager;
        private final InputStream is;
        
-       ImportOntologyAndAnnotationTask(final CyNetworkManager manager,
+       ImportOntologyAndAnnotationTask(final CyNetworkManager networkManager,
                                        final InputStreamTaskFactory factory, 
final InputStream is,
                                        final String ontologyDagName,
                                        final CyTableFactory tableFactory,
@@ -36,7 +36,7 @@
                                        final CyTableManager tableManager)
        {
                this.factory = factory;
-               this.manager = manager;
+               this.networkManager = networkManager;
                this.ontologyDagName = ontologyDagName;
                this.tableFactory = tableFactory;
                
@@ -53,12 +53,11 @@
                Task loadOBOTask = factory.createTaskIterator(is, 
ontologyDagName).next();
                
                final GeneAssociationReader gaReader =
-                       new GeneAssociationReader(tableFactory, 
ontologyDagName, gaStream,
-                                                 gaTableName, tableManager);
+                       new GeneAssociationReader(tableFactory, 
ontologyDagName, gaStream, gaTableName, tableManager);
                
-               insertTasksAfterCurrentTask(new 
MapGeneAssociationTask(gaReader, manager));
+               insertTasksAfterCurrentTask(new 
MapGeneAssociationTask(gaReader, tableManager, networkManager));
                insertTasksAfterCurrentTask(gaReader);
-               insertTasksAfterCurrentTask(new 
RegisterOntologyTask((CyNetworkReader) loadOBOTask, manager, ontologyDagName));
+               insertTasksAfterCurrentTask(new 
RegisterOntologyTask((CyNetworkReader) loadOBOTask, networkManager, 
ontologyDagName));
                insertTasksAfterCurrentTask(loadOBOTask);
                
        }

Modified: 
core3/impl/trunk/table-import-impl/src/main/java/org/cytoscape/tableimport/internal/task/MapGeneAssociationTask.java
===================================================================
--- 
core3/impl/trunk/table-import-impl/src/main/java/org/cytoscape/tableimport/internal/task/MapGeneAssociationTask.java
        2012-04-03 19:34:03 UTC (rev 28729)
+++ 
core3/impl/trunk/table-import-impl/src/main/java/org/cytoscape/tableimport/internal/task/MapGeneAssociationTask.java
        2012-04-03 20:24:20 UTC (rev 28730)
@@ -8,7 +8,7 @@
 import org.cytoscape.model.CyNetworkManager;
 import org.cytoscape.model.CyRow;
 import org.cytoscape.model.CyTable;
-import org.cytoscape.model.CyIdentifiable;
+import org.cytoscape.model.CyTableManager;
 import 
org.cytoscape.tableimport.internal.reader.ontology.GeneAssociationReader;
 import org.cytoscape.tableimport.internal.reader.ontology.OBOReader;
 import org.cytoscape.work.AbstractTask;
@@ -22,9 +22,13 @@
 
        final CyNetworkManager networkManager;
        private final CyTableReader tableReader;
+       private final CyTableManager tableManager;
 
-       MapGeneAssociationTask(final CyTableReader tableReader, final 
CyNetworkManager networkManager) {
+       MapGeneAssociationTask(final CyTableReader tableReader,
+                                                  final CyTableManager 
tableManager,
+                                                  final CyNetworkManager 
networkManager) {
                this.tableReader = tableReader;
+               this.tableManager = tableManager;
                this.networkManager = networkManager;
        }
 
@@ -38,6 +42,7 @@
                if (tables == null || tables[0] == null)
                        throw new NullPointerException("Could not find table.");
 
+               tableManager.addTable(tables[0]);
                mapping(taskMonitor, tables[0]);
        }
 

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