Search in sources :

Example 6 with IMarket

use of org.eclipse.epp.mpc.core.model.IMarket in project epp.mpc by eclipse.

the class MarketplaceWizardCommand method updateCategoryChoices.

private void updateCategoryChoices(final ComboTagFilter marketCategoryTagFilter, final ComboTagFilter marketFilter) {
    Set<Tag> newChoices = new HashSet<Tag>();
    List<Tag> choices = new ArrayList<Tag>();
    Set<IMarket> selectedMarkets = new HashSet<IMarket>();
    for (Tag marketTag : marketFilter.getSelected()) {
        selectedMarkets.add((IMarket) marketTag.getData());
    }
    final MarketplaceCatalog catalog = (MarketplaceCatalog) marketCategoryTagFilter.getCatalog();
    List<IMarket> markets = catalog.getMarkets();
    for (IMarket market : markets) {
        if (selectedMarkets.isEmpty() || selectedMarkets.contains(market)) {
            for (ICategory marketCategory : market.getCategory()) {
                Tag categoryTag = new Tag(ICategory.class, marketCategory.getId(), marketCategory.getName());
                categoryTag.setData(marketCategory);
                if (newChoices.add(categoryTag)) {
                    choices.add(categoryTag);
                }
            }
        }
    }
    Collections.sort(choices, new Comparator<Tag>() {

        public int compare(Tag o1, Tag o2) {
            return o1.getLabel().compareTo(o2.getLabel());
        }
    });
    marketCategoryTagFilter.setChoices(choices);
}
Also used : ICategory(org.eclipse.epp.mpc.core.model.ICategory) ArrayList(java.util.ArrayList) Tag(org.eclipse.equinox.internal.p2.discovery.model.Tag) MarketplaceCatalog(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog) IMarket(org.eclipse.epp.mpc.core.model.IMarket) HashSet(java.util.HashSet)

Example 7 with IMarket

use of org.eclipse.epp.mpc.core.model.IMarket in project epp.mpc by eclipse.

the class CachingMarketplaceService method getMarket.

public IMarket getMarket(IMarket market, IProgressMonitor monitor) throws CoreException {
    String marketKey = computeMarketKey(market);
    IMarket marketResult = null;
    if (marketKey != null) {
        marketResult = getCached(marketKey, IMarket.class);
    }
    if (marketResult == null) {
        marketResult = delegate.getMarket(market, monitor);
        if (marketResult != null) {
            synchronized (cache) {
                cacheMarket(marketResult);
            }
        }
    }
    return marketResult;
}
Also used : IMarket(org.eclipse.epp.mpc.core.model.IMarket)

Example 8 with IMarket

use of org.eclipse.epp.mpc.core.model.IMarket in project epp.mpc by eclipse.

the class CachingMarketplaceService method listMarkets.

public List<? extends IMarket> listMarkets(IProgressMonitor monitor) throws CoreException {
    // $NON-NLS-1$
    String marketsKey = "Markets:Markets";
    @SuppressWarnings("unchecked") List<? extends IMarket> marketsResult = getCached(marketsKey, List.class);
    if (marketsResult == null) {
        marketsResult = delegate.listMarkets(monitor);
        synchronized (cache) {
            cache(marketsKey, marketsResult);
            for (IMarket market : marketsResult) {
                cacheMarket(market);
            }
        }
    }
    return marketsResult;
}
Also used : IMarket(org.eclipse.epp.mpc.core.model.IMarket)

Example 9 with IMarket

use of org.eclipse.epp.mpc.core.model.IMarket in project epp.mpc by eclipse.

the class MarketplaceDiscoveryStrategyTest method testSearchByNodeUrl.

