Search in sources :

Example 1 with CyTables

use of org.cytoscape.io.internal.util.cytables.model.CyTables in project cytoscape-impl by cytoscape.

the class CyTablesXMLWriter method run.

@Override
public void run(TaskMonitor taskMonitor) throws Exception {
    final JAXBContext jc = JAXBContext.newInstance(CyTables.class.getPackage().getName(), this.getClass().getClassLoader());
    Marshaller m = jc.createMarshaller();
    taskMonitor.setProgress(0.25);
    m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
    taskMonitor.setProgress(0.5);
    CyTables model = buildModel();
    taskMonitor.setProgress(0.75);
    m.marshal(model, outputStream);
    taskMonitor.setProgress(1.0);
}
Also used : Marshaller(javax.xml.bind.Marshaller) CyTables(org.cytoscape.io.internal.util.cytables.model.CyTables) JAXBContext(javax.xml.bind.JAXBContext)

Example 2 with CyTables

use of org.cytoscape.io.internal.util.cytables.model.CyTables in project cytoscape-impl by cytoscape.

the class CyTablesXMLWriter method buildModel.

private CyTables buildModel() {
    CyTables model = new CyTables();
    VirtualColumns virtualColumns = new VirtualColumns();
    model.setVirtualColumns(virtualColumns);
    List<VirtualColumn> columns = virtualColumns.getVirtualColumn();
    for (CyTableMetadata metadata : tables) {
        CyTable table = metadata.getTable();
        String targetTable = tableFileNamesBySUID.get(table.getSUID());
        if (targetTable == null) {
            continue;
        }
        for (CyColumn cyColumn : table.getColumns()) {
            VirtualColumnInfo info = cyColumn.getVirtualColumnInfo();
            if (!info.isVirtual()) {
                continue;
            }
            String sourceTable = tableFileNamesBySUID.get(info.getSourceTable().getSUID());
            if (sourceTable == null) {
                // log this
                continue;
            }
            VirtualColumn column = new VirtualColumn();
            column.setName(cyColumn.getName());
            column.setSourceColumn(info.getSourceColumn());
            column.setSourceTable(sourceTable);
            column.setSourceJoinKey(info.getSourceJoinKey());
            column.setTargetTable(targetTable);
            column.setTargetJoinKey(info.getTargetJoinKey());
            columns.add(column);
        }
    }
    return model;
}
Also used : CyTable(org.cytoscape.model.CyTable) CyTables(org.cytoscape.io.internal.util.cytables.model.CyTables) CyColumn(org.cytoscape.model.CyColumn) CyTableMetadata(org.cytoscape.model.CyTableMetadata) VirtualColumnInfo(org.cytoscape.model.VirtualColumnInfo) VirtualColumn(org.cytoscape.io.internal.util.cytables.model.VirtualColumn) VirtualColumns(org.cytoscape.io.internal.util.cytables.model.VirtualColumns)

Aggregations

CyTables (org.cytoscape.io.internal.util.cytables.model.CyTables)2 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1 VirtualColumn (org.cytoscape.io.internal.util.cytables.model.VirtualColumn)1 VirtualColumns (org.cytoscape.io.internal.util.cytables.model.VirtualColumns)1 CyColumn (org.cytoscape.model.CyColumn)1 CyTable (org.cytoscape.model.CyTable)1 CyTableMetadata (org.cytoscape.model.CyTableMetadata)1 VirtualColumnInfo (org.cytoscape.model.VirtualColumnInfo)1