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