Search in sources :

Example 1 with Network

use of org.cytoscape.internal.io.networklist.Network in project cytoscape-impl by cytoscape.

the class SessionHandler method setSessionNetworks.

private void setSessionNetworks(final List<Network> netInfoList, final CySession sess) {
    final Map<Long, Integer> netOrder = new HashMap<>();
    for (final Network n : netInfoList) {
        // in order to retrieve the new SUID
        final CyNetwork net = sess.getObject(n.getId(), CyNetwork.class);
        if (net != null)
            netOrder.put(net.getSUID(), n.getOrder());
    }
    setSessionNetworks(netOrder);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Network(org.cytoscape.internal.io.networklist.Network) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyNetwork(org.cytoscape.model.CyNetwork) CyNetwork(org.cytoscape.model.CyNetwork)

Example 2 with Network

use of org.cytoscape.internal.io.networklist.Network in project cytoscape-impl by cytoscape.

the class SessionHandler method saveNetworkList.

private File saveNetworkList(final SessionAboutToBeSavedEvent e) {
    final Map<Long, Integer> netOrder = netPanel.getNetworkListOrder();
    // Create the JAXB objects
    final NetworkList netList = new NetworkList();
    for (final Entry<Long, Integer> entry : netOrder.entrySet()) {
        final Long suid = entry.getKey();
        final Integer order = entry.getValue();
        if (order != null) {
            final Network n = new Network();
            n.setId(suid);
            n.setOrder(order);
            netList.getNetwork().add(n);
        }
    }
    // Create temp file
    File tmpFile = new File(System.getProperty("java.io.tmpdir"), NETWORK_LIST_FILENAME);
    tmpFile.deleteOnExit();
    // Write to the file
    sessionIO.write(netList, tmpFile);
    return tmpFile;
}
Also used : NetworkList(org.cytoscape.internal.io.networklist.NetworkList) Network(org.cytoscape.internal.io.networklist.Network) CySubNetwork(org.cytoscape.model.subnetwork.CySubNetwork) CyNetwork(org.cytoscape.model.CyNetwork) File(java.io.File)

Aggregations

Network (org.cytoscape.internal.io.networklist.Network)2 CyNetwork (org.cytoscape.model.CyNetwork)2 CySubNetwork (org.cytoscape.model.subnetwork.CySubNetwork)2 File (java.io.File)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 NetworkList (org.cytoscape.internal.io.networklist.NetworkList)1