[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [p2-dev] Executing a P2 traverse query

Thanks!


Dave

On Mon, Dec 13, 2010 at 5:32 PM, Thomas Hallgren <thomas@xxxxxxx> wrote:
Hi Dave,

Just to clarify, the code you use for creating the newIU below, do you use that for creating the IU's that you pass as roots to the traverse query? If that's the case, then I understand why you have a problem. The IU doesn't have any requirements so naturally, the query won't find any matches.

You need to query for the root iu's first, using a standard IU query (with id and version) and then use the result from that query as root IU's into the traverse query. This can be done using two queries but you can also do it one single query also, like so:

select(iu | $0.exists(v | v.id == iu.id && v.version == iu.version)).traverse(parent | ...

You then pass a collection of IVersionedID instances as $0. There is an implementation class called VersionedID that takes a constructor with id and version that you can use.

HTH,

Thomas Hallgren



On 2010-12-14 00:20, David Orme wrote:

Here's the code I use to create an IU:

private IInstallableUnit newIU(String id, String versionString) {
    InstallableUnitDescription iuDesc = new MetadataFactory.InstallableUnitDescription();
    iuDesc.setId(id);
    Version version = Version.create(versionString);
    iuDesc.setVersion(version);
    ArrayList<IProvidedCapability> capabilities = new ArrayList<IProvidedCapability>();
    capabilities.add(MetadataFactory.createProvidedCapability(id, id, version));
    iuDesc.addProvidedCapabilities(capabilities);
    return MetadataFactory.createInstallableUnit(iuDesc);
}


Thanks again,

Dave



_______________________________________________ p2-dev mailing list


_______________________________________________
p2-dev mailing list
p2-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/p2-dev