use of org.cytoscape.io.internal.util.session.model.Child in project cytoscape-impl by cytoscape.
the class Cy2SessionReaderImpl method walkNetworkTree.
private void walkNetworkTree(final Network net, CyNetwork parent, final Map<String, Network> netMap, final TaskMonitor tm, final CyRootNetworkManager rootNetworkManager) {
// Get the list of children under this root
final List<Child> children = net.getChild();
// Traverse using recursive call
final int numChildren = children.size();
Child child = null;
Network childNet = null;
for (int i = 0; i < numChildren; i++) {
if (cancelled)
return;
child = children.get(i);
childNet = netMap.get(child.getId());
String entryName = xgmmlEntries.get(childNet.getFilename());
InputStream is = null;
// This is the original Cytoscape 2 parent.
CyNetwork cy2Parent = null;
try {
is = findEntry(entryName);
if (is != null) {
tm.setStatusMessage("Extracting network: " + entryName);
cy2Parent = extractNetworksAndViews(is, entryName, parent, childNet.isViewAvailable());
// Every 2.x network should be a child of the same root-network.
if (parent == null)
parent = rootNetworkManager.getRootNetwork(cy2Parent);
} else {
logger.error("Cannot find network file \"" + entryName + "\": ");
}
} catch (final Exception e) {
final String message = "Unable to read XGMML file \"" + childNet.getFilename() + "\": " + e.getMessage();
logger.error(message, e);
} finally {
if (is != null) {
try {
is.close();
} catch (final Exception ex) {
logger.error("Unable to close XGMML input stream.", ex);
}
is = null;
}
// Always try to load child networks, even if the parent network is bad
if (!cancelled && childNet.getChild().size() != 0)
walkNetworkTree(childNet, cy2Parent, netMap, tm, rootNetworkManager);
}
}
}
Aggregations