@Test
public void testSearchByNodeUrl() throws Exception {
    final INode[] testNode = new INode[1];
    final IMarketplaceService marketplaceService = new DefaultMarketplaceService(catalogUrl) {

        @Override
        public Node getNode(INode node, IProgressMonitor monitor) throws CoreException {
            testNode[0] = node;
            return (Node) node;
        }

        @Override
        public SearchResult search(IMarket market, ICategory category, String queryText, IProgressMonitor monitor) throws CoreException {
            Assert.fail("Unexpected invocation");
            // dead code
            return null;
        }
    };
    setupCatalog(marketplaceService);
    testNode[0] = null;
    catalog.performQuery(null, null, new URL(catalogUrl, "content/test").toExternalForm(), new NullProgressMonitor());
    assertNotNull(testNode[0]);
    assertNotNull(testNode[0].getUrl());
    testNode[0] = null;
    catalog.performQuery(null, null, new URL(catalogUrl, "node/12345").toExternalForm(), new NullProgressMonitor());
    assertNotNull(testNode[0]);
    assertNotNull(testNode[0].getId());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) INode(org.eclipse.epp.mpc.core.model.INode) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DefaultMarketplaceService(org.eclipse.epp.internal.mpc.core.service.DefaultMarketplaceService) Node(org.eclipse.epp.internal.mpc.core.model.Node) INode(org.eclipse.epp.mpc.core.model.INode) ICategory(org.eclipse.epp.mpc.core.model.ICategory) IMarketplaceService(org.eclipse.epp.mpc.core.service.IMarketplaceService) IMarket(org.eclipse.epp.mpc.core.model.IMarket) URL(java.net.URL) Test(org.junit.Test)

Example 10 with IMarket

use of org.eclipse.epp.mpc.core.model.IMarket in project epp.mpc by eclipse.

the class DefaultMarketplaceServiceTest method getCategory.

@Test
@org.junit.experimental.categories.Category(RemoteTests.class)
public void getCategory() throws CoreException {
    List<? extends IMarket> markets = marketplaceService.listMarkets(new NullProgressMonitor());
    assertNotNull(markets);
    assertFalse(markets.isEmpty());
    final String marketName = "Tools";
    IMarket market = null;
    for (IMarket m : markets) {
        if (marketName.equals(m.getName())) {
            market = m;
            break;
        }
    }
    assertNotNull("Expected market " + marketName, market);
    assertFalse(market.getCategory().isEmpty());
    final String categoryName = "Mylyn Connectors";
    ICategory category = null;
    for (ICategory c : market.getCategory()) {
        if (categoryName.equals(c.getName())) {
            category = c;
            break;
        }
    }
    assertNotNull("Expected category " + categoryName, category);
    ICategory result = marketplaceService.getCategory(category, new NullProgressMonitor());
    assertNotNull(result);
// FIXME: pending bug 302671
// assertEquals(category.getId(),result.getId());
// FIXME: pending bug 497242
// assertEquals(category.getName(), result.getName());
// assertEquals(category.getUrl(), result.getUrl());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ICategory(org.eclipse.epp.mpc.core.model.ICategory) IMarket(org.eclipse.epp.mpc.core.model.IMarket) Test(org.junit.Test)

Aggregations

IMarket (org.eclipse.epp.mpc.core.model.IMarket)16 ICategory (org.eclipse.epp.mpc.core.model.ICategory)10 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 Test (org.junit.Test)5 Tag (org.eclipse.equinox.internal.p2.discovery.model.Tag)3 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 NoSuchElementException (java.util.NoSuchElementException)2 DefaultMarketplaceService (org.eclipse.epp.internal.mpc.core.service.DefaultMarketplaceService)2 ISearchResult (org.eclipse.epp.mpc.core.model.ISearchResult)2 CatalogFilter (org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogFilter)2 MalformedURLException (java.net.MalformedURLException)1 URI (java.net.URI)1 HashSet (java.util.HashSet)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 Marketplace (org.eclipse.epp.internal.mpc.core.model.Marketplace)1 Node (org.eclipse.epp.internal.mpc.core.model.Node)1 MarketplaceCatalog (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog)1