Author: mes
Date: 2012-08-05 17:01:01 -0700 (Sun, 05 Aug 2012)
New Revision: 30103

Added:
   
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/AbstractTableFacade.java
   
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/LocalTableFacade.java.with_abstract
Modified:
   
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/api/model-api/src/main/java/org/cytoscape/model/CyNetwork.java
   
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/api/model-api/src/main/java/org/cytoscape/model/subnetwork/CyRootNetwork.java
   
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyRootNetworkImpl.java
   
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/CySubNetworkImpl.java
   
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/DefaultTablesNetwork.java
   
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/SharedTableFacade.java
Log:
first step in add row facade support

Modified: 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/api/model-api/src/main/java/org/cytoscape/model/CyNetwork.java
===================================================================
--- 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/api/model-api/src/main/java/org/cytoscape/model/CyNetwork.java
     2012-08-04 08:40:48 UTC (rev 30102)
+++ 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/api/model-api/src/main/java/org/cytoscape/model/CyNetwork.java
     2012-08-06 00:01:01 UTC (rev 30103)
@@ -57,6 +57,17 @@
        String DEFAULT_ATTRS = "USER";
 
        /**
+        * The name of the local <b>public</b> 
+        * CyTable that is created by default for CyNetworks, 
+        * CyNodes, and CyEdges. This table contains attributes
+        * which are specific to only this network.
+        * -- see {@link CyTableManager} for more information.
+        * The table should be referenced using this constant:
+        * <code>CyNetwork.DEFAULT_ATTRS</code>.
+        */
+       String LOCAL_ATTRS = "LOCAL_ATTRS";
+
+       /**
         * The name of the default <b>hidden</b> CyTable that is created 
         * by default for CyNetworks, CyNodes, and
         * CyEdges.  Other CyTables may also be associated with networks -- 

Modified: 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/api/model-api/src/main/java/org/cytoscape/model/subnetwork/CyRootNetwork.java
===================================================================
--- 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/api/model-api/src/main/java/org/cytoscape/model/subnetwork/CyRootNetwork.java
      2012-08-04 08:40:48 UTC (rev 30102)
+++ 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/api/model-api/src/main/java/org/cytoscape/model/subnetwork/CyRootNetwork.java
      2012-08-06 00:01:01 UTC (rev 30103)
@@ -69,11 +69,20 @@
 public interface CyRootNetwork extends CyNetwork {
 
        /**
-        * The name of the table shared by all subnetworks. 
+        * The name of the table containing the attributes shared
+        * by all subnetworks of this root network.  
+        * Direct use of this table is discouraged!
         */
        String SHARED_ATTRS = "SHARED_ATTRS";
 
        /**
+        * The name of the table that enables sharing default attributes
+        * with all subnetworks.
+        * Direct use of this table is discouraged!
+        */
+       String SHARED_DEFAULT_ATTRS = "SHARED_DEFAULT_ATTRS";
+
+       /**
         * The name of the shared name column found in the SHARED_ATTRS table. 
This
         * column value will be updated any time the value of the 
CyNetwork.NAME 
         * column in a default table is set. The purpose of this column is to 
serve

Added: 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/AbstractTableFacade.java
===================================================================
--- 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/AbstractTableFacade.java
                           (rev 0)
+++ 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/AbstractTableFacade.java
   2012-08-06 00:01:01 UTC (rev 30103)
@@ -0,0 +1,252 @@
+
+/*
+ Copyright (c) 2008, 2010-2012, The Cytoscape Consortium (www.cytoscape.org)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications.  In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage.  See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+package org.cytoscape.model.internal;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.cytoscape.equations.Equation;
+import org.cytoscape.equations.Interpreter;
+import org.cytoscape.event.CyEventHelper;
+import org.cytoscape.model.CyIdentifiable;
+import org.cytoscape.model.CyColumn;
+import org.cytoscape.model.CyRow;
+import org.cytoscape.model.CyTable;
+import org.cytoscape.model.SavePolicy;
+import org.cytoscape.model.SUIDFactory;
+import org.cytoscape.model.VirtualColumnInfo;
+import org.cytoscape.model.events.ColumnCreatedEvent;
+import org.cytoscape.model.events.ColumnDeletedEvent;
+import org.cytoscape.model.events.ColumnNameChangedEvent;
+import org.cytoscape.model.events.RowSetRecord;
+import org.cytoscape.model.events.RowsCreatedEvent;
+import org.cytoscape.model.events.RowsSetEvent;
+import org.cytoscape.model.events.TableAddedEvent;
+import org.cytoscape.model.events.TableAddedListener;
+import org.cytoscape.model.events.TablePrivacyChangedEvent;
+import org.cytoscape.model.events.TableTitleChangedEvent;
+
+import com.google.common.collect.SetMultimap;
+import com.google.common.collect.HashMultimap;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * An abstract table facade class. 
+ */
+public abstract class AbstractTableFacade implements CyTable {
+       
+       private static final Logger logger = 
LoggerFactory.getLogger(AbstractTableFacade.class);
+       private final CyTable actual;
+       private final Long suid;
+       private final Map<CyRow,CyRow> facadeRows; 
+
+       public AbstractTableFacade(CyTable actual) {
+               this.actual = actual;
+               this.suid = Long.valueOf(SUIDFactory.getNextSUID()); 
+               this.facadeRows = new HashMap<CyRow,CyRow>();
+       }
+
+       public Long getSUID() {
+               return suid;    
+       }
+
+       public boolean isPublic() {
+               return actual.isPublic();
+       }
+       
+       public void setPublic (boolean isPublic) {
+               actual.setPublic(isPublic);     
+       }
+
+       public CyTable.Mutability getMutability() {
+               return actual.getMutability();
+       }
+
+       public String getTitle() {
+               return actual.getTitle();
+       }
+
+       public void setTitle(String title) {
+               actual.setTitle(title);
+       }
+
+       public CyColumn getPrimaryKey() {
+               return actual.getPrimaryKey();
+       }
+
+       public CyColumn getColumn(String columnName) {
+               return actual.getColumn(columnName);
+       }
+
+       public Collection<CyColumn> getColumns() {
+               return actual.getColumns();
+       }
+
+       public void deleteColumn(String columnName) {
+               actual.deleteColumn(columnName);
+                       
+       }
+
+       public CyRow getRow(Object primaryKey) {
+               CyRow actualRow = actual.getRow(primaryKey);
+               if ( actualRow == null )
+                       return null;
+               
+               return getFacadeRow(actualRow);
+       }
+
+       private CyRow getFacadeRow(CyRow actualRow) {
+               CyRow ret = facadeRows.get(actualRow);
+               if ( ret == null ) { 
+                       ret = new RowFacade(actualRow,this);
+                       facadeRows.put(actualRow,ret);
+               }
+
+               return ret; 
+       }
+
+       public boolean rowExists(Object primaryKey) {
+               return actual.rowExists(primaryKey); 
+       }
+
+       public boolean deleteRows(Collection<?> primaryKeys) {
+               return actual.deleteRows(primaryKeys); 
+       }
+
+       public List<CyRow> getAllRows() {
+               return getFacadeRows(actual.getAllRows());      
+       }
+
+       public String getLastInternalError() {
+               return actual.getLastInternalError();
+       }
+
+       public Collection<CyRow> getMatchingRows(String columnName, Object 
value) {
+               return getFacadeRows(actual.getMatchingRows(columnName,value));
+       }
+
+       private List<CyRow> getFacadeRows(Collection<CyRow> rows) {
+               List<CyRow> frows = new ArrayList<CyRow>( rows.size() ); 
+               for ( CyRow r : rows )
+                       frows.add( getFacadeRow(r) ); 
+
+               return frows;
+       }
+
+       public int countMatchingRows(String columnName, Object value) {
+               return actual.countMatchingRows(columnName, value);
+
+       }
+
+       public int getRowCount() {
+               return actual.getRowCount();    
+       }
+
+       public SavePolicy getSavePolicy() {
+               return actual.getSavePolicy();
+       }
+
+       public void setSavePolicy(SavePolicy policy) {
+               actual.setSavePolicy(policy);
+       }
+
+       public void swap(CyTable otherTable) {
+               // TODO do we need to do something here?
+               actual.swap(otherTable);        
+       }
+
+       private class RowFacade implements CyRow {
+               private final CyRow actualRow;
+               private final CyTable table;
+
+               RowFacade(CyRow actualRow, CyTable table) {
+                       this.actualRow = actualRow;
+                       this.table = table;
+               }
+
+               @Override
+               public void set(String attributeName, Object value) {
+                       actualRow.set(attributeName,value);
+               }
+
+               @Override
+               public <T> T get(String attributeName, Class<? extends T> c) {
+                       return actualRow.get(attributeName, c);
+               }
+
+               @Override
+               public <T> T get(String attributeName, Class<? extends T> c, T 
defValue) {
+                       return actualRow.get(attributeName, c, defValue);
+               }
+
+               @Override
+               public <T> List<T> getList(String attributeName, Class<T> c) {
+                       return actualRow.getList(attributeName, c);
+               }
+
+               @Override
+               public <T> List<T> getList(String attributeName, Class<T> c, 
List<T> defValue) {
+                       return actualRow.getList( attributeName, c, defValue);
+               }
+
+               @Override
+               public Object getRaw(String attributeName) {
+                       return actualRow.getRaw(attributeName);
+               }
+
+               @Override
+               public boolean isSet(String attributeName) {
+                       return actualRow.isSet(attributeName);
+               }
+
+               @Override
+               public Map<String, Object> getAllValues() {
+                       return actualRow.getAllValues();
+               }
+
+               @Override
+               public CyTable getTable() {
+                       return table;
+               }
+
+               @Override
+               public String toString() {
+                       return "FACADE of: " + actualRow.toString();
+               }
+       }
+}

