Author: mes
Date: 2011-11-22 13:56:13 -0800 (Tue, 22 Nov 2011)
New Revision: 27560
Modified:
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyTableImpl.java
Log:
just reformatted some code for readability and fixed a potential locking issue
Modified:
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyTableImpl.java
===================================================================
---
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyTableImpl.java
2011-11-22 21:51:14 UTC (rev 27559)
+++
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyTableImpl.java
2011-11-22 21:56:13 UTC (rev 27560)
@@ -845,41 +845,40 @@
{
if (virtualColumnName == null)
throw new NullPointerException("\"virtualColumn\"
argument must never be null!");
- final String targetName =
getUniqueColumnName(virtualColumnName);
+ if (sourceColumnName == null)
+ throw new NullPointerException("\"sourceColumn\"
argument must never be null!");
+ if (sourceTable == null)
+ throw new NullPointerException("\"sourceTable\"
argument must never be null!");
+ if (targetJoinKeyName == null)
+ throw new NullPointerException("\"targetJoinKey\"
argument must never be null!");
- synchronized(this) {
- if (sourceColumnName == null)
- throw new
NullPointerException("\"sourceColumn\" argument must never be null!");
- if (sourceTable == null)
- throw new NullPointerException("\"sourceTable\"
argument must never be null!");
- if (targetJoinKeyName == null)
- throw new
NullPointerException("\"targetJoinKey\" argument must never be null!");
+ String targetName = "failed to create column";
+ synchronized(this) {
final CyColumn sourceColumn =
sourceTable.getColumn(sourceColumnName);
if (sourceColumn == null)
- throw new
IllegalArgumentException("\"sourceColumn\" is not a column in
\"sourceColumn\"!");
+ throw new
IllegalArgumentException("\""+sourceColumnName+"\" is not a column in source
table!");
final CyColumn targetJoinKeyType =
this.getColumn(targetJoinKeyName);
if (targetJoinKeyType == null)
- throw new
IllegalArgumentException("\"targetJoinKey\" is not a known column in this
table!");
+ throw new IllegalArgumentException("\""+
targetJoinKeyName +"\" is not a known column in this table!");
final CyColumn sourceJoinKeyType =
sourceTable.getPrimaryKey();
if (sourceJoinKeyType.getType() !=
targetJoinKeyType.getType())
- throw new
IllegalArgumentException("\"sourceJoinKey\" has a different type from
\"targetJoinKey\"!");
+ throw new
IllegalArgumentException("\""+sourceColumnName+"\" has a different type from
\""+targetJoinKeyName+"\"!");
++((CyTableImpl)sourceTable).virtualColumnReferenceCount;
- VirtualColumnInfo virtualInfo = new
VirtualColumnInfoImpl(true, sourceTable, sourceColumnName,
sourceTable.getPrimaryKey().getName(), targetJoinKeyName, isImmutable);
- final CyColumn targetColumn =
- new CyColumnImpl(this, virtualColumnName,
sourceColumn.getType(),
-
sourceColumn.getListElementType(),
- virtualInfo,
- /* isPrimaryKey = */ false,
- isImmutable,
- null);
+ VirtualColumnInfo virtualInfo = new
VirtualColumnInfoImpl(true, sourceTable, sourceColumnName,
+
sourceTable.getPrimaryKey().getName(),
+
targetJoinKeyName, isImmutable);
+ final CyColumn targetColumn = new CyColumnImpl(this,
virtualColumnName, sourceColumn.getType(),
+
sourceColumn.getListElementType(), virtualInfo,
+ /*
isPrimaryKey = */ false, isImmutable, null);
+ targetName = getUniqueColumnName(virtualColumnName);
types.put(targetName, targetColumn);
- virtualColumnMap.put(targetName,
- new VirtualColumn(sourceTable,
sourceColumnName, this,
-
sourceTable.getPrimaryKey().getName(), targetJoinKeyName));
+ virtualColumnMap.put(targetName, new
VirtualColumn(sourceTable, sourceColumnName, this,
+
sourceTable.getPrimaryKey().getName(),
+
targetJoinKeyName));
}
eventHelper.fireEvent(new ColumnCreatedEvent(this, targetName));
@@ -928,7 +927,7 @@
final CyColumn targetJoinKey =
this.getColumn(targetJoinKeyName);
if (targetJoinKey == null)
throw new IllegalArgumentException("\"" +
targetJoinKeyName
- + "\" is not a known
column in this table!");
+ + "\" is not a known
column in this table (" + getTitle() +")!");
final CyColumn sourceJoinKey = sourceTable.getPrimaryKey();
if (sourceJoinKey.getType() != targetJoinKey.getType())
--
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.