本文整理汇总了Java中org.eclipse.equinox.p2.query.QueryUtil.createIUQuery方法的典型用法代码示例。如果您正苦于以下问题:Java QueryUtil.createIUQuery方法的具体用法?Java QueryUtil.createIUQuery怎么用?Java QueryUtil.createIUQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.equinox.p2.query.QueryUtil
的用法示例。
在下文中一共展示了QueryUtil.createIUQuery方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findUnit
import org.eclipse.equinox.p2.query.QueryUtil; //导入方法依赖的package包/类
/**
* Finds the latest version of an installable unit in a repository.
*
* @param spec Version specification
* @return Installable unit or <code>null</code>.
* @throws CoreException on failure
*/
public IInstallableUnit findUnit(IVersionedId spec) {
String id = spec.getId();
Version version = spec.getVersion();
VersionRange range = VersionRange.emptyRange;
if (version != null && !version.equals(Version.emptyVersion))
range = new VersionRange(version, true, version, true);
IQuery<IInstallableUnit> query = QueryUtil.createIUQuery(id, range);
IQueryResult<IInstallableUnit> queryResult = getRepository().query(query, new NullProgressMonitor());
Iterator<IInstallableUnit> matches = queryResult.iterator();
// pick the newest match
IInstallableUnit newest = null;
while (matches.hasNext()) {
IInstallableUnit candidate = matches.next();
if (newest == null || (newest.getVersion().compareTo(candidate.getVersion()) < 0))
newest = candidate;
}
return newest;
}
示例2: findUnitAll
import org.eclipse.equinox.p2.query.QueryUtil; //导入方法依赖的package包/类
/**
* Finds the latest version of an installable unit in all repositories.
*
* @param spec Version specification
* @return Installable unit or <code>null</code>.
* @throws CoreException on failure
*/
public IInstallableUnit findUnitAll(IVersionedId spec) throws CoreException {
String id = spec.getId();
if (id == null) {
Installer.fail(InstallMessages.Error_NoId);
}
Version version = spec.getVersion();
VersionRange range = VersionRange.emptyRange;
if (version != null && !version.equals(Version.emptyVersion))
range = new VersionRange(version, true, version, true);
IQuery<IInstallableUnit> query = QueryUtil.createIUQuery(id, range);
Iterator<IInstallableUnit> matches = getManager().query(query, null).iterator();
// pick the newest match
IInstallableUnit newest = null;
while (matches.hasNext()) {
IInstallableUnit candidate = matches.next();
if (newest == null || (newest.getVersion().compareTo(candidate.getVersion()) < 0))
newest = candidate;
}
if (newest == null)
{
Installer.fail(InstallMessages.Error_IUNotFound + id);
}
return newest;
}
示例3: checkIfInstalled
import org.eclipse.equinox.p2.query.QueryUtil; //导入方法依赖的package包/类
/**
* Checks if a specific {@link IInstallableUnit} (IU) is installed
*
* @param installableUnitID The ID of the IU of interest
* @return true if the IU is installed
*/
public boolean checkIfInstalled(String installableUnitID) {
// --- Query the p2 profile for the InstallableUnit of interest -----------
IProfileRegistry profileRegistry = (IProfileRegistry) this.getProvisioningAgent().getService(IProfileRegistry.SERVICE_NAME);
IProfile profile = profileRegistry.getProfile(IProfileRegistry.SELF);
IQuery<IInstallableUnit> query = QueryUtil.createIUQuery(installableUnitID);
IQueryResult<IInstallableUnit> queryResult = profile.query(query, this.getProgressMonitor());
return !(queryResult.isEmpty());
}
示例4: findUnit
import org.eclipse.equinox.p2.query.QueryUtil; //导入方法依赖的package包/类
/**
* Finds the latest version of an installable unit in local repositories.
*
* @param spec Version specification
* @return Installable unit or <code>null</code>.
* @throws CoreException on failure
*/
public IInstallableUnit findUnit(IVersionedId spec) throws CoreException {
String id = spec.getId();
if (id == null) {
Installer.fail(InstallMessages.Error_NoId);
}
Version version = spec.getVersion();
VersionRange range = VersionRange.emptyRange;
if (version != null && !version.equals(Version.emptyVersion))
range = new VersionRange(version, true, version, true);
URI[] locations = manager.getKnownRepositories(IRepositoryManager.REPOSITORIES_LOCAL);
List<IMetadataRepository> queryables = new ArrayList<IMetadataRepository>(locations.length);
for (URI location : locations) {
queryables.add(getManager().loadRepository(location, new NullProgressMonitor()));
}
IQuery<IInstallableUnit> query = QueryUtil.createIUQuery(id, range);
IQueryable<IInstallableUnit> compoundQueryable = QueryUtil.compoundQueryable(queryables);
IQueryResult<IInstallableUnit> queryResult = compoundQueryable.query(query, new NullProgressMonitor());
Iterator<IInstallableUnit> matches = queryResult.iterator();
// pick the newest match
IInstallableUnit newest = null;
while (matches.hasNext()) {
IInstallableUnit candidate = matches.next();
if (newest == null || (newest.getVersion().compareTo(candidate.getVersion()) < 0))
newest = candidate;
}
return newest;
}
示例5: queryIuName
import org.eclipse.equinox.p2.query.QueryUtil; //导入方法依赖的package包/类
/**
* Returns the name for an installable unit.
*
* @param id IU identifier.
* @return IU name or <code>null</code> if the IU is not found.
*/
public String queryIuName(String id) {
IQuery<IInstallableUnit> query = QueryUtil.createIUQuery(id);
IQueryResult<IInstallableUnit> result = getMetadataRepositoryManager().query(query, null);
Iterator<IInstallableUnit> iter = result.iterator();
while (iter.hasNext()) {
IInstallableUnit unit = iter.next();
return unit.getProperty(IInstallableUnit.PROP_NAME, null);
}
return null;
}
示例6: shouldUpdate
import org.eclipse.equinox.p2.query.QueryUtil; //导入方法依赖的package包/类
public boolean shouldUpdate() {
try {
IProvisioningAgentProvider agentProvider= Activator.getDefault().getProvisioningAgentProvider();
if (agentProvider == null) {
Activator.getDefault().logErrorStatus("Could not find a provisioning agent provider.", new RuntimeException());
return false;
}
final IProvisioningAgent agent= agentProvider.createAgent(null);
IMetadataRepositoryManager metadataRepositoryManager= (IMetadataRepositoryManager)agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
if (metadataRepositoryManager == null) {
Activator.getDefault().logErrorStatus("Could not find the meta data repository manager.", new RuntimeException());
return false;
}
IArtifactRepositoryManager artifactRepositoryManager= (IArtifactRepositoryManager)agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
if (artifactRepositoryManager == null) {
Activator.getDefault().logErrorStatus("Could not find the artifact repository manager.", new RuntimeException());
return false;
}
metadataRepositoryManager.addRepository(getUpdateSiteURI(updateSite));
artifactRepositoryManager.addRepository(getUpdateSiteURI(updateSite));
metadataRepositoryManager.loadRepository(getUpdateSiteURI(updateSite), new NullProgressMonitor());
final IProfileRegistry registry= (IProfileRegistry)agent.getService(IProfileRegistry.SERVICE_NAME);
if (registry == null) {
Activator.getDefault().logErrorStatus("Could not find the profile registry.", new RuntimeException());
return false;
}
final IProfile profile= registry.getProfile(IProfileRegistry.SELF);
if (profile == null) {
Activator.getDefault().logErrorStatus("Could not find the profile.", new RuntimeException());
return false;
}
IQuery<IInstallableUnit> query= QueryUtil.createIUQuery(pluginID);
Collection<IInstallableUnit> iusToUpdate= profile.query(query, null).toUnmodifiableSet();
ProvisioningSession provisioningSession= new ProvisioningSession(agent);
final UpdateOperation updateOperation= new UpdateOperation(provisioningSession, iusToUpdate);
IStatus modalResolution= updateOperation.resolveModal(new NullProgressMonitor());
if (modalResolution.isOK())
return true;
} catch (ProvisionException e) {
Activator.getDefault().logErrorStatus("A provisioning exception occured while checking for updates.", e);
}
return false;
}