Search in sources :

Example 1 with DefaultDataSource

use of org.cytoscape.io.datasource.DefaultDataSource in project cytoscape-api by cytoscape.

the class DefaultDataSourceTest method setUp.

@Before
public void setUp() throws Exception {
    this.name = "test source";
    this.provider = "dummy provider";
    this.description = "dummy data source";
    this.category = DataCategory.NETWORK;
    this.location = new URL("http://chianti.ucsd.edu/test.sif");
    this.source = new DefaultDataSource(name, provider, description, category, location);
}
Also used : DefaultDataSource(org.cytoscape.io.datasource.DefaultDataSource) URL(java.net.URL) Before(org.junit.Before)

Example 2 with DefaultDataSource

use of org.cytoscape.io.datasource.DefaultDataSource 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)

Example 3 with DefaultDataSource

use of org.cytoscape.io.datasource.DefaultDataSource 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

URL (java.net.URL)3 DefaultDataSource (org.cytoscape.io.datasource.DefaultDataSource)3 MalformedURLException (java.net.MalformedURLException)2 DataCategory (org.cytoscape.io.DataCategory)2 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