Search in sources :

Example 1 with DataCategory

use of org.cytoscape.io.DataCategory in project cytoscape-impl by cytoscape.

the class DataSourceManagerImpl method getDataSources.

@Override
public Collection<DataSource> getDataSources(String providerName) {
    final Set<DataSource> sources = new LinkedHashSet<>();
    synchronized (lock) {
        Iterator<DataCategory> it = this.dataSourceMap.keySet().iterator();
        Map<String, DataSource> map;
        while (it.hasNext()) {
            map = this.dataSourceMap.get(it.next());
            Iterator<DataSource> it_ds = map.values().iterator();
            while (it_ds.hasNext()) {
                DataSource ds = it_ds.next();
                if (ds.getProvider().equals(providerName))
                    sources.add(ds);
            }
        }
        return sources;
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) DataCategory(org.cytoscape.io.DataCategory) DataSource(org.cytoscape.io.datasource.DataSource)

Example 2 with DataCategory

use of org.cytoscape.io.DataCategory in project cytoscape-api by cytoscape.

the class InputStreamTaskFactoryTest method setUp.

@Before
public void setUp() throws Exception {
    Set<String> extensions = new HashSet<String>();
    extensions.add("xml");
    Set<String> contentTypes = new HashSet<String>();
    String description = "test filter";
    DataCategory category = DataCategory.NETWORK;
    this.fileFilter = new BasicCyFileFilter(extensions, contentTypes, description, category, streamUtil);
    this.taskFactory = new DummyInputStreamTaskFactory(fileFilter);
}
Also used : DataCategory(org.cytoscape.io.DataCategory) BasicCyFileFilter(org.cytoscape.io.BasicCyFileFilter) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 3 with DataCategory

use of org.cytoscape.io.DataCategory in project cytoscape-api by cytoscape.

the class AbstractDataSourceTest method testGetDataCategory.

@Test
public void testGetDataCategory() {
    final DataCategory category = source.getDataCategory();
    assertEquals(this.category, category);
}
Also used : DataCategory(org.cytoscape.io.DataCategory) Test(org.junit.Test)

Example 4 with DataCategory

use of org.cytoscape.io.DataCategory in project cytoscape-impl by cytoscape.

the class FileHandler method init.

private void init() {
    input = isInput();
    final String fileCategory = getFileCategory();
    final DataCategory dataCategory = DataCategory.valueOf(fileCategory.toUpperCase());
    filters = fileTypesManager.getSupportedFileTypes(dataCategory, input);
    String displayName = dataCategory.getDisplayName().toLowerCase();
    String a = isVowel(displayName.charAt(0)) ? "an" : "a";
    setGui();
    updateFieldPanel(panel, label, controlPanel, horizontal);
    setTooltip(getTooltip(), textField, browseButton);
}
Also used : DataCategory(org.cytoscape.io.DataCategory)

Example 5 with DataCategory

use of org.cytoscape.io.DataCategory in project cytoscape-impl by cytoscape.

the class BookmarksUtilImpl method convertToDataSource.

public org.cytoscape.io.datasource.DataSource convertToDataSource(Bookmarks pBookmarks, String pCategoryName, DataSource pDataSource, String pProvider) {
    final String location = pDataSource.getHref();
    final String name = pDataSource.getName();
    final String description = "From Bookmarks";
    // final String provider = "Example";
    DataCategory dataType;
    URL url = null;
    if (pCategoryName.contentEquals("network")) {
        dataType = DataCategory.NETWORK;
    } else if (pCategoryName.contentEquals("table")) {
        dataType = DataCategory.TABLE;
    } else {
        return null;
    }
    try {
        url = new URL(location);
    } catch (MalformedURLException e) {
        logger.warn("Bookmark file coniatin invalid URL: " + location);
        return null;
    }
    return (new DefaultDataSource(name, pProvider, description, dataType, url));
}
Also used : DataCategory(org.cytoscape.io.DataCategory) MalformedURLException(java.net.MalformedURLException) DefaultDataSource(org.cytoscape.io.datasource.DefaultDataSource) URL(java.net.URL)

Aggregations

DataCategory (org.cytoscape.io.DataCategory)6 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 DefaultDataSource (org.cytoscape.io.datasource.DefaultDataSource)2 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 BasicCyFileFilter (org.cytoscape.io.BasicCyFileFilter)1 DataSource (org.cytoscape.io.datasource.DataSource)1 Bookmarks (org.cytoscape.property.bookmark.Bookmarks)1 BookmarksUtil (org.cytoscape.property.bookmark.BookmarksUtil)1 Category (org.cytoscape.property.bookmark.Category)1 DataSource (org.cytoscape.property.bookmark.DataSource)1 Before (org.junit.Before)1 Test (org.junit.Test)1