use of org.cytoscape.model.VirtualColumnInfo in project cytoscape-impl by cytoscape.
the class CloneNetworkTask method addVirtualColumn.
private void addVirtualColumn(CyColumn col, CyTable subTable) {
VirtualColumnInfo colInfo = col.getVirtualColumnInfo();
CyColumn checkCol = subTable.getColumn(col.getName());
if (checkCol == null)
subTable.addVirtualColumn(col.getName(), colInfo.getSourceColumn(), colInfo.getSourceTable(), colInfo.getTargetJoinKey(), true);
else if (!checkCol.getVirtualColumnInfo().isVirtual() || !checkCol.getVirtualColumnInfo().getSourceTable().equals(colInfo.getSourceTable()) || !checkCol.getVirtualColumnInfo().getSourceColumn().equals(colInfo.getSourceColumn()))
subTable.addVirtualColumn(col.getName(), colInfo.getSourceColumn(), colInfo.getSourceTable(), colInfo.getTargetJoinKey(), true);
}
use of org.cytoscape.model.VirtualColumnInfo in project cytoscape-impl by cytoscape.
the class AbstractNetworkFromSelectionTask method addVirtualColumn.
private void addVirtualColumn(CyColumn col, CyTable subTable) {
VirtualColumnInfo colInfo = col.getVirtualColumnInfo();
CyColumn checkCol = subTable.getColumn(col.getName());
if (checkCol == null)
subTable.addVirtualColumn(col.getName(), colInfo.getSourceColumn(), colInfo.getSourceTable(), colInfo.getTargetJoinKey(), col.isImmutable());
else if (!checkCol.getVirtualColumnInfo().isVirtual() || !checkCol.getVirtualColumnInfo().getSourceTable().equals(colInfo.getSourceTable()) || !checkCol.getVirtualColumnInfo().getSourceColumn().equals(colInfo.getSourceColumn()))
subTable.addVirtualColumn(col.getName(), colInfo.getSourceColumn(), colInfo.getSourceTable(), colInfo.getTargetJoinKey(), col.isImmutable());
}
use of org.cytoscape.model.VirtualColumnInfo in project cytoscape-impl by cytoscape.
the class CyTableImpl method createListColumn.
@Override
public <T> void createListColumn(final String columnName, final Class<T> listElementType, final boolean isImmutable, final List<T> defaultValue) {
synchronized (lock) {
if (columnName == null)
throw new NullPointerException("column name is null");
final String normalizedColName = normalizeColumnName(columnName);
if (types.containsKey(normalizedColName))
throw new IllegalArgumentException("column already exists with name: '" + columnName + "' with type: " + types.get(normalizedColName).getType());
if (listElementType == null)
throw new NullPointerException("listElementType is null");
checkClass(listElementType);
VirtualColumnInfo virtualInfo = NonVirtualColumnInfo.create(isImmutable);
types.put(normalizedColName, new CyColumnImpl(this, columnName, List.class, listElementType, virtualInfo, /* isPrimaryKey = */
false, isImmutable, defaultValue));
attributes.put(normalizedColName, columnFactory.create(primaryKeyType, List.class, listElementType, defaultInitSize));
colList.add(types.get(normalizedColName));
}
eventHelper.fireEvent(new ColumnCreatedEvent(this, columnName));
}
use of org.cytoscape.model.VirtualColumnInfo in project cytoscape-impl by cytoscape.
the class CyTableImpl method fireVirtualColumnRowSetEvent.
private void fireVirtualColumnRowSetEvent(CyTableImpl table, Object key, String columnName, Object newValue, Object newRawValue, Set<VirtualColumnInfo> seen) {
// Fire an event for this table
CyRow row = table.getRowNoCreate(key);
if (row == null) {
return;
}
eventHelper.addEventPayload((CyTable) table, new RowSetRecord(row, columnName, newValue, newRawValue), RowsSetEvent.class);
// ...then fire events for all dependents
Set<CyColumn> columnDependents;
synchronized (lock) {
String normalizedColumnName = normalizeColumnName(columnName);
columnDependents = dependents.get(normalizedColumnName);
if (columnDependents == null) {
return;
}
}
for (CyColumn dependent : columnDependents) {
VirtualColumnInfo info = dependent.getVirtualColumnInfo();
if (seen.contains(info)) {
continue;
}
seen.add(info);
CyTableImpl table2 = (CyTableImpl) dependent.getTable();
String targetJoinKey = info.getTargetJoinKey();
if (targetJoinKey.equals(table2.getPrimaryKey().getName())) {
fireVirtualColumnRowSetEvent(table2, key, dependent.getName(), newValue, newRawValue, seen);
} else {
String normalizedTargetJoinKey = table2.normalizeColumnName(targetJoinKey);
ColumnData keyToValueMap = table2.attributes.get(normalizedTargetJoinKey);
if (keyToValueMap != null) {
for (Object key2 : keyToValueMap.keySet()) {
if (keyToValueMap.get(key2).equals(key)) {
fireVirtualColumnRowSetEvent(table2, key2, dependent.getName(), newValue, newRawValue, seen);
}
}
}
}
}
}
use of org.cytoscape.model.VirtualColumnInfo in project cytoscape-impl by cytoscape.
the class CyTableImpl method createColumn.
@Override
public <T> void createColumn(final String columnName, final Class<? extends T> type, final boolean isImmutable, final T defaultValue) {
synchronized (lock) {
if (columnName == null)
throw new NullPointerException("column name is null");
final String normalizedColName = normalizeColumnName(columnName);
if (types.containsKey(normalizedColName))
throw new IllegalArgumentException("column already exists with name: '" + columnName + "' with type: " + types.get(normalizedColName).getType());
if (type == null)
throw new NullPointerException("type is null");
if (type == List.class)
throw new IllegalArgumentException("use createListColumn() to create List columns instead of createColumn for column '" + columnName + "'.");
checkClass(type);
VirtualColumnInfo virtualInfo = NonVirtualColumnInfo.create(isImmutable);
types.put(normalizedColName, new CyColumnImpl(this, columnName, type, /* listElementType = */
null, virtualInfo, /* isPrimaryKey = */
false, isImmutable, defaultValue));
attributes.put(normalizedColName, columnFactory.create(primaryKeyType, type, null, defaultInitSize));
colList.add(types.get(normalizedColName));
}
eventHelper.fireEvent(new ColumnCreatedEvent(this, columnName));
}
Aggregations