Search in sources :

Example 1 with DataSource

use of org.cytoscape.property.bookmark.DataSource in project cytoscape-impl by cytoscape.

the class OntologyPanelBuilder method setAnnotationComboBox.

@SuppressWarnings("unchecked")
protected void setAnnotationComboBox() throws JAXBException, IOException {
    final CyProperty<Bookmarks> bookmarksProp = serviceRegistrar.getService(CyProperty.class, "(cyPropertyName=bookmarks)");
    final BookmarksUtil bkUtil = serviceRegistrar.getService(BookmarksUtil.class);
    final Bookmarks bookmarks = bookmarksProp.getProperties();
    final List<DataSource> annotations = bkUtil.getDataSourceList("annotation", bookmarks.getCategory());
    String key = null;
    panel.annotationComboBox.addItem(DEF_ANNOTATION_ITEM);
    for (DataSource source : annotations) {
        key = source.getName();
        panel.annotationComboBox.addItem(key);
        annotationUrlMap.put(key, source.getHref());
        annotationFormatMap.put(key, source.getFormat());
        final Map<String, String> attrMap = new HashMap<String, String>();
        for (Attribute attr : source.getAttribute()) attrMap.put(attr.getName(), attr.getContent());
        annotationAttributesMap.put(key, attrMap);
    }
    panel.annotationComboBox.setToolTipText(getAnnotationTooltip());
}
Also used : Bookmarks(org.cytoscape.property.bookmark.Bookmarks) HashMap(java.util.HashMap) Attribute(org.cytoscape.property.bookmark.Attribute) BookmarksUtil(org.cytoscape.property.bookmark.BookmarksUtil) DataSource(org.cytoscape.property.bookmark.DataSource)

Example 2 with DataSource

use of org.cytoscape.property.bookmark.DataSource in project cytoscape-impl by cytoscape.

the class BookmarksUtilImpl method deleteBookmark.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.cytoscape.property.internal.bookmark.BookmarksUtil#deleteBookmark
	 * (org.cytoscape.properties.bookmark.Bookmarks, java.lang.String,
	 * org.cytoscape.properties.bookmark.DataSource)
	 */
public boolean deleteBookmark(Bookmarks pBookmarks, String pCategoryName, DataSource pDataSource) {
    org.cytoscape.io.datasource.DataSource data = null;
    if (!containsBookmarks(pBookmarks, pCategoryName, pDataSource)) {
        return false;
    }
    List<Category> theCategoryList = pBookmarks.getCategory();
    Category theCategory = getCategory(pCategoryName, theCategoryList);
    List<Object> theObjList = theCategory.getCategoryOrDataSource();
    for (int i = 0; i < theObjList.size(); i++) {
        Object obj = theObjList.get(i);
        if (obj instanceof DataSource) {
            DataSource theDataSource = (DataSource) obj;
            if (theDataSource.getName().equalsIgnoreCase(pDataSource.getName())) {
                if (dataSourceMap.containsKey(pDataSource)) {
                    register.unregisterService(dataSourceMap.get(pDataSource), org.cytoscape.io.datasource.DataSource.class);
                    dataSourceMap.remove(pDataSource);
                }
                theObjList.remove(i);
            }
        }
    }
    return true;
}
Also used : DataCategory(org.cytoscape.io.DataCategory) Category(org.cytoscape.property.bookmark.Category) DataSource(org.cytoscape.property.bookmark.DataSource) DefaultDataSource(org.cytoscape.io.datasource.DefaultDataSource)

Example 3 with DataSource

use of org.cytoscape.property.bookmark.DataSource in project cytoscape-impl by cytoscape.

the class OntologyPanelBuilder method setOntologyComboBox.

@SuppressWarnings("unchecked")
protected void setOntologyComboBox() {
    final CyProperty<Bookmarks> bookmarksProp = serviceRegistrar.getService(CyProperty.class, "(cyPropertyName=bookmarks)");
    final BookmarksUtil bkUtil = serviceRegistrar.getService(BookmarksUtil.class);
    final Bookmarks bookmarks = bookmarksProp.getProperties();
    final List<DataSource> annotations = bkUtil.getDataSourceList("ontology", bookmarks.getCategory());
    String key = null;
    for (DataSource source : annotations) {
        key = source.getName();
        panel.ontologyComboBox.addItem(key);
        ontologyUrlMap.put(key, source.getHref());
        ontologyDescriptionMap.put(key, bkUtil.getAttribute(source, "description"));
        ontologyTypeMap.put(key, bkUtil.getAttribute(source, "ontologyType"));
    }
    panel.ontologyComboBox.setToolTipText(getOntologyTooltip());
}
Also used : Bookmarks(org.cytoscape.property.bookmark.Bookmarks) BookmarksUtil(org.cytoscape.property.bookmark.BookmarksUtil) DataSource(org.cytoscape.property.bookmark.DataSource)

Example 4 with DataSource

use of org.cytoscape.property.bookmark.DataSource 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

DataSource (org.cytoscape.property.bookmark.DataSource)4 Bookmarks (org.cytoscape.property.bookmark.Bookmarks)3 BookmarksUtil (org.cytoscape.property.bookmark.BookmarksUtil)3 DataCategory (org.cytoscape.io.DataCategory)2 DefaultDataSource (org.cytoscape.io.datasource.DefaultDataSource)2 Category (org.cytoscape.property.bookmark.Category)2 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 HashMap (java.util.HashMap)1 Attribute (org.cytoscape.property.bookmark.Attribute)1