Author: ruschein
Date: 2011-02-03 16:31:17 -0800 (Thu, 03 Feb 2011)
New Revision: 24022
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
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyTableImpl.java
Log:
Added CyColumn.getVirtualTable().
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-04 00:22:56 UTC (rev 24021)
+++ core3/model-api/trunk/src/main/java/org/cytoscape/model/CyColumn.java
2011-02-04 00:31:17 UTC (rev 24022)
@@ -63,6 +63,12 @@
*/
CyTable getTable();
+ /** Returns the originating table for this column if this column is
virtual.
+ * @return the actual table that this column originates at if it is
virtual, or null if the
+ * column is not virtual
+ */
+ CyTable getVirtualTable();
+
/** Returns all the values, some of which may be null, for this given
column.
* @param type the datatype of this column. (You can use getType()
to obtain it.)
* @return the values in this column in some arbitrary but consistent
order
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-04 00:22:56 UTC (rev 24021)
+++
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyTableTest.java
2011-02-04 00:31:17 UTC (rev 24022)
@@ -698,4 +698,16 @@
assertNotNull(table.getColumn("xx"));
assertEquals(Long.class, table.getColumn("xx").getType());
}
+
+ @Test
+ public void testCyColumnGetVirtualTable() {
+ table.createColumn("x", Long.class, false);
+ CyColumn column = table.getColumn("x");
+ assertNull(column.getVirtualTable());
+ table2.createColumn("x2", Long.class, false);
+ table2.createListColumn("b", Boolean.class, false);
+ table.addVirtualColumn("b1", "b", table2, "x2", "x", true);
+ CyColumn column2 = table.getColumn("b1");
+ assertEquals(table2, column2.getVirtualTable());
+ }
}
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-04 00:22:56 UTC (rev 24021)
+++
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyColumnImpl.java
2011-02-04 00:31:17 UTC (rev 24022)
@@ -41,11 +41,12 @@
private final Class<?> columnType;
private final Class<?> listElementType;
private final boolean isVirtual;
+ private final CyTable virtTable;
private final boolean isPrimaryKey;
private final boolean isImmutable;
CyColumnImpl(final CyTableImpl table, final String columnName, final
Class<?> columnType,
- final Class<?> listElementType, final boolean isVirtual,
+ final Class<?> listElementType, final boolean isVirtual,
final CyTable virtTable,
final boolean isPrimaryKey, final boolean isImmutable)
{
this.table = table;
@@ -53,6 +54,7 @@
this.columnType = columnType;
this.listElementType = listElementType;
this.isVirtual = isVirtual;
+ this.virtTable = virtTable;
this.isPrimaryKey = isPrimaryKey;
this.isImmutable = isImmutable;
}
@@ -60,6 +62,9 @@
@Override
public CyTable getTable() { return table; }
+ @Override
+ public CyTable getVirtualTable() { return virtTable; }
+
/** @return the name of the column. */
@Override
public String getName() { return columnName; }
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-02-04 00:22:56 UTC (rev 24021)
+++
core3/model-impl/trunk/impl/src/main/java/org/cytoscape/model/internal/CyTableImpl.java
2011-02-04 00:31:17 UTC (rev 24022)
@@ -110,6 +110,7 @@
types.put(primaryKey, new CyColumnImpl(this, primaryKey,
primaryKeyType,
/* listElementType = */
null,
/* isVirtual = */ false,
+ /* virtTable = */ null,
/* isPrimaryKey = */
true,
/* isImmutable = */
true));
attributes.put(primaryKey, new HashMap<Object, Object>());
@@ -266,6 +267,7 @@
types.put(columnName, new CyColumnImpl(this,
columnName, type,
/*
listElementType = */ null,
/* isVirtual =
*/ false,
+ /* virtTable =
*/ null,
/* isPrimaryKey
= */ false,
isImmutable));
attributes.put(columnName, new HashMap<Object,
Object>());
@@ -291,10 +293,11 @@
+ columnName
+ "' with type: "
+
types.get(columnName).getType());
types.put(columnName, new CyColumnImpl(this,
columnName, List.class,
-
listElementType,
- /* isVirtual
= */ false,
- /*
isPrimaryKey = */ false,
-
isImmutable));
+ listElementType,
+ /* isVirtual =
*/ false,
+ /* virtTable =
*/ null,
+ /* isPrimaryKey
= */ false,
+ isImmutable));
attributes.put(columnName, new HashMap<Object,
Object>());
reverse.put(columnName, new HashMap<Object,
Set<Object>>());
}
@@ -777,7 +780,9 @@
final CyColumn targetColumn =
new CyColumnImpl(this, virtualColumnName,
sourceColumn.getType(),
sourceColumn.getListElementType(),
- /* isVirtual = */ true, /*
isPrimaryKey = */ false,
+ /* isVirtual = */ true,
+ /* virtTable = */ sourceTable,
+ /* isPrimaryKey = */ false,
isImmutable);
types.put(targetName, targetColumn);
virtualColumnMap.put(targetName,
--
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.