@Before public void setUp() throws Exception { NetworkTestSupport netSupport = new NetworkTestSupport(); TableTestSupport tableSupport = new TableTestSupport(); CyNetworkFactory cyNetworkFactory = netSupport.getNetworkFactory(); tableFactory = tableSupport.getTableFactory(); tableManager = mock(CyTableManager.class); dag = cyNetworkFactory.createNetwork(); tm = mock(TaskMonitor.class); serviceRegistrar = mock(CyServiceRegistrar.class); when(serviceRegistrar.getService(CyTableFactory.class)).thenReturn(tableFactory); when(serviceRegistrar.getService(CyTableManager.class)).thenReturn(tableManager); }
@Override public void run(TaskMonitor taskMonitor) throws Exception { parentTaskMonitor = taskMonitor; long start = System.currentTimeMillis(); taskMonitor.setProgress(0.01d); taskMonitor.setTitle("Loading PSI-MI 2.5.x XML File "); taskMonitor.setStatusMessage("Loading data file in PSI-MI 2.5 XML format."); // support to add network into existing collection this.initNodeMap(); PsimiXmlReader reader = new PsimiXmlReader(); EntrySet result = reader.read(inputStream); taskMonitor.setProgress(0.4d); taskMonitor.setStatusMessage("Data Loaded. Mapping Data to Network..."); if (cancelFlag) { inputStream.close(); reader = null; result = null; return; } // network = cyNetworkFactory.createNetwork(); String networkCollectionName = this.rootNetworkList.getSelectedValue().toString(); if (networkCollectionName.equalsIgnoreCase(CRERATE_NEW_COLLECTION_STRING)) { // This is a new network collection, create a root network and a subnetwork, which is a base // subnetwork network = cyNetworkFactory.createNetwork(); } else { // Add a new subNetwork to the given collection network = this.name2RootMap.get(networkCollectionName).addSubNetwork(); } mapper = new PSIMI25EntryMapper(network, result); mapper.map(); taskMonitor.setProgress(1.0d); logger.info( "PSI-MI XML Data Import finihsed in " + (System.currentTimeMillis() - start) + " msec."); }