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

On 2010-12-10 23:59, David Orme wrote:
OK; here's where I'm ending the week:

toInstallOrUpdate = allMetadataRepos.query(
new String[]{"com.example.rcpmain.ui.utils.feature.feature.group",
"com.example.rcpmain.ui.feature.feature.group"}), monitor).toUnmodifiableSet();

where traverseQuery is:

final String traverseQuery = "$0.traverse(parent | parent.requirements.collect(rc | select(iu |iu ~= rc)).flatten())";

The argument should be a collection (or array) of IU's, not strings. Also, be adviced that the createQuery uses a varargs so passing an array will expand into multiple args. If you want an array as $0, you must cast it to an Object. I.e. either

QueryUtil.createQuery(traverseQuery, (Object)new IInstallableUnit[] { iu1, iu2, iu3 }, monitor)


Collection<IInstallableUnit> roots = ...
QueryUtil.createQuery(traverseQuery, roots)

Thomas Hallgren