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

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())";


java.lang.IllegalArgumentException: Cannot convert a java.lang.String into an iterator

I'm puzzled and would appreciate a steer about how to use the API.  Thanks in advance.



On Fri, Dec 10, 2010 at 3:21 PM, David Orme <djo@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Ahhh; I see you've already answered my question, but cleverly disguised as an explanation. 

As a UI guy, I'm used to posting questions and answers in the form of terse code snippets to the SWT newsgroup, so apologies while I adjust to the customs of the natives around here. ;)

I have some questions/clarifications regarding this that I'll ask, as much for myself as for anyone else who searches the list archives later looking for this information:

On Fri, Dec 10, 2010 at 8:35 AM, Thomas Hallgren <thomas@xxxxxxx> wrote:
It expects a collection (i.e. your set of roots) as it's first argument. You then apply it to your IQueryable.

OK, this makes sense, but with two questions as caveats:  The signature of a Query with parameters is:

public static IQuery<IInstallableUnit> createQuery(String _expression_, Object... parameters) {

1) Do I literally pass a collection as the 0th vararg element or is each vararg element supposed to be a separate element of the collection?  If a collection, can I just pass any arbitrary Iterable?

2) What is the data type of the parameter?  A string which is the <featureID>.feature.group identifier?  Something else?
In the _expression_, 'parent' is the variable holding each item from the roots. The _expression_ compares all iu's from your IQueryable with the requirements of the 'parent' and this results in new instances that will become 'parent' as the query traverses recursively.

Yes, this makes perfect sense.  Thanks much for the detailed explanation.

If I work out an answer (through trial and error experimentation) before someone answers, I'll post it here.  Otherwise, if someone can get to it first, I'd appreciate a quick steer.  Thanks in advance and...


Dave Orme