Home » Modeling » OCL » how to define operations?
| | | | |
Re: how to define operations? [message #499875 is a reply to message #499585] |
Tue, 24 November 2009 12:48 |
|
--=-Ryv4AKQdpC0aUJ2IxmIZ
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hi, Joel,
The OCLHelper API is intended primarily for the processing of OCL
constraints, definitions, and queries that are embedded in a model,
where the contextual classifier/operation/etc. is determined by the
placement of the expression.
For specification of OCL constraints and definitions with the textual
syntax of the context, that is typically done in *.ocl resources and
parsed using the parse(...) methods of the org.eclipse.ocl.OCL class and
its specializations. This "loads" the constraints defined in the *.ocl
into one environment; the parsed results can be retrieved if necessary
from the OCL facade instance, but in the case of definitions, they will
be available in the environment for any subsequent OCL expressions to
use.
Since you evidently have the JUnit test suite on hand, look for uses of
the OCL class such as in (I hope this is the name) OCLDocumentTest.
HTH,
Christian
On Mon, 2009-11-23 at 13:29 +0100, Joel Greenyer wrote:
> Hi Ed,
> thanks for your answer.
> ...and process that expression via OCLHelper.defineOperation()?
>
> Ed Willink wrote:
> > Hi Joel
> >
> > From Warmer and Kleppe's book
> >
> > context CustomerCard::getTransactions(until:Date, from:Date) :
> > Set(Transaction)
> > body: self.transactions->select( i_Transaction : Transaction |
> > i_Transaction.date.isAfter(from)
> > and i_Transaction.date.isBefore(until) )
> >
> > The full example may be found
> >
> > /org.eclipse.qvt.declarative.examples.ocl.royalandloyal/ocls rc/RoyalAndLoyal/RoyalAndLoyal.ocl
> >
> >
> > which may be found in /cvsroot/modeling
> > org.eclipse.m2m/org.eclipse.qvt.declarative/examples
> >
> > I'm working on the QVT Declarative build right now, so watch
> > http://wiki.eclipse.org/MDT/OCL/FAQ#OCL_Editor for a more friendly
> > installation process.
> >
> > Regards
> >
> > Ed Willink
> >
> >
> >
> > Joel Greenyer wrote:
> >> Hi,
> >> I'd like to define an operation for a certain class context via OCL.
> >>
> >> I see in org.eclipse.ocl.ecore.tests.DefExpressionTest examples of how
> >> to invoke the OCLHelper.defineOperation() method. In the
> >> DefExpressionTest class, the context is set via helper.setContext()
> >> prior to defining the operation.
> >>
> >> Is there a way to specify the context textually, as one expression
> >> together with the operation definition? Or is there another way to
> >> retrieve the context class from a textual expression? The problem is
> >> that I cannot hard code the context classifier as it is done in the
> >> DefExpressionTest class.
> >>
> >> Could anyone please provide an example expression and/or small code
> >> snippet in how to do that?
> >> Thanks for helping.
> >>
> >> Joel
--=-Ryv4AKQdpC0aUJ2IxmIZ
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.24.1.1">
</HEAD>
<BODY>
Hi, Joel,<BR>
<BR>
The OCLHelper API is intended primarily for the processing of OCL constraints, definitions, and queries that are embedded in a model, where the contextual classifier/operation/etc. is determined by the placement of the expression.<BR>
<BR>
For specification of OCL constraints and definitions with the textual syntax of the context, that is typically done in *.ocl resources and parsed using the parse(...) methods of the org.eclipse.ocl.OCL class and its specializations. This "loads" the constraints defined in the *.ocl into one environment; the parsed results can be retrieved if necessary from the OCL facade instance, but in the case of definitions, they will be available in the environment for any subsequent OCL expressions to use.<BR>
<BR>
Since you evidently have the JUnit test suite on hand, look for uses of the OCL class such as in (I hope this is the name) OCLDocumentTest.<BR>
<BR>
HTH,<BR>
<BR>
Christian<BR>
<BR>
<BR>
On Mon, 2009-11-23 at 13:29 +0100, Joel Greenyer wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
Hi Ed,
thanks for your answer.
....and process that expression via OCLHelper.defineOperation()?
Ed Willink wrote:
> Hi Joel
>
> From Warmer and Kleppe's book
>
> context CustomerCard::getTransactions(until:Date, from:Date) :
> Set(Transaction)
> body: self.transactions->select( i_Transaction : Transaction |
> i_Transaction.date.isAfter(from)
> and i_Transaction.date.isBefore(until) )
>
> The full example may be found
>
> /org.eclipse.qvt.declarative.examples.ocl.royalandloyal/ocls rc/RoyalAndLoyal/RoyalAndLoyal.ocl
>
>
> which may be found in /cvsroot/modeling
> org.eclipse.m2m/org.eclipse.qvt.declarative/examples
>
> I'm working on the QVT Declarative build right now, so watch
> <A HREF="http://wiki.eclipse.org/MDT/OCL/FAQ#OCL_Editor">http://wiki.eclipse.org/MDT/OCL/FAQ#OCL_Editor</A> for a more friendly
> installation process.
>
> Regards
>
> Ed Willink
>
>
>
> Joel Greenyer wrote:
>> Hi,
>> I'd like to define an operation for a certain class context via OCL.
>>
>> I see in org.eclipse.ocl.ecore.tests.DefExpressionTest examples of how
>> to invoke the OCLHelper.defineOperation() method. In the
>> DefExpressionTest class, the context is set via helper.setContext()
>> prior to defining the operation.
>>
>> Is there a way to specify the context textually, as one expression
>> together with the operation definition? Or is there another way to
>> retrieve the context class from a textual expression? The problem is
>> that I cannot hard code the context classifier as it is done in the
>> DefExpressionTest class.
>>
>> Could anyone please provide an example expression and/or small code
>> snippet in how to do that?
>> Thanks for helping.
>>
>> Joel
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>
--=-Ryv4AKQdpC0aUJ2IxmIZ--
|
|
|
Re: how to define operations? [message #500084 is a reply to message #499875] |
Tue, 24 November 2009 21:19 |
Joel Greenyer Messages: 170 Registered: July 2009 |
Senior Member |
|
|
Hi Christian,
you make my day! It works with the parse() method. I guess I was totally on the wrong track here.
Thanks for the explanation!
Best
Joel
Christian W. Damus wrote:
> Hi, Joel,
>
> The OCLHelper API is intended primarily for the processing of OCL
> constraints, definitions, and queries that are embedded in a model,
> where the contextual classifier/operation/etc. is determined by the
> placement of the expression.
>
> For specification of OCL constraints and definitions with the textual
> syntax of the context, that is typically done in *.ocl resources and
> parsed using the parse(...) methods of the org.eclipse.ocl.OCL class and
> its specializations. This "loads" the constraints defined in the *.ocl
> into one environment; the parsed results can be retrieved if necessary
> from the OCL facade instance, but in the case of definitions, they will
> be available in the environment for any subsequent OCL expressions to use.
>
> Since you evidently have the JUnit test suite on hand, look for uses of
> the OCL class such as in (I hope this is the name) OCLDocumentTest.
>
> HTH,
>
> Christian
>
>
> On Mon, 2009-11-23 at 13:29 +0100, Joel Greenyer wrote:
>> Hi Ed,
>> thanks for your answer.
>> ...and process that expression via OCLHelper.defineOperation()?
>>
>> Ed Willink wrote:
>> > Hi Joel
>> >
>> > From Warmer and Kleppe's book
>> >
>> > context CustomerCard::getTransactions(until:Date, from:Date) :
>> > Set(Transaction)
>> > body: self.transactions->select( i_Transaction : Transaction |
>> > i_Transaction.date.isAfter(from)
>> > and i_Transaction.date.isBefore(until) )
>> >
>> > The full example may be found
>> >
>> > /org.eclipse.qvt.declarative.examples.ocl.royalandloyal/ocls rc/RoyalAndLoyal/RoyalAndLoyal.ocl
>> >
>> >
>> > which may be found in /cvsroot/modeling
>> > org.eclipse.m2m/org.eclipse.qvt.declarative/examples
>> >
>> > I'm working on the QVT Declarative build right now, so watch
>> > http://wiki.eclipse.org/MDT/OCL/FAQ#OCL_Editor for a more friendly
>> > installation process.
>> >
>> > Regards
>> >
>> > Ed Willink
>> >
>> >
>> >
>> > Joel Greenyer wrote:
>> >> Hi,
>> >> I'd like to define an operation for a certain class context via OCL.
>> >>
>> >> I see in org.eclipse.ocl.ecore.tests.DefExpressionTest examples of how
>> >> to invoke the OCLHelper.defineOperation() method. In the
>> >> DefExpressionTest class, the context is set via helper.setContext()
>> >> prior to defining the operation.
>> >>
>> >> Is there a way to specify the context textually, as one expression
>> >> together with the operation definition? Or is there another way to
>> >> retrieve the context class from a textual expression? The problem is
>> >> that I cannot hard code the context classifier as it is done in the
>> >> DefExpressionTest class.
>> >>
>> >> Could anyone please provide an example expression and/or small code
>> >> snippet in how to do that?
>> >> Thanks for helping.
>> >>
>> >> Joel
|
|
|
Goto Forum:
Current Time: Sat Oct 19 16:12:25 GMT 2024
Powered by FUDForum. Page generated in 0.04859 seconds
|