use of org.eclipse.equinox.p2.query.IQueryResult in project webtools.servertools by eclipse.
the class ExtensionUpdateSite method getInstallableUnits.
// Get the list of InstallableUnits and all its requirements
protected List<IServerExtension> getInstallableUnits(IMetadataRepository repo, IQuery<IInstallableUnit> query, URI url, IProgressMonitor monitor) {
List<IServerExtension> list = new ArrayList<IServerExtension>();
IQueryResult<IInstallableUnit> collector = repo.query(query, monitor);
for (IInstallableUnit iu : collector.toUnmodifiableSet()) {
Collection<IRequirement> req = iu.getRequirements();
if (req != null) {
for (IRequirement requirement : req) {
IMatchExpression<IInstallableUnit> matches = requirement.getMatches();
query = new ExpressionMatchQuery<IInstallableUnit>(IInstallableUnit.class, matches);
IQueryResult<IInstallableUnit> collector2 = repo.query(query, monitor);
Iterator<IInstallableUnit> iter2 = collector2.iterator();
while (iter2.hasNext()) {
IInstallableUnit iu2 = iter2.next();
if (!list.contains(iu2)) {
Extension ext = new Extension(iu2, url);
list.add(ext);
}
}
}
}
}
return list;
}
use of org.eclipse.equinox.p2.query.IQueryResult in project tycho by eclipse.
the class VerifierServiceImpl method verifyAllArtifactContent.
private boolean verifyAllArtifactContent(IArtifactRepository repository, MavenLogger logger) {
boolean valid = true;
IQueryResult<IArtifactKey> allKeys = repository.query(new ExpressionMatchQuery<>(IArtifactKey.class, ExpressionUtil.TRUE_EXPRESSION), null);
for (Iterator<IArtifactKey> keyIt = allKeys.iterator(); keyIt.hasNext(); ) {
IArtifactKey key = keyIt.next();
IArtifactDescriptor[] descriptors = repository.getArtifactDescriptors(key);
for (IArtifactDescriptor descriptor : descriptors) {
valid &= verifyArtifactContent(repository, logger, descriptor);
}
}
return valid;
}
use of org.eclipse.equinox.p2.query.IQueryResult in project tycho by eclipse.
the class ModuleMetadataRepositoryTest method unitsIn.
private static List<IVersionedId> unitsIn(IMetadataRepository repo) {
IQueryResult<IInstallableUnit> units = repo.query(QueryUtil.ALL_UNITS, null);
List<IVersionedId> unitIds = new ArrayList<>();
for (Iterator<IInstallableUnit> unitIterator = units.iterator(); unitIterator.hasNext(); ) {
IInstallableUnit unit = unitIterator.next();
VersionedId unitId = new VersionedId(unit.getId(), unit.getVersion());
unitIds.add(unitId);
}
return unitIds;
}
use of org.eclipse.equinox.p2.query.IQueryResult in project webtools.servertools by eclipse.
the class ExtensionUtility method getExistingFeatures.
private static List<Extension> getExistingFeatures(IProgressMonitor monitor) throws CoreException {
monitor.beginTask(Messages.discoverLocalConfiguration, 100);
IProfileRegistry profileRegistry = (IProfileRegistry) getService(Activator.getDefault().getBundle().getBundleContext(), IProfileRegistry.class.getName());
IProfile[] profiles = profileRegistry.getProfiles();
IProfile profile = profileRegistry.getProfile(IProfileRegistry.SELF);
if (profile == null) {
// it happens sometime , possibility of bug in profileRegistry
for (int i = 0; i < profiles.length; i++) {
if (profiles[i].getProfileId().equals(IProfileRegistry.SELF)) {
profile = profiles[i];
break;
}
}
}
List<Extension> list = new ArrayList<Extension>();
if (profile == null)
return list;
IQuery<IInstallableUnit> query = QueryUtil.createIUAnyQuery();
// Query query = new InstallableUnitQuery("org.eclipse.wst.server.core.serverAdapter");
// List<String> list2 = new ArrayList();
// Query query = new ExtensionInstallableUnitQuery(list2);
IQueryResult<IInstallableUnit> collector = profile.query(query, monitor);
Iterator<IInstallableUnit> iter = collector.iterator();
while (iter.hasNext()) {
IInstallableUnit iu = iter.next();
if (!list.contains(iu))
list.add(new Extension(iu, null));
}
monitor.done();
return list;
}
use of org.eclipse.equinox.p2.query.IQueryResult in project epp.mpc by eclipse.
the class AbstractProvisioningOperation method queryInstallableUnits.
/**
* Perform a query to get the installable units. This causes p2 to determine what features are available in each
* repository. We select installable units by matching both the feature id and the repository; it is possible though
* unlikely that the same feature id is available from more than one of the selected repositories, and we must
* ensure that the user gets the one that they asked for.
*/
protected List<IInstallableUnit> queryInstallableUnits(SubMonitor monitor, List<IMetadataRepository> repositories) throws URISyntaxException {
final List<IInstallableUnit> installableUnits = new ArrayList<IInstallableUnit>();
monitor.setWorkRemaining(repositories.size());
for (final IMetadataRepository repository : repositories) {
checkCancelled(monitor);
final Set<String> installableUnitIdsThisRepository = getDescriptorIds(repository);
IQuery<IInstallableUnit> query = QueryUtil.createLatestQuery(QueryUtil.createIUGroupQuery());
IQueryResult<IInstallableUnit> result = repository.query(query, monitor.newChild(1));
for (IInstallableUnit iu : result) {
String id = iu.getId();
if (installableUnitIdsThisRepository.contains(id)) {
installableUnits.add(iu);
}
}
}
return installableUnits;
}
Aggregations