use of org.eclipse.epp.internal.mpc.core.model.SearchResult in project epp.mpc by eclipse.
the class MarketplaceCatalogTest method setupCatalog.
protected void setupCatalog() throws MalformedURLException {
final SearchResult discoveryResult = new SearchResult();
discoveryResult.setNodes(discoveryNodes);
CatalogDescriptor catalogDescriptor = new CatalogDescriptor();
catalogDescriptor.setUrl(new URL("http://marketplace.eclipse.org"));
MarketplaceDiscoveryStrategy discoveryStrategy = new MarketplaceDiscoveryStrategy(catalogDescriptor) {
final MarketplaceCategory category = new MarketplaceCategory();
{
category.setId("<root>");
}
@Override
public void performDiscovery(IProgressMonitor monitor) throws CoreException {
if (!categories.contains(category)) {
categories.add(category);
}
handleSearchResult(category, discoveryResult, new NullProgressMonitor());
}
@Override
protected synchronized Map<String, IInstallableUnit> computeInstalledIUs(IProgressMonitor monitor) {
Map<String, IInstallableUnit> installedIus = new HashMap<String, IInstallableUnit>();
for (INode node : installedNodes) {
IIus ius = node.getIus();
if (ius != null) {
for (IIu iu : ius.getIuElements()) {
String featureId = iu.getId() + ".feature.group";
InstallableUnit installableUnit = new InstallableUnit();
installableUnit.setId(featureId);
installedIus.put(featureId, installableUnit);
}
}
}
return installedIus;
}
@Override
protected MarketplaceCategory findMarketplaceCategory(IProgressMonitor monitor) throws CoreException {
return category;
}
};
catalog = new MarketplaceCatalog() {
@Override
protected IStatus checkForUpdates(List<MarketplaceNodeCatalogItem> updateCheckNeeded, final Map<String, IInstallableUnit> installedIUs, final IProgressMonitor monitor) {
for (MarketplaceNodeCatalogItem item : updateCheckNeeded) {
checkedForUpdate.add(item.getData());
List<MarketplaceNodeInstallableUnitItem> installableUnitItems = item.getInstallableUnitItems();
boolean hasUpdate = updateAvailable.contains(item.getData());
for (MarketplaceNodeInstallableUnitItem iuItem : installableUnitItems) {
iuItem.setUpdateAvailable(hasUpdate);
}
}
return Status.OK_STATUS;
}
};
catalog.getDiscoveryStrategies().add(discoveryStrategy);
}
use of org.eclipse.epp.internal.mpc.core.model.SearchResult in project epp.mpc by eclipse.
the class MarketplaceDiscoveryStrategy method performNodeQuery.
public void performNodeQuery(IProgressMonitor monitor, Set<? extends INode> nodes) throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor, Messages.MarketplaceDiscoveryStrategy_searchingMarketplace, 1001);
try {
MarketplaceCategory catalogCategory = findMarketplaceCategory(progress.newChild(1));
catalogCategory.setContents(Contents.QUERY);
SearchResult result = new SearchResult();
result.setNodes(new ArrayList<Node>());
if (!monitor.isCanceled()) {
if (!nodes.isEmpty()) {
List<INode> resolvedNodes = marketplaceService.getNodes(nodes, progress.newChild(500));
for (INode node : resolvedNodes) {
result.getNodes().add((Node) node);
}
} else {
progress.setWorkRemaining(500);
}
result.setMatchCount(result.getNodes().size());
handleSearchResult(catalogCategory, result, progress.newChild(500));
}
} finally {
monitor.done();
}
}
use of org.eclipse.epp.internal.mpc.core.model.SearchResult in project epp.mpc by eclipse.
the class MarketplaceDiscoveryStrategy method installed.
public void installed(IProgressMonitor monitor) throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor, Messages.MarketplaceDiscoveryStrategy_findingInstalled, 1000);
try {
MarketplaceCategory catalogCategory = findMarketplaceCategory(progress.newChild(1));
catalogCategory.setContents(Contents.INSTALLED);
SearchResult result = computeInstalled(progress.newChild(500));
if (!monitor.isCanceled()) {
handleSearchResult(catalogCategory, result, progress.newChild(500));
}
} finally {
monitor.done();
}
}
use of org.eclipse.epp.internal.mpc.core.model.SearchResult in project epp.mpc by eclipse.
the class MarketplaceDiscoveryStrategy method related.
public void related(IProgressMonitor monitor) throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor, Messages.MarketplaceDiscoveryStrategy_searchingMarketplace, 801);
try {
MarketplaceCategory catalogCategory = findMarketplaceCategory(progress.newChild(1));
catalogCategory.setContents(Contents.RELATED);
SearchResult installed = computeInstalled(progress.newChild(200));
if (!monitor.isCanceled()) {
ISearchResult result = marketplaceService.related(installed.getNodes(), progress.newChild(300));
handleSearchResult(catalogCategory, result, progress.newChild(300));
maybeAddCatalogItem(catalogCategory);
}
} finally {
monitor.done();
}
}
use of org.eclipse.epp.internal.mpc.core.model.SearchResult in project epp.mpc by eclipse.
the class MarketplaceDiscoveryStrategy method computeInstalled.
protected SearchResult computeInstalled(IProgressMonitor monitor) throws CoreException {
SearchResult result = new SearchResult();
result.setNodes(new ArrayList<Node>());
SubMonitor progress = SubMonitor.convert(monitor, Messages.MarketplaceDiscoveryStrategy_ComputingInstalled, 1000);
Map<String, IInstallableUnit> installedIUs = computeInstalledIUs(progress.newChild(500));
if (!monitor.isCanceled()) {
Set<INode> catalogNodes = marketplaceInfo.computeInstalledNodes(catalogDescriptor.getUrl(), installedIUs);
if (!catalogNodes.isEmpty()) {
List<INode> resolvedNodes = marketplaceService.getNodes(catalogNodes, progress.newChild(490));
SubMonitor nodeProgress = SubMonitor.convert(progress.newChild(10), resolvedNodes.size());
for (INode node : resolvedNodes) {
// compute real installed state based on optional/required state
if (marketplaceInfo.computeInstalled(installedIUs.keySet(), node)) {
result.getNodes().add((Node) node);
}
nodeProgress.worked(1);
}
} else {
monitor.worked(500);
}
}
return result;
}
Aggregations