Author: jm
Date: 2011-06-21 12:25:33 -0700 (Tue, 21 Jun 2011)
New Revision: 25835

Modified:
   core3/model-api/trunk/src/main/java/org/cytoscape/model/CyTable.java
   
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyTableFactoryImpl.java
   
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyTableImpl.java
   
core3/model-impl/trunk/impl/src/test/java/org/cytoscape/model/CyTableManagerTest.java
   
core3/model-impl/trunk/impl/src/test/java/org/cytoscape/model/CyTableTest.java
Log:
Fix for ticket #274: Added property to CyTable that indicates how/if it should 
be saved

Modified: core3/model-api/trunk/src/main/java/org/cytoscape/model/CyTable.java
===================================================================
--- core3/model-api/trunk/src/main/java/org/cytoscape/model/CyTable.java        
2011-06-21 18:36:29 UTC (rev 25834)
+++ core3/model-api/trunk/src/main/java/org/cytoscape/model/CyTable.java        
2011-06-21 19:25:33 UTC (rev 25835)
@@ -30,7 +30,6 @@
 
 import java.util.Collection;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 
 
@@ -57,6 +56,11 @@
                @Override
                final public String toString() { return 
humanReadableRepresentation; }
        }
+       
+       public static enum SavePolicy {
+               DO_NOT_SAVE,  /* i.e. this table should not be serialized */
+               SESSION_FILE,
+       }
 
        /**
         * A public CyTable is a table that is accessible to the user through 
the user
@@ -204,4 +208,16 @@
         */
        void addVirtualColumns(CyTable sourceTable, String sourceJoinKey, 
String targetJoinKey,
                               boolean isImmutable);
+       
+       /**
+        * Returns how (or if) this CyTable should be saved.
+        * @return how (or if) this CyTable should be saved.
+        */
+       SavePolicy getSavePolicy();
+       
+       /**
+        * Sets how (or if) this CyTable should be saved.
+        * @param policy the policy to follow during the lifecycle of the 
CyTable.
+        */
+       void setSavePolicy(SavePolicy policy);
 }

Modified: 
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyTableFactoryImpl.java
===================================================================
--- 
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyTableFactoryImpl.java
      2011-06-21 18:36:29 UTC (rev 25834)
+++ 
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyTableFactoryImpl.java
      2011-06-21 19:25:33 UTC (rev 25835)
@@ -34,6 +34,7 @@
 import java.util.HashMap;
 
 import org.cytoscape.model.CyTable;
+import org.cytoscape.model.CyTable.SavePolicy;
 import org.cytoscape.model.CyTableFactory;
 import org.cytoscape.equations.Interpreter;
 import org.cytoscape.event.CyEventHelper;
@@ -61,7 +62,7 @@
                                   final boolean pub, final boolean isMutable)
        {
                CyTable table = new CyTableImpl(name, primaryKey, 
primaryKeyType, pub, isMutable,
-                                               help, interpreter);
+                                               SavePolicy.SESSION_FILE, help, 
interpreter);
                tm.addTable(table);
                return table;
        }

Modified: 
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyTableImpl.java
===================================================================
--- 
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyTableImpl.java
     2011-06-21 18:36:29 UTC (rev 25834)
+++ 
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyTableImpl.java
     2011-06-21 19:25:33 UTC (rev 25835)
@@ -88,11 +88,13 @@
        private final Map<String, VirtualColumn> virtualColumnMap;
        private int virtualColumnReferenceCount;
 
+       private SavePolicy savePolicy;
+       
        /**
         * Creates a new CyTableImpl object.
         */
        public CyTableImpl(final String title, final String primaryKey, 
Class<?> primaryKeyType,
-                          final boolean pub, final boolean isMutable, final 
CyEventHelper eventHelper,
+                          final boolean pub, final boolean isMutable, 
SavePolicy savePolicy, final CyEventHelper eventHelper,
                           final Interpreter interpreter)
        {
                this.title = title;
@@ -102,6 +104,7 @@
                this.suid = SUIDFactory.getNextSUID();
                this.eventHelper = eventHelper;
                this.interpreter = interpreter;
+               this.savePolicy = savePolicy;
 
                currentlyActiveAttributes = new HashSet<String>();
                attributes = new HashMap<String, Map<Object, Object>>();
@@ -874,6 +877,16 @@
                }
        }
 
