Author: ruschein
Date: 2011-02-15 16:11:46 -0800 (Tue, 15 Feb 2011)
New Revision: 24142

Modified:
   core3/model-api/trunk/src/main/java/org/cytoscape/model/CyColumn.java
   
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyTableTest.java
   
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyColumnImpl.java
Log:
Augmented the definition of an immutable column to include that immutable 
columns cannot be renamed.

Modified: core3/model-api/trunk/src/main/java/org/cytoscape/model/CyColumn.java
===================================================================
--- core3/model-api/trunk/src/main/java/org/cytoscape/model/CyColumn.java       
2011-02-16 00:02:35 UTC (rev 24141)
+++ core3/model-api/trunk/src/main/java/org/cytoscape/model/CyColumn.java       
2011-02-16 00:11:46 UTC (rev 24142)
@@ -38,6 +38,7 @@
 
        /** Change the name of this column.
         *  @param newName  the new column name
+        *  @throws IllegalArgumentException if the column is immutable
         */
        void setName(String newName);
 
@@ -53,7 +54,7 @@
        /** @return true if the column is the primary key, otherwise false. */
        boolean isPrimaryKey();
 
-       /** @return true if the column is immutable i.e. cannot be deleted, 
otherwise false.
+       /** @return true if the column is immutable i.e. cannot be deleted or 
renamed, otherwise false.
         *  Please note that this does not affect the ability to add or modify 
values in this column!
         */
        boolean isImmutable();

Modified: 
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyTableTest.java
===================================================================
--- 
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyTableTest.java
    2011-02-16 00:02:35 UTC (rev 24141)
+++ 
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyTableTest.java
    2011-02-16 00:11:46 UTC (rev 24142)
@@ -700,6 +700,13 @@
                assertEquals(Long.class, table.getColumn("xx").getType());
        }
 
+       @Test(expected=IllegalArgumentException.class)
+       public void testSetColumnNameWithImmutableColumn() {
+               table.createColumn("x", Long.class, true);
+               CyColumn column = table.getColumn("x");
+               column.setName("xx");
+       }
+
        @Test
        public void testCyColumnGetVirtualTable() {
                table.createColumn("x", Long.class, false);

Modified: 
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyColumnImpl.java
===================================================================
--- 
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyColumnImpl.java
    2011-02-16 00:02:35 UTC (rev 24141)
+++ 
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyColumnImpl.java
    2011-02-16 00:11:46 UTC (rev 24142)
@@ -74,6 +74,9 @@
                if (newName == null)
                        throw new NullPointerException("\"newName\" must not be 
null!");
 
+               if (isImmutable)
+                       throw new IllegalArgumentException("can't rename an 
immutable column!");
+
                final String oldName = columnName;
                columnName = newName;
                table.updateColumnName(oldName, newName);

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