Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF Query] recursive conditions
[EMF Query] recursive conditions [message #420335] Wed, 25 June 2008 05:40 Go to next message
Jim Steel is currently offline Jim SteelFriend
Messages: 54
Registered: July 2009
Member
Hi,

Does EMF Query handle recursive conditions? I'm trying to write a
condition along the lines of "p(x) or p(y) where y is a direct or
indirect container of x". I am trying

EObjectCondition p = ...

EObjectCondition p_or_parent_p = null;

EObjectCondition parent_p = new
EObjectReferenceValueCondition(containerReference, p_or_parent_p);

p_or_parent_p = p.OR(parent_p);

I'm having some NullPointerExceptions that I'm trying to sort out, but
if its a fundamental limitation of EMF Query, I'll have to work out some
other way of doing it.

Cheers,

Jim.
Re: [EMF Query] recursive conditions [message #420376 is a reply to message #420335] Thu, 26 June 2008 23:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

--=-VcA87hV+ckr/PIX58lUY
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi, Jim,

The stock query conditions (esp. EObjectReferenceValueCondition) only
handle one step of a reference chain. It would be interesting to add
support for predicates on the closure or a reference, such as we can do
in MDT OCL with the "closure" iterator.

Is that what you're getting at? I may have misunderstood.

HTH,

Christian

On Wed, 2008-06-25 at 15:40 +1000, Jim Steel wrote:

> Hi,
>
> Does EMF Query handle recursive conditions? I'm trying to write a
> condition along the lines of "p(x) or p(y) where y is a direct or
> indirect container of x". I am trying
>
> EObjectCondition p = ...
>
> EObjectCondition p_or_parent_p = null;
>
> EObjectCondition parent_p = new
> EObjectReferenceValueCondition(containerReference, p_or_parent_p);
>
> p_or_parent_p = p.OR(parent_p);
>
> I'm having some NullPointerExceptions that I'm trying to sort out, but
> if its a fundamental limitation of EMF Query, I'll have to work out some
> other way of doing it.
>
> Cheers,
>
> Jim.

--=-VcA87hV+ckr/PIX58lUY
Content-Type: text/html; charset=utf-8

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.16.0">
</HEAD>
<BODY>
Hi, Jim,<BR>
<BR>
The stock query conditions (esp. EObjectReferenceValueCondition) only handle one step of a reference chain.&nbsp; It would be interesting to add support for predicates on the closure or a reference, such as we can do in MDT OCL with the &quot;closure&quot; iterator.<BR>
<BR>
Is that what you're getting at?&nbsp; I may have misunderstood.<BR>
<BR>
HTH,<BR>
<BR>
Christian<BR>
<BR>
On Wed, 2008-06-25 at 15:40 +1000, Jim Steel wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">Hi,</FONT>

<FONT COLOR="#000000">Does EMF Query handle recursive conditions? I'm trying to write a </FONT>
<FONT COLOR="#000000">condition along the lines of &quot;p(x) or p(y) where y is a direct or </FONT>
<FONT COLOR="#000000">indirect container of x&quot;. I am trying</FONT>

<FONT COLOR="#000000">EObjectCondition p = ...</FONT>

<FONT COLOR="#000000">EObjectCondition p_or_parent_p = null;</FONT>

<FONT COLOR="#000000">EObjectCondition parent_p = new </FONT>
<FONT COLOR="#000000">EObjectReferenceValueCondition(containerReference, p_or_parent_p);</FONT>

<FONT COLOR="#000000">p_or_parent_p = p.OR(parent_p);</FONT>

<FONT COLOR="#000000">I'm having some NullPointerExceptions that I'm trying to sort out, but </FONT>
<FONT COLOR="#000000">if its a fundamental limitation of EMF Query, I'll have to work out some </FONT>
<FONT COLOR="#000000">other way of doing it.</FONT>

<FONT COLOR="#000000">Cheers,</FONT>

<FONT COLOR="#000000">Jim.</FONT>
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-VcA87hV+ckr/PIX58lUY--
Re: [EMF Query] recursive conditions [message #420378 is a reply to message #420376] Fri, 27 June 2008 01:55 Go to previous messageGo to next message
Jim Steel is currently offline Jim SteelFriend
Messages: 54
Registered: July 2009
Member
Yes, that was essentially what I was trying to do in this case. My
question was more general, about whether it was possible to reuse an
EObjectCondition twice in a tree, in this case in a recursive way.

I've since found another way of solving my particular problem, by
shifting the recursive call inside a custom EObjectCondition, a la

EObjectCondition recursiveMatch = new EObjectCondition() {

public boolean isSatisfied(EObject object) {
return matches(object);
}

private boolean matches(EObject object) {
if isAMatch(object) return true;
else return matches(object.eContainer());
}
};


If that makes sense....

Jim.




Christian W. Damus wrote:
> Hi, Jim,
>
> The stock query conditions (esp. EObjectReferenceValueCondition) only
> handle one step of a reference chain. It would be interesting to add
> support for predicates on the closure or a reference, such as we can do
> in MDT OCL with the "closure" iterator.
>
> Is that what you're getting at? I may have misunderstood.
>
> HTH,
>
> Christian
>
> On Wed, 2008-06-25 at 15:40 +1000, Jim Steel wrote:
>> Hi,
>>
>> Does EMF Query handle recursive conditions? I'm trying to write a
>> condition along the lines of "p(x) or p(y) where y is a direct or
>> indirect container of x". I am trying
>>
>> EObjectCondition p = ...
>>
>> EObjectCondition p_or_parent_p = null;
>>
>> EObjectCondition parent_p = new
>> EObjectReferenceValueCondition(containerReference, p_or_parent_p);
>>
>> p_or_parent_p = p.OR(parent_p);
>>
>> I'm having some NullPointerExceptions that I'm trying to sort out, but
>> if its a fundamental limitation of EMF Query, I'll have to work out some
>> other way of doing it.
>>
>> Cheers,
>>
>> Jim.
Re: [EMF Query] recursive conditions [message #420382 is a reply to message #420378] Fri, 27 June 2008 03:17 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

--=-DCW7Z59C/OrfXVySkZ0n
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi, Jim,

Yes, that makes perfect sense. That is your best work-around, for now.
If you are interested in a more general/re-usable condition object,
please do raise an enhancement request in Bugzilla.

I don't think any of the pre-fab condition objects have state that
changes during the execution of a query, so it should be possible to use
any of them multiple times in the same query expression.

Cheers,

Christian


On Fri, 2008-06-27 at 11:55 +1000, Jim Steel wrote:

> Yes, that was essentially what I was trying to do in this case. My
> question was more general, about whether it was possible to reuse an
> EObjectCondition twice in a tree, in this case in a recursive way.
>
> I've since found another way of solving my particular problem, by
> shifting the recursive call inside a custom EObjectCondition, a la
>
> EObjectCondition recursiveMatch = new EObjectCondition() {
>
> public boolean isSatisfied(EObject object) {
> return matches(object);
> }
>
> private boolean matches(EObject object) {
> if isAMatch(object) return true;
> else return matches(object.eContainer());
> }
> };
>
>
> If that makes sense....
>
> Jim.
>
>
>
>
> Christian W. Damus wrote:
> > Hi, Jim,
> >
> > The stock query conditions (esp. EObjectReferenceValueCondition) only
> > handle one step of a reference chain. It would be interesting to add
> > support for predicates on the closure or a reference, such as we can do
> > in MDT OCL with the "closure" iterator.
> >
> > Is that what you're getting at? I may have misunderstood.
> >
> > HTH,
> >
> > Christian
> >
> > On Wed, 2008-06-25 at 15:40 +1000, Jim Steel wrote:
> >> Hi,
> >>
> >> Does EMF Query handle recursive conditions? I'm trying to write a
> >> condition along the lines of "p(x) or p(y) where y is a direct or
> >> indirect container of x". I am trying
> >>
> >> EObjectCondition p = ...
> >>
> >> EObjectCondition p_or_parent_p = null;
> >>
> >> EObjectCondition parent_p = new
> >> EObjectReferenceValueCondition(containerReference, p_or_parent_p);
> >>
> >> p_or_parent_p = p.OR(parent_p);
> >>
> >> I'm having some NullPointerExceptions that I'm trying to sort out, but
> >> if its a fundamental limitation of EMF Query, I'll have to work out some
> >> other way of doing it.
> >>
> >> Cheers,
> >>
> >> Jim.

--=-DCW7Z59C/OrfXVySkZ0n
Content-Type: text/html; charset=utf-8

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.16.0">
</HEAD>
<BODY>
Hi, Jim,<BR>
<BR>
Yes, that makes perfect sense.&nbsp; That is your best work-around, for now.&nbsp; If you are interested in a more general/re-usable condition object, please do raise an enhancement request in Bugzilla.<BR>
<BR>
I don't think any of the pre-fab condition objects have state that changes during the execution of a query, so it should be possible to use any of them multiple times in the same query expression.<BR>
<BR>
Cheers,<BR>
<BR>
Christian<BR>
<BR>
<BR>
On Fri, 2008-06-27 at 11:55 +1000, Jim Steel wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">Yes, that was essentially what I was trying to do in this case. My </FONT>
<FONT COLOR="#000000">question was more general, about whether it was possible to reuse an </FONT>
<FONT COLOR="#000000">EObjectCondition twice in a tree, in this case in a recursive way.</FONT>

<FONT COLOR="#000000">I've since found another way of solving my particular problem, by </FONT>
<FONT COLOR="#000000">shifting the recursive call inside a custom EObjectCondition, a la</FONT>

<FONT COLOR="#000000">EObjectCondition recursiveMatch = new EObjectCondition() {</FONT>

<FONT COLOR="#000000"> public boolean isSatisfied(EObject object) {</FONT>
<FONT COLOR="#000000"> return matches(object);</FONT>
<FONT COLOR="#000000"> }</FONT>

<FONT COLOR="#000000"> private boolean matches(EObject object) {</FONT>
<FONT COLOR="#000000"> if isAMatch(object) return true;</FONT>
<FONT COLOR="#000000"> else return matches(object.eContainer());</FONT>
<FONT COLOR="#000000"> }</FONT>
<FONT COLOR="#000000">};</FONT>


<FONT COLOR="#000000">If that makes sense....</FONT>

<FONT COLOR="#000000">Jim.</FONT>




<FONT COLOR="#000000">Christian W. Damus wrote:</FONT>
<FONT COLOR="#000000">&gt; Hi, Jim,</FONT>
<FONT COLOR="#000000">&gt; </FONT>
<FONT COLOR="#000000">&gt; The stock query conditions (esp. EObjectReferenceValueCondition) only </FONT>
<FONT COLOR="#000000">&gt; handle one step of a reference chain. It would be interesting to add </FONT>
<FONT COLOR="#000000">&gt; support for predicates on the closure or a reference, such as we can do </FONT>
<FONT COLOR="#000000">&gt; in MDT OCL with the &quot;closure&quot; iterator.</FONT>
<FONT COLOR="#000000">&gt; </FONT>
<FONT COLOR="#000000">&gt; Is that what you're getting at? I may have misunderstood.</FONT>
<FONT COLOR="#000000">&gt; </FONT>
<FONT COLOR="#000000">&gt; HTH,</FONT>
<FONT COLOR="#000000">&gt; </FONT>
<FONT COLOR="#000000">&gt; Christian</FONT>
<FONT COLOR="#000000">&gt; </FONT>
<FONT COLOR="#000000">&gt; On Wed, 2008-06-25 at 15:40 +1000, Jim Steel wrote:</FONT>
<FONT COLOR="#000000">&gt;&gt; Hi,</FONT>
<FONT COLOR="#000000">&gt;&gt;</FONT>
<FONT COLOR="#000000">&gt;&gt; Does EMF Query handle recursive conditions? I'm trying to write a </FONT>
<FONT COLOR="#000000">&gt;&gt; condition along the lines of &quot;p(x) or p(y) where y is a direct or </FONT>
<FONT COLOR="#000000">&gt;&gt; indirect container of x&quot;. I am trying</FONT>
<FONT COLOR="#000000">&gt;&gt;</FONT>
<FONT COLOR="#000000">&gt;&gt; EObjectCondition p = ...</FONT>
<FONT COLOR="#000000">&gt;&gt;</FONT>
<FONT COLOR="#000000">&gt;&gt; EObjectCondition p_or_parent_p = null;</FONT>
<FONT COLOR="#000000">&gt;&gt;</FONT>
<FONT COLOR="#000000">&gt;&gt; EObjectCondition parent_p = new </FONT>
<FONT COLOR="#000000">&gt;&gt; EObjectReferenceValueCondition(containerReference, p_or_parent_p);</FONT>
<FONT COLOR="#000000">&gt;&gt;</FONT>
<FONT COLOR="#000000">&gt;&gt; p_or_parent_p = p.OR(parent_p);</FONT>
<FONT COLOR="#000000">&gt;&gt;</FONT>
<FONT COLOR="#000000">&gt;&gt; I'm having some NullPointerExceptions that I'm trying to sort out, but </FONT>
<FONT COLOR="#000000">&gt;&gt; if its a fundamental limitation of EMF Query, I'll have to work out some </FONT>
<FONT COLOR="#000000">&gt;&gt; other way of doing it.</FONT>
<FONT COLOR="#000000">&gt;&gt;</FONT>
<FONT COLOR="#000000">&gt;&gt; Cheers,</FONT>
<FONT COLOR="#000000">&gt;&gt;</FONT>
<FONT COLOR="#000000">&gt;&gt; Jim.</FONT>
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-DCW7Z59C/OrfXVySkZ0n--
Previous Topic:XMLResource.OPTION_CONFIGURATION_CACHE can produce ArrayIndexOutOfBoundsException
Next Topic:seeking advice: making generated contentproviders filterable
Goto Forum:
  


Current Time: Tue Sep 24 09:21:15 GMT 2024

Powered by FUDForum. Page generated in 0.06016 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top