How to get OCL variable from Java code [message #1068078] |
Thu, 11 July 2013 20:23  |
Eclipse User |
|
|
|
Hi,
I want to get an OCL variable after its evaluation from Java code.
For example, for the following expression:
context Application inv :
let seq : OrderedSet(AA)=
self.activity->select(a: AA| a.oclIsKindOf(xx)) in
seq->forAll(aa: AA| if aa.oclIsKindOf(xx)
and aa.oclAsType(xx).name='yyy' then
(let pos: Integer = seq->indexOf(aa) in
if pos>100000 then pos=0 else pos= seq->indexOf(aa) endif )
else false endif )
This is just an example.
I want to get the value of "pos" variable into an integer variable so i can use it after in my Java code, like:
int var= pos; or int var= (result of the evaluated expression)
Usualy, i used OCL expressions to impose some constraints that are evaluated to true or false using the "check" method.
Can any body give me some help here.
|
|
|
|
|
Re: How to get OCL variable from Java code [message #1068186 is a reply to message #1068174] |
Fri, 12 July 2013 10:48   |
Eclipse User |
|
|
|
Hi
The OCL tooling is all implemented with Java so you can certainly call
it, but the whole point of modeling is to abstract away from the Java,
so if as a novice you are already reaching for java, I strongly suspect
that you are either doing something foolish or have assumed that I
actually understood your very vague original question.
Regards
Ed Willink
On 12/07/2013 15:17, zernadji tarek wrote:
> Hi,
> Thanks for your response.
> I'm afraid that i'm not really experienced with OCLinEcore editor and
> also novice in the domain, but i'm investigating your solution which i
> find interesting.
> However, i did not understand what do you mean by "not trivially
> callable by Java.", i want to test the first solution for now, you
> mean that it is not possible to call it from Java code as i mentioned
> in my previous post: int var= result of OCL operation call
>
> Thanks in advance.
|
|
|
|
Re: How to get OCL variable from Java code [message #1068194 is a reply to message #1068191] |
Fri, 12 July 2013 11:38  |
Eclipse User |
|
|
|
Hi
If you want multiple results you should code a query rthat returns a
Collection or a Tuple.
If you really want to see the hidden results, dig into the query
evaluation path and replicate sufficient code to give you access to the
Environment where all the variables are held.
Regards
Ed Willink
On 12/07/2013 16:29, zernadji tarek wrote:
> Hi,
> Well, i don't really think that i'm doing something foolish. I'm
> coding in Java an interpreter of a lightweight language that i
> specified. I'm using OCL expressions inside as a query language of the
> models representing a certain application.
> So, i would like simply while interpreting some statements in the
> language to use OCL expressions like the one i presented in the
> previous posts. I want to make a generic search function that returns
> the position of an element in a instance of the model (Ecore
> model)that represents the application.
> That's why i want to get the result of the given OCL expression.
>
> I agree a 100% that modeling is to abstract from any implementation
> details.
>
> Thanks.
|
|
|
Powered by
FUDForum. Page generated in 0.02857 seconds