Author: mes
Date: 2010-09-05 16:44:18 -0700 (Sun, 05 Sep 2010)
New Revision: 21705
Modified:
core3/model-api/trunk/src/main/java/org/cytoscape/model/CyDataTable.java
core3/model-api/trunk/src/main/java/org/cytoscape/model/CyDataTableFactory.java
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyDataTableTest.java
Log:
added the concept of primary key to CyDataTable
Modified:
core3/model-api/trunk/src/main/java/org/cytoscape/model/CyDataTable.java
===================================================================
--- core3/model-api/trunk/src/main/java/org/cytoscape/model/CyDataTable.java
2010-09-05 23:43:28 UTC (rev 21704)
+++ core3/model-api/trunk/src/main/java/org/cytoscape/model/CyDataTable.java
2010-09-05 23:44:18 UTC (rev 21705)
@@ -72,6 +72,16 @@
String getTitle();
/**
+ * @return The name of the primary key column for this table.
+ */
+ String getPrimaryKey();
+
+ /**
+ * @return The class type of the primary key column for this table.
+ */
+ Class<?> getPrimaryKeyType();
+
+ /**
*
* @param title The human readable title for the CyDataTable suitable
for use in a user
* interface.
@@ -115,18 +125,18 @@
<T> List<T> getColumnValues(String columnName, Class<?extends T> type);
/**
+ * Returns the row specified by the primary key object and if a row
+ * for the specified key does not yet exist in the table, a new row
+ * will be created and the new row will be returned.
+ *
* @param primaryKey The primary key index of the row to return.
*
- * @return The {...@link CyRow} identified by the specified index.
+ * @return The {...@link CyRow} identified by the specified key or a new
+ * row identified by the key if one did not already exist.
*/
- CyRow getRow(long primaryKey);
+ CyRow getRow(Object primaryKey);
/**
- * @return A new {...@link CyRow} object for this CyDataTable.
- */
- CyRow addRow();
-
- /**
* Return a list of all the rows stored in this data table
*/
List<CyRow> getAllRows();
Modified:
core3/model-api/trunk/src/main/java/org/cytoscape/model/CyDataTableFactory.java
===================================================================
---
core3/model-api/trunk/src/main/java/org/cytoscape/model/CyDataTableFactory.java
2010-09-05 23:43:28 UTC (rev 21704)
+++
core3/model-api/trunk/src/main/java/org/cytoscape/model/CyDataTableFactory.java
2010-09-05 23:44:18 UTC (rev 21705)
@@ -46,13 +46,15 @@
*/
public interface CyDataTableFactory {
/**
- * @param name The name of the CyDataTable.
+ * @param title The name of the CyDataTable.
+ * @param primaryKey The name primaryKey column for this table.
+ * @param primaryKeyType The type of the primaryKey column for this
table.
* @param pub Whether or not the CyDataTable should be public.
*
* @return A new {...@link CyDataTable} with the specified name that is
either public or not (see
* {...@link CyDataTable#isPublic}.
*/
- CyDataTable createTable(String name, boolean pub);
+ CyDataTable createTable(String title, String primaryKey, Class<?>
primaryKeyType, boolean pub);
/**
* @param includePrivate Whether to include private CyDataTables
Modified:
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyDataTableTest.java
===================================================================
---
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyDataTableTest.java
2010-09-05 23:43:28 UTC (rev 21704)
+++
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyDataTableTest.java
2010-09-05 23:44:18 UTC (rev 21705)
@@ -67,15 +67,6 @@
/**
- * addRow was implemented to return null (rather than a row).
- * This is just to insure it continues to work.
- */
- public void testAddRow() {
- CyRow row = mgr.addRow();
- assertNotNull(row);
- }
-
- /**
* DOCUMENT ME!
*/
public void testAddStringAttr() {
@@ -281,5 +272,10 @@
assertFalse( mgr.getColumnTypeMap().containsKey("someInt") );
}
+ public void testPrimaryKey() {
+ String pk = mgr.getPrimaryKey();
+ assertEquals( mgr.getPrimaryKeyType(),
mgr.getColumnTypeMap().get(pk) );
+ }
+
// lots more needed
}
--
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.