Search in sources :

Example 91 with CyTable

use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.

the class ImportTableDataTask method getResults.

@Override
public Object getResults(Class requestedType) {
    if (requestedType.equals(List.class))
        return mappedTables;
    if (requestedType.equals(String.class)) {
        String str = "Mapped to tables:\n";
        for (CyTable table : mappedTables) {
            str += "   " + table.toString() + "\n";
        }
        return str;
    }
    if (requestedType.equals(JSONResult.class)) {
        CyJSONUtil cyJSONUtil = serviceRegistrar.getService(CyJSONUtil.class);
        JSONResult res = () -> {
            if (mappedTables.isEmpty())
                return "{}";
            return "{\"mappedTables\":" + cyJSONUtil.cyIdentifiablesToJson(mappedTables) + "}";
        };
        return res;
    }
    return null;
}
Also used : CyTable(org.cytoscape.model.CyTable) JSONResult(org.cytoscape.work.json.JSONResult) CyJSONUtil(org.cytoscape.util.json.CyJSONUtil)

Example 92 with CyTable

use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.

the class ImportTableDataTask method addTable.

private void addTable() {
    final CyTableManager tableMgr = serviceRegistrar.getService(CyTableManager.class);
    if (byReader) {
        if (this.reader != null && this.reader.getTables() != null) {
            for (CyTable table : reader.getTables()) {
                if (!newTableName.isEmpty())
                    table.setTitle(newTableName);
                tableMgr.addTable(table);
            }
        } else {
            if (reader == null)
                logger.warn("reader is null.");
            else
                logger.warn("No tables in reader.");
        }
    } else {
        if (tableMgr.getTable(globalTable.getSUID()) != null) {
            tableMgr.deleteTable(globalTable.getSUID());
            globalTable.setPublic(true);
        }
        if (!newTableName.isEmpty())
            globalTable.setTitle(newTableName);
        tableMgr.addTable(globalTable);
        mappedTables.add(globalTable);
    }
}
Also used : CyTable(org.cytoscape.model.CyTable) CyTableManager(org.cytoscape.model.CyTableManager)

Example 93 with CyTable

use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.

the class JoinTablesTask method applyMapping.

private void applyMapping(CyTable targetTable) {
    if (byReader) {
        if (reader.getTables() != null && reader.getTables().length > 0) {
            for (CyTable sourceTable : reader.getTables()) {
                copyColumns(sourceTable, targetTable);
                copyRows(sourceTable, targetTable);
            }
        }
    } else {
        copyColumns(globalTable, targetTable);
        copyRows(globalTable, targetTable);
    }
}
Also used : CyTable(org.cytoscape.model.CyTable)

Example 94 with CyTable

use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.

the class ListColumnsTask method run.

@Override
public void run(final TaskMonitor taskMonitor) {
    CyTable requestedTable = table.getTable();
    if (requestedTable == null) {
        taskMonitor.showMessage(TaskMonitor.Level.ERROR, "Unable to find table '" + table.getTableString() + "'");
        return;
    }
    columns = new ArrayList<CyColumn>(requestedTable.getColumns());
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "Columns for table " + getTableDescription(requestedTable) + ":");
    for (CyColumn column : columns) taskMonitor.showMessage(TaskMonitor.Level.INFO, "         " + column.toString());
}
Also used : CyTable(org.cytoscape.model.CyTable) CyColumn(org.cytoscape.model.CyColumn)

Example 95 with CyTable

use of org.cytoscape.model.CyTable in project cytoscape-impl by cytoscape.

the class ListEdgeAttributesTask method run.

@Override
public void run(final TaskMonitor taskMonitor) {
    if (network == null)
        network = appMgr.getCurrentNetwork();
    CyTable networkTable = getNetworkTable(network, CyEdge.class, namespace);
    columnList = networkTable.getColumns();
    taskMonitor.showMessage(TaskMonitor.Level.INFO, "   Edge columns for network " + DataUtils.getNetworkName(network) + ":");
    for (CyColumn column : columnList) {
        if (column.getType().equals(List.class))
            taskMonitor.showMessage(TaskMonitor.Level.INFO, "        " + column.getName() + ": " + DataUtils.getType(column.getListElementType()) + " list");
        else
            taskMonitor.showMessage(TaskMonitor.Level.INFO, "        " + column.getName() + ": " + DataUtils.getType(column.getType()));
    }
}
Also used : CyTable(org.cytoscape.model.CyTable) CyColumn(org.cytoscape.model.CyColumn)

Aggregations

CyTable (org.cytoscape.model.CyTable)282 CyNetwork (org.cytoscape.model.CyNetwork)79 CyRow (org.cytoscape.model.CyRow)73 CyColumn (org.cytoscape.model.CyColumn)71 ArrayList (java.util.ArrayList)55 CyNode (org.cytoscape.model.CyNode)43 CyEdge (org.cytoscape.model.CyEdge)35 Test (org.junit.Test)29 List (java.util.List)26 HashMap (java.util.HashMap)24 CyApplicationManager (org.cytoscape.application.CyApplicationManager)19 HashSet (java.util.HashSet)18 CyIdentifiable (org.cytoscape.model.CyIdentifiable)14 CyNetworkView (org.cytoscape.view.model.CyNetworkView)14 CyNetworkTableManager (org.cytoscape.model.CyNetworkTableManager)13 RowSetRecord (org.cytoscape.model.events.RowSetRecord)11 CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)11 CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)11 CyEventHelper (org.cytoscape.event.CyEventHelper)10 CyTableManager (org.cytoscape.model.CyTableManager)10