Modified: 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyRootNetworkImpl.java
===================================================================
--- 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyRootNetworkImpl.java
     2012-08-04 08:40:48 UTC (rev 30102)
+++ 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyRootNetworkImpl.java
     2012-08-06 00:01:01 UTC (rev 30103)
@@ -108,9 +108,9 @@
                
                createRootNetworkTables();
                initTables(this, 
-                          (SharedTableFacade)(networkTableMgr.getTable(this, 
CyNetwork.class, "SHARED_ATTRS_FACADE")),
-                          (SharedTableFacade)(networkTableMgr.getTable(this, 
CyNode.class, "SHARED_ATTRS_FACADE")),
-                                  
(SharedTableFacade)(networkTableMgr.getTable(this, CyEdge.class, 
"SHARED_ATTRS_FACADE")) );
+                          (SharedTableFacade)(networkTableMgr.getTable(this, 
CyNetwork.class, CyRootNetwork.SHARED_DEFAULT_ATTRS)),
+                          (SharedTableFacade)(networkTableMgr.getTable(this, 
CyNode.class, CyRootNetwork.SHARED_DEFAULT_ATTRS)),
+                                  
(SharedTableFacade)(networkTableMgr.getTable(this, CyEdge.class, 
CyRootNetwork.SHARED_DEFAULT_ATTRS)) );
 
                getRow(this).set(CyNetwork.NAME, "");
 