+       @Override
+       public SavePolicy getSavePolicy() {
+               return savePolicy;
+       }
+       
+       @Override
+       public void setSavePolicy(SavePolicy policy) {
+               savePolicy = policy;
+       }
+       
        private final class InternalRow implements CyRow {
                private final Object key;
                private final CyTable table;

Modified: 
core3/model-impl/trunk/impl/src/test/java/org/cytoscape/model/CyTableManagerTest.java
===================================================================
--- 
core3/model-impl/trunk/impl/src/test/java/org/cytoscape/model/CyTableManagerTest.java
       2011-06-21 18:36:29 UTC (rev 25834)
+++ 
core3/model-impl/trunk/impl/src/test/java/org/cytoscape/model/CyTableManagerTest.java
       2011-06-21 19:25:33 UTC (rev 25835)
@@ -31,6 +31,7 @@
 import java.util.Map;
 
 
+import org.cytoscape.model.CyTable.SavePolicy;
 import org.cytoscape.model.internal.CyTableManagerImpl;
 import org.cytoscape.model.internal.CyTableFactoryImpl;
 import org.cytoscape.model.internal.CyTableImpl;
@@ -75,10 +76,10 @@
        public void tableWithVirtColumnDeletionTest() {
                CyEventHelper eventHelper = new DummyCyEventHelper();
                final Interpreter interpreter = new InterpreterImpl();
-               CyTable table = new CyTableImpl("homer", "SUID", Long.class, 
true, true, eventHelper,
-                                               interpreter);
-               CyTable table2 = new CyTableImpl("marge", "SUID", Long.class, 
true, true, eventHelper,
-                                                interpreter);
+               CyTable table = new CyTableImpl("homer", "SUID", Long.class, 
true, true, SavePolicy.SESSION_FILE,
+                                               eventHelper, interpreter);
+               CyTable table2 = new CyTableImpl("marge", "SUID", Long.class, 
true, true, SavePolicy.SESSION_FILE,
+                                                eventHelper, interpreter);
 
                table.createColumn("x", Long.class, false);
                CyColumn column = table.getColumn("x");

Modified: 
core3/model-impl/trunk/impl/src/test/java/org/cytoscape/model/CyTableTest.java
===================================================================
--- 
core3/model-impl/trunk/impl/src/test/java/org/cytoscape/model/CyTableTest.java  
    2011-06-21 18:36:29 UTC (rev 25834)
+++ 
core3/model-impl/trunk/impl/src/test/java/org/cytoscape/model/CyTableTest.java  
    2011-06-21 19:25:33 UTC (rev 25835)
@@ -43,6 +43,7 @@
 import org.cytoscape.event.CyEventHelper;
 import org.cytoscape.event.CyMicroListener;
 import org.cytoscape.event.DummyCyEventHelper;
+import org.cytoscape.model.CyTable.SavePolicy;
 import org.cytoscape.model.internal.CyTableImpl;
 
 import static org.junit.Assert.*;
@@ -58,11 +59,11 @@
        public void setUp() {
                eventHelper = new DummyCyEventHelper();
                final Interpreter interpreter = new InterpreterImpl();
-               table = new CyTableImpl("homer", "SUID", Long.class, true, 
true, eventHelper,
-                                       interpreter);
+               table = new CyTableImpl("homer", "SUID", Long.class, true, 
true, SavePolicy.SESSION_FILE,
+                                       eventHelper, interpreter);
                attrs = table.getRow(1L);
-               table2 = new CyTableImpl("marge", "SUID", Long.class, true, 
true, eventHelper,
-                                        interpreter);
+               table2 = new CyTableImpl("marge", "SUID", Long.class, true, 
true, SavePolicy.SESSION_FILE,
+                                        eventHelper, interpreter);
        }
 
        @After

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