Search in sources :

Example 1 with DataSource

use of org.cytoscape.io.datasource.DataSource in project cytoscape-impl by cytoscape.

the class URLHandler method init.

private void init(final DataSourceManager dsManager) {
    // creation of the GUI and layout
    initGUI();
    // Get the DataSources of the appropriate DataCategory from the tunable parameters.
    final Collection<DataSource> dataSources = dsManager.getDataSources(DataCategory.valueOf(((String) getParams().get("fileCategory")).toUpperCase()));
    final SortedSet<String> labelSet = new TreeSet<String>();
    if (dataSources != null) {
        for (DataSource ds : dataSources) {
            String link = null;
            link = ds.getLocation().toString();
            final String sourceName = ds.getName();
            final String provider = ds.getProvider();
            final String sourceLabel = provider + ":" + sourceName;
            dataSourceMap.put(sourceLabel, link);
            labelSet.add(sourceLabel);
        }
    }
    for (final String label : labelSet) networkFileComboBox.addItem(label);
}
Also used : TreeSet(java.util.TreeSet) DataSource(org.cytoscape.io.datasource.DataSource)

Example 2 with DataSource

use of org.cytoscape.io.datasource.DataSource in project cytoscape-impl by cytoscape.

the class CyActivator method start.

@Override
public void start(BundleContext bc) {
    final CyServiceRegistrar serviceRegistrar = getService(bc, CyServiceRegistrar.class);
    DataSourceManagerImpl dataSourceManager = new DataSourceManagerImpl();
    registerService(bc, dataSourceManager, DataSourceManager.class, new Properties());
    registerServiceListener(bc, dataSourceManager::addDataSource, dataSourceManager::removeDataSource, DataSource.class);
    BookmarkDataSourceBuilder bkBuilder = new BookmarkDataSourceBuilder(serviceRegistrar);
    final Set<DataSource> bkDataSources = bkBuilder.getDataSources();
    for (final DataSource ds : bkDataSources) registerService(bc, ds, DataSource.class, new Properties());
}
Also used : BookmarkDataSourceBuilder(org.cytoscape.io.datasource.internal.bookmarks.BookmarkDataSourceBuilder) Properties(java.util.Properties) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) DataSource(org.cytoscape.io.datasource.DataSource)

Example 3 with DataSource

use of org.cytoscape.io.datasource.DataSource 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 4 with DataSource

use of org.cytoscape.io.datasource.DataSource in project cytoscape-impl by cytoscape.

the class DataSourceManagerImpl method containsDataSource.

@Override
public boolean containsDataSource(DataSource pDataSource) {
    synchronized (lock) {
        Collection<DataSource> dataSourcesSet = this.getDataSources(pDataSource.getDataCategory());
        if (dataSourcesSet == null || dataSourcesSet.size() == 0) {
            return false;
        }
        Iterator<DataSource> it = dataSourcesSet.iterator();
        while (it.hasNext()) {
            DataSource ds = it.next();
            if (ds.getName().equalsIgnoreCase(pDataSource.getName())) {
                return true;
            }
        }
    }
    return false;
}
Also used : DataSource(org.cytoscape.io.datasource.DataSource)

Aggregations

DataSource (org.cytoscape.io.datasource.DataSource)4 LinkedHashSet (java.util.LinkedHashSet)1 Properties (java.util.Properties)1 TreeSet (java.util.TreeSet)1 DataCategory (org.cytoscape.io.DataCategory)1 BookmarkDataSourceBuilder (org.cytoscape.io.datasource.internal.bookmarks.BookmarkDataSourceBuilder)1 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)1