@@ -160,7 +160,7 @@
                final CyTable edgeSharedTable = new 
SharedTableFacade(rawEdgeSharedTable,this,CyEdge.class,networkTableMgr);
 
                networkTableMgr.setTable(this, CyEdge.class, 
CyRootNetwork.SHARED_ATTRS, rawEdgeSharedTable);
-               networkTableMgr.setTable(this, CyEdge.class, 
"SHARED_ATTRS_FACADE", edgeSharedTable);
+               networkTableMgr.setTable(this, CyEdge.class, 
CyRootNetwork.SHARED_DEFAULT_ATTRS, edgeSharedTable);
 
                edgeSharedTable.createColumn(CyRootNetwork.SHARED_NAME, 
String.class, true);
                edgeSharedTable.createColumn(CyRootNetwork.SHARED_INTERACTION, 
String.class, true);
@@ -171,7 +171,7 @@
                final CyTable networkSharedTable = new 
SharedTableFacade(rawNetworkSharedTable,this,CyNetwork.class,networkTableMgr);
 
                networkTableMgr.setTable(this, CyNetwork.class, 
CyRootNetwork.SHARED_ATTRS, rawNetworkSharedTable);
-               networkTableMgr.setTable(this, CyNetwork.class, 
"SHARED_ATTRS_FACADE", networkSharedTable);
+               networkTableMgr.setTable(this, CyNetwork.class, 
CyRootNetwork.SHARED_DEFAULT_ATTRS, networkSharedTable);
                
                networkSharedTable.createColumn(CyRootNetwork.SHARED_NAME, 
String.class, true);
                
@@ -179,7 +179,7 @@
 
                final CyTable nodeSharedTable = new 
