Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » OCL and Query Questions
OCL and Query Questions [message #39175] Wed, 05 July 2006 09:23 Go to next message
Chris Lenz is currently offline Chris LenzFriend
Messages: 214
Registered: July 2009
Senior Member
Hi all,

Other questions about OCL and QUERY!

OCL is build on top of QUERY. Am I right?

What OCL standard is implemented yet.
Is it possible to define recursive funktions, like

def: let getSubroles(r: Role) : Set(Role) =
r.subrole->collect(x|getSubroles(x))->asSet()->union(r.subrole)

can anyone give me an example.

Thanx Chris
Re: OCL and Query Questions [message #39206 is a reply to message #39175] Wed, 05 July 2006 11:39 Go to previous messageGo to next message
Chris McGee is currently offline Chris McGeeFriend
Messages: 99
Registered: July 2009
Member
Hi Chris,

The core of OCL and Query are completely separate. Having said that, the
Query has an optional feature that allows one to write Query conditions
in OCL.

I hope this helps,
Chris McGee

Chris Lenz wrote:
> Hi all,
>
> Other questions about OCL and QUERY!
>
> OCL is build on top of QUERY. Am I right?
>
> What OCL standard is implemented yet.
> Is it possible to define recursive funktions, like
>
> def: let getSubroles(r: Role) : Set(Role) =
> r.subrole->collect(x|getSubroles(x))->asSet()->union(r.subrole)
>
> can anyone give me an example.
>
> Thanx Chris
Re: OCL and Query Questions [message #39237 is a reply to message #39206] Wed, 05 July 2006 12:51 Go to previous messageGo to next message
Chris Lenz is currently offline Chris LenzFriend
Messages: 214
Registered: July 2009
Senior Member
What's with that:

What OCL standard is implemented yet.
Is it possible to define recursive funktions, like

def: let getSubroles(r: Role) : Set(Role) =
r.subrole->collect(x|getSubroles(x))->asSet()->union(r.subrole)

can anyone give me an example.

Chris

> Hi Chris,
>
> The core of OCL and Query are completely separate. Having said that, the
> Query has an optional feature that allows one to write Query conditions
> in OCL.
>
> I hope this helps,
> Chris McGee
>
> Chris Lenz wrote:
>> Hi all,
>>
>> Other questions about OCL and QUERY!
>>
>> OCL is build on top of QUERY. Am I right?
>>
>> What OCL standard is implemented yet.
>> Is it possible to define recursive funktions, like
>>
>> def: let getSubroles(r: Role) : Set(Role) =
>> r.subrole->collect(x|getSubroles(x))->asSet()->union(r.subrole)
>>
>> can anyone give me an example.
>>
>> Thanx Chris
Re: OCL and Query Questions [message #39267 is a reply to message #39237] Wed, 05 July 2006 14:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hello, Chris,

EMFT implements the OCL 2.0 grammar, as specified in the latest interim
document from OMG (the spec is still in the finalization phase).

The API allows to define additional operations such as your example, below.
Try this:

IOCLHelper helper = HelperUtil.createOCLHelper();
helper.define("getSubroles(r : Role) : Set(Role) = " +
"r.subrole->collect(x|getSubroles(x))->asSet()->union(r.subrole) ");

Recursion is supported. Given this definition, subsequent evaluation of
queries and constraints can use the getSubroles operation as it would any
other defined by your Ecore model.

However, EMFT provides an extra goodie (not defined by the OCL spec) that
obviates the need for this particular recursive operation definition: the
transitive closure iterator. The above operation is fully equivalent to
the following expression:

r->closure(subrole)

This actually has the benefit of not being susceptible to infinite recursion
in cases of cycles, which I don't think the alternative implementation
would avoid in its current form (it would require some fancy iteration
expressions and set differences; a much more complex expression overall).

HTH,

Christian


Chris Lenz wrote:

> What's with that:
>
> What OCL standard is implemented yet.
> Is it possible to define recursive funktions, like
>
> def: let getSubroles(r: Role) : Set(Role) =
> r.subrole->collect(x|getSubroles(x))->asSet()->union(r.subrole)
>
> can anyone give me an example.
>
> Chris
>

<snip>
Re: OCL and Query Questions [message #48315 is a reply to message #39267] Mon, 04 September 2006 08:32 Go to previous messageGo to next message
Chris Lenz is currently offline Chris LenzFriend
Messages: 214
Registered: July 2009
Senior Member
Hi Christian:
I want to ask if the recursive problem is planned to get fixed:

Ok can you give me a hint that I can make a quickhack.

We use your pacage for validating uml model, and I have to thank for
your real great work :-).
Best regards from Austria



Christian W. Damus schrieb:
> Hello, Chris,
>
> EMFT implements the OCL 2.0 grammar, as specified in the latest interim
> document from OMG (the spec is still in the finalization phase).
>
> The API allows to define additional operations such as your example, below.
> Try this:
>
> IOCLHelper helper = HelperUtil.createOCLHelper();
> helper.define("getSubroles(r : Role) : Set(Role) = " +
> "r.subrole->collect(x|getSubroles(x))->asSet()->union(r.subrole) ");
>
> Recursion is supported. Given this definition, subsequent evaluation of
> queries and constraints can use the getSubroles operation as it would any
> other defined by your Ecore model.
>
> However, EMFT provides an extra goodie (not defined by the OCL spec) that
> obviates the need for this particular recursive operation definition: the
> transitive closure iterator. The above operation is fully equivalent to
> the following expression:
>
> r->closure(subrole)
>
> This actually has the benefit of not being susceptible to infinite recursion
> in cases of cycles, which I don't think the alternative implementation
> would avoid in its current form (it would require some fancy iteration
> expressions and set differences; a much more complex expression overall).
>
> HTH,
>
> Christian
>
>
> Chris Lenz wrote:
>
>> What's with that:
>>
>> What OCL standard is implemented yet.
>> Is it possible to define recursive funktions, like
>>
>> def: let getSubroles(r: Role) : Set(Role) =
>> r.subrole->collect(x|getSubroles(x))->asSet()->union(r.subrole)
>>
>> can anyone give me an example.
>>
>> Chris
>>
>
> <snip>
Re: OCL and Query Questions [message #48343 is a reply to message #48315] Mon, 04 September 2006 09:24 Go to previous message
Chris Lenz is currently offline Chris LenzFriend
Messages: 214
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040403020307070904080806
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

I have created a patch that works for me :-)

Chris Lenz schrieb:
> Hi Christian:
> I want to ask if the recursive problem is planned to get fixed:
>
> Ok can you give me a hint that I can make a quickhack.
>
> We use your pacage for validating uml model, and I have to thank for
> your real great work :-).
> Best regards from Austria
>
>
>
> Christian W. Damus schrieb:
>> Hello, Chris,
>>
>> EMFT implements the OCL 2.0 grammar, as specified in the latest interim
>> document from OMG (the spec is still in the finalization phase).
>>
>> The API allows to define additional operations such as your example, below.
>> Try this:
>>
>> IOCLHelper helper = HelperUtil.createOCLHelper();
>> helper.define("getSubroles(r : Role) : Set(Role) = " +
>> "r.subrole->collect(x|getSubroles(x))->asSet()->union(r.subrole) ");
>>
>> Recursion is supported. Given this definition, subsequent evaluation of
>> queries and constraints can use the getSubroles operation as it would any
>> other defined by your Ecore model.
>>
>> However, EMFT provides an extra goodie (not defined by the OCL spec) that
>> obviates the need for this particular recursive operation definition: the
>> transitive closure iterator. The above operation is fully equivalent to
>> the following expression:
>>
>> r->closure(subrole)
>>
>> This actually has the benefit of not being susceptible to infinite recursion
>> in cases of cycles, which I don't think the alternative implementation
>> would avoid in its current form (it would require some fancy iteration
>> expressions and set differences; a much more complex expression overall).
>>
>> HTH,
>>
>> Christian
>>
>>
>> Chris Lenz wrote:
>>
>>> What's with that:
>>>
>>> What OCL standard is implemented yet.
>>> Is it possible to define recursive funktions, like
>>>
>>> def: let getSubroles(r: Role) : Set(Role) =
>>> r.subrole->collect(x|getSubroles(x))->asSet()->union(r.subrole)
>>>
>>> can anyone give me an example.
>>>
>>> Chris
>>>
>> <snip>


--------------040403020307070904080806
Content-Type: text/plain;
name="recursion.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="recursion.txt"

### Eclipse Workspace Patch 1.0
#P org.eclipse.emf.ocl
Index: src/org/eclipse/emf/ocl/internal/parser/OCLParser.java
============================================================ =======
RCS file: /cvsroot/technology/org.eclipse.emft/ocl/plugins/org.eclipse .emf.ocl/src/org/eclipse/emf/ocl/internal/parser/OCLParser.j ava,v
retrieving revision 1.16
diff -u -r1.16 OCLParser.java
--- src/org/eclipse/emf/ocl/internal/parser/OCLParser.java 5 May 2006 13:19:14 -0000 1.16
+++ src/org/eclipse/emf/ocl/internal/parser/OCLParser.java 4 Sep 2006 08:59:15 -0000
@@ -1497,12 +1497,12 @@
operationString(operName, args),
contextEnv.getContextClassifier().getName()));
}
-
- expression = oclExpressionCS(defExpr.getExpressionCS(), contextEnv);
feature = TypeUtil.defineOperation(
contextEnv.getContextClassifier(),
unquote(operCS.getSimpleNameCS().getValue()),
params, type);
+ expression = oclExpressionCS(defExpr.getExpressionCS(), contextEnv);
+
}

