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

Hi Tomas,

After playing with queries for awhile, we came up with the following that works for us but I'm not sure if it should:

We currently test against the following:

RCPApp
F1
F2
F3

Somewhat surprisingly (based on what's on the P2 query web site), the following query worked for us:

select(iu | $0.exists(root | iu.id == root.id || iu.version == root.version)

where $0 is a collection of IVersionedId referencing just F1 and F2.

The log shows that this query selected only F1 and F2.

You'll notice the conspicuous absence of a "traverse" function.  Yet, our tests show that this works--the updated Product contains F1, F2, and F3 and the UI lets us call both the F2 and F3 utility methods..

If this is not just incidental behavior, we're happy with this.  But are you?


Regards,

Dave Orme

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