SharedTableFacade(rawNodeSharedTable,this,CyNode.class,networkTableMgr);
                networkTableMgr.setTable(this, CyNode.class, 
CyRootNetwork.SHARED_ATTRS, rawNodeSharedTable);
-               networkTableMgr.setTable(this, CyNode.class, 
"SHARED_ATTRS_FACADE", nodeSharedTable);
+               networkTableMgr.setTable(this, CyNode.class, 
CyRootNetwork.SHARED_DEFAULT_ATTRS, nodeSharedTable);
                
                nodeSharedTable.createColumn(CyRootNetwork.SHARED_NAME, 
String.class, true);
        }
@@ -288,10 +288,10 @@
                networkAddedListenerDelegator.addListener(sub);
                
                subNetworks.add(sub);
-               
nameSetListener.addInterestedTables(sub.getDefaultNetworkTable(),networkTableMgr.getTable(this,
 CyNetwork.class, "SHARED_ATTRS_FACADE"));
-               
nameSetListener.addInterestedTables(sub.getDefaultNodeTable(),networkTableMgr.getTable(this,
 CyNode.class, "SHARED_ATTRS_FACADE"));
-               
nameSetListener.addInterestedTables(sub.getDefaultEdgeTable(),networkTableMgr.getTable(this,
 CyEdge.class, "SHARED_ATTRS_FACADE"));
-               
interactionSetListener.addInterestedTables(sub.getDefaultEdgeTable(), 
networkTableMgr.getTable(this, CyEdge.class, "SHARED_ATTRS_FACADE"));
+               
nameSetListener.addInterestedTables(sub.getDefaultNetworkTable(),networkTableMgr.getTable(this,
 CyNetwork.class, CyRootNetwork.SHARED_DEFAULT_ATTRS));
+               
nameSetListener.addInterestedTables(sub.getDefaultNodeTable(),networkTableMgr.getTable(this,
 CyNode.class, CyRootNetwork.SHARED_DEFAULT_ATTRS));
+               
nameSetListener.addInterestedTables(sub.getDefaultEdgeTable(),networkTableMgr.getTable(this,
 CyEdge.class, CyRootNetwork.SHARED_DEFAULT_ATTRS));
+               
interactionSetListener.addInterestedTables(sub.getDefaultEdgeTable(), 
networkTableMgr.getTable(this, CyEdge.class, 
CyRootNetwork.SHARED_DEFAULT_ATTRS));
 
                
                return sub;
@@ -327,17 +327,17 @@
 
        @Override
        public CyTable getSharedNetworkTable() {
-               return networkTableMgr.getTable(this, CyNetwork.class, 
"SHARED_ATTRS_FACADE"); 
+               return networkTableMgr.getTable(this, CyNetwork.class, 
CyRootNetwork.SHARED_DEFAULT_ATTRS); 
        }
 
        @Override
        public CyTable getSharedNodeTable() {
-               return networkTableMgr.getTable(this, CyNode.class, 
"SHARED_ATTRS_FACADE"); 
+               return networkTableMgr.getTable(this, CyNode.class, 
CyRootNetwork.SHARED_DEFAULT_ATTRS); 
        }
 
        @Override
        public CyTable getSharedEdgeTable() {
-               return networkTableMgr.getTable(this, CyEdge.class, 
"SHARED_ATTRS_FACADE"); 
+               return networkTableMgr.getTable(this, CyEdge.class, 
CyRootNetwork.SHARED_DEFAULT_ATTRS); 
        }
 
        @Override

Modified: 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/CySubNetworkImpl.java
===================================================================
--- 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/CySubNetworkImpl.java
      2012-08-04 08:40:48 UTC (rev 30102)
+++ 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/CySubNetworkImpl.java
      2012-08-06 00:01:01 UTC (rev 30103)
@@ -90,9 +90,9 @@
                this.savePolicy = savePolicy;
                
                initTables(this, 
-                          (SharedTableFacade)(networkTableMgr.getTable(parent, 
CyNetwork.class, "SHARED_ATTRS_FACADE")),
-                          (SharedTableFacade)(networkTableMgr.getTable(parent, 
CyNode.class, "SHARED_ATTRS_FACADE")),
-                                  
(SharedTableFacade)(networkTableMgr.getTable(parent, CyEdge.class, 
"SHARED_ATTRS_FACADE")) );
+                          (SharedTableFacade)(networkTableMgr.getTable(parent, 
CyNetwork.class, CyRootNetwork.SHARED_DEFAULT_ATTRS)),
+                          (SharedTableFacade)(networkTableMgr.getTable(parent, 
CyNode.class, CyRootNetwork.SHARED_DEFAULT_ATTRS)),
+                                  
(SharedTableFacade)(networkTableMgr.getTable(parent, CyEdge.class, 
CyRootNetwork.SHARED_DEFAULT_ATTRS)) );
 
                fireAddedNodesAndEdgesEvents = false;           
        }

