@Override public IQueryResult<IInstallableUnit> updatesFor(IInstallableUnit toUpdate, ProvisioningContext context, IProgressMonitor monitor) { Map<String, IInstallableUnit> resultsMap = new HashMap<>(); SubMonitor sub = SubMonitor.convert(monitor, 1000); IQueryable<IInstallableUnit> queryable = context.getMetadata(sub.newChild(500)); IQueryResult<IInstallableUnit> matches = queryable.query(new UpdateQuery(toUpdate), sub.newChild(500)); for (Iterator<IInstallableUnit> it = matches.iterator(); it.hasNext();) { IInstallableUnit iu = it.next(); String key = iu.getId() + "_" + iu.getVersion().toString(); //$NON-NLS-1$ IInstallableUnit currentIU = resultsMap.get(key); if (currentIU == null || hasHigherFidelity(iu, currentIU)) resultsMap.put(key, iu); } sub.done(); return new CollectionResult<>(resultsMap.values()); }
IQueryable<IInstallableUnit> queryable = context.getMetadata(sub.newChild(500)); IQueryResult<IInstallableUnit> matches = queryable.query(QueryUtil.createIUQuery(null, VersionRange.emptyRange), sub.newChild(500));
private Collection<IInstallableUnit> findIUsWithSameId(IInstallableUnit iu, IProgressMonitor monitor) { SubMonitor sub = SubMonitor.convert(monitor, 2); IQueryable<IInstallableUnit> metadata = provisioningContext.getMetadata(sub.newChild(1)); return metadata.query(QueryUtil.createIUQuery(iu.getId()), sub.newChild(1)).toUnmodifiableSet(); }
/** * This factory method creates an {@link SynchronizeOperation} that will cause the current installation to exclusively contain the elements listed once executed. * @param toInstall the elements to install. This can not be null. * @param repos the repositories to install the elements from. If null is passed, it will use all previously registered repositories. * @param monitor the progress monitor * @return an instance of {@link SynchronizeOperation}. */ public SynchronizeOperation createSynchronizeOperation(Collection<? extends IVersionedId> toInstall, Collection<URI> repos, IProgressMonitor monitor) throws ProvisionException { IProvisioningAgent agent = getAgent(); ProvisioningContext ctx = createProvisioningContext(repos, agent); Collection<IInstallableUnit> iusToInstall; if (toInstall == null) iusToInstall = ctx.getMetadata(monitor).query(QueryUtil.createIUGroupQuery(), monitor).toUnmodifiableSet(); else iusToInstall = gatherIUs(ctx.getMetadata(monitor), toInstall, false, monitor); SynchronizeOperation resultingOperation = new SynchronizeOperation(new ProvisioningSession(agent), iusToInstall); resultingOperation.setProvisioningContext(ctx); resultingOperation.setProfileId(IProfileRegistry.SELF); return resultingOperation; } }
private Collection<IInstallableUnit> findIUsWithSameId(IInstallableUnit iu, IProgressMonitor monitor) { SubMonitor sub = SubMonitor.convert(monitor, 2); IQueryable<IInstallableUnit> metadata = provisioningContext.getMetadata(sub.newChild(1)); return metadata.query(QueryUtil.createIUQuery(iu.getId()), sub.newChild(1)).toUnmodifiableSet(); }
/** * This factory method creates an {@link InstallOperation} to install all the elements listed from the specified repositories. * @param toInstall the elements to install. This can not be null. * @param repos the repositories to install the elements from. If null is passed, it will use all previously registered repositories. * @param monitor the progress monitor * @return an operation to install */ public InstallOperation createInstallOperation(Collection<? extends IVersionedId> toInstall, Collection<URI> repos, IProgressMonitor monitor) throws ProvisionException { Assert.isNotNull(toInstall); IProvisioningAgent agent = getAgent(); //add the repos ProvisioningContext ctx = createProvisioningContext(repos, agent); //find the ius to install and create the operation InstallOperation resultingOperation = new InstallOperation(new ProvisioningSession(agent), gatherIUs(ctx.getMetadata(monitor), toInstall, false, monitor)); resultingOperation.setProvisioningContext(ctx); resultingOperation.setProfileId(IProfileRegistry.SELF); return resultingOperation; }
/** * This factory method creates an {@link InstallOperation} to install all the elements listed from the specified repositories. * @param toInstall the elements to install. This can not be null. * @param repos the repositories to install the elements from. If null is passed, it will use all previously registered repositories. * @param monitor the progress monitor * @return an operation to install */ public InstallOperation createInstallOperation(Collection<? extends IVersionedId> toInstall, Collection<URI> repos, IProgressMonitor monitor) throws ProvisionException { Assert.isNotNull(toInstall); IProvisioningAgent agent = getAgent(); //add the repos ProvisioningContext ctx = createProvisioningContext(repos, agent); //find the ius to install and create the operation InstallOperation resultingOperation = new InstallOperation(new ProvisioningSession(agent), gatherIUs(ctx.getMetadata(monitor), toInstall, false, monitor)); resultingOperation.setProvisioningContext(ctx); resultingOperation.setProfileId(IProfileRegistry.SELF); return resultingOperation; }
/** * This factory method creates an {@link SynchronizeOperation} that will cause the current installation to exclusively contain the elements listed once executed. * @param toInstall the elements to install. This can not be null. * @param repos the repositories to install the elements from. If null is passed, it will use all previously registered repositories. * @param monitor the progress monitor * @return an instance of {@link SynchronizeOperation}. */ public SynchronizeOperation createSynchronizeOperation(Collection<? extends IVersionedId> toInstall, Collection<URI> repos, IProgressMonitor monitor) throws ProvisionException { IProvisioningAgent agent = getAgent(); ProvisioningContext ctx = createProvisioningContext(repos, agent); Collection<IInstallableUnit> iusToInstall; if (toInstall == null) iusToInstall = ctx.getMetadata(monitor).query(QueryUtil.createIUGroupQuery(), monitor).toUnmodifiableSet(); else iusToInstall = gatherIUs(ctx.getMetadata(monitor), toInstall, false, monitor); SynchronizeOperation resultingOperation = new SynchronizeOperation(new ProvisioningSession(agent), iusToInstall); resultingOperation.setProvisioningContext(ctx); resultingOperation.setProfileId(IProfileRegistry.SELF); return resultingOperation; } }