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);
}
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));
}
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);
}
}
}
}
Aggregations