wikipathways / cytoscape-wikipathways-app

WikiPathways app for Cytoscape to open and access pathways from WikiPathways
Apache License 2.0
5 stars 7 forks source link

CyNetworkReaderManager.getReader(InputStream,String) will never return a GpmlReaderTask as a CyNetworkReader #1

Closed mlcreech closed 7 years ago

mlcreech commented 10 years ago

CyNetworkReaderManager.getReader(InputStream,String) will never return a GpmlReaderTask as a CyNetworkReader.

The problem is that the definition of GpmlReaderTaskFactory constructor:

public class GpmlReaderTaskFactory extends AbstractInputStreamTaskFactory { public GpmlReaderTaskFactory(final StreamUtil streamUtil) { super(new BasicCyFileFilter(new String[]{"gpml"}, new String[]{"text/xml"}, "GPML files", DataCategory.NETWORK, streamUtil)); } }

Simply passes in a BasicCyFileFilter. This filter will always return false for its accepts (InputStream, DataCategory) method. This method is then used by getReader() to decide if this GpmlReaderTask is a potential reader. Here's the code for accepts():

public class BasicCyFileFilter implements CyFileFilter { ... /* * This method always returns false in this particular implementation. You * must extend this class and override this method to get alternative * behavior. Ideally this method would return true if this class is capable * of processing the specified InputStream. * @param stream * The stream that references the file we'd like to read. * @param category * The type of input that we're considering. * @return Always returns false in this particular implementation. */ public boolean accepts(InputStream stream, DataCategory category) { return false; } }

What's needed is that BasicCyFileFilter must be extended and the accepts(InputStream,DataCategory) method overridden with something that returns true under the appropriate conditions.

AdamStuart commented 7 years ago

Don't know how this affects users