Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » OCL Constraint to java code(OCL Constraint)
OCL Constraint to java code [message #1694377] Tue, 05 May 2015 01:06 Go to next message
ilan rosenfeld is currently offline ilan rosenfeldFriend
Messages: 1
Registered: May 2015
Junior Member
Hello people. I am writing to you because I have been working with Acceleo this last few weeks, and i have a doubt which answer I can not find anywhere.
Using the "Papyrus" tool, i have defined a class model, which is composed by classes which have methods. One of these has pre and post conditions, and a bodyCondition, all of them defined in the OCL language and being Constraints.
My problem is that i want to translate the body of these constraints into java code; for example, the bodyCondition says: {OCL} self.cars -> union (Bag{car}).
In the generate.xml, I am writing: [o.bodyCondition.specification/], being o the operation/method, but after translating, i get this:
org.eclipse.uml2.uml.internal.impl.OpaqueExpressionImpl@6735fd (name: addCarBody, visibility: <unset>) (body: [self.cars->union(Bag{car})], language: [OCL])
I just want to get the body, but i dont know how.
I would really appreciate if you could help me with this issue. Also, if you knew how to translate that OCL sentence into java code, I would solve two problems.
Thank you in advance.
Re: OCL Constraint to java code [message #1694475 is a reply to message #1694377] Tue, 05 May 2015 14:24 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5534
Registered: July 2009
Senior Member
Hi

The OCL to Java code generator has been rewritten three times. The first
version was in Acceleo and demonstrated that simple M2T is inadequate
for a serious code generation task.

The current implementation is 100% Java. You can find it in
org.eclipse.ocl.examples.codegen. It is configurable and probably has
about five different versions so far, including an extension for QVTd.
It is far from perfect but it aspires to 100% OCL and is used in
earnest. The constraints defined in Pivot.ocl form part of the live OCL
code.

Regards

Ed Willink





On 05/05/2015 15:07, ilan rosenfeld wrote:
> Hello people. I am writing to you because I have been working with
> Acceleo this last few weeks, and i have a doubt which answer I can not
> find anywhere.
> Using the "Papyrus" tool, i have defined a class model, which is
> composed by classes which have methods. One of these has pre and post
> conditions, and a bodyCondition, all of them defined in the OCL
> language and being Constraints. My problem is that i want to
> translate the body of these constraints into java code; for example,
> the bodyCondition says: {OCL} self.cars -> union (Bag{car}).
> In the generate.xml, I am writing: [o.bodyCondition.specification/],
> being o the operation/method, but after translating, i get this:
> mailto:org.eclipse.uml2.uml.internal.impl.OpaqueExpressionImpl@6735fd
> (name: addCarBody, visibility: <unset>) (body:
> [self.cars->union(Bag{car})], language: [OCL])
> I just want to get the body, but i dont know how.
> I would really appreciate if you could help me with this issue. Also,
> if you knew how to translate that OCL sentence into java code, I would
> solve two problems.
> Thank you in advance.
Previous Topic:[XPAND]Unkown type while accessing multiple models
Next Topic:[acceleo] Unable to generate code
Goto Forum:
  


Current Time: Mon Dec 18 01:36:08 GMT 2017

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

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