Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » OCL and Query Questions
| | |
Re: OCL and Query Questions [message #39267 is a reply to message #39237] |
Wed, 05 July 2006 14:19 |
Eclipse User |
|
|
|
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 |
Chris Lenz 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 |
Chris Lenz 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 #582105 is a reply to message #39237] |
Wed, 05 July 2006 14:19 |
Eclipse User |
|
|
|
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 |
Chris Lenz 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 |
Chris Lenz 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--
|
|
|
Goto Forum:
Current Time: Sat May 04 12:47:02 GMT 2024
Powered by FUDForum. Page generated in 0.03671 seconds
|