Search in sources :

Example 1 with IQueryResult

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;
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 2 with IQueryResult

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;
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) IArtifactKey(org.eclipse.equinox.p2.metadata.IArtifactKey)

Example 3 with IQueryResult

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;
}
Also used : IVersionedId(org.eclipse.equinox.p2.metadata.IVersionedId) VersionedId(org.eclipse.equinox.p2.metadata.VersionedId) IVersionedId(org.eclipse.equinox.p2.metadata.IVersionedId) ArrayList(java.util.ArrayList) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 4 with IQueryResult

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;
}
Also used : IProfileRegistry(org.eclipse.equinox.p2.engine.IProfileRegistry) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) IProfile(org.eclipse.equinox.p2.engine.IProfile)

Example 5 with IQueryResult

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;
}
Also used : ArrayList(java.util.ArrayList) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) IMetadataRepository(org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)

Aggregations

IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)17 ArrayList (java.util.ArrayList)6 IMetadataRepository (org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)5 HashMap (java.util.HashMap)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)2 IProfile (org.eclipse.equinox.p2.engine.IProfile)2 IProfileRegistry (org.eclipse.equinox.p2.engine.IProfileRegistry)2 IArtifactKey (org.eclipse.equinox.p2.metadata.IArtifactKey)2 IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)2 VersionRange (org.eclipse.equinox.p2.metadata.VersionRange)2 IQuery (org.eclipse.equinox.p2.query.IQuery)2 IMetadataRepositoryManager (org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager)2 File (java.io.File)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Map (java.util.Map)1