Modified: 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/DefaultTablesNetwork.java
===================================================================
--- 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/DefaultTablesNetwork.java
  2012-08-04 08:40:48 UTC (rev 30102)
+++ 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/DefaultTablesNetwork.java
  2012-08-06 00:01:01 UTC (rev 30103)
@@ -132,7 +132,7 @@
        private void createNetworkTables(long suidx, CyTableFactory 
tableFactory, boolean pubTables, SharedTableFacade sharedNetworkTable) {        
    
                final CyTable defTable = tableFactory.createTable(suidx
                                + " default network", CyIdentifiable.SUID, 
Long.class, pubTables, false, InitialTableSize.SMALL);
-               networkTableManager.setTable(networkRef.get(), CyNetwork.class, 
"LOCAL_ATTRS", defTable);
+               networkTableManager.setTable(networkRef.get(), CyNetwork.class, 
CyNetwork.LOCAL_ATTRS, defTable);
                LocalTableFacade localTable = new 
LocalTableFacade(defTable,sharedNetworkTable);
                networkTableManager.setTable(networkRef.get(), CyNetwork.class, 
CyNetwork.DEFAULT_ATTRS, localTable);
                if ( eventHelper instanceof TableEventHelperFacade )
@@ -149,7 +149,7 @@
        private void createNodeTables(long suidx, CyTableFactory tableFactory, 
boolean pubTables, int num, SharedTableFacade sharedNodeTable) {
                final CyTable defTable = tableFactory.createTable(suidx
                                + " default node", CyIdentifiable.SUID, 
Long.class, pubTables, false, InitialTableSize.SMALL);
-               networkTableManager.setTable(networkRef.get(), CyNode.class, 
"LOCAL_ATTRS", defTable);
+               networkTableManager.setTable(networkRef.get(), CyNode.class, 
CyNetwork.LOCAL_ATTRS, defTable);
                LocalTableFacade localTable = new 
LocalTableFacade(defTable,sharedNodeTable);
                networkTableManager.setTable(networkRef.get(), CyNode.class, 
CyNetwork.DEFAULT_ATTRS, localTable);
                if ( eventHelper instanceof TableEventHelperFacade )
@@ -166,7 +166,7 @@
        private void createEdgeTables(long suidx, CyTableFactory tableFactory, 
boolean pubTables, int num, SharedTableFacade sharedEdgeTable) {
                final CyTable defTable = tableFactory.createTable(suidx + " 
default edge", CyIdentifiable.SUID, Long.class,
                                pubTables, false, InitialTableSize.SMALL);
-               networkTableManager.setTable(networkRef.get(), CyEdge.class, 
"LOCAL_ATTRS", defTable);
+               networkTableManager.setTable(networkRef.get(), CyEdge.class, 
CyNetwork.LOCAL_ATTRS, defTable);
 
                LocalTableFacade localTable = new 
LocalTableFacade(defTable,sharedEdgeTable);
                networkTableManager.setTable(networkRef.get(), CyEdge.class, 
CyNetwork.DEFAULT_ATTRS, localTable);

Added: 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/LocalTableFacade.java.with_abstract
===================================================================
--- 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/LocalTableFacade.java.with_abstract
                                (rev 0)
+++ 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/LocalTableFacade.java.with_abstract
        2012-08-06 00:01:01 UTC (rev 30103)
@@ -0,0 +1,122 @@
+
+/*
+ Copyright (c) 2008, 2010-2012, The Cytoscape Consortium (www.cytoscape.org)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications.  In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage.  See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+package org.cytoscape.model.internal;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.cytoscape.equations.Equation;
+import org.cytoscape.equations.Interpreter;
+import org.cytoscape.event.CyEventHelper;
+import org.cytoscape.model.CyIdentifiable;
+import org.cytoscape.model.CyColumn;
+import org.cytoscape.model.CyRow;
+import org.cytoscape.model.CyTable;
+import org.cytoscape.model.SavePolicy;
+import org.cytoscape.model.SUIDFactory;
+import org.cytoscape.model.VirtualColumnInfo;
+import org.cytoscape.model.events.ColumnCreatedEvent;
+import org.cytoscape.model.events.ColumnDeletedEvent;
+import org.cytoscape.model.events.ColumnNameChangedEvent;
+import org.cytoscape.model.events.RowSetRecord;
+import org.cytoscape.model.events.RowsCreatedEvent;
+import org.cytoscape.model.events.RowsSetEvent;
+import org.cytoscape.model.events.TableAddedEvent;
+import org.cytoscape.model.events.TableAddedListener;
+import org.cytoscape.model.events.TablePrivacyChangedEvent;
+import org.cytoscape.model.events.TableTitleChangedEvent;
+
+import com.google.common.collect.SetMultimap;
+import com.google.common.collect.HashMultimap;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * A facade class that provides a unified interface for a default table
+ * that has properties of both shared and local tables. All accessor methods
+ * query the local table.  All table metadata (public, mutability, etc.) is
+ * stored and accessed in the local table. All column creation methods create 
the columns
+ * on the shared table and then immediately create a virtual column of this
+ * new column in the local table.  All virtual column methods create virtual 
+ * columns in both the shared and local tables. 
+ */
+public final class LocalTableFacade extends AbstractTableFacade implements 
CyTable {
+       
+       
+       private static final Logger logger = 
LoggerFactory.getLogger(LocalTableFacade.class);
+       private final CyTable shared;
+       private final CyTable local;
+
+       public LocalTableFacade(CyTable local, SharedTableFacade shared) {
+               super(local);
+               this.local = local;
+               this.shared = shared;
+
+               // this adds virtual columns for any existing columns already 
in the shared table
+               local.addVirtualColumns(shared.getActualTable(), 
CyIdentifiable.SUID, true);
+       }
+
+       CyTable getLocalTable() {
+               return local;
+       }
+
+       public <T> void createColumn(String columnName, Class<?extends T> type, 
boolean isImmutable) {
+               createColumn(columnName,type,isImmutable,null);
+       }
+
+       public <T> void createColumn(String columnName, Class<?extends T> type, 
boolean isImmutable, T defaultValue) {
+               logger.debug("delegating createColumn '" + columnName + "' from 
local " + local.getTitle() + " to shared: " + shared.getTitle());
+               shared.createColumn(columnName,type,isImmutable,defaultValue);
+       }
+
+       public <T> void createListColumn(String columnName, Class<T> 
listElementType, boolean isImmutable) {
+               createListColumn(columnName,listElementType,isImmutable,null);
+       }
+
+       public <T> void createListColumn(String columnName, Class<T> 
listElementType, boolean isImmutable, List<T> defaultValue ) {
+               
shared.createListColumn(columnName,listElementType,isImmutable,defaultValue);
+       }
+
+       public String addVirtualColumn(String virtualColumn, String 
sourceColumn, CyTable sourceTable, String targetJoinKey, boolean isImmutable) {
+               String s = shared.addVirtualColumn(virtualColumn, sourceColumn, 
sourceTable, targetJoinKey, isImmutable);
+               return s;
+       }
+
+       public void addVirtualColumns(CyTable sourceTable, String 
targetJoinKey, boolean isImmutable) {
+               shared.addVirtualColumns(sourceTable, targetJoinKey, 
isImmutable);
+       }
+}

Modified: 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/SharedTableFacade.java
===================================================================
--- 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/SharedTableFacade.java
     2012-08-04 08:40:48 UTC (rev 30102)
+++ 
csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/model-impl/impl/src/main/java/org/cytoscape/model/internal/SharedTableFacade.java
     2012-08-06 00:01:01 UTC (rev 30103)
@@ -43,6 +43,7 @@
 import org.cytoscape.model.CyColumn;
 import org.cytoscape.model.CyRow;
 import org.cytoscape.model.CyTable;
+import org.cytoscape.model.CyNetwork;
 import org.cytoscape.model.SavePolicy;
 import org.cytoscape.model.SUIDFactory;
 import org.cytoscape.model.CyNetworkTableManager;
@@ -70,18 +71,17 @@
 
 /**
  */
-public final class SharedTableFacade implements CyTable {
+public final class SharedTableFacade extends AbstractTableFacade implements 
CyTable {
        
        private static final Logger logger = 
LoggerFactory.getLogger(SharedTableFacade.class);
-       private final CyTable shared;
-       private final Long suid;
+       private final CyTable shared; 
        private final CyRootNetwork rootNetwork; 
        private final Class<? extends CyIdentifiable> type;
        private final CyNetworkTableManager netTableMgr;
 
        public SharedTableFacade(CyTable shared, CyRootNetwork rootNetwork, 
Class<? extends CyIdentifiable> type, CyNetworkTableManager netTableMgr ) {
+               super(shared);
                this.shared = shared;
-               this.suid = Long.valueOf(SUIDFactory.getNextSUID()); 
                this.rootNetwork = rootNetwork;
                this.type = type;
                this.netTableMgr = netTableMgr;
@@ -94,56 +94,15 @@
        private List<CyTable> localTables() {
                logger.debug("  - looking for local tables: ");
                List<CyTable> tables = new ArrayList<CyTable>();
-               tables.add( netTableMgr.getTable( rootNetwork, type, 
"LOCAL_ATTRS" ) );
+               tables.add( netTableMgr.getTable( rootNetwork, type, 
CyNetwork.LOCAL_ATTRS ) );
                for (CyNetwork sub : rootNetwork.getSubNetworkList()) {
                        logger.debug("  -- found subnetwork with local tables: 
" + sub.toString());
-                       tables.add( netTableMgr.getTable( sub, type, 
"LOCAL_ATTRS" ) );
+                       tables.add( netTableMgr.getTable( sub, type, 
CyNetwork.LOCAL_ATTRS ) );
                }
                return tables;
        }
 
 
-       public Long getSUID() {
-               return suid;    
-       }
-
-       public boolean isPublic() {
-               return shared.isPublic();
-       }
-       
-       public void setPublic (boolean isPublic) {
-               shared.setPublic(isPublic);     
-       }
-
-       public CyTable.Mutability getMutability() {
-               return shared.getMutability();
-       }
-
-       public String getTitle() {
-               return shared.getTitle();
-       }
-
-       public void setTitle(String title) {
-               shared.setTitle(title);
-       }
-
-       public CyColumn getPrimaryKey() {
-               return shared.getPrimaryKey();
-       }
-
-       public CyColumn getColumn(String columnName) {
-               return shared.getColumn(columnName);
-       }
-
-       public Collection<CyColumn> getColumns() {
-               return shared.getColumns();
-       }
-
-       public void deleteColumn(String columnName) {
-               shared.deleteColumn(columnName);
-                       
-       }
-
        public <T> void createColumn(String columnName, Class<?extends T> type, 
boolean isImmutable) {
                createColumn(columnName, type, isImmutable,null);
        }
@@ -172,38 +131,6 @@
                        
local.addVirtualColumn(columnName,columnName,shared,CyIdentifiable.SUID,isImmutable);
        }
 
-       public CyRow getRow(Object primaryKey) {
-               return shared.getRow(primaryKey);
-       }
-
-       public boolean rowExists(Object primaryKey) {
-               return shared.rowExists(primaryKey); 
-       }
-
-       public boolean deleteRows(Collection<?> primaryKeys) {
-               return shared.deleteRows(primaryKeys); 
-       }
-
-       public List<CyRow> getAllRows() {
-               return shared.getAllRows();     
-       }
-
-       public String getLastInternalError() {
-               return shared.getLastInternalError();
-       }
-
-       public Collection<CyRow> getMatchingRows(String columnName, Object 
value) {
-               return shared.getMatchingRows(columnName,value);        
-       }
-
-       public int countMatchingRows(String columnName, Object value) {
-               return shared.countMatchingRows(columnName, value);
-       }
-
-       public int getRowCount() {
-               return shared.getRowCount();    
-       }
-
        public String addVirtualColumn(String virtualColumn, String 
sourceColumn, CyTable sourceTable, String targetJoinKey, boolean isImmutable) {
                //String ret = shared.addVirtualColumn(virtualColumn, 
sourceColumn, sourceTable, targetJoinKey, isImmutable);
                for ( CyTable local : localTables() ) 
@@ -216,16 +143,4 @@
                for ( CyTable local : localTables() ) 
                        local.addVirtualColumns(sourceTable, targetJoinKey, 
isImmutable);
        }
-
-       public SavePolicy getSavePolicy() {
-               return shared.getSavePolicy();
-       }
-
-       public void setSavePolicy(SavePolicy policy) {
-               shared.setSavePolicy(policy);
-       }
-
-       public void swap(CyTable otherTable) {
-               shared.swap(otherTable);        
-       }
 }

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