Constraint astNode = umlFactory.createConstraint();

--------------040403020307070904080806--
Re: OCL and Query Questions [message #582073 is a reply to message #39175] Wed, 05 July 2006 11:39 Go to previous message
Chris McGee is currently offline Chris McGeeFriend
Messages: 99
Registered: July 2009
Member
Hi Chris,

The core of OCL and Query are completely separate. Having said that, the
Query has an optional feature that allows one to write Query conditions
in OCL.

I hope this helps,
Chris McGee

Chris Lenz wrote:
> Hi all,
>
> Other questions about OCL and QUERY!
>
> OCL is build on top of QUERY. Am I right?
>
> What OCL standard is implemented yet.
> Is it possible to define recursive funktions, like
>
> def: let getSubroles(r: Role) : Set(Role) =
> r.subrole->collect(x|getSubroles(x))->asSet()->union(r.subrole)
>
> can anyone give me an example.
>
> Thanx Chris
Re: OCL and Query Questions [message #582083 is a reply to message #39206] Wed, 05 July 2006 12:51 Go to previous message
Chris Lenz is currently offline Chris LenzFriend
Messages: 214
Registered: July 2009
Senior Member
What's with that:

What OCL standard is implemented yet.
Is it possible to define recursive funktions, like

def: let getSubroles(r: Role) : Set(Role) =
r.subrole->collect(x|getSubroles(x))->asSet()->union(r.subrole)

can anyone give me an example.

Chris

> Hi Chris,
>
> The core of OCL and Query are completely separate. Having said that, the
> Query has an optional feature that allows one to write Query conditions
> in OCL.
>
> I hope this helps,
> Chris McGee
>
> Chris Lenz wrote:
>> Hi all,
>>
>> Other questions about OCL and QUERY!
>>
>> OCL is build on top of QUERY. Am I right?
>>
>> What OCL standard is implemented yet.
>> Is it possible to define recursive funktions, like
>>
>> def: let getSubroles(r: Role) : Set(Role) =
>> r.subrole->collect(x|getSubroles(x))->asSet()->union(r.subrole)
>>
>> can anyone give me an example.
>>
>> Thanx Chris
Re: OCL and Query Questions [message #582105 is a reply to message #39237] Wed, 05 July 2006 14:19 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hello, Chris,

EMFT implements the OCL 2.0 grammar, as specified in the latest interim
document from OMG (the spec is still in the finalization phase).

The API allows to define additional operations such as your example, below.
Try this:

IOCLHelper helper = HelperUtil.createOCLHelper();
helper.define("getSubroles(r : Role) : Set(Role) = " +
"r.subrole->collect(x|getSubroles(x))->asSet()->union(r.subrole) ");

Recursion is supported. Given this definition, subsequent evaluation of
queries and constraints can use the getSubroles operation as it would any
other defined by your Ecore model.

However, EMFT provides an extra goodie (not defined by the OCL spec) that
obviates the need for this particular recursive operation definition: the
transitive closure iterator. The above operation is fully equivalent to
the following expression:

r->closure(subrole)

This actually has the benefit of not being susceptible to infinite recursion
in cases of cycles, which I don't think the alternative implementation
would avoid in its current form (it would require some fancy iteration
expressions and set differences; a much more complex expression overall).

HTH,

Christian


Chris Lenz wrote:

> What's with that:
>
> What OCL standard is implemented yet.
> Is it possible to define recursive funktions, like
>
> def: let getSubroles(r: Role) : Set(Role) =
> r.subrole->collect(x|getSubroles(x))->asSet()->union(r.subrole)
>
> can anyone give me an example.
>
> Chris
>

<snip>
Re: OCL and Query Questions [message #587085 is a reply to message #39267] Mon, 04 September 2006 08:32 Go to previous message
Chris Lenz is currently offline Chris LenzFriend
Messages: 214
Registered: July 2009
Senior Member
Hi Christian:
I want to ask if the recursive problem is planned to get fixed:

Ok can you give me a hint that I can make a quickhack.

We use your pacage for validating uml model, and I have to thank for
your real great work :-).
Best regards from Austria



Christian W. Damus schrieb:
> Hello, Chris,
>
> EMFT implements the OCL 2.0 grammar, as specified in the latest interim
> document from OMG (the spec is still in the finalization phase).
>
> The API allows to define additional operations such as your example, below.
> Try this:
>
> IOCLHelper helper = HelperUtil.createOCLHelper();
> helper.define("getSubroles(r : Role) : Set(Role) = " +
> "r.subrole->collect(x|getSubroles(x))->asSet()->union(r.subrole) ");
>
> Recursion is supported. Given this definition, subsequent evaluation of
> queries and constraints can use the getSubroles operation as it would any
> other defined by your Ecore model.
>
> However, EMFT provides an extra goodie (not defined by the OCL spec) that
> obviates the need for this particular recursive operation definition: the
> transitive closure iterator. The above operation is fully equivalent to
> the following expression:
>
> r->closure(subrole)
>
> This actually has the benefit of not being susceptible to infinite recursion
> in cases of cycles, which I don't think the alternative implementation
> would avoid in its current form (it would require some fancy iteration
> expressions and set differences; a much more complex expression overall).
>
> HTH,
>
> Christian
>
>
> Chris Lenz wrote:
>
>> What's with that:
>>
>> What OCL standard is implemented yet.
>> Is it possible to define recursive funktions, like
>>
>> def: let getSubroles(r: Role) : Set(Role) =
>> r.subrole->collect(x|getSubroles(x))->asSet()->union(r.subrole)
>>
>> can anyone give me an example.
>>
>> Chris
>>
>
> <snip>
Re: OCL and Query Questions [message #587094 is a reply to message #48315] Mon, 04 September 2006 09:24 Go to previous message
Chris Lenz is currently offline Chris LenzFriend
Messages: 214
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040403020307070904080806
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

I have created a patch that works for me :-)

Chris Lenz schrieb:
> Hi Christian:
> I want to ask if the recursive problem is planned to get fixed:
>
> Ok can you give me a hint that I can make a quickhack.
>
> We use your pacage for validating uml model, and I have to thank for
> your real great work :-).
> Best regards from Austria
>
>
>
> Christian W. Damus schrieb:
>> Hello, Chris,
>>
>> EMFT implements the OCL 2.0 grammar, as specified in the latest interim
>> document from OMG (the spec is still in the finalization phase).
>>
>> The API allows to define additional operations such as your example, below.
>> Try this:
>>
>> IOCLHelper helper = HelperUtil.createOCLHelper();
>> helper.define("getSubroles(r : Role) : Set(Role) = " +
>> "r.subrole->collect(x|getSubroles(x))->asSet()->union(r.subrole) ");
>>
>> Recursion is supported. Given this definition, subsequent evaluation of
>> queries and constraints can use the getSubroles operation as it would any
>> other defined by your Ecore model.
>>
>> However, EMFT provides an extra goodie (not defined by the OCL spec) that
>> obviates the need for this particular recursive operation definition: the
>> transitive closure iterator. The above operation is fully equivalent to
>> the following expression:
>>
>> r->closure(subrole)
>>
>> This actually has the benefit of not being susceptible to infinite recursion
>> in cases of cycles, which I don't think the alternative implementation
>> would avoid in its current form (it would require some fancy iteration
>> expressions and set differences; a much more complex expression overall).
>>
>> HTH,
>>
>> Christian
>>
>>
>> Chris Lenz wrote:
>>
>>> What's with that:
>>>
>>> What OCL standard is implemented yet.
>>> Is it possible to define recursive funktions, like
>>>
>>> def: let getSubroles(r: Role) : Set(Role) =
>>> r.subrole->collect(x|getSubroles(x))->asSet()->union(r.subrole)
>>>
>>> can anyone give me an example.
>>>
>>> Chris
>>>
>> <snip>


--------------040403020307070904080806
Content-Type: text/plain;
name="recursion.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="recursion.txt"

### Eclipse Workspace Patch 1.0
#P org.eclipse.emf.ocl
Index: src/org/eclipse/emf/ocl/internal/parser/OCLParser.java
============================================================ =======
RCS file: /cvsroot/technology/org.eclipse.emft/ocl/plugins/org.eclipse .emf.ocl/src/org/eclipse/emf/ocl/internal/parser/OCLParser.j ava,v
retrieving revision 1.16
diff -u -r1.16 OCLParser.java
--- src/org/eclipse/emf/ocl/internal/parser/OCLParser.java 5 May 2006 13:19:14 -0000 1.16
+++ src/org/eclipse/emf/ocl/internal/parser/OCLParser.java 4 Sep 2006 08:59:15 -0000
@@ -1497,12 +1497,12 @@
operationString(operName, args),
contextEnv.getContextClassifier().getName()));
}
-
- expression = oclExpressionCS(defExpr.getExpressionCS(), contextEnv);
feature = TypeUtil.defineOperation(
contextEnv.getContextClassifier(),
unquote(operCS.getSimpleNameCS().getValue()),
params, type);
+ expression = oclExpressionCS(defExpr.getExpressionCS(), contextEnv);
+
}

Constraint astNode = umlFactory.createConstraint();

--------------040403020307070904080806--
Previous Topic:How to implement constraint for group of objects?
Next Topic:OAW cannot resolve Ecore reference?
Goto Forum:
  


Current Time: Thu Apr 25 00:05:54 GMT 2024

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

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

Back to the top