Search in sources :

Example 1 with VirtualColumnInfo

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);
}
Also used : CyColumn(org.cytoscape.model.CyColumn) VirtualColumnInfo(org.cytoscape.model.VirtualColumnInfo)

Example 2 with VirtualColumnInfo

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());
}
Also used : CyColumn(org.cytoscape.model.CyColumn) VirtualColumnInfo(org.cytoscape.model.VirtualColumnInfo)

Example 3 with VirtualColumnInfo

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));
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) VirtualColumnInfo(org.cytoscape.model.VirtualColumnInfo) ColumnCreatedEvent(org.cytoscape.model.events.ColumnCreatedEvent)

Example 4 with VirtualColumnInfo

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);
                    }
                }
            }
        }
    }
}
Also used : RowSetRecord(org.cytoscape.model.events.RowSetRecord) CyColumn(org.cytoscape.model.CyColumn) VirtualColumnInfo(org.cytoscape.model.VirtualColumnInfo) ColumnData(org.cytoscape.model.internal.column.ColumnData) CyRow(org.cytoscape.model.CyRow)

Example 5 with VirtualColumnInfo

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));
}
Also used : VirtualColumnInfo(org.cytoscape.model.VirtualColumnInfo) ColumnCreatedEvent(org.cytoscape.model.events.ColumnCreatedEvent)

Aggregations

VirtualColumnInfo (org.cytoscape.model.VirtualColumnInfo)13 CyColumn (org.cytoscape.model.CyColumn)11 CyTable (org.cytoscape.model.CyTable)5 CyRow (org.cytoscape.model.CyRow)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 CyEdge (org.cytoscape.model.CyEdge)2 CyIdentifiable (org.cytoscape.model.CyIdentifiable)2 CyNetwork (org.cytoscape.model.CyNetwork)2 CyNode (org.cytoscape.model.CyNode)2 ColumnCreatedEvent (org.cytoscape.model.events.ColumnCreatedEvent)2 RowSetRecord (org.cytoscape.model.events.RowSetRecord)2 CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)2 CyApplicationManager (org.cytoscape.application.CyApplicationManager)1 ParseState (org.cytoscape.io.internal.read.xgmml.ParseState)1 CyTables (org.cytoscape.io.internal.util.cytables.model.CyTables)1 VirtualColumn (org.cytoscape.io.internal.util.cytables.model.VirtualColumn)1 VirtualColumns (org.cytoscape.io.internal.util.cytables.model.VirtualColumns)1 ObjectType (org.cytoscape.io.internal.util.xgmml.ObjectType)1 CyTableMetadata (org.cytoscape.model.CyTableMetadata)1