Search in sources :

Example 16 with IQueryResult

use of org.eclipse.equinox.p2.query.IQueryResult in project tycho by eclipse.

the class ArtifactMatcher method resolveReference.

public static IInstallableUnit resolveReference(String type, String id, Version version, LinkedHashSet<IInstallableUnit> candidateUnits) throws IllegalArtifactReferenceException {
    if (id == null) {
        throw new IllegalArtifactReferenceException("ID is required");
    }
    VersionRange versionRange = getVersionRangeFromReference(version);
    IQuery<IInstallableUnit> query = QueryUtil.createLatestQuery(ArtifactTypeHelper.createQueryFor(type, id, versionRange));
    IQueryResult<IInstallableUnit> matchingIUs = query.perform(candidateUnits.iterator());
    if (matchingIUs.isEmpty()) {
        return null;
    } else {
        return matchingIUs.iterator().next();
    }
}
Also used : IllegalArtifactReferenceException(org.eclipse.tycho.artifacts.IllegalArtifactReferenceException) VersionRange(org.eclipse.equinox.p2.metadata.VersionRange) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 17 with IQueryResult

use of org.eclipse.equinox.p2.query.IQueryResult in project tycho by eclipse.

the class VerifierServiceImpl method verifyReferencedArtifactsExist.

private boolean verifyReferencedArtifactsExist(final IMetadataRepository metadata, final IArtifactRepository artifactRepository, MavenLogger logger) {
    final IQueryResult<IInstallableUnit> collector = metadata.query(QueryUtil.ALL_UNITS, monitor);
    boolean valid = true;
    for (Iterator<IInstallableUnit> iterator = collector.iterator(); iterator.hasNext(); ) {
        IInstallableUnit iu = iterator.next();
        final Collection<IArtifactKey> artifacts = iu.getArtifacts();
        for (IArtifactKey key : artifacts) {
            valid &= verifyArtifactExists(key, artifactRepository, logger);
        }
    }
    return valid;
}
Also used : IArtifactKey(org.eclipse.equinox.p2.metadata.IArtifactKey) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 18 with IQueryResult

use of org.eclipse.equinox.p2.query.IQueryResult in project tycho by eclipse.

the class ResolutionDataImpl method setAvailableIUsAndFilter.

/**
 * Sets the available installable units, removing all non-applicable execution environment
 * units.
 *
 * @see #setAvailableIUs(Collection)
 */
public void setAvailableIUsAndFilter(IQueryable<IInstallableUnit> unfilteredAvailableUnits) {
    this.availableIUs = new LinkedHashSet<>();
    IQueryResult<IInstallableUnit> allUnits = unfilteredAvailableUnits.query(QueryUtil.ALL_UNITS, new NullProgressMonitor());
    copyApplyingEEFilter(allUnits.iterator(), this.availableIUs, eeResolutionHints);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

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