Search in sources :

Example 6 with DataCategory

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

the class BookmarkDataSourceBuilder method buildDataSource.

private void buildDataSource() {
    final BookmarksUtil bookmarksUtil = serviceRegistrar.getService(BookmarksUtil.class);
    final Bookmarks bookMarks = (Bookmarks) serviceRegistrar.getService(CyProperty.class, "(cyPropertyName=bookmarks)").getProperties();
    final List<Category> categoryList = bookMarks.getCategory();
    for (final Category category : categoryList) {
        final DataCategory dataType = CONVERSION_MAP.get(category.getName());
        if (dataType == null)
            continue;
        final List<DataSource> theDataSourceList = bookmarksUtil.getDataSourceList(category.getName(), categoryList);
        if (theDataSourceList != null) {
            for (final DataSource ds : theDataSourceList) {
                final String location = ds.getHref();
                final String name = ds.getName();
                final String description = "From Bookmarks";
                final String provider = "Example";
                URL url = null;
                try {
                    url = new URL(location);
                } catch (MalformedURLException e) {
                    logger.warn("Bookmark file coniatin invalid URL: " + location);
                    continue;
                }
                final org.cytoscape.io.datasource.DataSource dataSource = new DefaultDataSource(name, provider, description, dataType, url);
                datasourceSet.add(dataSource);
            }
        }
    }
}
Also used : Bookmarks(org.cytoscape.property.bookmark.Bookmarks) DataCategory(org.cytoscape.io.DataCategory) MalformedURLException(java.net.MalformedURLException) DataCategory(org.cytoscape.io.DataCategory) Category(org.cytoscape.property.bookmark.Category) BookmarksUtil(org.cytoscape.property.bookmark.BookmarksUtil) DefaultDataSource(org.cytoscape.io.datasource.DefaultDataSource) URL(java.net.URL) DataSource(org.cytoscape.property.bookmark.DataSource) DefaultDataSource(org.cytoscape.io.datasource.DefaultDataSource)

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